forked from NOAA-EMC/global-workflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add task to prepare emissions for GEFS (NOAA-EMC#2562)
This PR: - introduces a task to prepare emissions for a forecast into the GEFS application. - adds configuration, j-job, rocoto job, ex-script and the python class for this job - updates GEFS workflow to be able to generate the XML to call this job. - updates the `fcst` and `efcs` job dependencies in the GEFS application to depend on `prep_emissions` if aerosols are turned ON. - provides a placeholder for @bbakernoaa to work on the details for preparing emissions. Co-authored-by: Walter Kolczynski - NOAA <[email protected]>
- Loading branch information
1 parent
233c188
commit 9b6f840
Showing
15 changed files
with
259 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#! /usr/bin/env bash | ||
|
||
source "${HOMEgfs}/ush/preamble.sh" | ||
source "${HOMEgfs}/ush/jjob_header.sh" -e "prep_emissions" -c "base prep_emissions" | ||
|
||
############################################## | ||
# Set variables used in the script | ||
############################################## | ||
# TODO: Set local variables used in this script e.g. GDATE may be needed for previous cycle | ||
|
||
############################################## | ||
# Begin JOB SPECIFIC work | ||
############################################## | ||
# Generate COM variables from templates | ||
# TODO: Add necessary COMIN, COMOUT variables for this job | ||
|
||
############################################################### | ||
# Run relevant script | ||
EXSCRIPT=${PREP_EMISSIONS_PY:-${SCRgfs}/exglobal_prep_emissions.py} | ||
${EXSCRIPT} | ||
status=$? | ||
(( status != 0 )) && ( echo "FATAL ERROR: Error executing ${EXSCRIPT}, ABORT!"; exit "${status}" ) | ||
|
||
############################################## | ||
# End JOB SPECIFIC work | ||
############################################## | ||
|
||
############################################## | ||
# Final processing | ||
############################################## | ||
if [[ -e "${pgmout}" ]] ; then | ||
cat "${pgmout}" | ||
fi | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#! /usr/bin/env bash | ||
|
||
source "${HOMEgfs}/ush/preamble.sh" | ||
|
||
############################################################### | ||
# Source UFSDA workflow modules | ||
source "${HOMEgfs}/ush/load_fv3gfs_modules.sh" | ||
status=$? | ||
(( status != 0 )) && exit "${status}" | ||
|
||
export job="prep_emissions" | ||
export jobid="${job}.$$" | ||
|
||
############################################################### | ||
# setup python path for workflow utilities and tasks | ||
PYTHONPATH="${PYTHONPATH:+${PYTHONPATH}:}${HOMEgfs}/ush/python" | ||
export PYTHONPATH | ||
|
||
############################################################### | ||
# Execute the JJOB | ||
"${HOMEgfs}/jobs/JGLOBAL_PREP_EMISSIONS" | ||
status=$? | ||
exit "${status}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#! /usr/bin/env bash | ||
|
||
########## config.prep_emissions ########## | ||
# aerosol emissions preprocessing specific | ||
|
||
echo "BEGIN: config.prep_emissions" | ||
|
||
# Get task specific resources | ||
source "${EXPDIR}/config.resources" prep_emissions | ||
|
||
echo "END: config.prep_emissions" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env python3 | ||
# exglobal_prep_emissions.py | ||
# This script creates a emissions object | ||
# which perform the pre-processing for aerosol emissions | ||
import os | ||
|
||
from wxflow import Logger, cast_strdict_as_dtypedict | ||
from pygfs import AerosolEmissions | ||
|
||
|
||
# Initialize root logger | ||
logger = Logger(level=os.environ.get("LOGGING_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 emissions pre-processing task | ||
emissions = AerosolEmissions(config) | ||
emissions.initialize() | ||
emissions.configure() | ||
emissions.execute(emissions.task_config.DATA, emissions.task_config.APRUN) | ||
emissions.finalize() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
import os | ||
|
||
from .task.analysis import Analysis | ||
from .task.aero_emissions import AerosolEmissions | ||
from .task.aero_analysis import AerosolAnalysis | ||
from .task.atm_analysis import AtmAnalysis | ||
from .task.atmens_analysis import AtmEnsAnalysis | ||
from .task.snow_analysis import SnowAnalysis | ||
from .task.upp import UPP | ||
from .task.oceanice_products import OceanIceProducts | ||
from .task.gfs_forecast import GFSForecast | ||
|
||
__docformat__ = "restructuredtext" | ||
__version__ = "0.1.0" | ||
pygfs_directory = os.path.dirname(__file__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import os | ||
from logging import getLogger | ||
from typing import Dict, Any, Union | ||
from pprint import pformat | ||
|
||
from wxflow import (AttrDict, | ||
parse_j2yaml, | ||
FileHandler, | ||
Jinja, | ||
logit, | ||
Task, | ||
add_to_datetime, to_timedelta, | ||
WorkflowException, | ||
Executable, which) | ||
|
||
logger = getLogger(__name__.split('.')[-1]) | ||
|
||
|
||
class AerosolEmissions(Task): | ||
"""Aerosol Emissions pre-processing Task | ||
""" | ||
|
||
@logit(logger, name="AerosolEmissions") | ||
def __init__(self, config: Dict[str, Any]) -> None: | ||
"""Constructor for the Aerosol Emissions task | ||
Parameters | ||
---------- | ||
config : Dict[str, Any] | ||
Incoming configuration for the task from the environment | ||
Returns | ||
------- | ||
None | ||
""" | ||
super().__init__(config) | ||
|
||
local_variable = "something" | ||
|
||
localdict = AttrDict( | ||
{'variable_used_repeatedly': local_variable} | ||
) | ||
self.task_config = AttrDict(**self.config, **self.runtime_config, **localdict) | ||
|
||
@staticmethod | ||
@logit(logger) | ||
def initialize() -> None: | ||
"""Initialize the work directory | ||
""" | ||
|
||
@staticmethod | ||
@logit(logger) | ||
def configure() -> None: | ||
"""Configure the artifacts in the work directory. | ||
Copy run specific data to run directory | ||
""" | ||
|
||
@staticmethod | ||
@logit(logger) | ||
def execute(workdir: Union[str, os.PathLike], aprun_cmd: str) -> None: | ||
"""Run the executable (if any) | ||
Parameters | ||
---------- | ||
workdir : str | os.PathLike | ||
work directory with the staged data, parm files, namelists, etc. | ||
aprun_cmd : str | ||
launcher command for executable.x | ||
Returns | ||
------- | ||
None | ||
""" | ||
|
||
@staticmethod | ||
@logit(logger) | ||
def finalize() -> None: | ||
"""Perform closing actions of the task. | ||
Copy data back from the DATA/ directory to COM/ | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters