From d5ac217955839f48fcd59b9376524c3f809d8fb1 Mon Sep 17 00:00:00 2001 From: David John Gagne Date: Fri, 9 Feb 2024 15:53:49 -0700 Subject: [PATCH] Fixed sphinx docs. --- doc/conf.py | 317 ++---------------- doc/data_processing.rst | 1 + doc/hagelslag.data.rst | 133 ++++++-- doc/hagelslag.evaluation.rst | 49 ++- doc/hagelslag.processing.rst | 69 ++-- doc/hagelslag.rst | 15 +- doc/hagelslag.util.rst | 155 ++++++--- doc/modules.rst | 2 - hagelslag/data/FV3ModelGrid.py | 4 +- hagelslag/data/GribModelGrid.py | 16 +- hagelslag/data/HRRREModelGrid.py | 3 +- {test => hagelslag/test}/__init__.py | 0 {test => hagelslag/test}/test_STObject.py | 0 .../test}/test_data_MRMSGrid.py | 0 {test => hagelslag/test}/test_evaluation.py | 0 {test => hagelslag/test}/test_tracking.py | 6 +- hagelslag/util/lsr_calibration_dataset.py | 2 +- .../util/mrms_mesh_calibration_dataset.py | 2 +- hagelslag/util/munkres.py | 14 - hagelslag/util/testing_sector.py | 157 ++++----- 20 files changed, 395 insertions(+), 550 deletions(-) rename {test => hagelslag/test}/__init__.py (100%) rename {test => hagelslag/test}/test_STObject.py (100%) rename {test => hagelslag/test}/test_data_MRMSGrid.py (100%) rename {test => hagelslag/test}/test_evaluation.py (100%) rename {test => hagelslag/test}/test_tracking.py (97%) diff --git a/doc/conf.py b/doc/conf.py index d29b30c..38b7a75 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -1,309 +1,32 @@ -# -*- coding: utf-8 -*- +# Configuration file for the Sphinx documentation builder. # -# hagelslag documentation build configuration file, created by -# sphinx-quickstart on Thu Oct 1 17:36:49 2015. -# -# This file is execfile()d with the current directory set to its -# containing dir. -# -# Note that not all possible configuration values are present in this -# autogenerated file. -# -# All configuration values have a default; values that are commented out -# serve to show the default. - -import os -import sys - -from mock import Mock as MagicMock - - -class Mock(MagicMock): - @classmethod - def __getattr__(cls, name): - return Mock() - - -MOCK_MODULES = ['numpy', 'scipy', 'pandas', 'skimage', 'netCDF4', 'basemap', 'matplotlib', "pyproj", "Nio", - "scipy.spatial", - "pygrib", "mpl_toolkits", "mpl_toolkits.axes_grid1", "mpl_toolkits.basemap", - "mpl_toolkits.basemap.pyproj", - "sklearn", 'skimage.morphology', "scipy.ndimage", "matplotlib.pyplot", "scipy.stats", "scipy.signal", - "skimage.measure", "skimage.segmentation", "scipy.interpolate", "skimage.draw", - "mpl_toolkits.axes_grid1.inset_locator", "glue", "sklearn.linear_model", "glue.viewers", - "glue.viewers.custom", - "glue.viewers.custom.qt", "glue.core", "shapefile", "ncepgrib2", - "glue.config", "sklearn.decomposition", "sklearn.model_selection", "arrow"] -sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES) +# For the full list of built-in configuration values, see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html -# If extensions (or modules to document with autodoc) are in another directory, -# add these directories to sys.path here. If the directory is relative to the -# documentation root, use os.path.abspath to make it absolute, like shown here. -sys.path.insert(0, os.path.abspath('..')) +# -- Project information ----------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information -# -- General configuration ------------------------------------------------ +project = 'hagelslag' +copyright = '2017-2024, David John Gagne' +author = 'David John Gagne' +release = '0.6' -# If your documentation needs a minimal Sphinx version, state it here. -# needs_sphinx = '1.0' +# -- General configuration --------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. -extensions = [ - 'sphinx.ext.autodoc', - 'sphinx.ext.doctest', - 'sphinx.ext.coverage', - 'sphinx.ext.mathjax', - 'sphinx.ext.napoleon' -] +extensions = ['sphinx.ext.napoleon', + 'sphinx.ext.doctest', + 'sphinx.ext.coverage', + 'sphinx.ext.mathjax', + ] -# Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] +exclude_patterns = [] -# The suffix(es) of source filenames. -# You can specify multiple suffix as a list of string: -# source_suffix = ['.rst', '.md'] -source_suffix = '.rst' - -# The encoding of source files. -# source_encoding = 'utf-8-sig' - -# The master toctree document. -master_doc = 'index' - -# General information about the project. -project = u'hagelslag' -copyright = u'2017-2022, David John Gagne II' -author = u'David John Gagne II' - -# The version info for the project you're documenting, acts as replacement for -# |version| and |release|, also used in various other places throughout the -# built documents. -# -# The short X.Y version. -version = '0.5' -# The full version, including alpha/beta/rc tags. -release = '0.5' - -# The language for content autogenerated by Sphinx. Refer to documentation -# for a list of supported languages. -# -# This is also used if you do content translation via gettext catalogs. -# Usually you set "language" from the command line for these cases. -language = None - -# There are two options for replacing |today|: either, you set today to some -# non-false value, then it is used: -# today = '' -# Else, today_fmt is used as the format for a strftime call. -# today_fmt = '%B %d, %Y' - -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -exclude_patterns = ['_build'] -# The reST default role (used for this markup: `text`) to use for all -# documents. -# default_role = None -# If true, '()' will be appended to :func: etc. cross-reference text. -# add_function_parentheses = True +# -- Options for HTML output ------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output -# If true, the current module name will be prepended to all description -# unit titles (such as .. function::). -# add_module_names = True - -# If true, sectionauthor and moduleauthor directives will be shown in the -# output. They are ignored by default. -# show_authors = False - -# The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' - -# A list of ignored prefixes for module index sorting. -# modindex_common_prefix = [] - -# If true, keep warnings as "system message" paragraphs in the built documents. -# keep_warnings = False - -# If true, `todo` and `todoList` produce output, else they produce nothing. -todo_include_todos = False - -# -- Options for HTML output ---------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -html_theme = 'nature' - -# Theme options are theme-specific and customize the look and feel of a theme -# further. For a list of options available for each theme, see the -# documentation. -html_theme_options = {'sidebarwidth': 375} - -# Add any paths that contain custom themes here, relative to this directory. -# html_theme_path = [] - -# The name for this set of Sphinx documents. If None, it defaults to -# " v documentation". -# html_title = None - -# A shorter title for the navigation bar. Default is the same as html_title. -# html_short_title = None - -# The name of an image file (relative to this directory) to place at the top -# of the sidebar. -# html_logo = None - -# The name of an image file (within the static path) to use as favicon of the -# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 -# pixels large. -# html_favicon = None - -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". +html_theme = 'sphinx_book_theme' html_static_path = ['_static'] - -# Add any extra paths that contain custom files (such as robots.txt or -# .htaccess) here, relative to this directory. These files are copied -# directly to the root of the documentation. -# html_extra_path = [] - -# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, -# using the given strftime format. -# html_last_updated_fmt = '%b %d, %Y' - -# If true, SmartyPants will be used to convert quotes and dashes to -# typographically correct entities. -# html_use_smartypants = True - -# Custom sidebar templates, maps document names to template names. -# html_sidebars = {} - -# Additional templates that should be rendered to pages, maps page names to -# template names. -# html_additional_pages = {} - -# If false, no module index is generated. -# html_domain_indices = True - -# If false, no index is generated. -# html_use_index = True - -# If true, the index is split into individual pages for each letter. -# html_split_index = False - -# If true, links to the reST sources are added to the pages. -# html_show_sourcelink = True - -# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. -# html_show_sphinx = True - -# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -# html_show_copyright = True - -# If true, an OpenSearch description file will be output, and all pages will -# contain a tag referring to it. The value of this option must be the -# base URL from which the finished HTML is served. -# html_use_opensearch = '' - -# This is the file name suffix for HTML files (e.g. ".xhtml"). -# html_file_suffix = None - -# Language to be used for generating the HTML full-text search index. -# Sphinx supports the following languages: -# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' -# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr' -# html_search_language = 'en' - -# A dictionary with options for the search language support, empty by default. -# Now only 'ja' uses this config value -# html_search_options = {'type': 'default'} - -# The name of a javascript file (relative to the configuration directory) that -# implements a search results scorer. If empty, the default will be used. -# html_search_scorer = 'scorer.js' - -# Output file base name for HTML help builder. -htmlhelp_basename = 'hagelslagdoc' - -# -- Options for LaTeX output --------------------------------------------- - -latex_elements = { - # The paper size ('letterpaper' or 'a4paper'). - # 'papersize': 'letterpaper', - - # The font size ('10pt', '11pt' or '12pt'). - # 'pointsize': '10pt', - - # Additional stuff for the LaTeX preamble. - # 'preamble': '', - - # Latex figure (float) alignment - # 'figure_align': 'htbp', -} - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, -# author, documentclass [howto, manual, or own class]). -latex_documents = [ - (master_doc, 'hagelslag.tex', u'hagelslag Documentation', - u'David John Gagne II', 'manual'), -] - -# The name of an image file (relative to this directory) to place at the top of -# the title page. -# latex_logo = None - -# For "manual" documents, if this is true, then toplevel headings are parts, -# not chapters. -# latex_use_parts = False - -# If true, show page references after internal links. -# latex_show_pagerefs = False - -# If true, show URL addresses after external links. -# latex_show_urls = False - -# Documents to append as an appendix to all manuals. -# latex_appendices = [] - -# If false, no module index is generated. -# latex_domain_indices = True - - -# -- Options for manual page output --------------------------------------- - -# One entry per manual page. List of tuples -# (source start file, name, description, authors, manual section). -man_pages = [ - (master_doc, 'hagelslag', u'hagelslag Documentation', - [author], 1) -] - -# If true, show URL addresses after external links. -# man_show_urls = False - - -# -- Options for Texinfo output ------------------------------------------- - -# Grouping the document tree into Texinfo files. List of tuples -# (source start file, target name, title, author, -# dir menu entry, description, category) -texinfo_documents = [ - (master_doc, 'hagelslag', u'hagelslag Documentation', - author, 'hagelslag', 'One line description of project.', - 'Miscellaneous'), -] - -# Documents to append as an appendix to all manuals. -# texinfo_appendices = [] - -# If false, no module index is generated. -# texinfo_domain_indices = True - -# How to display URL addresses: 'footnote', 'no', or 'inline'. -# texinfo_show_urls = 'footnote' - -# If true, do not generate a @detailmenu in the "Top" node's menu. -# texinfo_no_detailmenu = False diff --git a/doc/data_processing.rst b/doc/data_processing.rst index d77712d..cb59a5c 100644 --- a/doc/data_processing.rst +++ b/doc/data_processing.rst @@ -86,6 +86,7 @@ arguments for pyproj projections except for dx, dy, sw_lon, sw_lat, ne_lon, and to reconstruct the CAM grid. If you do not specify the map projection correctly, the created lat-lon and x-y grids may have a different number of grid dimensions than the data. Double check to be sure. The contents of an example map file are below:: + proj=lcc # map projection a=6370000 # Major Radius of Earth in m. Note that WRF uses a spherical Earth. b=6370000 # Minor radius of Earth in m diff --git a/doc/hagelslag.data.rst b/doc/hagelslag.data.rst index 003f557..87a2459 100644 --- a/doc/hagelslag.data.rst +++ b/doc/hagelslag.data.rst @@ -4,75 +4,154 @@ hagelslag.data package Submodules ---------- +hagelslag.data.FV3ModelGrid module +---------------------------------- + +.. automodule:: hagelslag.data.FV3ModelGrid + :members: + :undoc-members: + :show-inheritance: + +hagelslag.data.GribModelGrid module +----------------------------------- + +.. automodule:: hagelslag.data.GribModelGrid + :members: + :undoc-members: + :show-inheritance: + +hagelslag.data.HREFv2ModelGrid module +------------------------------------- + +.. automodule:: hagelslag.data.HREFv2ModelGrid + :members: + :undoc-members: + :show-inheritance: + +hagelslag.data.HRRREModelGrid module +------------------------------------ + +.. automodule:: hagelslag.data.HRRREModelGrid + :members: + :undoc-members: + :show-inheritance: + hagelslag.data.HRRRModelGrid module ----------------------------------- .. automodule:: hagelslag.data.HRRRModelGrid - :members: - :undoc-members: - :show-inheritance: + :members: + :undoc-members: + :show-inheritance: + +hagelslag.data.HRRRZarrModelGrid module +--------------------------------------- + +.. automodule:: hagelslag.data.HRRRZarrModelGrid + :members: + :undoc-members: + :show-inheritance: hagelslag.data.HailForecastGrid module -------------------------------------- .. automodule:: hagelslag.data.HailForecastGrid - :members: - :undoc-members: - :show-inheritance: + :members: + :undoc-members: + :show-inheritance: + +hagelslag.data.MPASHrrrGrid module +---------------------------------- + +.. automodule:: hagelslag.data.MPASHrrrGrid + :members: + :undoc-members: + :show-inheritance: hagelslag.data.MRMSGrid module ------------------------------ .. automodule:: hagelslag.data.MRMSGrid - :members: - :undoc-members: - :show-inheritance: + :members: + :undoc-members: + :show-inheritance: hagelslag.data.ModelGrid module ------------------------------- .. automodule:: hagelslag.data.ModelGrid - :members: - :undoc-members: - :show-inheritance: + :members: + :undoc-members: + :show-inheritance: hagelslag.data.ModelOutput module --------------------------------- .. automodule:: hagelslag.data.ModelOutput - :members: - :undoc-members: - :show-inheritance: + :members: + :undoc-members: + :show-inheritance: hagelslag.data.NCARModelGrid module ----------------------------------- .. automodule:: hagelslag.data.NCARModelGrid - :members: - :undoc-members: - :show-inheritance: + :members: + :undoc-members: + :show-inheritance: + +hagelslag.data.NCARStormEventModelGrid module +--------------------------------------------- + +.. automodule:: hagelslag.data.NCARStormEventModelGrid + :members: + :undoc-members: + :show-inheritance: + +hagelslag.data.NCARWRF2020ModelGrid module +------------------------------------------ + +.. automodule:: hagelslag.data.NCARWRF2020ModelGrid + :members: + :undoc-members: + :show-inheritance: hagelslag.data.SSEFModelGrid module ----------------------------------- .. automodule:: hagelslag.data.SSEFModelGrid - :members: - :undoc-members: - :show-inheritance: + :members: + :undoc-members: + :show-inheritance: + +hagelslag.data.VSEModelGrid module +---------------------------------- + +.. automodule:: hagelslag.data.VSEModelGrid + :members: + :undoc-members: + :show-inheritance: hagelslag.data.WRFModelGrid module ---------------------------------- .. automodule:: hagelslag.data.WRFModelGrid - :members: - :undoc-members: - :show-inheritance: + :members: + :undoc-members: + :show-inheritance: + +hagelslag.data.ZarrModelGrid module +----------------------------------- +.. automodule:: hagelslag.data.ZarrModelGrid + :members: + :undoc-members: + :show-inheritance: Module contents --------------- .. automodule:: hagelslag.data - :members: - :undoc-members: - :show-inheritance: + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/hagelslag.evaluation.rst b/doc/hagelslag.evaluation.rst index ea10062..9b45652 100644 --- a/doc/hagelslag.evaluation.rst +++ b/doc/hagelslag.evaluation.rst @@ -8,63 +8,62 @@ hagelslag.evaluation.ContingencyTable module -------------------------------------------- .. automodule:: hagelslag.evaluation.ContingencyTable - :members: - :undoc-members: - :show-inheritance: + :members: + :undoc-members: + :show-inheritance: hagelslag.evaluation.GridEvaluator module ----------------------------------------- .. automodule:: hagelslag.evaluation.GridEvaluator - :members: - :undoc-members: - :show-inheritance: + :members: + :undoc-members: + :show-inheritance: hagelslag.evaluation.MetricPlotter module ----------------------------------------- .. automodule:: hagelslag.evaluation.MetricPlotter - :members: - :undoc-members: - :show-inheritance: + :members: + :undoc-members: + :show-inheritance: hagelslag.evaluation.MulticlassContingencyTable module ------------------------------------------------------ .. automodule:: hagelslag.evaluation.MulticlassContingencyTable - :members: - :undoc-members: - :show-inheritance: + :members: + :undoc-members: + :show-inheritance: hagelslag.evaluation.NeighborEvaluator module --------------------------------------------- .. automodule:: hagelslag.evaluation.NeighborEvaluator - :members: - :undoc-members: - :show-inheritance: + :members: + :undoc-members: + :show-inheritance: hagelslag.evaluation.ObjectEvaluator module ------------------------------------------- .. automodule:: hagelslag.evaluation.ObjectEvaluator - :members: - :undoc-members: - :show-inheritance: + :members: + :undoc-members: + :show-inheritance: hagelslag.evaluation.ProbabilityMetrics module ---------------------------------------------- .. automodule:: hagelslag.evaluation.ProbabilityMetrics - :members: - :undoc-members: - :show-inheritance: - + :members: + :undoc-members: + :show-inheritance: Module contents --------------- .. automodule:: hagelslag.evaluation - :members: - :undoc-members: - :show-inheritance: + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/hagelslag.processing.rst b/doc/hagelslag.processing.rst index 9f0cfd6..28c0d3c 100644 --- a/doc/hagelslag.processing.rst +++ b/doc/hagelslag.processing.rst @@ -8,79 +8,86 @@ hagelslag.processing.EnhancedWatershedSegmenter module ------------------------------------------------------ .. automodule:: hagelslag.processing.EnhancedWatershedSegmenter - :members: - :undoc-members: - :show-inheritance: + :members: + :undoc-members: + :show-inheritance: hagelslag.processing.EnsembleProducts module -------------------------------------------- .. automodule:: hagelslag.processing.EnsembleProducts - :members: - :undoc-members: - :show-inheritance: + :members: + :undoc-members: + :show-inheritance: hagelslag.processing.Hysteresis module -------------------------------------- .. automodule:: hagelslag.processing.Hysteresis - :members: - :undoc-members: - :show-inheritance: + :members: + :undoc-members: + :show-inheritance: hagelslag.processing.ObjectMatcher module ----------------------------------------- .. automodule:: hagelslag.processing.ObjectMatcher - :members: - :undoc-members: - :show-inheritance: + :members: + :undoc-members: + :show-inheritance: hagelslag.processing.STObject module ------------------------------------ .. automodule:: hagelslag.processing.STObject - :members: - :undoc-members: - :show-inheritance: + :members: + :undoc-members: + :show-inheritance: hagelslag.processing.TrackModeler module ---------------------------------------- .. automodule:: hagelslag.processing.TrackModeler - :members: - :undoc-members: - :show-inheritance: + :members: + :undoc-members: + :show-inheritance: hagelslag.processing.TrackProcessing module ------------------------------------------- .. automodule:: hagelslag.processing.TrackProcessing - :members: - :undoc-members: - :show-inheritance: + :members: + :undoc-members: + :show-inheritance: hagelslag.processing.TrackSampler module ---------------------------------------- .. automodule:: hagelslag.processing.TrackSampler - :members: - :undoc-members: - :show-inheritance: + :members: + :undoc-members: + :show-inheritance: + +hagelslag.processing.Watershed module +------------------------------------- + +.. automodule:: hagelslag.processing.Watershed + :members: + :undoc-members: + :show-inheritance: hagelslag.processing.tracker module ----------------------------------- .. automodule:: hagelslag.processing.tracker - :members: - :undoc-members: - :show-inheritance: - + :members: + :undoc-members: + :show-inheritance: Module contents --------------- .. automodule:: hagelslag.processing - :members: - :undoc-members: - :show-inheritance: + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/hagelslag.rst b/doc/hagelslag.rst index 67891ed..a623fe6 100644 --- a/doc/hagelslag.rst +++ b/doc/hagelslag.rst @@ -5,16 +5,17 @@ Subpackages ----------- .. toctree:: + :maxdepth: 4 - hagelslag.data - hagelslag.evaluation - hagelslag.processing - hagelslag.util + hagelslag.data + hagelslag.evaluation + hagelslag.processing + hagelslag.util Module contents --------------- .. automodule:: hagelslag - :members: - :undoc-members: - :show-inheritance: + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/hagelslag.util.rst b/doc/hagelslag.util.rst index b7a578f..61b794e 100644 --- a/doc/hagelslag.util.rst +++ b/doc/hagelslag.util.rst @@ -8,95 +8,142 @@ hagelslag.util.Config module ---------------------------- .. automodule:: hagelslag.util.Config - :members: - :undoc-members: - :show-inheritance: + :members: + :undoc-members: + :show-inheritance: -hagelslag.util.convert_mrms_grids module ----------------------------------------- +hagelslag.util.convert\_mrms\_grids module +------------------------------------------ .. automodule:: hagelslag.util.convert_mrms_grids - :members: - :undoc-members: - :show-inheritance: + :members: + :undoc-members: + :show-inheritance: -hagelslag.util.create_model_grid_us_mask module ------------------------------------------------ +hagelslag.util.create\_model\_grid\_us\_mask module +--------------------------------------------------- .. automodule:: hagelslag.util.create_model_grid_us_mask - :members: - :undoc-members: - :show-inheritance: + :members: + :undoc-members: + :show-inheritance: -hagelslag.util.custom_grib_table module ---------------------------------------- +hagelslag.util.create\_sector\_grid\_data module +------------------------------------------------ + +.. automodule:: hagelslag.util.create_sector_grid_data + :members: + :undoc-members: + :show-inheritance: + +hagelslag.util.custom\_grib\_table module +----------------------------------------- .. automodule:: hagelslag.util.custom_grib_table - :members: - :undoc-members: - :show-inheritance: + :members: + :undoc-members: + :show-inheritance: -hagelslag.util.derived_vars module ----------------------------------- +hagelslag.util.derived\_vars module +----------------------------------- .. automodule:: hagelslag.util.derived_vars - :members: - :undoc-members: - :show-inheritance: + :members: + :undoc-members: + :show-inheritance: -hagelslag.util.make_proj_grids module -------------------------------------- +hagelslag.util.hrefv2\_symbolic\_Links module +--------------------------------------------- + +.. automodule:: hagelslag.util.hrefv2_symbolic_Links + :members: + :undoc-members: + :show-inheritance: + +hagelslag.util.lsr\_calibration\_dataset module +----------------------------------------------- + +.. automodule:: hagelslag.util.lsr_calibration_dataset + :members: + :undoc-members: + :show-inheritance: + +hagelslag.util.make\_proj\_grids module +--------------------------------------- .. automodule:: hagelslag.util.make_proj_grids - :members: - :undoc-members: - :show-inheritance: + :members: + :undoc-members: + :show-inheritance: -hagelslag.util.merge_forecast_data module ------------------------------------------ +hagelslag.util.merge\_forecast\_data module +------------------------------------------- .. automodule:: hagelslag.util.merge_forecast_data - :members: - :undoc-members: - :show-inheritance: + :members: + :undoc-members: + :show-inheritance: + +hagelslag.util.mrms\_mesh\_calibration\_dataset module +------------------------------------------------------ + +.. automodule:: hagelslag.util.mrms_mesh_calibration_dataset + :members: + :undoc-members: + :show-inheritance: hagelslag.util.munkres module ----------------------------- .. automodule:: hagelslag.util.munkres - :members: - :undoc-members: - :show-inheritance: + :members: + :undoc-members: + :show-inheritance: -hagelslag.util.output_tree_ensembles module -------------------------------------------- +hagelslag.util.output\_tree\_ensembles module +--------------------------------------------- .. automodule:: hagelslag.util.output_tree_ensembles - :members: - :undoc-members: - :show-inheritance: + :members: + :undoc-members: + :show-inheritance: -hagelslag.util.show_importance_ranks module -------------------------------------------- +hagelslag.util.show\_importance\_ranks module +--------------------------------------------- .. automodule:: hagelslag.util.show_importance_ranks - :members: - :undoc-members: - :show-inheritance: + :members: + :undoc-members: + :show-inheritance: -hagelslag.util.test_size_distributions module ---------------------------------------------- +hagelslag.util.storm\_patch\_center\_coords module +-------------------------------------------------- + +.. automodule:: hagelslag.util.storm_patch_center_coords + :members: + :undoc-members: + :show-inheritance: + +hagelslag.util.test\_size\_distributions module +----------------------------------------------- .. automodule:: hagelslag.util.test_size_distributions - :members: - :undoc-members: - :show-inheritance: + :members: + :undoc-members: + :show-inheritance: + +hagelslag.util.testing\_sector module +------------------------------------- +.. automodule:: hagelslag.util.testing_sector + :members: + :undoc-members: + :show-inheritance: Module contents --------------- .. automodule:: hagelslag.util - :members: - :undoc-members: - :show-inheritance: + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/modules.rst b/doc/modules.rst index 9c47dcd..9b14dcf 100644 --- a/doc/modules.rst +++ b/doc/modules.rst @@ -5,5 +5,3 @@ hagelslag :maxdepth: 4 hagelslag - setup - test diff --git a/hagelslag/data/FV3ModelGrid.py b/hagelslag/data/FV3ModelGrid.py index 5232c80..bea39ad 100644 --- a/hagelslag/data/FV3ModelGrid.py +++ b/hagelslag/data/FV3ModelGrid.py @@ -1,6 +1,5 @@ #!/usr/bin/env python import numpy as np - from .GribModelGrid import GribModelGrid from .ModelGrid import ModelGrid @@ -8,6 +7,7 @@ class FV3ModelGrid(GribModelGrid): """ Extension of the ModelGrid class for interfacing with the HREFv2 ensemble. + Args: member (str): Name of the ensemble member run_date (datetime.datetime object): Date of the initial step of the ensemble run @@ -16,7 +16,7 @@ class FV3ModelGrid(GribModelGrid): end_date (datetime.datetime object): Last time step extracted. path (str): Path to model output files single_step (boolean (default=True): Whether variable information is stored with each time step in a separate - file (True) or one file containing all timesteps (False). + file (True) or one file containing all timesteps (False). """ def __init__(self, member, run_date, variable, start_date, diff --git a/hagelslag/data/GribModelGrid.py b/hagelslag/data/GribModelGrid.py index 7c38577..190158f 100644 --- a/hagelslag/data/GribModelGrid.py +++ b/hagelslag/data/GribModelGrid.py @@ -12,13 +12,13 @@ class GribModelGrid(object): Given a list of file names, loads the values of a single variable from a model run. Supports model output in grib2 format Attributes: - filenames (list of str): List of grib2 files containing model output - run_date (ISO date string or datetime.datetime object): Date of the initialization time of the model run. - start_date (ISO date string or datetime.datetime object): Date of the first timestep extracted. - end_date (ISO date string or datetime.datetime object): Date of the last timestep extracted. - variable (str): Grib2 variable - member (str): Individual ensemble member. - frequency (str): Spacing between model time steps. + filenames (list of str): List of grib2 files containing model output + run_date (ISO date string or datetime.datetime object): Date of the initialization time of the model run. + start_date (ISO date string or datetime.datetime object): Date of the first timestep extracted. + end_date (ISO date string or datetime.datetime object): Date of the last timestep extracted. + variable (str): Grib2 variable + member (str): Individual ensemble member. + frequency (str): Spacing between model time steps. """ def __init__(self, @@ -60,6 +60,7 @@ def format_grib_name(self, selected_variable): Assigns name to grib2 message number with name 'unknown'. Names based on NOAA grib2 abbreviations. Names: + 197: RETOP: Echo Top 198: MAXREF: Hourly Maximum of Simulated Reflectivity at 1 km AGL 199: MXUPHL: Hourly Maximum of Updraft Helicity over Layer 2km to 5 km AGL, and 0km to 3km AGL @@ -73,6 +74,7 @@ def format_grib_name(self, selected_variable): Args: selected_variable(str): Name of selected variable for loading + Returns: Given an uknown string name of a variable, returns the grib2 message Id and units of the variable, based on the self.unknown_name and diff --git a/hagelslag/data/HRRREModelGrid.py b/hagelslag/data/HRRREModelGrid.py index 8c07924..6fe0912 100644 --- a/hagelslag/data/HRRREModelGrid.py +++ b/hagelslag/data/HRRREModelGrid.py @@ -9,6 +9,7 @@ class HRRREModelGrid(GribModelGrid): """ Extension of the ModelGrid class for interfacing with the HREFv2 ensemble. + Args: member (str): Name of the ensemble member run_date (datetime.datetime object): Date of the initial step of the ensemble run @@ -17,7 +18,7 @@ class HRRREModelGrid(GribModelGrid): end_date (datetime.datetime object): Last time step extracted. path (str): Path to model output files single_step (boolean (default=True): Whether variable information is stored with each time step in a separate - file (True) or one file containing all timesteps (False). + file (True) or one file containing all timesteps (False). """ def __init__(self, member, run_date, variable, start_date, diff --git a/test/__init__.py b/hagelslag/test/__init__.py similarity index 100% rename from test/__init__.py rename to hagelslag/test/__init__.py diff --git a/test/test_STObject.py b/hagelslag/test/test_STObject.py similarity index 100% rename from test/test_STObject.py rename to hagelslag/test/test_STObject.py diff --git a/test/test_data_MRMSGrid.py b/hagelslag/test/test_data_MRMSGrid.py similarity index 100% rename from test/test_data_MRMSGrid.py rename to hagelslag/test/test_data_MRMSGrid.py diff --git a/test/test_evaluation.py b/hagelslag/test/test_evaluation.py similarity index 100% rename from test/test_evaluation.py rename to hagelslag/test/test_evaluation.py diff --git a/test/test_tracking.py b/hagelslag/test/test_tracking.py similarity index 97% rename from test/test_tracking.py rename to hagelslag/test/test_tracking.py index 37d74b5..c33e2a5 100644 --- a/test/test_tracking.py +++ b/hagelslag/test/test_tracking.py @@ -9,11 +9,11 @@ class TestTracking(unittest.TestCase): def setUp(self): - current_dir_files = os.listdir("./") + current_dir_files = os.listdir("/") if "testdata" not in current_dir_files: - start_path = "../" + start_path = "../../" else: - start_path = "./" + start_path = "/" self.model_path = start_path + "testdata/spring2015_unidata/" self.ensemble_name = "SSEF" self.member ="wrf-s3cn_arw" diff --git a/hagelslag/util/lsr_calibration_dataset.py b/hagelslag/util/lsr_calibration_dataset.py index b627c63..e3fdc8e 100644 --- a/hagelslag/util/lsr_calibration_dataset.py +++ b/hagelslag/util/lsr_calibration_dataset.py @@ -5,7 +5,7 @@ import pyproj from netCDF4 import Dataset -from make_proj_grids import read_ncar_map_file, make_proj_grids +from .make_proj_grids import read_ncar_map_file, make_proj_grids def main(): diff --git a/hagelslag/util/mrms_mesh_calibration_dataset.py b/hagelslag/util/mrms_mesh_calibration_dataset.py index bbf133a..ebe6691 100644 --- a/hagelslag/util/mrms_mesh_calibration_dataset.py +++ b/hagelslag/util/mrms_mesh_calibration_dataset.py @@ -6,7 +6,7 @@ from pyproj import Proj from netCDF4 import Dataset -from make_proj_grids import make_proj_grids, read_ncar_map_file +from .make_proj_grids import make_proj_grids, read_ncar_map_file def main(): diff --git a/hagelslag/util/munkres.py b/hagelslag/util/munkres.py index d1b218a..0e266ac 100644 --- a/hagelslag/util/munkres.py +++ b/hagelslag/util/munkres.py @@ -321,8 +321,6 @@ def __init__(self): @staticmethod def make_cost_matrix(profit_matrix, inversion_function): """ - **DEPRECATED** - Please use the module function ``make_cost_matrix()``. """ return make_cost_matrix(profit_matrix, inversion_function) @@ -681,18 +679,6 @@ def make_cost_matrix(profit_matrix, inversion_function): another numeric argument which is presumed to be the cost inverse of the original profit. - This is a static method. Call it like this: - - .. python:: - - cost_matrix = Munkres.make_cost_matrix(matrix, inversion_func) - - For example: - - .. python:: - - cost_matrix = Munkres.make_cost_matrix(matrix, lambda x : sys.maxsize - x) - :Parameters: profit_matrix : list of lists The matrix to convert from a profit to a cost matrix diff --git a/hagelslag/util/testing_sector.py b/hagelslag/util/testing_sector.py index 61247d7..f823c0e 100644 --- a/hagelslag/util/testing_sector.py +++ b/hagelslag/util/testing_sector.py @@ -3,95 +3,96 @@ import numpy as np import pandas as pd -from create_sector_grid_data import SectorProcessor +from .create_sector_grid_data import SectorProcessor from hagelslag.processing.ObjectMatcher import centroid_distance, time_distance from hagelslag.processing.ObjectMatcher import shifted_centroid_distance -# date_index = pd.DatetimeIndex([pd.Timestamp.utcnow().strftime("%Y%m%d")]) -work_path = "/ai-hail/aburke/2018_HREFv2_data/" -scratch_path = "/hail/aburke/testing_weights/figuring_out_files/" -ensemble_members = ['nam_00', 'nam_12', 'arw_00', 'arw_12', 'nssl_00', 'nssl_12', 'nmmb_00', 'nmmb_12'] +if __name__ == "__main__": + # date_index = pd.DatetimeIndex([pd.Timestamp.utcnow().strftime("%Y%m%d")]) + work_path = "/ai-hail/aburke/2018_HREFv2_data/" + scratch_path = "/hail/aburke/testing_weights/figuring_out_files/" + ensemble_members = ['nam_00', 'nam_12', 'arw_00', 'arw_12', 'nssl_00', 'nssl_12', 'nmmb_00', 'nmmb_12'] -config = dict(dates=None, - start_hour=12, - end_hour=36, - watershed_variable="MAXUVV", - ensemble_name="HREFv2", - ensemble_members=ensemble_members, - model_path=work_path + 'symbolic_hrefv2_data', - model_watershed_params=(8, 1, 80, 100, 60), - size_filter=12, - gaussian_window=2, - mrms_path=work_path + "MRMS/", - mrms_variable="MESH_Max_60min_00.50", - mrms_watershed_params=(19, 1, 100, 100, 75), - object_matcher_params=([shifted_centroid_distance], np.array([1.0]), - np.array([24000])), + config = dict(dates=None, + start_hour=12, + end_hour=36, + watershed_variable="MAXUVV", + ensemble_name="HREFv2", + ensemble_members=ensemble_members, + model_path=work_path + 'symbolic_hrefv2_data', + model_watershed_params=(8, 1, 80, 100, 60), + size_filter=12, + gaussian_window=2, + mrms_path=work_path + "MRMS/", + mrms_variable="MESH_Max_60min_00.50", + mrms_watershed_params=(19, 1, 100, 100, 75), + object_matcher_params=([shifted_centroid_distance], np.array([1.0]), + np.array([24000])), - track_matcher_params=([centroid_distance, time_distance], - np.array([80000, 2])), + track_matcher_params=([centroid_distance, time_distance], + np.array([80000, 2])), - storm_variables=['MAXUVV', 'Storm relative helicity_3000', 'Storm relative helicity_1000', - 'MAXREF', 'MXUPHL_5000', 'MAXDVV'], + storm_variables=['MAXUVV', 'Storm relative helicity_3000', 'Storm relative helicity_1000', + 'MAXREF', 'MXUPHL_5000', 'MAXDVV'], - potential_variables=['Precipitable water_0', 'Temperature_1000', 'Dew point temperature_1000', - 'Geopotential Height_500', 'Temperature_500', - 'Dew point temperature_500', 'U component of wind_500', 'V component of wind_500', - 'Geopotential Height_700', 'Temperature_700', 'Dew point temperature_700', - 'U component of wind_700', - 'V component of wind_700', 'Geopotential Height_850', 'Temperature_850', - 'Dew point temperature_850', - 'U component of wind_850', 'V component of wind_850', 'MAXUW', 'MAXVW', - 'Surface lifted index', 'Convective available potential energy_0', - 'Convective inhibition_0'], + potential_variables=['Precipitable water_0', 'Temperature_1000', 'Dew point temperature_1000', + 'Geopotential Height_500', 'Temperature_500', + 'Dew point temperature_500', 'U component of wind_500', 'V component of wind_500', + 'Geopotential Height_700', 'Temperature_700', 'Dew point temperature_700', + 'U component of wind_700', + 'V component of wind_700', 'Geopotential Height_850', 'Temperature_850', + 'Dew point temperature_850', + 'U component of wind_850', 'V component of wind_850', 'MAXUW', 'MAXVW', + 'Surface lifted index', 'Convective available potential energy_0', + 'Convective inhibition_0'], - tendency_variables=[], - shape_variables=["area", "eccentricity", "major_axis_length", "minor_axis_length", "orientation", - "extent"], - variable_statistics=["mean", "max", "min", "std", "skew", - "percentile_10", "percentile_50", "percentile_90"], - csv_path=scratch_path + "track_data_spring2018_MAXUVV_closest_csv/", - geojson_path=scratch_path + "track_data_spring2018_MAXUVV_closest_json/", - nc_path=scratch_path + "track_data_spring2018_MAXUVV_patch_nc/", - unique_matches=True, - patch_radius=16, - closest_matches=True, - match_steps=True, - train=False, - single_step=True, - label_type="gamma", - model_map_file="/hail/aburke/hagelslag/mapfiles/hrefv2_2018_map.txt", - mask_file="/hail/aburke/hagelslag/mapfiles/hrefv2_us_mask.nc", - run_date_format="%Y%m%d-%H%M", - sector_csv_outpath=scratch_path + 'track_data_spring2018_MAXUVV_closest_csv/', - sector_nc_outpath=scratch_path + 'track_data_spring2018_MAXUVV_patch_nc/', - sector_mapfile="/hail/aburke/hagelslag/mapfiles/hrefv2_sectors/C_2018_map.txt" - ) + tendency_variables=[], + shape_variables=["area", "eccentricity", "major_axis_length", "minor_axis_length", "orientation", + "extent"], + variable_statistics=["mean", "max", "min", "std", "skew", + "percentile_10", "percentile_50", "percentile_90"], + csv_path=scratch_path + "track_data_spring2018_MAXUVV_closest_csv/", + geojson_path=scratch_path + "track_data_spring2018_MAXUVV_closest_json/", + nc_path=scratch_path + "track_data_spring2018_MAXUVV_patch_nc/", + unique_matches=True, + patch_radius=16, + closest_matches=True, + match_steps=True, + train=False, + single_step=True, + label_type="gamma", + model_map_file="/hail/aburke/hagelslag/mapfiles/hrefv2_2018_map.txt", + mask_file="/hail/aburke/hagelslag/mapfiles/hrefv2_us_mask.nc", + run_date_format="%Y%m%d-%H%M", + sector_csv_outpath=scratch_path + 'track_data_spring2018_MAXUVV_closest_csv/', + sector_nc_outpath=scratch_path + 'track_data_spring2018_MAXUVV_patch_nc/', + sector_mapfile="/hail/aburke/hagelslag/mapfiles/hrefv2_sectors/C_2018_map.txt" + ) -sector = 'E' + sector = 'E' -date_index = pd.DatetimeIndex(start="2018-05-01T00:00", end="2018-06-02T00:00", freq="1D") + date_index = pd.date_range(start="2018-05-01T00:00", end="2018-06-02T00:00", freq="1D") -sector_mapfile = "/hail/aburke/hagelslag/mapfiles/hrefv2_sectors/{0}_2018_map.txt".format(sector) -ensemble_name = "HREFv2" -member = 'arw_00' -run_date = datetime(2018, 7, 1) -run_date_format = "%Y%m%d-%H%M" -csv_path = '/hail/aburke/HREF_Scripts_and_Data/hwt_2018/track_data_spring2018_MAXUVV_closest_csv/' -nc_path = '/hail/aburke/HREF_Scripts_and_Data/hwt_2018/track_data_spring2018_MAXUVV_patch_nc/' -sector_csv_outpath = "/hail/aburke/testing_weights/sector_trained/{0}/track_data_spring2018_MAXUVV_closest_csv/".format( - sector) -sector_nc_outpath = "/hail/aburke/testing_weights/sector_trained/{0}/track_data_spring2018_MAXUVV_patch_nc/".format( - sector) -patch_radius = 16 + sector_mapfile = "/hail/aburke/hagelslag/mapfiles/hrefv2_sectors/{0}_2018_map.txt".format(sector) + ensemble_name = "HREFv2" + member = 'arw_00' + run_date = datetime(2018, 7, 1) + run_date_format = "%Y%m%d-%H%M" + csv_path = '/hail/aburke/HREF_Scripts_and_Data/hwt_2018/track_data_spring2018_MAXUVV_closest_csv/' + nc_path = '/hail/aburke/HREF_Scripts_and_Data/hwt_2018/track_data_spring2018_MAXUVV_patch_nc/' + sector_csv_outpath = "/hail/aburke/testing_weights/sector_trained/{0}/track_data_spring2018_MAXUVV_closest_csv/".format( + sector) + sector_nc_outpath = "/hail/aburke/testing_weights/sector_trained/{0}/track_data_spring2018_MAXUVV_patch_nc/".format( + sector) + patch_radius = 16 -for run_date in date_index: - for member in ensemble_members: - sector = SectorProcessor(sector_mapfile, - ensemble_name, member, - run_date, run_date_format) + for run_date in date_index: + for member in ensemble_members: + sector = SectorProcessor(sector_mapfile, + ensemble_name, member, + run_date, run_date_format) - sector.output_sector_netcdf(nc_path, sector_nc_outpath, patch_radius, config) + sector.output_sector_netcdf(nc_path, sector_nc_outpath, patch_radius, config) - # for key in ['track_step', 'track_total']: - # sector.output_sector_csv(csv_path,key,sector_csv_outpath) + # for key in ['track_step', 'track_total']: + # sector.output_sector_csv(csv_path,key,sector_csv_outpath)