ec-jrc / pyPoseidon

Framework for Hydrodynamic simulations
https://pyposeidon.readthedocs.io/
European Union Public License 1.2
21 stars 8 forks source link

Consistent meteo with mesh #101

Closed brey closed 1 year ago

brey commented 2 years ago

Based on private communication with Joseph starting from v5.9 the mesh needs to be consistent with the meteo.

That is, if the mesh is [-180,180]/[0,360] so must be the meteo forcing.

Include a check and shift if needed.

pmav99 commented 2 years ago

a "naive" way to do this is to use something like this:

d = xr.open_dataset('./sflux/sflux_air_1.0001.nc')
d1 = d.isel(ny_grid=slice(2560,5120))

d2 = d.isel(ny_grid=slice(0, 2560))

d1['lon'] = d1.lon - 360.

new = xr.concat([d1, d2], dim="ny_grid")
new.to_netcdf('./sflux/sflux_air_1.0001.nc')

The downside of this approach is that it doubles the RAM requirements. I.e. if sflux_air_1.0001.nc is 26GB then we need 52GB of RAM in order to fix the longitude.

I haven't tried it but, but I assume that the conversion would be more efficient if the fix was applied directly on the input meteo file (e.g. 20220713.00.tropical_cyclone.grib).