[pyngl-talk] PyNGL and xarray

Mateus da Silva Teixeira mateusstex at gmail.com
Wed Mar 27 10:54:58 MDT 2019


Hi Karin,

Thank you for your answer.

Yes, I already had seen that and I have used it like you wrote.

However, I think that would be great for PyNGL if it could take all
information for graphics (coords, attributes etc) from a xarray.DataArray,
like NCL does (with variables that have coordinates), without we have to
provide coordinates information via resources.

So, if here is a place to make suggestions, it would be a great feature of
PyNGL.

Best regards,
Mateus


Em qua, 27 de mar de 2019 às 13:12, Karin Meier-Fleischer via pyngl-talk <
pyngl-talk at ucar.edu> escreveu:

> 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
>
>
> _______________________________________________
> 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/406727f8/attachment-0001.html>


More information about the pyngl-talk mailing list