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
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<add_link source_path="script_configuration_dir" source="cull_mesh.py" dest="cull_mesh.py"/>
<add_link source_path="mpas_tools" source="ocean/coastline_alteration/add_land_locked_cells_to_mask.py" dest="add_land_locked_cells_to_mask.py"/>
<add_link source_path="mpas_tools" source="ocean/coastline_alteration/widen_transect_edge_masks.py" dest="widen_transect_edge_masks.py"/>
<add_link source_path="mpas_tools" source="ocean/coastline_alteration/add_critical_land_blockages_to_mask.py" dest="add_critical_land_blockages_to_mask.py"/>

<run_script name="run.py">
<step executable="./cull_mesh.py">
Expand Down
82 changes: 66 additions & 16 deletions testing_and_setup/compass/ocean/global_ocean/cull_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
The optional --with_critical_passages flag indicates that critical
passages are to be opened. Otherwise, steps 2, 5 and 9 are skipped
"""

from __future__ import absolute_import, division, print_function, \
unicode_literals

import os
import os.path
import subprocess
Expand Down Expand Up @@ -58,7 +62,8 @@ def removeFile(fileName):
'-f', landCoverage,
'-m', landCoverageMask,
'-o', 'land_coverage.geojson']
print "running", ' '.join(args)
print("running {}".format(' '.join(args)))

subprocess.check_call(args, env=os.environ.copy())

# Add the appropriate land coverage below 60S (either all ice or grounded ice).
Expand All @@ -71,29 +76,37 @@ def removeFile(fileName):

args = ['{}/merge_features.py'.format(path), '-f', antarcticLandCoverage,
'-o', 'land_coverage.geojson']
print "running", ' '.join(args)
print("running {}".format(' '.join(args)))

subprocess.check_call(args, env=os.environ.copy())


# Create the land mask based on the land coverage, i.e. coastline data.
# Run command is:
# ./MpasMaskCreator.x base_mesh.nc land_mask.nc -f land_coverage.geojson
args = [
'./MpasMaskCreator.x',
'base_mesh.nc',
'land_mask_1_from_land_coverage.nc',
'-f',
'land_coverage.geojson']
print "running", ' '.join(args)
'-f', 'land_coverage.geojson']
print("running {}".format(' '.join(args)))

subprocess.check_call(args, env=os.environ.copy())

if options.with_critical_passages:
outMaskFile = 'land_mask_2_from_land_locked_cells.nc'
else:
outMaskFile = 'land_mask_final.nc'

# Add land-locked cells to land coverage mask.
args = ['./add_land_locked_cells_to_mask.py',
'-f', 'land_mask_1_from_land_coverage.nc',
'-o', 'land_mask_final.nc',
'-o', outMaskFile,
'-m', 'base_mesh.nc',
'-l', '43.0',
'-n', '20']
print "running", ' '.join(args)
print("running {}".format(' '.join(args)))

subprocess.check_call(args, env=os.environ.copy())

# create seed points for a flood fill of the ocean
Expand All @@ -104,7 +117,8 @@ def removeFile(fileName):
'-d', '{}/ocean/point'.format(path),
'-t', 'seed_point',
'-o', 'seed_points.geojson']
print "running", ' '.join(args)
print("running {}".format(' '.join(args)))

subprocess.check_call(args, env=os.environ.copy())

if options.with_critical_passages:
Expand All @@ -114,7 +128,8 @@ def removeFile(fileName):
'-d', '{}/ocean/transect'.format(path),
'-t', 'Critical_Passage',
'-o', 'critical_passages.geojson']
print "running", ' '.join(args)
print("running {}".format(' '.join(args)))

subprocess.check_call(args, env=os.environ.copy())

# create masks from the transects
Expand All @@ -123,7 +138,8 @@ def removeFile(fileName):
# -f critical_passages.geojson
args = ['./MpasMaskCreator.x', 'base_mesh.nc', 'critical_passages_mask.nc',
'-f', 'critical_passages.geojson']
print "running", ' '.join(args)
print("running {}".format(' '.join(args)))

subprocess.check_call(args, env=os.environ.copy())

# Alter critical passages to be at least two cells wide, to avoid sea ice
Expand All @@ -132,7 +148,36 @@ def removeFile(fileName):
'-f', 'critical_passages_mask.nc',
'-m', 'base_mesh.nc',
'-l', '43.0']
print "running", ' '.join(args)
print("running {}".format(' '.join(args)))

subprocess.check_call(args, env=os.environ.copy())

# merge transects for critical land blockages into
# critical_land_blockages.geojson
removeFile('critical_land_blockages.geojson')
args = ['{}/merge_features.py'.format(path),
'-d', '{}/ocean/transect'.format(path),
'-t', 'Critical_Land_Blockage',
'-o', 'critical_land_blockages.geojson']
print("running {}".format(' '.join(args)))

subprocess.check_call(args, env=os.environ.copy())

# create masks from the transects for critical land blockages
args = ['./MpasMaskCreator.x', 'base_mesh.nc',
'critical_land_blockages_mask.nc',
'-f', 'critical_land_blockages.geojson']
print("running {}".format(' '.join(args)))

subprocess.check_call(args, env=os.environ.copy())

# add critical land blockages to land_mask_final.nc
args = ['./add_critical_land_blockages_to_mask.py',
'-f', 'land_mask_2_from_land_locked_cells.nc',
'-o', 'land_mask_final.nc',
'-b', 'critical_land_blockages_mask.nc']
print("running {}".format(' '.join(args)))

subprocess.check_call(args, env=os.environ.copy())

# Cull the mesh based on the land mask while keeping critical passages open
Expand All @@ -141,7 +186,8 @@ def removeFile(fileName):
# -p critical_passages_mask.nc
args = ['./MpasCellCuller.x', 'base_mesh.nc', 'culled_mesh_preliminary.nc',
'-m', 'land_mask_final.nc', '-p', 'critical_passages_mask.nc']
print "running", ' '.join(args)
print("running {}".format(' '.join(args)))

subprocess.check_call(args, env=os.environ.copy())
else:

Expand All @@ -150,15 +196,17 @@ def removeFile(fileName):
# ./MpasCellCuller.x base_mesh.nc culled_mesh_preliminary.nc -m land_mask_final.nc
args = ['./MpasCellCuller.x', 'base_mesh.nc', 'culled_mesh_preliminary.nc',
'-m', 'land_mask_final.nc']
print "running", ' '.join(args)
print("running {}".format(' '.join(args)))

subprocess.check_call(args, env=os.environ.copy())

# create a mask for the flood fill seed points
# Run command is:
# ./MpasMaskCreator.x culled_mesh_preliminary.nc seed_mask.nc -s seed_points.geojson
args = ['./MpasMaskCreator.x', 'culled_mesh_preliminary.nc', 'seed_mask.nc',
'-s', 'seed_points.geojson']
print "running", ' '.join(args)
print("running {}".format(' '.join(args)))

subprocess.check_call(args, env=os.environ.copy())


Expand All @@ -168,7 +216,8 @@ def removeFile(fileName):
args = ['./MpasCellCuller.x', 'culled_mesh_preliminary.nc', 'culled_mesh.nc',
'-i', 'seed_mask.nc']

print "running", ' '.join(args)
print("running {}".format(' '.join(args)))

subprocess.check_call(args, env=os.environ.copy())

if options.with_critical_passages:
Expand All @@ -179,5 +228,6 @@ def removeFile(fileName):
args = ['./MpasMaskCreator.x', 'culled_mesh.nc',
'critical_passages_mask_final.nc',
'-f', 'critical_passages.geojson']
print "running", ' '.join(args)
print("running {}".format(' '.join(args)))

subprocess.check_call(args, env=os.environ.copy())