Skip to content

Commit

Permalink
Fix formatting with pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
xylar committed Feb 17, 2023
1 parent 4c10b26 commit 357a6f3
Show file tree
Hide file tree
Showing 12 changed files with 122 additions and 99 deletions.
43 changes: 24 additions & 19 deletions compass/ocean/tests/global_ocean/__init__.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
from compass.testgroup import TestGroup

from compass.ocean.tests.global_ocean.mesh import Mesh
from compass.ocean.tests.global_ocean.mesh.qu240.dynamic_adjustment import \
QU240DynamicAdjustment
from compass.ocean.tests.global_ocean.mesh.ec30to60.dynamic_adjustment import \
EC30to60DynamicAdjustment
from compass.ocean.tests.global_ocean.mesh.arrm10to60.dynamic_adjustment \
import ARRM10to60DynamicAdjustment
from compass.ocean.tests.global_ocean.mesh.so12to60.dynamic_adjustment import \
SO12to60DynamicAdjustment
from compass.ocean.tests.global_ocean.mesh.wc14.dynamic_adjustment import \
WC14DynamicAdjustment
from compass.ocean.tests.global_ocean.analysis_test import AnalysisTest
from compass.ocean.tests.global_ocean.daily_output_test import DailyOutputTest
from compass.ocean.tests.global_ocean.decomp_test import DecompTest
from compass.ocean.tests.global_ocean.files_for_e3sm import FilesForE3SM
from compass.ocean.tests.global_ocean.init import Init
from compass.ocean.tests.global_ocean.mesh import Mesh
from compass.ocean.tests.global_ocean.mesh.arrm10to60.dynamic_adjustment import ( # noqa: E501
ARRM10to60DynamicAdjustment,
)
from compass.ocean.tests.global_ocean.mesh.ec30to60.dynamic_adjustment import (
EC30to60DynamicAdjustment,
)
from compass.ocean.tests.global_ocean.mesh.qu240.dynamic_adjustment import (
QU240DynamicAdjustment,
)
from compass.ocean.tests.global_ocean.mesh.so12to60.dynamic_adjustment import (
SO12to60DynamicAdjustment,
)
from compass.ocean.tests.global_ocean.mesh.wc14.dynamic_adjustment import (
WC14DynamicAdjustment,
)
from compass.ocean.tests.global_ocean.monthly_output_test import (
MonthlyOutputTest,
)
from compass.ocean.tests.global_ocean.performance_test import PerformanceTest
from compass.ocean.tests.global_ocean.restart_test import RestartTest
from compass.ocean.tests.global_ocean.decomp_test import DecompTest
from compass.ocean.tests.global_ocean.threads_test import ThreadsTest
from compass.ocean.tests.global_ocean.analysis_test import AnalysisTest
from compass.ocean.tests.global_ocean.daily_output_test import DailyOutputTest
from compass.ocean.tests.global_ocean.monthly_output_test import \
MonthlyOutputTest
from compass.ocean.tests.global_ocean.files_for_e3sm import FilesForE3SM
from compass.testgroup import TestGroup


class GlobalOcean(TestGroup):
Expand Down
2 changes: 1 addition & 1 deletion compass/ocean/tests/global_ocean/files_for_e3sm/README
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ E3SM members should NOT attempt to upload these files. The files produced here
are only a subset of those needed to support a new mesh in E3SM and should not
be uploaded on their own. E3SM experts who know how to produce the other
coupling files may upload these files along with other required datasets to the
LCRC server.
LCRC server.
48 changes: 28 additions & 20 deletions compass/ocean/tests/global_ocean/files_for_e3sm/__init__.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@
import os

