pangeo-data / xESMF

Universal Regridder for Geospatial Data
http://xesmf.readthedocs.io/
MIT License
189 stars 34 forks source link

xesmf util.grid_2d across International Dateline with negative longitudes in W. Hemisphere #247

Open jwynnsmith opened 1 year ago

jwynnsmith commented 1 year ago

Good afternoon:

I have a 2 km squared grid that I need to bin GOES-17 GLM Flash longitudes and latitudes to individual grid cells.
From here I will go on to use he scipy binned_statistics_2d function I am using the xe.util.grid_2d to define the grid. The GOES-17 GLM crosses the International Dateline where the EH goes from 0 to 180 (Dateline) and the WH goes from -180 (Dateline) to 0.

Specifically, a function with the following lons/lats does not work for the longitudes:

lon_km = 111.321 lat_km = 110.567 two_km_lon = 2/lon_km two_km_lat = 2/lat_km

ds_out = xe.util.grid_2d(141.78874488924427, -55.7888745, two_km_lon, -81.06280786164186,81.06280786164186, two_km_lat)

as the lon_max is technically a smaller number than the lon_min.

How can I work around this with out having to had 360 to the WH longitudes? If this issue has already been addressed, can you point me to that link? Best regards Jonathan

huard commented 1 year ago

Hi Jonathan,

I'm not aware of another solution than what you're proposing.