Skip to content

Commit

Permalink
feat(TU): add wrf mercator products for TU
Browse files Browse the repository at this point in the history
  • Loading branch information
benatouba committed Jul 9, 2024
1 parent 1873ab9 commit 251d982
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions salem/sio.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,22 +126,25 @@ def read_shapefile_to_grid(fpath, grid):

def _wrf_grid_from_dataset(ds):
"""Get the WRF projection out of the file."""

pargs = dict()
pargs = {}
if hasattr(ds, 'PROJ_ENVI_STRING'):
# HAR and other TU Berlin files
dx = ds.GRID_DX
dy = ds.GRID_DY
pargs['lat_1'] = ds.PROJ_STANDARD_PAR1
pargs['lat_2'] = ds.PROJ_STANDARD_PAR2
pargs['lat_0'] = ds.PROJ_CENTRAL_LAT
pargs['lon_0'] = ds.PROJ_CENTRAL_LON
pargs['center_lon'] = ds.PROJ_CENTRAL_LON
dx = ds.GRID_DX or ds.DX
dy = ds.GRID_DY or ds.DY
if ds.PROJ_NAME in ['Lambert Conformal Conic',
'WRF Lambert Conformal']:
proj_id = 1
pargs['lat_1'] = ds.PROJ_STANDARD_PAR1
pargs['lat_2'] = ds.PROJ_STANDARD_PAR2
pargs['lat_0'] = ds.PROJ_CENTRAL_LAT
pargs['lon_0'] = ds.PROJ_CENTRAL_LON
pargs['center_lon'] = ds.PROJ_CENTRAL_LON
elif ds.PROJ_NAME in ['lat-lon']:
proj_id = 6
elif "mercator" in ds.PROJ_NAME.lower():
proj_id = 3
pargs['lat_ts'] = ds.TRUELAT1
pargs['center_lon'] = ds.CEN_LON
else:
proj_id = 99 # pragma: no cover
else:
Expand Down Expand Up @@ -1214,4 +1217,4 @@ def ds_closer():
except AttributeError:
combined = combined.drop(vns)

return combined
return combined

0 comments on commit 251d982

Please sign in to comment.