[pyngl-talk] PyNGL and xarray

Karin Meier-Fleischer meier-fleischer at dkrz.de
Wed Mar 27 10:12:33 MDT 2019


HI Mateus,

you can use xarray already you have to add .values to the 
sfXArray/sfYArray resources.

lat = xr.open_dataset('your_file').lat
lon = xr.open_dataset('your_file').lon
...
res.sfXArray = lon.values
res.sfYArray = lat.values

lon.values will give you the xarray data array lon as a numpy array.
See also xarray.pydata.org/en/stable/generated/xarray.DataArray.values.html

Bye
Karin

Am 27.03.19 um 14:14 schrieb Mateus da Silva Teixeira via pyngl-talk:
> Hi,
>
> I'm beginning to use Python since the news about NCL is being placed 
> in maintenance mode, and since it was said that PyNIO will also be 
> placed in maintenance mode, I'm using other libraries to open data 
> files and PyNGL for graphics.
>
> Reading about Ngl.contour_map(), I found that it expects a numpy array 
> with data to plot and coordinates information are given to sfXArray 
> and sfYArray resources.
>
> Is there a plan to use xarray.DataArray as a data model for PyNGL? It 
> has large similarities with NCL's variable model, which is borrowed 
> from netCDF model.
>
> I'm asking it because it seems more natural to use xarray, which 
> contains all metadata for a variable, than use a numpy array.
>
> Thanks and excuse me if it's a already defined topic in future 
> development of PyNGL.
>
> Best regards,
>
> Mateus
>
>
>
>
> _______________________________________________
> 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/20190327/ee4cc6b6/attachment.html>


More information about the pyngl-talk mailing list