From d017f7be9682f0435dad513912c686039f2b0f0c Mon Sep 17 00:00:00 2001 From: Carolyn Begeman Date: Thu, 11 Jan 2024 17:16:19 -0600 Subject: [PATCH] Fixup docstrings --- polaris/ocean/ice_shelf/__init__.py | 45 ++++++++++++++++++- polaris/ocean/ice_shelf/ssh_adjustment.py | 18 +++++--- polaris/ocean/ice_shelf/ssh_forward.py | 32 ++++++++++--- .../tasks/ice_shelf_2d/default/__init__.py | 15 ++++--- polaris/ocean/tasks/ice_shelf_2d/forward.py | 14 +++++- polaris/ocean/tasks/ice_shelf_2d/validate.py | 7 +-- polaris/ocean/tasks/ice_shelf_2d/viz.py | 14 +++++- 7 files changed, 121 insertions(+), 24 deletions(-) diff --git a/polaris/ocean/ice_shelf/__init__.py b/polaris/ocean/ice_shelf/__init__.py index c21078d5e..81b0c2b34 100644 --- a/polaris/ocean/ice_shelf/__init__.py +++ b/polaris/ocean/ice_shelf/__init__.py @@ -8,10 +8,22 @@ class IceShelfTask(Task): """ - shared_steps : dict of dict of polaris.Steps - The shared steps to include as symlinks + A class for tasks with domains containing ice shelves + + Attributes + ---------- + sshdir : string + The directory to put the ssh_adjustment steps in + + component : polaris.ocean.Ocean + The ocean component that this task belongs to + + resolution : float + The resolution of the test case in km """ def __init__(self, component, resolution, name, subdir, sshdir=None): + """ + """ if sshdir is None: sshdir = subdir super().__init__(component=component, name=name, subdir=subdir) @@ -24,6 +36,35 @@ def setup_ssh_adjustment_steps(self, init, config, config_filename, yaml_filename='ssh_forward.yaml', yaml_replacements=None): + """ + Parameters + ---------- + init : polaris.Step + the step that produced the initial condition + + config : polaris.config.PolarisConfigParser + The configuration for this task + + config_filename : str + the configuration filename + + package : Package + The package name or module object that contains ``namelist`` + from which ssh_forward steps will derive their configuration + + yaml_filename : str, optional + the yaml filename used for ssh_forward steps + + yaml_replacements : Dict, optional + key, string combinations for templated replacements in the yaml + file + + Returns + ------- + shared_step : polaris.Step + the final ssh_adjustment step that produces the input to the next + forward step + """ resolution = self.resolution component = self.component indir = self.sshdir diff --git a/polaris/ocean/ice_shelf/ssh_adjustment.py b/polaris/ocean/ice_shelf/ssh_adjustment.py index 7eb4a45f8..0b1543828 100644 --- a/polaris/ocean/ice_shelf/ssh_adjustment.py +++ b/polaris/ocean/ice_shelf/ssh_adjustment.py @@ -18,14 +18,23 @@ def __init__(self, component, resolution, init, forward, indir=None, Parameters ---------- + component : polaris.ocean.Ocean + The ocean component that this task belongs to + resolution : float The resolution of the test case in m - coord_type: str - The coordinate type (e.g., 'z-star', 'single_layer', etc.) + init : polaris.Step + the step that produced the initial condition + + forward: polaris.Step + the step that produced the state which will be adjusted - iteration : int, optional - the iteration number + indir : str, optional + the directory the step is in, to which ``name`` will be appended + + name : str, optional + the name of this step """ self.resolution = resolution @@ -46,7 +55,6 @@ def run(self): """ Adjust the sea surface height or land-ice pressure to be dynamically consistent with one another. - """ logger = self.logger config = self.config diff --git a/polaris/ocean/ice_shelf/ssh_forward.py b/polaris/ocean/ice_shelf/ssh_forward.py index e02c6036e..cd32d5a1c 100644 --- a/polaris/ocean/ice_shelf/ssh_forward.py +++ b/polaris/ocean/ice_shelf/ssh_forward.py @@ -12,11 +12,15 @@ class SshForward(OceanModelStep): resolution : float The resolution of the task in km - dt : float - The model time step in seconds + package : Package + The package name or module object that contains ``namelist`` - btr_dt : float - The model barotropic time step in seconds + yaml_filename : str, optional + the yaml filename used for ssh_forward steps + + yaml_replacements : Dict, optional + key, string combinations for templated replacements in the yaml + file """ def __init__(self, component, resolution, mesh, init, name='ssh_forward', subdir=None, @@ -37,16 +41,32 @@ def __init__(self, component, resolution, mesh, init, name : str the name of the task + mesh: polaris.Step + The step used to produce the mesh + + init: polaris.Step + The step used to produce the initial condition + subdir : str, optional the subdirectory for the step. If neither this nor ``indir`` are provided, the directory is the ``name`` - indir : str, optional - the directory the step is in, to which ``name`` will be appended + package : str, optional + where ssh_forward steps will derive their configuration + + yaml_filename : str, optional + the yaml filename used for ssh_forward steps + + yaml_replacements : Dict, optional + key, string combinations for templated replacements in the yaml + file iteration : int, optional the iteration number + indir : str, optional + the directory the step is in, to which ``name`` will be appended + ntasks : int, optional the number of tasks the step would ideally use. If fewer tasks are available on the system, the step will run on all available diff --git a/polaris/ocean/tasks/ice_shelf_2d/default/__init__.py b/polaris/ocean/tasks/ice_shelf_2d/default/__init__.py index 403b0cbfc..235ff2c86 100644 --- a/polaris/ocean/tasks/ice_shelf_2d/default/__init__.py +++ b/polaris/ocean/tasks/ice_shelf_2d/default/__init__.py @@ -7,12 +7,11 @@ class Default(IceShelfTask): """ The default ice shelf 2d test case simply creates the mesh and - initial condition, then performs a short forward run. + initial condition, then performs a short forward run. Optionally, + tidal forcing can be added or visualization and restart steps. Attributes ---------- - include_viz : bool - Include Viz step """ def __init__(self, component, resolution, indir, init, config, @@ -33,10 +32,16 @@ def __init__(self, component, resolution, indir, init, config, The directory the task is in, to which the test case name will be added - include_viz : bool + config : polaris.config.PolarisConfigParser + The configuration for this task + + include_viz : bool, optional Include VizMap and Viz steps for each resolution - include_tides: bool + include_restart : bool, optional + Include restart and validation steps to test restart capabilities + + include_tides : bool, optional Include tidal forcing in the forward step """ if include_tides and include_restart: diff --git a/polaris/ocean/tasks/ice_shelf_2d/forward.py b/polaris/ocean/tasks/ice_shelf_2d/forward.py index bd4beff2a..b8ad03372 100644 --- a/polaris/ocean/tasks/ice_shelf_2d/forward.py +++ b/polaris/ocean/tasks/ice_shelf_2d/forward.py @@ -29,7 +29,13 @@ def __init__(self, component, resolution, mesh, init, resolution : km The resolution of the task in km - name : str + mesh: polaris.Step + The step used to produce the mesh + + init: polaris.Step + The step used to produce the initial condition + + name : str, optional the name of the task subdir : str, optional @@ -50,6 +56,12 @@ def __init__(self, component, resolution, mesh, init, openmp_threads : int, optional the number of OpenMP threads the step will use + + do_restart : bool, optional + if true, the step is restart from another forward run + + tidal_forcing : bool, optional + if true, apply tidal forcing in the forward step """ if do_restart: name = 'restart' diff --git a/polaris/ocean/tasks/ice_shelf_2d/validate.py b/polaris/ocean/tasks/ice_shelf_2d/validate.py index 249347a07..b8c17ab40 100644 --- a/polaris/ocean/tasks/ice_shelf_2d/validate.py +++ b/polaris/ocean/tasks/ice_shelf_2d/validate.py @@ -9,7 +9,7 @@ class Validate(Step): Attributes ---------- step_subdirs : list of str - The number of processors used in each run + The steps to be compared (full run and restart run) """ def __init__(self, component, step_subdirs, indir): """ @@ -21,10 +21,11 @@ def __init__(self, component, step_subdirs, indir): The component the step belongs to step_subdirs : list of str - The number of processors used in each run + The steps to be compared (full run and restart run) indir : str - the directory the step is in, to which ``name`` will be appended + the directory the step is in, to which ``validate`` will be + appended """ super().__init__(component=component, name='validate', indir=indir) diff --git a/polaris/ocean/tasks/ice_shelf_2d/viz.py b/polaris/ocean/tasks/ice_shelf_2d/viz.py index 81a46e7aa..84d334935 100644 --- a/polaris/ocean/tasks/ice_shelf_2d/viz.py +++ b/polaris/ocean/tasks/ice_shelf_2d/viz.py @@ -20,8 +20,18 @@ def __init__(self, component, indir, mesh, init): Parameters ---------- - test_case : compass.TestCase - The test case this step belongs to + component : polaris.Component + The component the step belongs to + + indir : str, optional + the directory the step is in, to which ``viz`` will be appended + + mesh: polaris.Step + The step used to produce the mesh + + init: polaris.Step + The step used to produce the initial condition + """ super().__init__(component=component, name='viz', indir=indir) self.add_input_file(