from compass.io import symlink, package_path
from compass.testcase import TestCase
from compass.ocean.tests.global_ocean.files_for_e3sm.ocean_initial_condition \
import OceanInitialCondition
from compass.ocean.tests.global_ocean.files_for_e3sm.seaice_initial_condition \
import SeaiceInitialCondition
from compass.ocean.tests.global_ocean.files_for_e3sm.ocean_graph_partition \
import OceanGraphPartition
from compass.ocean.tests.global_ocean.files_for_e3sm.seaice_graph_partition \
import SeaiceGraphPartition
from compass.io import package_path, symlink
from compass.ocean.tests.global_ocean.configure import configure_global_ocean
from compass.ocean.tests.global_ocean.files_for_e3sm.diagnostic_maps import (
DiagnosticMaps,
)
from compass.ocean.tests.global_ocean.files_for_e3sm.diagnostic_masks import (
DiagnosticMasks,
)
from compass.ocean.tests.global_ocean.files_for_e3sm.e3sm_to_cmip_maps import (
E3smToCmipMaps,
)
from compass.ocean.tests.global_ocean.files_for_e3sm.ocean_graph_partition import ( # noqa: E501
OceanGraphPartition,
)
from compass.ocean.tests.global_ocean.files_for_e3sm.ocean_initial_condition import ( # noqa: E501
OceanInitialCondition,
)
from compass.ocean.tests.global_ocean.files_for_e3sm.scrip import Scrip
from compass.ocean.tests.global_ocean.files_for_e3sm.e3sm_to_cmip_maps import \
E3smToCmipMaps
from compass.ocean.tests.global_ocean.files_for_e3sm.diagnostic_maps \
import DiagnosticMaps
from compass.ocean.tests.global_ocean.files_for_e3sm.diagnostic_masks \
import DiagnosticMasks
from compass.ocean.tests.global_ocean.files_for_e3sm.seaice_graph_partition import ( # noqa: E501
SeaiceGraphPartition,
)
from compass.ocean.tests.global_ocean.files_for_e3sm.seaice_initial_condition import ( # noqa: E501
SeaiceInitialCondition,
)
from compass.ocean.tests.global_ocean.forward import get_forward_subdir
from compass.ocean.tests.global_ocean.configure import configure_global_ocean
from compass.testcase import TestCase


