Skip to content

Commit

Permalink
Rename coordinates too, not just dimensions.
Browse files Browse the repository at this point in the history
  • Loading branch information
samsrabin committed Aug 28, 2024
1 parent 6d97218 commit bd42b18
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/landusedata/landusepft.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def main(args):
# this will contain different data from a future CLM landuse x pft update
ds_output['frac_secnd'] = ds_output.frac_primr.copy(deep=True)

# ds_regrid = ds_regrid.rename_dims(dims_dict={'lat':'lsmlat','lon':'lsmlon'})
# ds_regrid = ds_regrid.rename({'lat':'lsmlat','lon':'lsmlon'})

# Output dataset to netcdf file
print('Writing fates landuse x pft dataset to file')
Expand Down
2 changes: 1 addition & 1 deletion src/landusedata/luh2.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def main(args):

# Rename the dimensions for the output. This needs to happen after the "LONGXY/LATIXY" assignment
if (not 'lsmlat' in list(regrid_luh2.dims)):
regrid_luh2 = regrid_luh2.rename_dims({'lat':'lsmlat','lon':'lsmlon'})
regrid_luh2 = regrid_luh2.rename({'lat':'lsmlat','lon':'lsmlon'})

# Reapply the coordinate attributes. This is a workaround for an xarray bug (#8047)
# Currently only need time
Expand Down
2 changes: 1 addition & 1 deletion src/landusedata/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def _RegridTargetPrep(regrid_target):
regrid_target = regrid_target.drop_vars("lon", errors="ignore")

# Rename dimensions and add coordinates
regrid_target = regrid_target.rename_dims(dims_dict={'lsmlat':'lat','lsmlon':'lon'})
regrid_target = regrid_target.rename({'lsmlat':'lat','lsmlon':'lon'})
regrid_target['lon'] = regrid_target.LONGXY.isel(lat=0)
regrid_target['lat'] = regrid_target.LATIXY.isel(lon=0)

Expand Down

0 comments on commit bd42b18

Please sign in to comment.