Skip to content

Commit b25b559

Browse files
authored
Merge pull request #9 from Dewberry/bugfix/general_improvements
Bugfix/general improvements
2 parents c726f5b + ef3b64b commit b25b559

File tree

12 files changed

+252
-91
lines changed

12 files changed

+252
-91
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,4 +171,7 @@ cython_debug/
171171
.pypirc
172172
catalogs
173173
holding
174-
.DS_Store
174+
.DS_Store
175+
176+
bighorn
177+
indian-creek

build-local.sh

100755100644
File mode changed.

docs/make.sh

100755100644
File mode changed.

docs/source/change_log.rst

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
.. note::
22
Go to the `Releases <https://github.com/Dewberry/stormhub/releases.html>`__ page for a list of all releases.
33

4+
Release v0.1.0
5+
==============
6+
7+
**Tag:** v0.1.0
8+
9+
**Published at:** 2025-01-31T21:13:10Z
10+
11+
**Author:** github-actions[bot]
12+
13+
**Release Notes:**
14+
15+
Summary^^^^^^^^
16+
This feature release adds routines for developing STAC catalogs using AORC data. Source code was ported from existing internal libraries and refactored for this initial release.
17+
18+
419
Release v0.1.0rc1
520
=================
621

@@ -12,6 +27,6 @@ Release v0.1.0rc1
1227

1328
**Release Notes:**
1429

15-
30+
Initial code compilation from existing internal libraries, adapted for STAC catalogs.
1631

1732

docs/source/tech_summary.rst

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ Storm Transposition Module
88

99
Data Source
1010
-----------
11-
The Analysis Of Record for Calibration (AORC) dataset is available on the AWS `Registry of Open Data <https://registry.opendata.aws/noaa-nws-aorc/>`_, and provides the
12-
source data for precipitation and temperature data used in this module. (Other sources may be added but are not currently available). This gridded / houlry data is available for the CONUS
13-
beginning on 1972-02-01 and is updated regularly.
11+
The Analysis Of Record for Calibration (AORC) dataset is available on the AWS `Registry of Open Data <https://registry.opendata.aws/noaa-nws-aorc/>`_, and provides the
12+
source data for precipitation and temperature data used in this module. (Other sources may be added but are not currently available). This gridded / hourly data is available for the CONUS
13+
beginning on 1972-02-01 and is updated regularly.
1414

1515

1616
The primary inputs used for the data development workflow are as follows.
1717

18-
Watershed = The waterhsed which will be used for hydrologic modeling.
18+
Watershed = The watershed which will be used for hydrologic modeling.
1919

2020
Transposition Area = A region containing the watershed that has been developed as a hydro-meteorologically homogenous region.
2121

@@ -46,10 +46,10 @@ cells of the watershed within the transposition region. The centroid location an
4646
.. image:: ./images/2011-event.png
4747

4848

49-
3. **Iterate over the period of record or desired date range**: In order to process multiple dates for a range (from start_date - end_date), there is an optional argumen `check_every_n_hours`. If set to 1, the process will sum up the storm duration for every hour from the start_date
49+
3. **Iterate over the period of record or desired date range**: In order to process multiple dates for a range (from start_date - end_date), there is an optional argument `check_every_n_hours`. If set to 1, the process will sum up the storm duration for every hour from the start_date
5050
to the end_date. For a 72-hour event, this would require processing 350,400 datasets (every hour for the period) for 40 years of record and would represent the most precise estimate to aid in identifying the start hour for the event. To save in processing
5151
time and data, an alternate interval can be used. For example, selecting `check_every_n_hours` = 24 would result in 14,600 datasets processed for the same 40 year period.
52-
52+
5353
check_every_n_hours = 6 (This would get check the totals every 6 hours, or 4 times a day)
5454

5555

@@ -67,15 +67,15 @@ After processing the data for every date in the requested date range, a csv is c
6767
|1979-02-01T18 | 0.02 | 0.02 | 0.02 | -92.66397464708892 |40.50038658823523|
6868
+------------------------+------------+----------+----------+---------------------+-----------------+
6969