class FilesForE3SM(TestCase):
Expand All @@ -38,7 +45,7 @@ class FilesForE3SM(TestCase):
dynamic_adjustment : compass.ocean.tests.global_ocean.dynamic_adjustment.DynamicAdjustment
The test case that performs dynamic adjustment to dissipate
fast-moving waves from the initial condition
"""
""" # noqa: E501
def __init__(self, test_group, mesh=None, init=None,
dynamic_adjustment=None):
"""
Expand All @@ -58,11 +65,12 @@ def __init__(self, test_group, mesh=None, init=None,
dynamic_adjustment : compass.ocean.tests.global_ocean.dynamic_adjustment.DynamicAdjustment, optional
The test case that performs dynamic adjustment to dissipate
fast-moving waves from the initial condition
"""
""" # noqa: E501
name = 'files_for_e3sm'
if dynamic_adjustment is not None:
time_integrator = dynamic_adjustment.time_integrator
subdir = get_forward_subdir(init.init_subdir, time_integrator, name)
subdir = get_forward_subdir(
init.init_subdir, time_integrator, name)
else:
subdir = name

Expand Down
29 changes: 17 additions & 12 deletions compass/ocean/tests/global_ocean/files_for_e3sm/diagnostic_maps.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import os
import glob
import pyproj
import numpy
import os

from pyremap import get_lat_lon_descriptor, ProjectionGridDescriptor, \
MpasMeshDescriptor, Remapper
import numpy
import pyproj
from pyremap import (
MpasMeshDescriptor,
ProjectionGridDescriptor,
Remapper,
get_lat_lon_descriptor,
)

from compass.io import symlink
from compass.ocean.tests.global_ocean.files_for_e3sm.files_for_e3sm_step \
import FilesForE3SMStep
from compass.ocean.tests.global_ocean.files_for_e3sm.files_for_e3sm_step import ( # noqa: E501
FilesForE3SMStep,
)


class DiagnosticMaps(FilesForE3SMStep):
Expand All @@ -24,7 +29,7 @@ def __init__(self, test_case):
----------
test_case : compass.ocean.tests.global_ocean.files_for_e3sm.FilesForE3SM
The test case this step belongs to
"""
""" # noqa: E501

super().__init__(test_case, name='diagnostics_maps', ntasks=36,
min_tasks=1)
Expand Down Expand Up @@ -206,8 +211,8 @@ def _make_mapping_file(mesh_name, out_grid_name, mesh_filename, out_descriptor,

remapper = Remapper(in_descriptor, out_descriptor, mapping_file_name)

remapper.build_mapping_file(method='bilinear', mpiTasks=ntasks, tempdir='.',
logger=logger,
remapper.build_mapping_file(method='bilinear', mpiTasks=ntasks,
tempdir='.', logger=logger,
esmf_parallel_exec=parallel_executable)

# now the same on vertices (e.g. for streamfunctions)
Expand All @@ -217,6 +222,6 @@ def _make_mapping_file(mesh_name, out_grid_name, mesh_filename, out_descriptor,

remapper = Remapper(in_descriptor, out_descriptor, mapping_file_name)

remapper.build_mapping_file(method='bilinear', mpiTasks=ntasks, tempdir='.',
logger=logger,
remapper.build_mapping_file(method='bilinear', mpiTasks=ntasks,
tempdir='.', logger=logger,
esmf_parallel_exec=parallel_executable)
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import os
import xarray as xr

import mpas_tools.io
import xarray as xr
from geometric_features import GeometricFeatures
from geometric_features.aggregation import get_aggregator_by_name
from mpas_tools.io import write_netcdf
from mpas_tools.logging import check_call
from mpas_tools.ocean.moc import add_moc_southern_boundary_transects
from mpas_tools.io import write_netcdf
import mpas_tools.io

from compass.io import symlink
from compass.ocean.tests.global_ocean.files_for_e3sm.files_for_e3sm_step \
import FilesForE3SMStep
from compass.ocean.tests.global_ocean.files_for_e3sm.files_for_e3sm_step import ( # noqa: E501
FilesForE3SMStep,
)


class DiagnosticMasks(FilesForE3SMStep):
Expand All @@ -27,7 +28,7 @@ def __init__(self, test_case):
----------
test_case : compass.ocean.tests.global_ocean.files_for_e3sm.FilesForE3SM
The test case this step belongs to
"""
""" # noqa: E501

super().__init__(test_case, name='diagnostics_masks', cpus_per_task=18,
min_cpus_per_task=1)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import os
import xarray

from mpas_tools.logging import check_call

from compass.io import symlink
from compass.ocean.tests.global_ocean.files_for_e3sm.files_for_e3sm_step \
import FilesForE3SMStep
from compass.ocean.tests.global_ocean.files_for_e3sm.files_for_e3sm_step import ( # noqa: E501
FilesForE3SMStep,
)


class E3smToCmipMaps(FilesForE3SMStep):
Expand All @@ -21,7 +21,7 @@ def __init__(self, test_case):
----------
test_case : compass.ocean.tests.global_ocean.files_for_e3sm.FilesForE3SM
The test case this step belongs to
"""
""" # noqa: E501

super().__init__(test_case, name='e3sm_to_cmip_maps', ntasks=36,
min_tasks=1)
Expand Down Expand Up @@ -76,7 +76,7 @@ def make_e3sm_to_cmip_maps(config, logger, mesh_short_name, creation_date,
The number of parallel tasks to use for remapping
"""

link_dir = f'../assembled_files/diagnostics/maps'
link_dir = '../assembled_files/diagnostics/maps'

