Skip to content

Commit

Permalink
Update tool names in landice framework and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
xylar committed Jan 11, 2025
1 parent 58323b0 commit e3c62f5
Show file tree
Hide file tree
Showing 14 changed files with 52 additions and 57 deletions.
24 changes: 12 additions & 12 deletions compass/landice/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -688,22 +688,22 @@ def build_mali_mesh(self, cell_width, x1, y1, geom_points,
logger.info('writing grid_converted.nc')
write_netcdf(dsMesh, 'grid_converted.nc')
levels = section.get('levels')
args = ['create_landice_grid_from_generic_MPAS_grid.py',
args = ['create_landice_grid_from_generic_mpas_grid',
'-i', 'grid_converted.nc',
'-o', 'grid_preCull.nc',
'-l', levels, '-v', 'glimmer']

check_call(args, logger=logger)

args = ['interpolate_to_mpasli_grid.py', '-s',
args = ['interpolate_to_mpasli_grid', '-s',
gridded_dataset, '-d',
'grid_preCull.nc', '-m', 'b', '-t']

check_call(args, logger=logger)

cullDistance = section.get('cull_distance')
if float(cullDistance) > 0.:
args = ['define_cullMask.py', '-f',
args = ['define_landice_cull_mask', '-f',
'grid_preCull.nc', '-m',
'distance', '-d', cullDistance]

Expand All @@ -715,7 +715,7 @@ def build_mali_mesh(self, cell_width, x1, y1, geom_points,
if geojson_file is not None:
# This step is only necessary because the GeoJSON region
# is defined by lat-lon.
args = ['set_lat_lon_fields_in_planar_grid.py', '-f',
args = ['set_lat_lon_fields_in_planar_grid', '-f',
'grid_preCull.nc', '-p', projection]

check_call(args, logger=logger)
Expand All @@ -742,7 +742,7 @@ def build_mali_mesh(self, cell_width, x1, y1, geom_points,
write_netcdf(dsMesh, 'culled.nc')

logger.info('Marking horns for culling')
args = ['mark_horns_for_culling.py', '-f', 'culled.nc']
args = ['mark_horns_for_culling', '-f', 'culled.nc']

check_call(args, logger=logger)

Expand All @@ -753,24 +753,24 @@ def build_mali_mesh(self, cell_width, x1, y1, geom_points,
dsMesh = sort_mesh(dsMesh)
write_netcdf(dsMesh, 'dehorned.nc')

args = ['create_landice_grid_from_generic_MPAS_grid.py', '-i',
args = ['create_landice_grid_from_generic_mpas_grid', '-i',
'dehorned.nc', '-o',
mesh_name, '-l', levels, '-v', 'glimmer',
'--beta', '--thermal', '--obs', '--diri']

check_call(args, logger=logger)

args = ['interpolate_to_mpasli_grid.py', '-s',
args = ['interpolate_to_mpasli_grid', '-s',
gridded_dataset, '-d', mesh_name, '-m', 'b']

check_call(args, logger=logger)

logger.info('Marking domain boundaries dirichlet')
args = ['mark_domain_boundaries_dirichlet.py',
args = ['mark_domain_boundaries_dirichlet',
'-f', mesh_name]
check_call(args, logger=logger)

args = ['set_lat_lon_fields_in_planar_grid.py', '-f',
args = ['set_lat_lon_fields_in_planar_grid', '-f',
mesh_name, '-p', projection]
check_call(args, logger=logger)

Expand Down Expand Up @@ -1061,7 +1061,7 @@ def __guess_scrip_name(filename):

logger.info('creating scrip file for source dataset')
# Note: writing scrip file to workdir
args = ['create_SCRIP_file_from_planar_rectangular_grid.py',
args = ['create_scrip_file_from_planar_rectangular_grid',
'-i', source_file,
'-s', source_scrip,
'-p', proj,
Expand All @@ -1080,8 +1080,8 @@ def __guess_scrip_name(filename):
check_call(args, logger=logger)

# Perform actual interpolation using the weights
logger.info('calling interpolate_to_mpasli_grid.py')
args = ['interpolate_to_mpasli_grid.py',
logger.info('calling interpolate_to_mpasli_grid')
args = ['interpolate_to_mpasli_grid',
'-s', source_file,
'-d', dest_file,
'-m', 'e',
Expand Down
4 changes: 2 additions & 2 deletions compass/landice/tests/antarctica/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ def run(self):
# Also, it should be assessed if bilinear or
# barycentric used here is preferred for this application.
# Current thinking is they are both equally appropriate.
logger.info('calling interpolate_to_mpasli_grid.py')
args = ['interpolate_to_mpasli_grid.py', '-s',
logger.info('calling interpolate_to_mpasli_grid')
args = ['interpolate_to_mpasli_grid', '-s',
preprocessed_gridded_dataset,
'-d',
self.mesh_filename,
Expand Down
2 changes: 1 addition & 1 deletion compass/landice/tests/antarctica/mesh_gen/mesh_gen.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ bedmachine_filename = BedMachineAntarctica_2020-07-15_v02_edits_floodFill_extrap
measures_filename = antarctica_ice_velocity_450m_v2_edits_extrap.nc

# projection of the source datasets, according to the dictionary keys
# create_SCRIP_file_from_planar_rectangular_grid.py from MPAS_Tools
# create_scrip_file_from_planar_rectangular_grid from MPAS_Tools
src_proj = ais-bedmap2

# number of processors to use for ESMF_RegridWeightGen
Expand Down
9 changes: 4 additions & 5 deletions compass/landice/tests/circular_shelf/setup_mesh.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import numpy
from netCDF4 import Dataset as NetCDFFile

from mpas_tools.planar_hex import make_planar_hex_mesh
from mpas_tools.io import write_netcdf
from mpas_tools.mesh.conversion import convert, cull
from mpas_tools.logging import check_call
from mpas_tools.mesh.conversion import convert, cull
from mpas_tools.planar_hex import make_planar_hex_mesh
from netCDF4 import Dataset as NetCDFFile

from compass.model import make_graph_file
from compass.step import Step
Expand Down Expand Up @@ -60,7 +59,7 @@ def run(self):
write_netcdf(dsMesh, 'mpas_grid.nc')

levels = section.get('levels')
args = ['create_landice_grid_from_generic_MPAS_grid.py',
args = ['create_landice_grid_from_generic_mpas_grid',
'-i', 'mpas_grid.nc',
'-o', 'landice_grid.nc',
'-l', levels,
Expand Down
11 changes: 5 additions & 6 deletions compass/landice/tests/dome/setup_mesh.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import numpy
from netCDF4 import Dataset as NetCDFFile

from mpas_tools.planar_hex import make_planar_hex_mesh
from mpas_tools.io import write_netcdf
from mpas_tools.mesh.conversion import convert, cull
from mpas_tools.logging import check_call
from mpas_tools.mesh.conversion import convert, cull
from mpas_tools.planar_hex import make_planar_hex_mesh
from netCDF4 import Dataset as NetCDFFile

from compass.model import make_graph_file
from compass.step import Step
Expand Down Expand Up @@ -71,7 +70,7 @@ def run(self):
write_netcdf(dsMesh, 'mpas_grid.nc')

levels = section.get('levels')
args = ['create_landice_grid_from_generic_MPAS_grid.py',
args = ['create_landice_grid_from_generic_mpas_grid',
'-i', 'mpas_grid.nc',
'-o', 'landice_grid.nc',
'-l', levels]
Expand Down Expand Up @@ -158,7 +157,7 @@ def _setup_dome_initial_conditions(config, logger, filename):
thickness_field[r < r0] = h0 * (1.0 - (r[r < r0] / r0) ** 2) ** 0.5
elif dome_type == 'halfar':
thickness_field[r < r0] = h0 * (
1.0 - (r[r < r0] / r0) ** (4.0 / 3.0)) ** (3.0 / 7.0)
1.0 - (r[r < r0] / r0) ** (4.0 / 3.0)) ** (3.0 / 7.0)
else:
raise ValueError('Unexpected dome_type: {}'.format(dome_type))
thickness[0, :] = thickness_field
Expand Down
9 changes: 4 additions & 5 deletions compass/landice/tests/eismint2/setup_mesh.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import xarray

from mpas_tools.planar_hex import make_planar_hex_mesh
from mpas_tools.io import write_netcdf
from mpas_tools.mesh.conversion import convert, cull
from mpas_tools.logging import check_call
from mpas_tools.mesh.conversion import convert, cull
from mpas_tools.planar_hex import make_planar_hex_mesh

from compass.model import make_graph_file
from compass.step import Step
Expand Down Expand Up @@ -48,7 +47,7 @@ def run(self):
dsMesh.close()

radius = section.get('radius')
args = ['define_cullMask.py',
args = ['define_landice_cull_mask',
'-f', 'mpas_grid.nc',
'-m', 'radius',
'-d', radius]
Expand All @@ -61,7 +60,7 @@ def run(self):
write_netcdf(dsMesh, 'mpas_grid2.nc')

levels = section.get('levels')
args = ['create_landice_grid_from_generic_MPAS_grid.py',
args = ['create_landice_grid_from_generic_mpas_grid',
'-i', 'mpas_grid2.nc',
'-o', 'landice_grid.nc',
'-l', levels,
Expand Down
9 changes: 4 additions & 5 deletions compass/landice/tests/enthalpy_benchmark/setup_mesh.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from netCDF4 import Dataset as NetCDFFile

from mpas_tools.planar_hex import make_planar_hex_mesh
from mpas_tools.io import write_netcdf
from mpas_tools.mesh.conversion import convert, cull
from mpas_tools.logging import check_call
from mpas_tools.mesh.conversion import convert, cull
from mpas_tools.planar_hex import make_planar_hex_mesh
from netCDF4 import Dataset as NetCDFFile

from compass.model import make_graph_file
from compass.step import Step
Expand Down Expand Up @@ -49,7 +48,7 @@ def run(self):
dsMesh = convert(dsMesh, logger=logger)
write_netcdf(dsMesh, 'mpas_grid.nc')

args = ['create_landice_grid_from_generic_MPAS_grid.py',
args = ['create_landice_grid_from_generic_mpas_grid',
'-i', 'mpas_grid.nc',
'-o', 'landice_grid.nc',
'-l', levels,
Expand Down
2 changes: 1 addition & 1 deletion compass/landice/tests/greenland/mesh_gen/mesh_gen.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ bedmachine_filename = BedMachineGreenland-v5_edits_floodFill_extrap.nc
measures_filename = greenland_vel_mosaic500_extrap.nc

# projection of the source datasets, according to the dictionary keys
# create_SCRIP_file_from_planar_rectangular_grid.py from MPAS_Tools
# create_scrip_file_from_planar_rectangular_grid from MPAS_Tools
src_proj = gis-gimp

# number of processors to use for ESMF_RegridWeightGen
Expand Down
9 changes: 4 additions & 5 deletions compass/landice/tests/hydro_radial/setup_mesh.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import numpy as np
from netCDF4 import Dataset as NetCDFFile

from mpas_tools.planar_hex import make_planar_hex_mesh
from mpas_tools.io import write_netcdf
from mpas_tools.mesh.conversion import convert, cull
from mpas_tools.logging import check_call
from mpas_tools.mesh.conversion import convert, cull
from mpas_tools.planar_hex import make_planar_hex_mesh
from netCDF4 import Dataset as NetCDFFile

from compass.model import make_graph_file
from compass.step import Step
Expand Down Expand Up @@ -72,7 +71,7 @@ def run(self):
write_netcdf(dsMesh, 'mpas_grid.nc')

levels = section.get('levels')
args = ['create_landice_grid_from_generic_MPAS_grid.py',
args = ['create_landice_grid_from_generic_mpas_grid',
'-i', 'mpas_grid.nc',
'-o', 'landice_grid.nc',
'-l', levels,
Expand Down
6 changes: 3 additions & 3 deletions compass/landice/tests/ismip6_forcing/create_mapfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def build_mapping_file(config, cores, logger, ismip6_grid_file, mapping_file,
if scrip_from_latlon:
create_scrip_from_latlon(ismip6_grid_file, source_grid_scripfile)
else:
args = ["create_SCRIP_file_from_planar_rectangular_grid.py",
args = ["create_scrip_file_from_planar_rectangular_grid",
"--input", ismip6_grid_file,
"--scrip", source_grid_scripfile,
"--proj", ismip6_projection,
Expand All @@ -89,7 +89,7 @@ def build_mapping_file(config, cores, logger, ismip6_grid_file, mapping_file,
mali_mesh_copy = f"{mali_mesh_file}_copy"
shutil.copy(mali_mesh_file, f"{mali_mesh_file}_copy")

args = ["set_lat_lon_fields_in_planar_grid.py",
args = ["set_lat_lon_fields_in_planar_grid",
"--file", mali_mesh_copy,
"--proj", ismip6_projection]

Expand Down Expand Up @@ -133,7 +133,7 @@ def create_scrip_from_latlon(source_grid_file, source_grid_scripfile):
dataset.
This function is needed, c.f. the scrip utility in the MPAS-Tools repo
(i.e. `create_SCRIP_file_from_planar_rectangular_grid.py`), when a dataset
(i.e. `create_scrip_file_from_planar_rectangular_grid`), when a dataset
does not have `x`/`y` coordinates to generate the scrip file from. This is
the case for the atmospheric forcing datasets from ISMIP6
and for RACMO products.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ def _build_mapping_files(self, config, logger):
args = ['ncremap',
'-g', slm_scripfile,
'-G',
f'latlon={nglv},{2*int(nglv)}#lat_typ=gss#lat_drc=n2s']
f'latlon={nglv},{2 * int(nglv)}#lat_typ=gss#lat_drc=n2s']

check_call(args, logger=logger)

# mali scripfile
# first have to adjust lat-lon values as if they are on sphere
shutil.copy(init_cond_path, mali_meshfile)
args = ['set_lat_lon_fields_in_planar_grid.py',
args = ['set_lat_lon_fields_in_planar_grid',
'--file', mali_meshfile,
'--proj', 'ais-bedmap2-sphere']

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def run(self):

# mark horns for culling
logger.info('Marking horns for culling')
args = ['mark_horns_for_culling.py', '-f',
args = ['mark_horns_for_culling', '-f',
os.path.join(tmpdir, f'{source_file_rootname}_culled.nc')]
check_call(args, logger=logger)

Expand All @@ -158,8 +158,8 @@ def run(self):
write_netcdf(ds_out, dest_mesh_only_name)

# set lat/lon
logger.info('calling set_lat_lon_fields_in_planar_grid.py')
args = ['set_lat_lon_fields_in_planar_grid.py',
logger.info('calling set_lat_lon_fields_in_planar_grid')
args = ['set_lat_lon_fields_in_planar_grid',
'-f', dest_mesh_only_name, '-p', mesh_projection]
check_call(args, logger=logger)

Expand Down Expand Up @@ -206,8 +206,8 @@ def run(self):

elif interp_method == 'mali_interp':
# create landice mesh
logger.info('calling create_landice_grid_from_generic_MPAS_grid.py') # noqa
args = ['create_landice_grid_from_generic_MPAS_grid.py',
logger.info('calling create_landice_grid_from_generic_mpas_grid') # noqa
args = ['create_landice_grid_from_generic_mpas_grid',
'-i', os.path.join(tmpdir, 'dest_mesh_only.nc'),
'-o', dest_file_name,
'-l', f'{levels}', '-v', 'glimmer',
Expand All @@ -216,8 +216,8 @@ def run(self):

# interpolate to new mesh using nearest neighbor to ensure we get
# identical values
logger.info('calling interpolate_to_mpasli_grid.py')
args = ['interpolate_to_mpasli_grid.py',
logger.info('calling interpolate_to_mpasli_grid')
args = ['interpolate_to_mpasli_grid',
'-s', source_file_path,
'-d', dest_file_name, '-m', 'n']
check_call(args, logger=logger)
Expand All @@ -226,7 +226,7 @@ def run(self):

# mark Dirichlet boundaries
logger.info('Marking domain boundaries dirichlet')
args = ['mark_domain_boundaries_dirichlet.py',
args = ['mark_domain_boundaries_dirichlet',
'-f', dest_file_name]
check_call(args, logger=logger)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ grow_iters = 15
# nstd weight file and then uses ncremap to perform remapping.
# This method supports interpolating ancillary files (below)
# but likely needs to be run on a compute node and is more fragile.
# 'mali_interp' uses the MALI interpolation script interpolate_to_mpasli_grid.py
# 'mali_interp' uses the MALI interpolation script interpolate_to_mpasli_grid
# This method does not support ancillary files but may be more robust
# and can likely be run quickly on a login node.
interp_method = ncremap
Expand Down
2 changes: 1 addition & 1 deletion compass/landice/tests/mismipplus/setup_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def run(self):
levels = section.get('levels')
vertMethod = section.get('vetical_layer_distribution')

args = ['create_landice_grid_from_generic_MPAS_grid.py',
args = ['create_landice_grid_from_generic_mpas_grid',
'-i', 'mpas_grid.nc',
'-o', 'landice_grid.nc',
'-l', levels,
Expand Down

0 comments on commit e3c62f5

Please sign in to comment.