diff --git a/testing_and_setup/compass/ocean/global_ocean/config_files/config_culled_mesh.xml b/testing_and_setup/compass/ocean/global_ocean/config_files/config_culled_mesh.xml index 1661abb424..06f2242e92 100644 --- a/testing_and_setup/compass/ocean/global_ocean/config_files/config_culled_mesh.xml +++ b/testing_and_setup/compass/ocean/global_ocean/config_files/config_culled_mesh.xml @@ -9,6 +9,7 @@ + diff --git a/testing_and_setup/compass/ocean/global_ocean/cull_mesh.py b/testing_and_setup/compass/ocean/global_ocean/cull_mesh.py index 224d3fb567..48065e7310 100755 --- a/testing_and_setup/compass/ocean/global_ocean/cull_mesh.py +++ b/testing_and_setup/compass/ocean/global_ocean/cull_mesh.py @@ -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 @@ -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). @@ -71,9 +76,11 @@ 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 @@ -81,19 +88,25 @@ def removeFile(fileName): './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 @@ -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: @@ -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 @@ -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 @@ -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 @@ -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: @@ -150,7 +196,8 @@ 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 @@ -158,7 +205,8 @@ def removeFile(fileName): # ./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()) @@ -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: @@ -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())