Source code for compass.landice.tests.eismint2.setup_mesh

import xarray

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

from compass.model import make_graph_file
from compass.step import Step

[docs]class SetupMesh(Step): """ A step for creating a mesh and initial condition for EISMINT2 test cases """
[docs] def __init__(self, test_case): """ Create the step Parameters ---------- test_case : compass.TestCase The test case this step belongs to """ super().__init__(test_case=test_case, name='setup_mesh') self.add_output_file(filename='') self.add_output_file(filename='')
# no setup() method is needed
[docs] def run(self): """ Run this step of the test case """ logger = self.logger section = self.config['eismint2'] nx = section.getint('nx') ny = section.getint('ny') dc = section.getfloat('dc') dsMesh = make_planar_hex_mesh(nx=nx, ny=ny, dc=dc, nonperiodic_x=False, nonperiodic_y=False) dsMesh = convert(dsMesh, logger=logger) write_netcdf(dsMesh, '') dsMesh.close() radius = section.get('radius') args = ['', '-f', '', '-m', 'radius', '-d', radius] check_call(args, logger) dsMesh = xarray.open_dataset('') dsMesh = cull(dsMesh, logger=logger) dsMesh = convert(dsMesh, logger=logger) write_netcdf(dsMesh, '') levels = section.get('levels') args = ['', '-i', '', '-o', '', '-l', levels, '--thermal', '--beta'] check_call(args, logger) make_graph_file(mesh_filename='', graph_filename='')