70-
4. **Top events and date declustering** With the staticics in place, user settings can be used to create a STAC collection for the watershed / transpositon region / storm duration using the following inputs.
71-
70+
4. **Top events and date declustering** With the statistics in place, user settings can be used to create a STAC collection for the watershed / transpositon region / storm duration using the following inputs.
71+
7272
min_precip_threshold = 2 (Defaults to 1, this can be used to filter out events based on a minimum threshold)
73-
73+
7474
top_n_events = 440 (This will be the total # of events in the collection. 440 would represent the top 10 events for 44 years)
7575

7676
To avoid double counting what is essentially the same storm because the N hour duration for several consecutive periods may result in a top storm, results of the query are iterated and added to a list,
7777
a process filters storms to be skipped if there is any temporal overlap with a storm already existing in the list (the overlap is determined using the start time and duration of the top storm). As shown
78-
in these images, these records are considered to be a single storm, and would be declustered, wherein the day with the greater mean precipitation would be included in the top storms collection and the other
78+
in these images, these records are considered to be a single storm, and would be declustered, wherein the day with the greater mean precipitation would be included in the top storms collection and the other
7979
would be dropped.
8080

8181

@@ -91,7 +91,7 @@ would be dropped.
9191

9292

9393
5. The following additional arguments are available.
94-
94+
9595
.. code:: bash
9696
9797
specific_dates # Can be provided to resume processing in the event of a failure or other use cases
@@ -102,23 +102,23 @@ would be dropped.
102102
103103
104104
105-
Results
105+
Results
106106
-------
107107

108-
A Storm Catalog is created containing a copy of the watershed, transposition domain, and the *valid transpositon domain* which is the space within the transposition domain wherein a
109-
watershed can be transposed without encountering null space (i.e. part of the watershed extending outside of the trnasposition domain).
108+
A Storm Catalog is created containing a copy of the watershed, transposition domain, and the *valid transpositon domain* which is the space within the transposition domain wherein a
109+
watershed can be transposed without encountering null space (i.e. part of the watershed extending outside of the transposition domain).
110110

111111
.. image:: ./images/catalog.png
112112

113113

114-
STAC Collections will be added to the catalog for each storm duration requested. The collection will include relevant data including summary statistics, plots, and other assets to rpovide
114+
STAC Collections will be added to the catalog for each storm duration requested. The collection will include relevant data including summary statistics, plots, and other assets to provide
115115
context and metadata for the data.
116116

117117
.. image:: ./images/storm-collection.png
118118

119119

120-
The collection is compised of STAC Items, which provide links to source data and derivative products. For example, a model speciric timeseries file may be required for hydrologic modeling.
121-
These files can be created and added to the event item alongside metadata and other information. Assets may include additional data required for modeling (i.e. temperature data, also available via AORC).
120+
The collection is composed of STAC Items, which provide links to source data and derivative products. For example, a model specific timeseries file may be required for hydrologic modeling.
121+
These files can be created and added to the event item alongside metadata and other information. Assets may include additional data required for modeling (i.e. temperature data, also available via AORC).
122122
.. image:: ./images/storm-item.png
123123

124124

@@ -129,5 +129,5 @@ These files can be created and added to the event item alongside metadata and ot
129129
This feature was evaluated and used in pilot projects, does not currently exist in this repository, but may be incorporated in the future.
130130

131131

132-
Where possible, `NOAA Atlas-14 precipitation frequency estimates <https://hdsc.nws.noaa.gov/hdsc/pfds/pfds_gis.html>`_ may be considered to normalize the average accumulation for each storm.
133-
.. image:: ./images/2yr03da.PNG
132+
Where possible, `NOAA Atlas-14 precipitation frequency estimates <https://hdsc.nws.noaa.gov/hdsc/pfds/pfds_gis.html>`_ may be considered to normalize the average accumulation for each storm.
133+
.. image:: ./images/2yr03da.png

docs/source/user_guide.rst

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Getting Started
33
################
44

5-
This section provides a high level overview for using stormhub for production, including starting the stormhub server and create objects.
5+
This section provides a high level overview for using stormhub for production, including starting the stormhub server and creating objects.
66

77
Installation
88
------------
@@ -18,20 +18,21 @@ have Python already installed and setup:
1818
1919
Note that it is highly recommended to create a python `virtual environment
2020
<https://docs.python.org/3/library/venv.html>`_ to install, test, and run
21-
stormhub.
21+
stormhub. It is also recommended to avoid use of Windows Subsystem for Linux (WSL)
22+
as issues can arise with the parallel processing within stormhub.
2223

2324

2425
Starting the server
2526
-------------------
2627

2728
For convenience, a local file server is provided. This server is not necessary for data
28-
production, but is useful for visualizing and exploring the data.
29+
production, but is useful for visualizing and exploring the data.
2930

3031
**Start the stormhub file:**
3132

3233
.. code-block:: bash
3334
34-
stormhub-server <path-to-local-dir>
35+
stormhub-server <path-to-local-dir>
3536
3637
3738
Local file server is useful for interacting with STAC browser for viewing the data locally. This is not required....
@@ -44,7 +45,7 @@ Local file server is useful for interacting with STAC browser for viewing the da
4445
Workflows
4546
---------
4647

47-
A config file shown in below includes the information required to create a new catalog.
48+
A config file shown below includes the information required to create a new catalog.
4849

4950
.. code-block:: json
5051
@@ -62,7 +63,7 @@ A config file shown in below includes the information required to create a new c
6263
}
6364
6465
65-
The following snippet provides an example of how to build and create a storm catalog. Requires an example watershed and transposition domain (examples availble in the `repo <https://github.com/Dewberry/stormhub/tree/main/catalogs/example-input-data>`_).
66+
The following snippet provides an example of how to build and create a storm catalog. Requires an example watershed and transposition domain (examples available in the `repo <https://github.com/Dewberry/stormhub/tree/main/catalogs/example-input-data>`_).
6667

