Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add stub ex-scripts, recentering class, and ctest for recentering task #916

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions scripts/exgdas_global_marine_analysis_ecen.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env python3
AndrewEichmann-NOAA marked this conversation as resolved.
Show resolved Hide resolved
# exgdas_global_marine_analysis_ecen.py
# This script creates an MarineRecenter class
# and runs the initialize, run, and finalize methods
# which currently are stubs
import os

from wxflow import Logger, cast_strdict_as_dtypedict
# TODO (AFE): change to from pygfs.task.marine_recenter import MarineRecenter
from soca.marine_recenter import MarineRecenter
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a comment with a TODO: to move marine_recenter.py to ush/python/pygfs/task in the global-workflow so that when the time comes, it is easily achieved.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it helps, it would be:

from pygfs.task.marine_recenter import MarineRecenter


# Initialize root logger
logger = Logger(level='DEBUG', colored_log=True)


if __name__ == '__main__':

# Take configuration from environment and cast it as python dictionary
config = cast_strdict_as_dtypedict(os.environ)

# Instantiate the aerosol analysis task
MarineRecen = MarineRecenter(config)
MarineRecen.initialize()
MarineRecen.run()
MarineRecen.finalize()
1 change: 1 addition & 0 deletions test/soca/gw/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ set(jjob_list "JGLOBAL_PREP_OCEAN_OBS"
"JGDAS_GLOBAL_OCEAN_ANALYSIS_PREP"
"JGDAS_GLOBAL_OCEAN_ANALYSIS_BMAT"
"JGDAS_GLOBAL_OCEAN_ANALYSIS_RUN"
"JGDAS_GLOBAL_OCEAN_ANALYSIS_ECEN"
"JGDAS_GLOBAL_OCEAN_ANALYSIS_CHKPT"
"JGDAS_GLOBAL_OCEAN_ANALYSIS_POST"
"JGDAS_GLOBAL_OCEAN_ANALYSIS_VRFY")
Expand Down
1 change: 1 addition & 0 deletions test/soca/gw/run_jjobs.yaml.test
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ gw environement:

run scripts:
GDASPREPOCNOBSPY: @HOMEgfs@/sorc/gdas.cd/scripts/exglobal_prep_ocean_obs.py
GDASOCNCENPY: @HOMEgfs@/sorc/gdas.cd/scripts/exgdas_global_marine_analysis_ecen.py

setup_expt config:
base:
Expand Down
46 changes: 46 additions & 0 deletions ush/soca/marine_recenter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env python3

import os
from logging import getLogger
from typing import Dict, List, Any
from wxflow import AttrDict, FileHandler, logit, Task

logger = getLogger(__name__.split('.')[-1])


class MarineRecenter(Task):

@logit(logger, name="MarineRecenter")
def __init__(self, config):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add stub documentation and follow typing hints. E.g.

Suggested change
def __init__(self, config):
def __init__(self, config: Dict) -> None:
"""Stub constructor for ocean recentering task
Parameters:
------------
config: Dict
configuration of XYZ
Returns
--------
None

Please see examples of tasks in ush/python/pygfs/task of the global-workflow.

logger.info("init")
super().__init__(config)

# Create a local dictionary that is repeatedly used across this class
local_dict = AttrDict(
{
"diags": os.path.join(self.runtime_config['DATA'], 'diags'), # output dir for soca DA obs space
"obs_in": os.path.join(self.runtime_config['DATA'], 'obs') , # input " "
"bkg_dir": os.path.join(self.runtime_config['DATA'], 'bkg'), # ice and ocean backgrounds
"anl_out": os.path.join(self.runtime_config['DATA'], 'Data'), # output dir for soca DA
"static_ens": os.path.join(self.runtime_config['DATA'], 'static_ens') # clim. ens.
}
)

# task_config is everything that this task should need
self.task_config = AttrDict(**self.config, **self.runtime_config, **local_dict)

#_soca_ensb_yaml_temp
print(self.task_config)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use logger.info or logger.debug
Also, since printing a dictionary, please use pformat

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is temporary for debugging


@logit(logger)
def initialize(self):
logger.info("initialize")


@logit(logger)
def run(self):
logger.info("run")

@logit(logger)
def finalize(self):
logger.info("finalize")
Loading