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

Mateus da Silva Teixeira mateusstex at gmail.com
Tue Jun 25 07:10:40 MDT 2019


Hi,

Did you take a look at the PyNGL examples for WRF data? I think they can help you.

http://www.pyngl.ucar.edu/Examples/gallery.shtml <http://www.pyngl.ucar.edu/Examples/gallery.shtml>

I have similar problems with WRF data in Lambert conformal projection and these examples help me to plot this kind of data.

Best regards,

Mateus



> Em 25 de jun de 2019, à(s) 09:56, LEROUX Marie-Dominique via pyngl-talk <pyngl-talk at ucar.edu> escreveu:
> 
> 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/>www.meteofrance.re <http://www.meteofrance.re/>  <https://twitter.com/meteofrance>
> 
> <MFBLEU-RVB.jpg> <http://www.meteofrance.com/>
> <new_RRsum_talk.py>_______________________________________________
> pyngl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/pyngl-talk

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/pyngl-talk/attachments/20190625/9b57aded/attachment.html>


More information about the pyngl-talk mailing list