Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove critical passages from landIceFracObserved #846

Merged
Merged
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
22 changes: 16 additions & 6 deletions compass/ocean/mesh/cull.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ def _cull_mesh_with_logging(logger, with_cavities, with_critical_passages,

if has_remapped_topo:
_cull_topo(with_cavities, process_count, logger, latitude_threshold,
sweep_count)
sweep_count, dsPreserve)

if with_cavities:
dsMask = xr.open_dataset('topography_culled.nc')
Expand Down Expand Up @@ -476,7 +476,7 @@ def _cull_mesh_with_logging(logger, with_cavities, with_critical_passages,


def _cull_topo(with_cavities, process_count, logger, latitude_threshold,
sweep_count):
sweep_count, ds_preserve):

ds_topo = xr.open_dataset('topography.nc')
ds_base = xr.open_dataset('base_mesh.nc')
Expand All @@ -489,8 +489,9 @@ def _cull_topo(with_cavities, process_count, logger, latitude_threshold,

if with_cavities:
_add_land_ice_mask_and_mask_draft(ds_topo, ds_base,
ds_map_culled_to_base, logger,
latitude_threshold, sweep_count)
ds_map_culled_to_base, ds_preserve,
logger, latitude_threshold,
sweep_count)
write_netcdf(ds_topo, 'topography_with_land_ice_mask.nc')

logger.info('Culling topography')
Expand Down Expand Up @@ -525,9 +526,18 @@ def _land_mask_from_topo(with_cavities, topo_filename, mask_filename):


def _add_land_ice_mask_and_mask_draft(ds_topo, ds_base_mesh,
ds_map_culled_to_base, logger,
latitude_threshold, sweep_count):
ds_map_culled_to_base, ds_perserve,
logger, latitude_threshold, sweep_count):

land_ice_frac = ds_topo.landIceFracObserved
# we don't what land ice where we are preserving critical passages
for ds in ds_perserve:
not_preserve = ds.transectCellMasks.sum(dim='nTransects') == 0
land_ice_frac = land_ice_frac.where(not_preserve, 0.0)

land_ice_frac.to_netcdf('land_ice_frac_without_critical_passages.nc')

ds_topo['landIceFracObserved'] = land_ice_frac

# we want the mask to be 1 where there's at least half land-ice
land_ice_mask = xr.where(land_ice_frac > 0.5, 1, 0)
Expand Down
Loading