-
Notifications
You must be signed in to change notification settings - Fork 0
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
Stat Analysis Implementation #6
Changes from 13 commits
fbe784d
cce943c
3f7a4ae
0ac03dc
7619723
8064939
f693390
e94e3d6
e4f0733
d412762
17dbc15
b621034
243e1e0
587a7c5
4d0b219
c7e5f05
668c39d
7893aa1
2b98b84
9cd2fcd
e15422d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#! /usr/bin/env bash | ||
|
||
source "${HOMEgfs}/ush/preamble.sh" | ||
export DATA=${DATA:-${DATAROOT}/${RUN}statanl_${cyc}} | ||
source "${HOMEgfs}/ush/jjob_header.sh" -e "anlstat" -c "base anlstat" | ||
|
||
############################################## | ||
# Set variables used in the script | ||
############################################## | ||
|
||
|
||
############################################## | ||
# Begin JOB SPECIFIC work | ||
############################################## | ||
|
||
|
||
############################################################### | ||
# Run relevant script | ||
|
||
EXSCRIPT=${ANLSTATSPY:-${SCRgfs}/exglobal_analysis_stats.py} | ||
${EXSCRIPT} | ||
status=$? | ||
[[ ${status} -ne 0 ]] && exit "${status}" | ||
|
||
############################################## | ||
# End JOB SPECIFIC work | ||
############################################## | ||
|
||
############################################## | ||
# Final processing | ||
############################################## | ||
if [[ -e "${pgmout}" ]] ; then | ||
cat "${pgmout}" | ||
fi | ||
|
||
exit 0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#! /usr/bin/env bash | ||
|
||
source "${HOMEgfs}/ush/preamble.sh" | ||
|
||
############################################################### | ||
# Source UFSDA workflow modules | ||
. "${HOMEgfs}/ush/load_ufsda_modules.sh" | ||
status=$? | ||
[[ ${status} -ne 0 ]] && exit "${status}" | ||
|
||
export job="anlstat" | ||
export jobid="${job}.$$" | ||
|
||
############################################################### | ||
# Execute the JJOB | ||
"${HOMEgfs}/jobs/JGLOBAL_ANALYSIS_STATS" | ||
status=$? | ||
exit "${status}" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash -x | ||
|
||
########## config.anlstat ########## | ||
# Analysis Stat | ||
|
||
echo "BEGIN: config.anlstat" | ||
|
||
# Get task specific resources | ||
source "${EXPDIR}/config.resources" anlstat | ||
|
||
echo "END: config.anlstat" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nearly duplicate file? probably needs removed |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash -x | ||
|
||
########## config.anlstat ########## | ||
# Analysis Stat | ||
|
||
echo "BEGIN: config.anlstat" | ||
|
||
# Get task specific resources | ||
source "${EXPDIR}/config.resources" anlstat | ||
|
||
echo "END: config.anlstat" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env python3 | ||
# exglobal_analysis_stats.py | ||
# This script will run the OOPS/JEDI code to | ||
|
||
import os | ||
|
||
from wxflow import Logger, cast_strdict_as_dtypedict | ||
from pygfs.task.stat_analysis import StatAnalysis | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should change to using the new Jedi class |
||
|
||
# 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) | ||
|
||
# Call StatAnalysis | ||
anl = StatAnalysis(config) | ||
anl.initialize() |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -252,7 +252,7 @@ fi | |
#------------------------------ | ||
if [[ -d "${HOMEgfs}/sorc/gdas.cd" ]]; then | ||
cd "${HOMEgfs}/parm/gdas" || exit 1 | ||
declare -a gdasapp_comps=("aero" "atm" "io" "ioda" "snow" "soca" "jcb-gdas" "jcb-algorithms") | ||
declare -a gdasapp_comps=("aero" "atm" "io" "ioda" "snow" "soca" "stats" "jcb-gdas" "jcb-algorithms") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thinking about this more, I think we just need snow/stats, soca/stats, aero/stats, atm/stats, rather than a stats dir |
||
for comp in "${gdasapp_comps[@]}"; do | ||
[[ -d "${comp}" ]] && rm -rf "${comp}" | ||
${LINK_OR_COPY} "${HOMEgfs}/sorc/gdas.cd/parm/${comp}" . | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import os | ||
from logging import getLogger | ||
from typing import Dict, List | ||
from pprint import pformat | ||
import numpy as np | ||
from netCDF4 import Dataset | ||
|
||
from wxflow import (AttrDict, | ||
FileHandler, | ||
to_fv3time, to_YMD, to_YMDH, to_timedelta, add_to_datetime, | ||
rm_p, | ||
parse_j2yaml, save_as_yaml, | ||
Jinja, | ||
logit, | ||
Executable, | ||
WorkflowException) | ||
from pygfs.task.analysis import Analysis | ||
|
||
logger = getLogger(__name__.split('.')[-1]) | ||
|
||
|
||
class StatAnalysis(Analysis): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see comment above about that we should migrate to the new Jedi class There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See NOAA-EMC#2805 |
||
""" | ||
Class for global stat analysis tasks | ||
""" | ||
|
||
@logit(logger, name="StatAnalysis") | ||
def __init__(self, config): | ||
super().__init__(config) | ||
|
||
_res = int(self.task_config['CASE'][1:]) | ||
_window_begin = add_to_datetime(self.task_config.current_cycle, -to_timedelta(f"{self.task_config['assim_freq']}H") / 2) | ||
_letkfoi_yaml = os.path.join(self.task_config.DATA, f"{self.task_config.RUN}.t{self.task_config['cyc']:02d}z.letkfoi.yaml") | ||
|
||
# Create a local dictionary that is repeatedly used across this class | ||
local_dict = AttrDict( | ||
{ | ||
'APREFIX': f"{self.task_config.RUN}.t{self.task_config.cyc:02d}z.", | ||
'jedi_yaml': _letkfoi_yaml | ||
} | ||
) | ||
|
||
# Extend task_config with local_dict | ||
self.task_config = AttrDict(**self.task_config, **local_dict) | ||
|
||
@logit(logger) | ||
def initialize(self: Analysis) -> None: | ||
""" | ||
Initialize global stat analysis. | ||
""" | ||
super().initialize() | ||
CoryMartin-NOAA marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
logger.info(f"Copying files to {self.task_config.DATA}/stats") | ||
|
||
aerostat = os.path.join(self.task_config.COM_CHEM_ANALYSIS, f"{self.task_config['APREFIX']}aerostat") | ||
dest = os.path.join(self.task_config.DATA, "stats") | ||
statlist = [aerostat, dest] | ||
FileHandler({'copy': statlist}).sync() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only needed if we intend on changing the path for
DATA
from the default