Skip to content

Commit

Permalink
fix line length
Browse files Browse the repository at this point in the history
  • Loading branch information
gspetro-NOAA committed Sep 11, 2024
1 parent 5330ab7 commit c037c6a
Show file tree
Hide file tree
Showing 10 changed files with 137 additions and 66 deletions.
28 changes: 19 additions & 9 deletions ush/UFS_plot_domains.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,25 @@


def get_lambert_points(gnomonic_map, lambert_map, pps):
"""This function takes the lambert domain we have defined, lambert_map, as well as
pps (the number of points to interpolate and draw for each side of the lambert "rectangle"),
and returns an array of two lists: one a list of tuples of the 4*ppf + 4 vertices mapping the approximate shape
of the lambert domain on the gnomonic map, the other a list of "draw" instructions to be used by
the PathPatch function
pps is recommended 10 or less due to time of calculation
Start array with bottom left point, "MOVETO" instruction"""
"""This function takes the lambert domain we have defined, ``lambert_map``, and ``pps``,
and returns an array of two lists: one a list of tuples of the ``4*ppf + 4`` vertices mapping
the approximate shape of the lambert domain on the gnomonic map, the other a list of "draw"
instructions to be used by the PathPatch function.
Start array with bottom left point, "MOVETO" instruction
Args:
gnomonic_map:
lambert_map:
pps: The number of points to interpolate and draw for each side of the lambert
"rectangle". It is recommended to set to 10 or less due to time of calculation.
Returns:
vertices, instructions: A tuple of two lists---a list of tuples of the ``4*ppf + 4``
vertices mapping the approximate shape of the lambert domain
on the gnomonic map, the other a list of "draw" instructions
to be used by the PathPatch function.
"""

