-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved from the incorrect directory to this directory
- Loading branch information
Showing
4 changed files
with
259 additions
and
1 deletion.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
...ns/tc_and_extra_tc/UserScript_TCDIAG_fcstGFSO_SHIP_obsOFCL_SingleInit/plot_time_series.py
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,55 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import os | ||
from time import perf_counter | ||
import logging | ||
import yaml | ||
import metcalcpy.util.read_env_vars_in_config as readconfig | ||
import metplotpy.plots.tcmpr_plots.tcmpr as tcmpr | ||
# from metplotpy.plots.tcmpr_plots.tcmpr import Tcmpr | ||
from metplotpy.plots.tcmpr_plots.tcmpr_config import TcmprConfig | ||
|
||
def main(): | ||
|
||
# Determine location of the default YAML config files and then | ||
# read defaults stored in YAML formatted file into the dictionary | ||
if 'METPLOTPY_BASE' in os.environ: | ||
location = os.path.join(os.environ['METPLOTPY_BASE'], 'metplotpy/plots/config') | ||
else: | ||
location = os.path.realpath(os.path.join(os.path.dirname(os.path.dirname(__file__)), 'config')) | ||
|
||
with open(os.path.join(location, "tcmpr_defaults.yaml"), 'r') as stream: | ||
try: | ||
defaults = yaml.load(stream, Loader=yaml.FullLoader) | ||
except yaml.YAMLError as exc: | ||
print(exc) | ||
|
||
# Read in the YAML configuration file. Environment variables in | ||
# the configuration file are supported. | ||
try: | ||
input_config_file = os.getenv("TIME_SERIES_PLOT_YAML_CONFIG_NAME", "plot_time_series.yaml") | ||
settings = readconfig.parse_config(input_config_file) | ||
logging.info(settings) | ||
except yaml.YAMLError as exc: | ||
logging.error(exc) | ||
|
||
|
||
# merge user defined parameters into defaults if they exist | ||
docs = {**defaults, **settings} | ||
|
||
|
||
config_obj = TcmprConfig(docs) | ||
|
||
try: | ||
start = perf_counter() | ||
|
||
tcmpr.create_plot(config_obj) | ||
end = perf_counter() | ||
execution_time = end - start | ||
logging.info(f"Finished creating time series plot, execution time: {execution_time} seconds") | ||
except ValueError as val_er: | ||
print(val_er) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
145 changes: 145 additions & 0 deletions
145
.../tc_and_extra_tc/UserScript_TCDIAG_fcstGFSO_SHIP_obsOFCL_SingleInit/plot_time_series.yaml
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,145 @@ | ||
colors: | ||
# color-blind friendly colors: green and purple | ||
- | ||
- '#1AFF1A' | ||
- '#4B0092' | ||
|
||
fixed_vars_vals_input: | ||
BASIN: | ||
- AL | ||
LEVEL: | ||
- TS | ||
- EX | ||
- HU | ||
INIT: | ||
- '2022-09-26 00:00:00' | ||
|
||
|
||
indy_vals: | ||
- 0 | ||
- 6 | ||
- 12 | ||
- 18 | ||
- 24 | ||
- 30 | ||
- 36 | ||
- 42 | ||
- 48 | ||
- 54 | ||
- 60 | ||
- 66 | ||
- 72 | ||
- 78 | ||
- 84 | ||
- 90 | ||
- 96 | ||
- 102 | ||
- 108 | ||
- 114 | ||
- 120 | ||
- 126 | ||
indy_label: | ||
- '00' | ||
- '06' | ||
- '12' | ||
- '18' | ||
- '24' | ||
- '30' | ||
- '36' | ||
- '42' | ||
- '48' | ||
- '54' | ||
- '60' | ||
- '66' | ||
- '72' | ||
- '78' | ||
- '84' | ||
- '90' | ||
- '96' | ||
- '102' | ||
- '108' | ||
- '114' | ||
- '120' | ||
- '126' | ||
|
||
|
||
list_stat_1: | ||
- "SHEAR_MAGNITUDE" | ||
|
||
|
||
plot_disp: | ||
- 'True' | ||
- 'True' | ||
|
||
|
||
series_order: | ||
- 1 | ||
- 2 | ||
|
||
|
||
series_val_1: | ||
AMODEL: | ||
- GFSO | ||
- SHIP | ||
|
||
series_ci: | ||
- 'True' | ||
- 'True' | ||
|
||
series_line_width: | ||
- 1 | ||
- 1 | ||
|
||
series_line_style: | ||
- '-' | ||
- '-' | ||
|
||
series_symbols: | ||
- 'circle-open' | ||
- 'circle-open' | ||
|
||
series_symbols_size: | ||
- 7 | ||
- 7 | ||
|
||
show_nstats: 'False' | ||
tcst_dir: !ENV '${REFORMAT_OUTPUT_BASE}' | ||
tcst_files: [ ] | ||
title: 'SHIP and GFSO for Ian, 2022-09-26 init time 00, all available fcst leads' | ||
|
||
mar: | ||
l: 0 #left margin | ||
r: 0 #right margin | ||
b: 90 #bottom margin | ||
t: 100 #top margin | ||
|
||
title_offset: -2.03 | ||
yaxis_1: 'shear magnitude (units go here)' | ||
|
||
plot_type_list: | ||
- 'point' | ||
|
||
rp_diff: | ||
# - '>=1' | ||
- '>=100' | ||
event_equal: 'True' | ||
skill_ref: | ||
# - HFSA | ||
|
||
plot_dir: !ENV '${TIME_SERIES_PLOT_OUTPUT_BASE}/time_series' | ||
prefix: '' | ||
subtitle: | ||
log_level: INFO | ||
log_filename: !ENV '${METPLUS_BASE}/tcmpr_log.out' | ||
baseline_file: !ENV '${METPLOTPY_BASE}/metplotpy/plots/tcmpr_plots/hfip_baseline.dat' | ||
column_info_file: !ENV '${METPLOTPY_BASE}/metplotpy/plots/tcmpr_plots/plot_tcmpr_hdr.dat' | ||
hfip_bsln: 'no' | ||
|
||
|
||
connect_points: True | ||
is_tcdiag_linetype: True | ||
|
||
|
||
|
||
|
||
|
58 changes: 58 additions & 0 deletions
58
...ons/tc_and_extra_tc/UserScript_TCDIAG_fcstGFSO_SHIP_obsOFCL_SingleInit/reformat_tcdiag.py
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,58 @@ | ||
#!/usr/bin/env python3 | ||
|
||
|
||
import os | ||
import time | ||
import logging | ||
|
||
from METdbLoad.ush.read_data_files import ReadDataFiles | ||
from METdbLoad.ush.read_load_xml import XmlLoadFile | ||
from METreformat.write_stat_ascii import WriteStatAscii | ||
from metcalcpy.util import read_env_vars_in_config as readconfig | ||
|
||
|
||
logger = logging.getLogger(__name__) | ||
|
||
def main(): | ||
|
||
# Read in the YAML configuration file. Environment variables in | ||
# the configuration file are supported. | ||
input_config_file = os.getenv("REFORMAT_YAML_CONFIG_NAME", "reformat_tcdiag.yaml") | ||
settings = readconfig.parse_config(input_config_file) | ||
logging.info(settings) | ||
|
||
|
||
# Replacing the need for an XML specification file, pass in the XMLLoadFile and | ||
# ReadDataFile parameters | ||
rdf_obj: ReadDataFiles = ReadDataFiles() | ||
xml_loadfile_obj: XmlLoadFile = XmlLoadFile(None) | ||
|
||
# Retrieve all the filenames in the data_dir specified in the YAML config file | ||
load_files = xml_loadfile_obj.filenames_from_template(settings['input_data_dir'], | ||
{}) | ||
|
||
flags = xml_loadfile_obj.flags | ||
line_types = xml_loadfile_obj.line_types | ||
beg_read_data = time.perf_counter() | ||
rdf_obj.read_data(flags, load_files, line_types) | ||
end_read_data = time.perf_counter() | ||
time_to_read = end_read_data - beg_read_data | ||
logger.info("Time to read input .stat data files using METdbLoad: {time_to_read}") | ||
file_df = rdf_obj.tcst_data | ||
|
||
# Check if the output file already exists, if so, delete it to avoid | ||
# appending output from subsequent runs into the same file. | ||
existing_output_file = os.path.join(settings['output_dir'], settings['output_filename']) | ||
logger.info("Checking if {existing_output_file} already exists") | ||
if os.path.exists(existing_output_file): | ||
logger.info("Removing existing output file {existing_output_file}") | ||
os.remove(existing_output_file) | ||
|
||
# Write stat file in ASCII format | ||
stat_lines_obj: WriteStatAscii = WriteStatAscii(settings) | ||
# stat_lines_obj.write_stat_ascii(file_df, parms, logger) | ||
stat_lines_obj.write_stat_ascii(file_df, settings) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
2 changes: 1 addition & 1 deletion
2
...s/tc_and_extra_tc/UserScript_TCDIAG_fcstGFSO_SHIP_obsOFCL_SingleInit/reformat_tcdiag.yaml
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