6768
.. code-block:: python
6869

stormhub/hydro_domain.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
from datetime import datetime
22
from typing import Any, Union
3-
3+
import logging
44
import fiona.errors
55
import geopandas as gpd
66
from pystac import Item
77
from pystac.extensions.projection import ProjectionExtension
8-
from shapely.geometry import Polygon, mapping, shape
8+
from shapely.geometry import Polygon, mapping, shape, MultiPolygon
99

1010
HYDRO_DOMAIN_DESCRIPTION = "hydro_domain:description"
1111
HYDRO_DOMAIN_TYPE = "hydro_domain:type"
@@ -121,7 +121,16 @@ def load_geometry(self, geometry_source: Union[str, Polygon]) -> Polygon:
121121
else:
122122
raise ValueError("geometry_source must be a file path or a Polygon object")
123123

124-
if len(gdf) != 1 or not isinstance(gdf.geometry.iloc[0], Polygon):
124+
if len(gdf) != 1:
125+
raise ValueError("The geometry must contain a single polygon")
126+
127+
geometry = gdf.geometry.iloc[0]
128+
if isinstance(geometry, MultiPolygon) and len(geometry.geoms) == 1:
129+
logging.warning("Multipolygon type detected, attempting conversion to Polygon.")
130+
geometry = geometry.geoms[0]
131+
gdf.at[gdf.index[0], "geometry"] = geometry
132+
133+
if not isinstance(geometry, Polygon):
125134
raise ValueError("The geometry must contain a single polygon")
126135

127136
try:

stormhub/met/aorc/aorc.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,13 @@ def aorc_thumbnail(
267267
edgecolor="gray",
268268
)
269269
ax.add_patch(valid_area_plt_polygon)
270+
watershed_plt_polygon = patches.Polygon(
271+
np.column_stack(self.watershed_geometry.exterior.coords.xy),
272+
lw=0.7,
273+
facecolor="none",
274+
edgecolor="gray",
275+
)
276+
ax.add_patch(watershed_plt_polygon)
270277
transposed_watershed_plt_polygon = patches.Polygon(
271278
np.column_stack(self._transposed_watershed.exterior.coords.xy),
272279
lw=1,
@@ -283,7 +290,7 @@ def aorc_thumbnail(
283290
filename = f"{self.item_id}.thumbnail.png"
284291
fn = os.path.join(self.local_directory, filename)
285292
fig.savefig(fn, bbox_inches="tight")
286-
asset = Asset(fn, media_type=MediaType.PNG, roles=["thumbnail"])
293+
asset = Asset(filename, media_type=MediaType.PNG, roles=["thumbnail"])
287294
self.add_asset("thumbnail", asset)
288295
if return_fig:
289296
return fig

0 commit comments

Comments
 (0)