[pyngl-talk] Transiting from NCL to PyNgl and PyNio for a Lambert conformal grid with non-regular lat/lon coordinates

LEROUX Marie-Dominique marie-dominique.leroux at meteo.fr
Tue Jun 25 06:56:44 MDT 2019


Dear all, 

For the past 2 weeks, I have been trying to recode my former NCL scripts (Version 6.5.0) to Python scripts using the PyNio and PyNgl packages and Python 3.7.3. 
I have a netcdf data file in a Lambert conformal projection with 2-dimensional lat/lon coordinates (not regular). 
I can't manage to visualize contours on my map plot using the "Ngl.contour_map" command. 
I am quite certain to know where it comes from since I am able to reproduce this problem with my NCL code when I get rid of 2 lines ( RR at lat2d = lat2d and RR at lon2d = lon2d). 

I am attaching the python code and the resulting figure to the e-mail and I have already dropped the large netcdf file (11 Mo) on the ftp server (ftp.cgd.ucar.edu). 
Its name: SWIO12_CNRM_ESM2_1_HIST_pr_mm_day_1981-2010.AN.nc 

In my NCL script I have the following lines : 
; read horizontal coordinates 
lat2d = a->nav_lat ;(y,x) with: y=10 - x=10 
lon2d = a->nav_lon 
RR = a->pr 
printVarSummary(RR) 
RR at lat2d = lat2d ; mandatory for plotting 
RR at lon2d = lon2d ;printVarSummary(RR) 
printVarSummary(RR) 

that adds both attributes lat2d and lon2d to my RR variable so that it plots well 
It turns the first PrintVarSummary(RR) : 

Variable: RR 
Type: float 
Total Size: 15840 bytes 
3960 values 
Number of Dimensions: 3 
Dimensions and sizes: [time_counter | 30] x [y | 11] x [x | 12] 
Coordinates: 
time_counter: [4149790200..5064939000] 
Number Of Attributes: 9 
long_name : total precipitation 
units : mm 
coordinates : nav_lat nav_lon 
_FillValue : 1e+20 
missing_value : 1e+20 
online_operation : average 
interval_operation : 450 s 
interval_write : 1 h 
cell_methods : time: mean (interval: 450 s) 

--->>> into : 

Variable: RR 
Type: float 
Total Size: 15840 bytes 
3960 values 
Number of Dimensions: 3 
Dimensions and sizes: [time_counter | 30] x [lat | 11] x [lon | 12] 
Coordinates: 
time_counter: [4149790200..5064939000] 
Number Of Attributes: 11 
lon2d : <ARRAY of 132 elements> 
lat2d : <ARRAY of 132 elements> 
long_name : total precipitation 
units : mm 
coordinates : nav_lat nav_lon 
_FillValue : 1e+20 
missing_value : 1e+20 
online_operation : average 
interval_operation : 450 s 
interval_write : 1 h 
cell_methods : time: mean (interval: 450 s) 



How can we do that using some Python routines? Set new attributes (lat2d and lon2d) to an existing object or to the numpy array? 
(I've made some vain trials - commented in the attached script - that write into my Netcdf file and end up with a Core Dump or Memory error) 


Thanks for your kind help, as I've not find anything helpful on the website examples, 
Best regards 
MD 

Marie-Dominique LEROUX 
— 
Responsable adjointe 
Division Etudes et Climatologie ( DIROI/EC) 
Tel : +262 (0)2 62 92 11 22 
50 Boulevard du chaudron 
97491 Sainte Clotilde Cedex 

Researcher ID Home Page : 
[ http://www.researcherid.com/rid/A-9781-2018 | http://www.researcherid.com/rid/A-9781-2018 ] 
[ http://www.meteofrance.re/ ] [ http://www.meteofrance.re/ ] [ http://www.meteofrance.re/ | www.meteofrance.re ] [ https://twitter.com/meteofrance |   ] 

[ http://www.meteofrance.com/ ] 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/pyngl-talk/attachments/20190625/58efd074/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: MFBLEU-RVB.jpg
Type: image/jpeg
Size: 252680 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/pyngl-talk/attachments/20190625/58efd074/attachment-0001.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: new_RRsum_talk.py
Type: text/x-python
Size: 4795 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/pyngl-talk/attachments/20190625/58efd074/attachment-0001.py>


More information about the pyngl-talk mailing list