try:
os.makedirs(link_dir)
Expand All @@ -86,9 +86,9 @@ def make_e3sm_to_cmip_maps(config, logger, mesh_short_name, creation_date,
src_scrip_filename = 'ocean.scrip.nc'
cmip6_grid_res = config.get('files_for_e3sm', 'cmip6_grid_res')
if cmip6_grid_res == '180x360':
dst_scrip_filename = f'cmip6_180x360_scrip.20181001.nc'
dst_scrip_filename = 'cmip6_180x360_scrip.20181001.nc'
elif cmip6_grid_res == '720x1440':
dst_scrip_filename = f'cmip6_720x1440_scrip.20181001.nc'
dst_scrip_filename = 'cmip6_720x1440_scrip.20181001.nc'
else:
raise ValueError(f'Unexpected cmip6_grid_res: {cmip6_grid_res}')

Expand Down Expand Up @@ -116,7 +116,7 @@ def make_e3sm_to_cmip_maps(config, logger, mesh_short_name, creation_date,
check_call(args, logger=logger)

map_filename = \
f'map_{mesh_short_name}_to_cmip6_{cmip6_grid_res}_{suffix}.{creation_date}.nc'
f'map_{mesh_short_name}_to_cmip6_{cmip6_grid_res}_{suffix}.{creation_date}.nc' # noqa: E501

symlink(os.path.abspath(local_map_filename),
f'{link_dir}/{map_filename}')
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import os
import xarray as xr
from datetime import datetime

import xarray as xr

from compass.io import symlink
from compass.step import Step

Expand Down Expand Up @@ -94,7 +95,7 @@ def setup(self):
self.with_ice_shelf_cavities = \
(with_ice_shelf_cavities.lower() == 'true')

def run(self):
def run(self): # noqa: C901
"""
Run this step of the testcase
"""
Expand Down Expand Up @@ -136,12 +137,11 @@ def run(self):
# assume it's already YYYYMMDD
pass
break


if mesh_short_name == 'autodetect':
raise ValueError(
'No mesh short name provided in "mesh_short_name" config option '
'and none found in MPAS_Mesh_Short_Name attribute.')
'No mesh short name provided in "mesh_short_name" config '
'option and none found in MPAS_Mesh_Short_Name attribute.')

if creation_date == 'autodetect':
now = datetime.now()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import os
import numpy as np
from glob import glob

import numpy as np
from mpas_tools.logging import check_call

from compass.io import symlink
from compass.ocean.tests.global_ocean.files_for_e3sm.files_for_e3sm_step \
import FilesForE3SMStep
from compass.ocean.tests.global_ocean.files_for_e3sm.graph_partition import \
get_core_list
from compass.ocean.tests.global_ocean.files_for_e3sm.files_for_e3sm_step import ( # noqa: E501
FilesForE3SMStep,
)
from compass.ocean.tests.global_ocean.files_for_e3sm.graph_partition import (
get_core_list,
)


class OceanGraphPartition(FilesForE3SMStep):
Expand All @@ -23,7 +25,7 @@ def __init__(self, test_case):
----------
test_case : compass.ocean.tests.global_ocean.files_for_e3sm.FilesForE3SM
The test case this step belongs to
"""
""" # noqa: E501

super().__init__(test_case, name='ocean_graph_partition')

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import os
import xarray

import xarray
from mpas_tools.io import write_netcdf

from compass.io import symlink
from compass.ocean.tests.global_ocean.files_for_e3sm.files_for_e3sm_step \
import FilesForE3SMStep
from compass.ocean.tests.global_ocean.files_for_e3sm.files_for_e3sm_step import ( # noqa: E501
FilesForE3SMStep,
)


class OceanInitialCondition(FilesForE3SMStep):
Expand All @@ -21,7 +22,7 @@ def __init__(self, test_case):
----------
test_case : compass.ocean.tests.global_ocean.files_for_e3sm.FilesForE3SM
The test case this step belongs to
"""
""" # noqa: E501

super().__init__(test_case, name='ocean_initial_condition')

Expand Down
8 changes: 4 additions & 4 deletions compass/ocean/tests/global_ocean/files_for_e3sm/scrip.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import os
import xarray

from mpas_tools.scrip.from_mpas import scrip_from_mpas

from compass.io import symlink
from compass.ocean.tests.global_ocean.files_for_e3sm.files_for_e3sm_step \
import FilesForE3SMStep
from compass.ocean.tests.global_ocean.files_for_e3sm.files_for_e3sm_step import ( # noqa: E501
FilesForE3SMStep,
)


class Scrip(FilesForE3SMStep):
Expand All @@ -20,7 +20,7 @@ def __init__(self, test_case):
----------
test_case : compass.ocean.tests.global_ocean.files_for_e3sm.FilesForE3SM
The test case this step belongs to
"""
""" # noqa: E501

super().__init__(test_case, name='scrip')

Expand Down
Loading

0 comments on commit 357a6f3

Please sign in to comment.