vertices = [
gnomonic_map(*lambert_map(lambert_map.xmin, lambert_map.ymin, inverse=True))
Expand Down
3 changes: 2 additions & 1 deletion ush/calculate_cost.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ def calculate_cost(config_fn):
config_fn (str): Name of a configuration file containing experiment parameters
Returns:
cost (list): Cost array containing information related to experiment parameters (e.g., time step and grid)
cost (list): Cost array containing information related to experiment parameters
(e.g., time step and grid)
Raises:
ValueError: If ``GRID_GEN_METHOD`` is set to an invalid value
Expand Down
9 changes: 6 additions & 3 deletions ush/get_crontab_contents.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ def get_crontab_contents(called_from_cron, machine, debug):
platforms the version or location of this may change depending on other circumstances.
Args:
called_from_cron (bool): Set this value to ``True`` if script is called from within a crontab
called_from_cron (bool): Set this value to ``True`` if script is called from within a
crontab
machine (str) : The name of the current machine
debug (bool): ``True`` will give more verbose output
Returns:
Expand Down Expand Up @@ -49,7 +50,8 @@ def add_crontab_line(called_from_cron, machine, crontab_line, exptdir, debug) ->
"""Adds crontab line to cron table
Args:
called_from_cron (bool): Set this value to ``True`` if script is called from within a crontab
called_from_cron (bool): Set this value to ``True`` if script is called from within
a crontab.
machine (str) : The name of the current machine
crontab_line (str) : Line to be added to cron table
exptdir (str) : Path to the experiment directory
Expand Down Expand Up @@ -124,7 +126,8 @@ def delete_crontab_line(called_from_cron, machine, crontab_line, debug) -> None:
but not IN PROGRESS status
Args:
called_from_cron (bool): Set this value to ``True`` if script is called from within a crontab
called_from_cron (bool): Set this value to ``True`` if script is called from within
a crontab
machine (str) : The name of the current machine
crontab_line (str) : Line to be deleted from cron table
debug (bool): ``True`` will give more verbose output
Expand Down
6 changes: 4 additions & 2 deletions ush/link_fix.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,12 @@ def link_fix(
source_dir (str) : Path to directory that the ``file_group`` fix files are linked from
target_dir (str) : Directory that the fix files should be linked to
dot_or_uscore (str) : Either a dot (``.``) or an underscore (``_``)
nhw (int) : Wide halo width (grid parameter setting: N=number of cells, H=halo, W=wide halo)
nhw (int) : Wide halo width (grid parameter setting: N=number of cells,
H=halo, W=wide halo)
constants (dict): Dictionary containing the constants used by the SRW App
run_task (bool): Whether the task is to be run in the experiment
climo_fields (list): List of fields needed for surface climatology (see ``fixed_files_mapping.yaml`` for details)
climo_fields (list): List of fields needed for surface climatology (see
``fixed_files_mapping.yaml`` for details)
Returns:
res (str): File/grid resolution
Expand Down
3 changes: 2 additions & 1 deletion ush/mrms_pull_topofhour.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ def main():
None
Raises:
FileNotFoundError: If no valid file was found within 15 minutes of the valid time of the forecast
FileNotFoundError: If no valid file was found within 15 minutes of the valid
time of the forecast
"""
#Parse input arguments
Expand Down
78 changes: 51 additions & 27 deletions ush/retrieve_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,16 +194,21 @@ def arg_list_to_range(args):

def fill_template(template_str, cycle_date, templates_only=False, **kwargs):

"""Fills in the provided template string with date time information, and returns the resulting string.
"""Fills in the provided template string with date time information, and returns the
resulting string.
Args:
template_str : A string containing Python templates
cycle_date : A datetime object that will be used to fill in date and time information
templates_only (bool): When ``True``, this function will only return the templates available.
cycle_date : A datetime object that will be used to fill in date and time
information
templates_only (bool): When ``True``, this function will only return the templates
available.
Keyword Args:
ens_group (int): A number associated with a bin where ensemble members are stored in archive files.
fcst_hr (int): An integer forecast hour. String formatting should be included in the ``template_str``.
ens_group (int): A number associated with a bin where ensemble members are stored in
archive files.
fcst_hr (int): An integer forecast hour. String formatting should be included in the
``template_str``.
mem (int): A single ensemble member. Should be a positive integer value.
Returns:
Expand Down Expand Up @@ -279,8 +284,9 @@ def find_archive_files(paths, file_names, cycle_date, ens_group):
Args:
paths (list): Archive paths
file_names (list): Archive file names
cycle_date (int) : Cycle date (YYYYMMDDHH or YYYYMMDDHHmm format)
ens_group (int) : A number associated with a bin where ensemble members are stored in archive files
cycle_date (int): Cycle date (YYYYMMDDHH or YYYYMMDDHHmm format)
ens_group (int): A number associated with a bin where ensemble members are stored
in archive files
Returns:
A tuple containing (existing_archives, list_item) or ("", 0)
Expand Down Expand Up @@ -317,7 +323,8 @@ def find_archive_files(paths, file_names, cycle_date, ens_group):

def get_file_templates(cla, known_data_info, data_store, use_cla_tmpl=False):

"""Returns the file templates requested by user input, either from the command line, or from the known data information dictionary.
"""Returns the file templates requested by user input, either from the command line,
or from the known data information dictionary.
Args:
Expand Down Expand Up @@ -359,15 +366,18 @@ def get_requested_files(cla, file_templates, input_locs, method="disk", **kwargs

# pylint: disable=too-many-locals

"""Copies files from disk locations or downloads files from a URL, depending on the option specified by the user.
"""Copies files from disk locations or downloads files from a URL, depending on the option
specified by the user.
This function expects that the output directory exists and is writeable.
Args:
cla (str) : Command line arguments (Namespace object)
file_templates (list): A list of file templates
input_locs (str) : A string containing a single data location, either a URL or disk path, or a list of paths/URLs.
method (str) : Choice of ``"disk"`` or ``"download"`` to indicate protocol for retrieval
input_locs (str) : A string containing a single data location, either a URL or disk
path, or a list of paths/URLs.
method (str) : Choice of ``"disk"`` or ``"download"`` to indicate protocol for
retrieval
Keyword Args:
members (list): A list of integers corresponding to the ensemble members
Expand Down Expand Up @@ -461,12 +471,13 @@ def get_requested_files(cla, file_templates, input_locs, method="disk", **kwargs

def hsi_single_file(file_path, mode="ls"):

"""Calls ``hsi`` as a subprocess for Python and returns information about whether the ``file_path`` was found.
"""Calls ``hsi`` as a subprocess for Python and returns information about whether the
``file_path`` was found.
Args:
file_path (str): File path on HPSS
mode (str): The ``hsi`` command to run. ``ls`` is default. May also pass ``get`` to retrieve the file path.
mode (str): The ``hsi`` command to run. ``ls`` is default. May also pass ``get``
to retrieve the file path.
"""
cmd = f"hsi {mode} {file_path}"

Expand All @@ -488,19 +499,23 @@ def hpss_requested_files(cla, file_names, store_specs, members=-1, ens_group=-1)

# pylint: disable=too-many-locals

"""This function interacts with the "hpss" protocol in a provided data store specs file to download a set of files requested by the user. Depending on the type of archive file (``zip`` or ``tar``), it will
either pull the entire file and unzip it or attempt to pull individual files from a tar file.
"""This function interacts with the "hpss" protocol in a provided data store specs file to
download a set of files requested by the user. Depending on the type of archive file (``zip``
or ``tar``), it will either pull the entire file and unzip it or attempt to pull individual
files from a tar file.
It cleans up the local disk after files are deemed available in order to remove any empty subdirectories that may still be present.
It cleans up the local disk after files are deemed available in order to remove any empty
subdirectories that may still be present.
This function exepcts that the output directory exists and is writable.
Args:
cla (str) : Command line arguments (Namespace object)
cla (str): Command line arguments (Namespace object)
file_names (list): List of file names
store_specs (dict): Data-store specifications (specs) file
members (list): A list of integers corresponding to the ensemble members
ens_group (int) : A number associated with a bin where ensemble members are stored in archive files
ens_group (int): A number associated with a bin where ensemble members are stored in
archive files
Returns:
A Python set of unavailable files
Expand Down Expand Up @@ -666,7 +681,8 @@ def load_str(arg):
def config_exists(arg):

"""
Checks to ensure that the provided config file exists. If it does, load it with YAML's safe loader and return the resulting dictionary.
Checks to ensure that the provided config file exists. If it does, load it with YAML's safe
loader and return the resulting dictionary.
Args:
arg (str): Path to a configuration file
Expand Down Expand Up @@ -698,15 +714,18 @@ def pair_locs_with_files(input_locs, file_templates, check_all):
#. Get multiple files from multiple corresponding paths/URLs
#. Check all paths for all file templates until files are found
The default will be to handle #1 and #2. #3 will be indicated by a flag in the YAML: ``check_all: True``
The default will be to handle #1 and #2. #3 will be indicated by a flag in the YAML:
``check_all: True``
Args:
input_locs (list): Input locations
file_templates (list): File templates
check_all (bool): Flag that indicates whether all input locations should be checked for all available file templates
check_all (bool): Flag that indicates whether all input locations should be checked
for all available file templates
Returns:
locs_files (list): Iterable containing multiple locations and file templates for files that should be searched in those locations
locs_files (list): Iterable containing multiple locations and file templates for files
that should be searched in those locations
"""

if not check_all:
Expand Down Expand Up @@ -758,7 +777,8 @@ def path_exists(arg):

def _setup_logging(debug=False):

"""Calls initialization functions for logging package, and sets the user-defined level for logging in the script."""
"""Calls initialization functions for logging package, and sets the user-defined level for
logging in the script."""

level = logging.INFO
if debug:
Expand All @@ -771,7 +791,8 @@ def _setup_logging(debug=False):

def _write_summary_file(cla, data_store, file_templates) -> None:

"""Given the command line arguments and the data store from which the data was retrieved, write a bash summary file that is needed by the workflow elements downstream.
"""Given the command line arguments and the data store from which the data was retrieved,
write a bash summary file that is needed by the workflow elements downstream.
"""

members = cla.members if isinstance(cla.members, list) else [-1]
Expand Down Expand Up @@ -960,7 +981,8 @@ def get_ens_groups(members):
Args:
members (list): List of ensemble members.
Returns:
ens_groups: A dictionary where keys are the ensemble group and values are lists of ensemble members requested in that group
ens_groups: A dictionary where keys are the ensemble group and values are lists of
ensemble members requested in that group
"""

if members is None:
Expand All @@ -979,7 +1001,9 @@ def get_ens_groups(members):
def parse_args(argv):

"""
Maintains the arguments accepted by this script. Please see Python's `argparse <https://docs.python.org/3/library/argparse.html>`__ documenation for more information about settings of each argument.
Maintains the arguments accepted by this script. Please see Python's
`argparse <https://docs.python.org/3/library/argparse.html>`_ documenation for more
information about settings of each argument.
Args:
argv (list): Command line arguments to parse
Expand Down
4 changes: 3 additions & 1 deletion ush/set_cycle_dates.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ def set_cycle_dates(date_start, date_end, incr_cycl_freq):
date_end (datetime.datetime): End date
incr_cycl_freq (int): Cycle frequency increment in hours
Returns:
all_cdates: An array of cycle date-hours whose elements have the form ``YYYYMMDDHH``, where ``YYYY`` is a four-digit year, ``MM`` is a two- digit month, ``DD`` is a two-digit day of the month, and ``HH`` is a two-digit hour of the day
all_cdates: An array of cycle date-hours whose elements have the form ``YYYYMMDDHH``,
where ``YYYY`` is a four-digit year, ``MM`` is a two- digit month, ``DD``
is a two-digit day of the month, and ``HH`` is a two-digit hour of the day
"""

print_input_args(locals())
Expand Down
6 changes: 5 additions & 1 deletion ush/set_gridparams_ESGgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ def set_gridparams_ESGgrid(
lat_ctr (float): The latitude of the center of the grid (in degrees).
nx (int): The number of cells in the zonal direction on the regional grid.
ny (int): The number of cells in the meridional direction on the regional grid.
halo_width (int): The width (in number of grid cells) of the wide :term:`halo` to add around the regional grid before shaving the halo down to the width(s) expected by the forecast model. For predefined grids, this value is set in ``setup.py`` based on the ``ESGgrid_WIDE_HALO_WIDTH`` value in ``predef_grid_params.yaml``.
halo_width (int): The width (in number of grid cells) of the wide :term:`halo` to add
around the regional grid before shaving the halo down to the width(s)
expected by the forecast model. For predefined grids, this value is
set in ``setup.py`` based on the ``ESGgrid_WIDE_HALO_WIDTH`` value in
``predef_grid_params.yaml``.
delx (float): The cell size in the zonal direction of the regional grid (in meters).
dely (float): The cell size in the meridional direction of the regional grid (in meters).
pazi (float): The rotational parameter for the “ESGgrid” (in degrees).
Expand Down
Loading

0 comments on commit c037c6a

Please sign in to comment.