Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 12 additions & 25 deletions compass/ocean/tests/utility/combine_topo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,10 @@ def _modify_bedmachine(self):
grounded_mask = np.logical_or(np.logical_or(mask == 1, mask == 2),
mask == 4).astype(float)

bedmachine['bathymetry'] = bedmachine.bed.where(ocean_mask, 0.)
bedmachine['ice_draft'] = \
(bedmachine.surface -
bedmachine.thickness).where(ocean_mask, 0.)
bedmachine['bathymetry'] = bedmachine.bed
bedmachine['ice_draft'] = bedmachine.surface - bedmachine.thickness
bedmachine.ice_draft.attrs['units'] = 'meters'
bedmachine['thickness'] = \
bedmachine.thickness.where(ocean_mask, 0.)
bedmachine['thickness'] = bedmachine.thickness

bedmachine['ice_mask'] = ice_mask
bedmachine['grounded_mask'] = grounded_mask
Expand Down Expand Up @@ -231,11 +228,6 @@ def _remap_bedmachine(self):
logger = self.logger
logger.info('Remap BedMachineAntarctica to GEBCO 1/80 deg grid')

config = self.config

section = config['combine_topo']
renorm_thresh = section.getfloat('renorm_thresh')

in_filename = 'BedMachineAntarctica-v3_mod.nc'
out_filename = 'BedMachineAntarctica_on_GEBCO_low.nc'
gebco_filename = 'GEBCO_2023_0.0125_degree.nc'
Expand Down Expand Up @@ -265,16 +257,6 @@ def _remap_bedmachine(self):
for field in ['bathymetry', 'ice_draft', 'thickness']:
bedmachine_on_gebco_low[field].attrs['unit'] = 'meters'

# renormalize the fields based on the ocean masks
ocean_mask = bedmachine_on_gebco_low.ocean_mask

valid = ocean_mask > renorm_thresh
norm = ocean_mask.where(valid, 1.)
norm = 1. / norm
for field in ['bathymetry', 'ice_draft', 'thickness']:
bedmachine_on_gebco_low[field] = \
norm * bedmachine_on_gebco_low[field].where(valid, 0.)

bedmachine_on_gebco_low.to_netcdf(out_filename)
logger.info(' Done.')

Expand Down Expand Up @@ -305,17 +287,22 @@ def _combine(self):
bedmachine_bathy = bedmachine.bathymetry
valid = bedmachine_bathy.notnull()
bedmachine_bathy = bedmachine_bathy.where(valid, 0.)
bedmachine_bathy = bedmachine_bathy.where(bedmachine_bathy < 0., 0.)

combined['bathymetry'] = \
alpha * gebco.bathymetry.where(gebco.bathymetry < 0, 0.) + \
alpha * gebco.bathymetry.where(gebco.bathymetry < 0., 0.) + \
(1.0 - alpha) * bedmachine_bathy
bathy_mask = xr.where(combined.bathymetry < 0., 1.0, 0.0)

for field in ['ice_draft', 'thickness']:
combined[field] = bedmachine[field]
combined[field] = bathy_mask * bedmachine[field]
for field in ['bathymetry', 'ice_draft', 'thickness']:
combined[field].attrs['unit'] = 'meters'

fill = {'ice_mask': 0., 'grounded_mask': 0.,
'ocean_mask': combined['bathymetry'] < 0.}
combined['bathymetry_mask'] = bathy_mask

fill = {'ice_draft': 0., 'thickness': 0., 'ice_mask': 0.,
'grounded_mask': 0., 'ocean_mask': combined.bathymetry_mask}

for field, fill_val in fill.items():
valid = bedmachine[field].notnull()
Expand Down
6 changes: 1 addition & 5 deletions compass/ocean/tests/utility/combine_topo/combine_topo.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ antarctic_filename = BedMachineAntarctica-v3.nc
global_filename = GEBCO_2023.nc

# the name of the output topography file, to be copied to the bathymetry database
cobined_filename = BedMachineAntarctica_v3_and_GEBCO_2023_0.0125_degree_20240323.nc
cobined_filename = BedMachineAntarctica_v3_and_GEBCO_2023_0.0125_degree_20240611.nc

# the target and minimum number of MPI tasks to use in remapping
ntasks = 512
Expand All @@ -15,7 +15,3 @@ min_tasks = 128
# latitudes between which the topography datasets get blended
latmin = -62.
latmax = -60.

# the threshold for masks below which interpolated variables are not
# renormalized
renorm_thresh = 1e-3