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 documentation to ush/HWP_tools.py #515

Merged
merged 33 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
ec78cac
adding API rst files
edwardhartnett Oct 6, 2024
8b437eb
moved files
edwardhartnett Oct 6, 2024
5a393e2
more docs work
edwardhartnett Oct 6, 2024
5e185f3
more docs work
edwardhartnett Oct 6, 2024
5cb7f8d
more docs work
edwardhartnett Oct 6, 2024
b86dce1
more docs work
edwardhartnett Oct 6, 2024
60843d5
more docs work
edwardhartnett Oct 6, 2024
5b8e852
more docs work
edwardhartnett Oct 6, 2024
7bb62e4
more docs work
edwardhartnett Oct 6, 2024
e7575ce
more docs work
edwardhartnett Oct 6, 2024
3c4d4ad
more docs work
edwardhartnett Oct 6, 2024
1e37abc
more docs work
edwardhartnett Oct 6, 2024
11df1de
more
edwardhartnett Oct 6, 2024
dd745b7
adding files
edwardhartnett Oct 6, 2024
51afbcb
more work
edwardhartnett Oct 7, 2024
9d1abe3
more work
edwardhartnett Oct 7, 2024
4dcb01d
more work
edwardhartnett Oct 7, 2024
2bb5cc6
renamed directory
edwardhartnett Oct 7, 2024
cc014c0
moving stuff
edwardhartnett Oct 7, 2024
fc587ec
more moving
edwardhartnett Oct 7, 2024
9e4051c
more moving
edwardhartnett Oct 7, 2024
016153f
more work simplifing build
edwardhartnett Oct 7, 2024
4867639
changed workflow
edwardhartnett Oct 7, 2024
1803e53
changed workflow
edwardhartnett Oct 7, 2024
c6a6882
added some docs
edwardhartnett Oct 7, 2024
3a91031
added some docs
edwardhartnett Oct 7, 2024
2afd5b8
added some docs
edwardhartnett Oct 7, 2024
b100b68
added some docs
edwardhartnett Oct 7, 2024
813047d
added some docs
edwardhartnett Oct 7, 2024
ae52034
merged
edwardhartnett Oct 8, 2024
0edb0af
more docs
edwardhartnett Oct 8, 2024
2ebb0b1
more docs
edwardhartnett Oct 8, 2024
d6289af
more docs
edwardhartnett Oct 8, 2024
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
7 changes: 6 additions & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
sphinxcontrib-bibtex
sphinx_rtd_theme
docutils==0.16
docutils==0.16
numpy
xarray
matplotlib
netCDF4
matplotlib
52 changes: 52 additions & 0 deletions ush/HWP_tools.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
"""
This file provides Hourly Wildfire Potential (HWP) tools.

edwardhartnett marked this conversation as resolved.
Show resolved Hide resolved
"""

import numpy as np
import os
import datetime as dt
Expand All @@ -7,6 +12,14 @@
import fnmatch

def check_restart_files(hourly_hwpdir, fcst_dates):
"""Check the restart files.

Args:
hourly_hwpdir: the directory where the RESTART data is copied (nwges/HOURLY_HWP)
fcst_dates: Forecast dates
Returns:
lists of hours with and without available RESTART files
"""
hwp_avail_hours = []
hwp_non_avail_hours = []

Expand All @@ -25,6 +38,29 @@ def check_restart_files(hourly_hwpdir, fcst_dates):
return(hwp_avail_hours, hwp_non_avail_hours)

def copy_missing_restart(nwges_dir, hwp_non_avail_hours, hourly_hwpdir):
"""Check the restart files.

The script loops through hwp_non_avail_hours (missing files in
nwges/HOURLY_HWP) and determines if an alternative RESTART file in
nwges/fcst_fv3lam/RESTART is available instead. If so, it is
appended to restart_avail_hours.

Args:
nwges_dir: holds the boundary, INPUT, and RESTART files (e.g,
described here:
[ufs-community/ufs-srweather-app#654](https://github.com/ufs-community/ufs-srweather-app/issues/654))
The use of NWGES is a bit of a legacy variable name in
production. It is often used to define a directory holding
DA-relevant files (such as first guess and analysis files)
outside of the main COM output directory.
hwp_non_avail_hours: a list of hours without available RESTART files
hourly_hwpdir: the directory where the RESTART data is copied (nwges/HOURLY_HWP)
Returns:
list of::
- restart_avail_hours
- restart_nonavail_hours_test which is a subset of hwp_non_avail_hours.

"""
restart_avail_hours = []
restart_nonavail_hours_test = []

Expand Down Expand Up @@ -79,6 +115,22 @@ def copy_missing_restart(nwges_dir, hwp_non_avail_hours, hourly_hwpdir):
return(restart_avail_hours, restart_nonavail_hours_test)

def process_hwp(fcst_dates, hourly_hwpdir, cols, rows, intp_dir, rave_to_intp):
"""Check the restart files.

Args:
fcst_dates: a list of forecasts (for production/ops/ebb=2, it is {current_day - 25 hours: current_day-1hours}, for ebb=1, it is current_day:current_day+24 hours)
hourly_hwpdir: the directory where the RESTART data is copied (nwges/HOURLY_HWP)
cols: hard coded dimension for the RRFS_NA_3km and RRFS_CONUS_3km domains:: cols = 2700 if predef_grid == 'RRFS_NA_3km' else 1092
rows: hard coded dimension for the RRFS_NA_3km and RRFS_CONUS_3km domains:: rows = 3950 if predef_grid == 'RRFS_NA_3km' else 1820
intp_dir: the working directory for smoke processing (${CYCLE_DIR}/process_smoke)
rave_to_intp: a string based on the grid name:: rave_to_intp = predef_grid+"intp"
Returns:
list of::
- average (through time) of HWP_AVE in the available RESTART files
- hwp_ave_arr converted to an xarray DataArray
- the total precipitation vector (totprcp) reshaped to the 2D grid
- totprcp_ave_arr converted to an xarray DataArray
"""
edwardhartnett marked this conversation as resolved.
Show resolved Hide resolved
hwp_ave = []
totprcp = np.zeros((cols*rows))
var1, var2 = 'rrfs_hwp_ave', 'totprcp_ave'
Expand Down
Loading