Skip to content

Commit

Permalink
Fix broken web site time series plots. (#249)
Browse files Browse the repository at this point in the history
* Change NowcastWorker mock to pytest fixture

Test suite maintenance.

re: issue #81

* Update make_plots worker main() function docstring

Removed not informative "Set up and run the worker." line at the beginning.

re: issue #121

* Change logging mocks to pytest caplog fixture

Replace unittest.mock.patch decorator with pytest caplog fixture for tests of
logging.

Test suite maintenance re: issue #82.

* Add unit tests for YAML config file elements

Add unit tests for production YAML config file elements related to worker;
re: issue #117.

* Remove unused ferry_data_dir configuration retrieval

The ferry_data_dir configuration was retrieved but not used in the make_plots.py
worker script. This change removes the unneeded line to tidy up the code and
avoid potential confusion in the future.

* Update to V21-11 dataset URLs in config & tests

The URLs for '3d tracer fields' and '3d biology fields' have been updated in the
test_make_plots.py and nowcast.yaml files.

* Rename physics dataset keys to '3d physics fields'

This commit changes the '3d tracer fields' key in the nowcast.yaml configuration
file, the make_plots.py worker and test_make_plots.py tests to
'3d physics fields'. This change better reflects in the relevant data source
URLs.

* Update zooplankton field var names in make_plots

Update zooplankton field variable names for the time series plot function in the
make_plots worker. Specifically, change "mesozooplankton" and "microzooplankton"
to "z1_zooplankton" and "z2_zooplankton". This update ensures consistency with
the V21-11 model output variable names.

* Replace Mesodinium rubrum w/ Diatoms in time series plots

In the 'make_plots' worker, the field variable 'mesodinium' was changed to
'diatoms' for the time series plots. The 'diatoms_flagellates_timeseries'
dictionary key is adjusted accordingly. This is necessary due to the removal of
the Mesodinium rubrum variable from the V21-11 model calculations and output.

* Add z1 & z2 zooplankton to color dict in website_theme

Two new types of zooplankton, 'z1_zooplankton' and 'z2_zooplankton', have been
added to the color dictionary of nowcast/figures/website_theme.py file. This
change would allow the correct color to be displayed for these new types in the
corresponding plots.
  • Loading branch information
douglatornell authored Mar 30, 2024
1 parent 2bdd7ca commit 0c53aac
Show file tree
Hide file tree
Showing 4 changed files with 259 additions and 79 deletions.
8 changes: 4 additions & 4 deletions config/nowcast.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -540,11 +540,11 @@ figures:
https://salishsea.eos.ubc.ca/erddap/griddap/ubcSSaSurfaceAtmosphereFieldsV1
tide stn ssh time series:
# **Must be quoted to project {} characters**
'https://salishsea.eos.ubc.ca/erddap/griddap/ubcSSf{place}SSH10m'
3d tracer fields:
https://salishsea.eos.ubc.ca/erddap/griddap/ubcSSg3DTracerFields1hV19-05
"https://salishsea.eos.ubc.ca/erddap/griddap/ubcSSf{place}SSH10m"
3d physics fields:
https://salishsea.eos.ubc.ca/erddap/griddap/ubcSSg3DPhysicsFields1hV21-11
3d biology fields:
https://salishsea.eos.ubc.ca/erddap/griddap/ubcSSg3DBiologyFields1hV19-05
https://salishsea.eos.ubc.ca/erddap/griddap/ubcSSg3DBiologyFields1hV21-11
2nd narrows hadcp time series:
https://salishsea.eos.ubc.ca/erddap/tabledap/ubcVFPA2ndNarrowsCurrent2sV1
wwatch3 fields:
Expand Down
2 changes: 2 additions & 0 deletions nowcast/figures/website_theme.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@
"flagellates": "darkgreen",
"mesozooplankton": "brown",
"microzooplankton": "darkgreen",
"z1_zooplankton": "brown",
"z2_zooplankton": "darkgreen",
"nitrate": "darkgreen",
"salinity": "blue",
"2nd Narrows model current direction": {"x2": "blue", "r12": "purple"},
Expand Down
19 changes: 8 additions & 11 deletions nowcast/workers/make_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@


def main():
"""Set up and run the worker.
For command-line usage see:
"""For command-line usage see:
:command:`python -m nowcast.workers.make_plots --help`
"""
Expand Down Expand Up @@ -139,6 +137,7 @@ def main():
""",
)
worker.run(make_plots, success, failure)
return worker


def success(parsed_args):
Expand All @@ -157,8 +156,7 @@ def success(parsed_args):
def failure(parsed_args):
logger.critical(
f"{parsed_args.model} {parsed_args.plot_type} plots failed for "
f'{parsed_args.run_date.format("YYYY-MM-DD")} {parsed_args.run_type} '
f"failed"
f'{parsed_args.run_date.format("YYYY-MM-DD")} {parsed_args.run_type}'
)
msg_type = (
f"failure {parsed_args.model} {parsed_args.run_type} "
Expand Down Expand Up @@ -603,7 +601,7 @@ def _prep_nowcast_green_research_fig_functions(
)
place = "S3"
phys_dataset = xarray.open_dataset(
config["figures"]["dataset URLs"]["3d tracer fields"]
config["figures"]["dataset URLs"]["3d physics fields"]
)
bio_dataset = xarray.open_dataset(
config["figures"]["dataset URLs"]["3d biology fields"]
Expand All @@ -618,13 +616,13 @@ def _prep_nowcast_green_research_fig_functions(
"function": time_series_plots.make_figure,
"args": (bio_dataset, "nitrate", "diatoms", place),
},
"mesodinium_flagellates_timeseries": {
"diatoms_flagellates_timeseries": {
"function": time_series_plots.make_figure,
"args": (bio_dataset, "microzooplankton", "flagellates", place),
"args": (bio_dataset, "diatoms", "flagellates", place),
},
"mesozoo_microzoo_timeseries": {
"z1_z2_zooplankton_timeseries": {
"function": time_series_plots.make_figure,
"args": (bio_dataset, "mesozooplankton", "microzooplankton", place),
"args": (bio_dataset, "z1_zooplankton", "z2_zooplankton", place),
},
}
)
Expand Down Expand Up @@ -684,7 +682,6 @@ def _prep_comparison_fig_functions(
f"preparing render list for {run_date.format('YYYY-MM-DD')} NEMO nowcast-blue comparison figures"
)
hrdps_dataset_url = config["figures"]["dataset URLs"]["HRDPS fields"]
ferry_data_dir = config["observations"]["ferry data"]
dev_results_dir = os.path.join(dev_results_home, dmy)
grid_T_hr = _results_dataset("1h", "grid_T", results_dir)
dev_grid_T_hr = _results_dataset("1h", "grid_T", dev_results_dir)
Expand Down
Loading

0 comments on commit 0c53aac

Please sign in to comment.