xarray-contrib/xwrf

[FEATURE]: Implement map_proj==6

Opened this issue · 2 comments

What is your issue?

Hello,

I'm trying to load wrf data using xarray open_mfdataset and xwrf.postprocess()
However xwrf is return this error message

ds=xa.open_mfdataset(dados_wrf,concat_dim='Time',combine='nested').xwrf.postprocess()

File ~/miniconda3/envs/geo/lib/python3.12/site-packages/xwrf/accessors.py:147 in postprocess
_ds = ds.pipe(include_projection_coordinates)

File ~/miniconda3/envs/geo/lib/python3.12/site-packages/xarray/core/common.py:775 in pipe
return func(self, *args, **kwargs)

_File ~/miniconda3/envs/geo/lib/python3.12/site-packages/xwrf/postprocess.py:105 in include_projection_coordinates
_grid_components = wrf_grid_from_dataset(ds)

_File ~/miniconda3/envs/geo/lib/python3.12/site-packages/xwrf/grid.py:61 in wrf_grid_from_dataset
raise NotImplementedError(f'WRF proj not implemented yet: {proj_id}')

NotImplementedError: WRF proj not implemented yet: 6

Could help me with this problem? Is there some argument that I'm missing in my code?

Thank you for any help

With best regards,

Taoan

Hi, thanks for making an issue. This means that the cylindrical equidistant projection is not yet implemented in xwrf. As you can see here, for now we only support the map projections 0-3.

xwrf/xwrf/grid.py

Lines 41 to 61 in 37dad39

if proj_id == 0:
# Idealized Run, Cartesian grid
pass
elif proj_id == 1:
# Lambert
pargs['proj'] = 'lcc'
del pargs['center_lon']
elif proj_id == 2:
# Polar stereo
pargs['proj'] = 'stere'
pargs['lat_ts'] = pargs['lat_1']
pargs['lat_0'] = 90.0
del pargs['lat_1'], pargs['lat_2'], pargs['center_lon']
elif proj_id == 3:
# Mercator
pargs['proj'] = 'merc'
pargs['lat_ts'] = pargs['lat_1']
pargs['lon_0'] = pargs['center_lon']
del pargs['lat_0'], pargs['lat_1'], pargs['lat_2'], pargs['center_lon']
else:
raise NotImplementedError(f'WRF proj not implemented yet: {proj_id}')

However, a quick google search reveals that salem already implemented map_proj 6, so it should be easy to do on our end. We will require tests before merging this into main but you're welcome to start a pull request and we'll guide you along.

Hi, thank you for the clarification.
I don't have experience with this type of implementation, but I'll study it to try to make some contribution.