NCAR / wrf-python

A collection of diagnostic and interpolation routines for use with output from the Weather Research and Forecasting (WRF-ARW) Model.
https://wrf-python.readthedocs.io
Apache License 2.0
411 stars 155 forks source link

WRF data geotransform and extporting data to geoTiff #193

Open isaacWpark opened 2 years ago

isaacWpark commented 2 years ago

I'm trying to export 2d slices of wrf data to geotiffs, and have been stymied by the fact that:

-the projection information is not present in the .crs of the xarray object -the projected coordinates of the upper-left corner of the upper-left pixel are not present in the attributes and do not seem to be otherwise accessible.

While we are able to extract the proj4 from a cartopy object created from the xarray data using wrf.get_cartopy , we have been unable to extract the projected coordinates of the upper left corner of the upper-left pixel. Without those coordinates, we cannot transform the data into an evenly spaced grid in order to export it to a raster dataset. Any help would be appreciated.

Best,

Isaac Park

@mann1123

jthielen commented 2 years ago

Would the projected geospatial coordinate functionality of xwrf meet your needs instead?

DWesl commented 2 months ago
  • the projected coordinates of the upper-left corner of the upper-left pixel are not present in the attributes and do not seem to be otherwise accessible.

Does -ds.attrs["DX"] * ds.dims["west_east"] / 2 and ds.attrs["DY"] * ds.dims["south_north"] / 2 not work for your purposes? This would only work for the outer domain, but I think there's attributes somewhere in the WRF output to say where nested domains lie in their parent domains.

Alternately, would the Cartopy transform_point function work? I.e. crs = wrf.get_cartopy(...); crs.transform_point(ds.coords["XLONG"][0, 0], ds.coords["XLAT"][0, 0], crs.as_geodetic()).

If you are able to install more packages, the xwrf package mentioned above can add x and y coordinates.