ngiab-data-preprocess 4.6.5__py3-none-any.whl → 4.6.7__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data_processing/dataset_utils.py +6 -2
- data_processing/gpkg_utils.py +2 -1
- map_app/static/css/toggle.css +3 -3
- map_app/static/js/data_processing.js +8 -7
- ngiab_data_cli/__main__.py +1 -1
- ngiab_data_cli/arguments.py +10 -2
- {ngiab_data_preprocess-4.6.5.dist-info → ngiab_data_preprocess-4.6.7.dist-info}/METADATA +13 -12
- {ngiab_data_preprocess-4.6.5.dist-info → ngiab_data_preprocess-4.6.7.dist-info}/RECORD +12 -12
- {ngiab_data_preprocess-4.6.5.dist-info → ngiab_data_preprocess-4.6.7.dist-info}/WHEEL +0 -0
- {ngiab_data_preprocess-4.6.5.dist-info → ngiab_data_preprocess-4.6.7.dist-info}/entry_points.txt +0 -0
- {ngiab_data_preprocess-4.6.5.dist-info → ngiab_data_preprocess-4.6.7.dist-info}/licenses/LICENSE +0 -0
- {ngiab_data_preprocess-4.6.5.dist-info → ngiab_data_preprocess-4.6.7.dist-info}/top_level.txt +0 -0
data_processing/dataset_utils.py
CHANGED
|
@@ -107,9 +107,13 @@ def clip_dataset_to_bounds(
|
|
|
107
107
|
"""
|
|
108
108
|
# check time range here in case just this function is imported and not the whole module
|
|
109
109
|
start_time, end_time = validate_time_range(dataset, start_time, end_time)
|
|
110
|
+
samplex = dataset.x.values[:2]
|
|
111
|
+
intervalx = samplex[1] - samplex[0]
|
|
112
|
+
sampley = dataset.y.values[:2]
|
|
113
|
+
intervaly = sampley[1] - sampley[0]
|
|
110
114
|
dataset = dataset.sel(
|
|
111
|
-
x=slice(bounds[0], bounds[2]),
|
|
112
|
-
y=slice(bounds[1], bounds[3]),
|
|
115
|
+
x=slice(bounds[0]-intervalx, bounds[2]+intervalx),
|
|
116
|
+
y=slice(bounds[1]-intervaly, bounds[3]+intervaly),
|
|
113
117
|
time=slice(start_time, end_time),
|
|
114
118
|
)
|
|
115
119
|
logger.info("Selected time range and clipped to bounds")
|
data_processing/gpkg_utils.py
CHANGED
|
@@ -530,7 +530,7 @@ def get_cat_to_nhd_feature_id(gpkg: Path = FilePaths.conus_hydrofabric) -> Dict[
|
|
|
530
530
|
)
|
|
531
531
|
|
|
532
532
|
table_name = list(tables)[0]
|
|
533
|
-
sql_query = f"SELECT divide_id, hf_id FROM {table_name} WHERE divide_id IS NOT NULL AND hf_id IS NOT NULL"
|
|
533
|
+
sql_query = f"SELECT divide_id, hf_id FROM {table_name} WHERE divide_id IS NOT NULL AND hf_id IS NOT NULL ORDER BY hf_hydroseq DESC"
|
|
534
534
|
|
|
535
535
|
with sqlite3.connect(gpkg) as conn:
|
|
536
536
|
result: List[Tuple[str, str]] = conn.execute(sql_query).fetchall()
|
|
@@ -539,6 +539,7 @@ def get_cat_to_nhd_feature_id(gpkg: Path = FilePaths.conus_hydrofabric) -> Dict[
|
|
|
539
539
|
for cat, feature in result:
|
|
540
540
|
# the ids are stored as floats this converts to int to match nwm output
|
|
541
541
|
# numeric ids should be stored as strings.
|
|
542
|
+
# Because of the ORDER BY above, the lowest hf_hydroseq "wins"
|
|
542
543
|
mapping[cat] = int(feature)
|
|
543
544
|
|
|
544
545
|
return mapping
|
map_app/static/css/toggle.css
CHANGED
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
.toggle-input:checked + .toggle-label .toggle-text-left {
|
|
80
80
|
color: #888; /* Grey color for non-selected text */
|
|
81
81
|
}
|
|
82
|
-
|
|
82
|
+
|
|
83
83
|
.toggle-input:checked + .toggle-label .toggle-text-right {
|
|
84
84
|
color: #888; /* Grey color for non-selected text */
|
|
85
85
|
}
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
top: -40px;
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
.menu-switch__input {
|
|
94
|
+
#menuToggle .menu-switch__input {
|
|
95
95
|
opacity: 0;
|
|
96
96
|
width: 100%;
|
|
97
97
|
height: 100%;
|
|
@@ -162,7 +162,7 @@
|
|
|
162
162
|
height: 1.4em;
|
|
163
163
|
position: relative;
|
|
164
164
|
top: -0.2em;
|
|
165
|
-
margin-right: 1em;
|
|
165
|
+
margin-right: 1em;
|
|
166
166
|
vertical-align: top;
|
|
167
167
|
cursor: pointer;
|
|
168
168
|
text-align: center;
|
|
@@ -19,12 +19,13 @@ async function subset() {
|
|
|
19
19
|
document.getElementById('output-path').innerHTML = "Subset canceled. Geopackage located at " + filename;
|
|
20
20
|
return;
|
|
21
21
|
}
|
|
22
|
-
}
|
|
22
|
+
}
|
|
23
23
|
// check what kind of subset
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
if (document.getElementById('radio-nexus').checked) {
|
|
25
|
+
var subset_type = 'nexus'
|
|
26
|
+
} else {
|
|
27
|
+
var subset_type = 'catchment'
|
|
28
|
+
}
|
|
28
29
|
|
|
29
30
|
const startTime = performance.now(); // Start the timer
|
|
30
31
|
fetch('/subset', {
|
|
@@ -126,7 +127,7 @@ async function forcings() {
|
|
|
126
127
|
body: JSON.stringify(forcing_dir),
|
|
127
128
|
})
|
|
128
129
|
.then(async (response) => response.text())
|
|
129
|
-
.then(progressFile => {
|
|
130
|
+
.then(progressFile => {
|
|
130
131
|
pollForcingsProgress(progressFile); // Start polling for progress
|
|
131
132
|
})
|
|
132
133
|
fetch('/forcings', {
|
|
@@ -138,7 +139,7 @@ async function forcings() {
|
|
|
138
139
|
.catch(error => {
|
|
139
140
|
console.error('Error:', error);
|
|
140
141
|
}).finally(() => {
|
|
141
|
-
document.getElementById('forcings-button').disabled = false;
|
|
142
|
+
document.getElementById('forcings-button').disabled = false;
|
|
142
143
|
});
|
|
143
144
|
} else {
|
|
144
145
|
alert('No existing geopackage found. Please subset the data before getting forcings');
|
ngiab_data_cli/__main__.py
CHANGED
ngiab_data_cli/arguments.py
CHANGED
|
@@ -3,6 +3,7 @@ from datetime import datetime
|
|
|
3
3
|
|
|
4
4
|
# Constants
|
|
5
5
|
DATE_FORMAT = "%Y-%m-%d" # used for datetime parsing
|
|
6
|
+
DATE_FORMAT2 = "%Y-%m-%d %H:%M" # used for datetime parsing
|
|
6
7
|
DATE_FORMAT_HINT = "YYYY-MM-DD" # printed in help message
|
|
7
8
|
|
|
8
9
|
|
|
@@ -91,13 +92,13 @@ def parse_arguments() -> argparse.Namespace:
|
|
|
91
92
|
parser.add_argument(
|
|
92
93
|
"--start_date",
|
|
93
94
|
"--start",
|
|
94
|
-
type=lambda s: datetime.strptime(s, DATE_FORMAT),
|
|
95
|
+
type=lambda s: datetime.strptime(s, DATE_FORMAT) if len(s) == 10 else datetime.strptime(s, DATE_FORMAT2),
|
|
95
96
|
help=f"Start date for forcings/realization (format {DATE_FORMAT_HINT})",
|
|
96
97
|
)
|
|
97
98
|
parser.add_argument(
|
|
98
99
|
"--end_date",
|
|
99
100
|
"--end",
|
|
100
|
-
type=lambda s: datetime.strptime(s, DATE_FORMAT),
|
|
101
|
+
type=lambda s: datetime.strptime(s, DATE_FORMAT) if len(s) == 10 else datetime.strptime(s, DATE_FORMAT2),
|
|
101
102
|
help=f"End date for forcings/realization (format {DATE_FORMAT_HINT})",
|
|
102
103
|
)
|
|
103
104
|
parser.add_argument(
|
|
@@ -147,6 +148,13 @@ def parse_arguments() -> argparse.Namespace:
|
|
|
147
148
|
choices=["aorc", "nwm"],
|
|
148
149
|
default="nwm",
|
|
149
150
|
)
|
|
151
|
+
parser.add_argument(
|
|
152
|
+
"--subset_type",
|
|
153
|
+
type=str,
|
|
154
|
+
help="By nexus: get everything flowing into the downstream nexus of the selected catchment. By catchment: get everything flowing into the selected catchment.",
|
|
155
|
+
choices=["nexus", "catchment"],
|
|
156
|
+
default="nexus",
|
|
157
|
+
)
|
|
150
158
|
parser.add_argument(
|
|
151
159
|
"-a",
|
|
152
160
|
"--all",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ngiab_data_preprocess
|
|
3
|
-
Version: 4.6.
|
|
3
|
+
Version: 4.6.7
|
|
4
4
|
Summary: Graphical Tools for creating Next Gen Water model input data.
|
|
5
5
|
Author-email: Josh Cunningham <jcunningham8@ua.edu>
|
|
6
6
|
Project-URL: Homepage, https://github.com/CIROH-UA/NGIAB_data_preprocess
|
|
@@ -75,13 +75,13 @@ This repository contains tools for preparing data to run a [NextGen](https://git
|
|
|
75
75
|
|
|
76
76
|
## What does this tool do?
|
|
77
77
|
|
|
78
|
-
This tool prepares data to run a NextGen-based simulation by creating a run package that can be used with NGIAB.
|
|
79
|
-
It uses geometry and model attributes from the [v2.2 hydrofabric](https://lynker-spatial.s3-us-west-2.amazonaws.com/hydrofabric/v2.2/conus/conus_nextgen.gpkg) more information on [all data sources here](https://lynker-spatial.s3-us-west-2.amazonaws.com/hydrofabric/v2.2/hfv2.2-data_model.html).
|
|
78
|
+
This tool prepares data to run a NextGen-based simulation by creating a run package that can be used with NGIAB.
|
|
79
|
+
It uses geometry and model attributes from the [v2.2 hydrofabric](https://lynker-spatial.s3-us-west-2.amazonaws.com/hydrofabric/v2.2/conus/conus_nextgen.gpkg) more information on [all data sources here](https://lynker-spatial.s3-us-west-2.amazonaws.com/hydrofabric/v2.2/hfv2.2-data_model.html).
|
|
80
80
|
The raw forcing data is [nwm retrospective v3 forcing](https://noaa-nwm-retrospective-3-0-pds.s3.amazonaws.com/index.html#CONUS/zarr/forcing/) data or the [AORC 1km gridded data](https://noaa-nws-aorc-v1-1-1km.s3.amazonaws.com/index.html) depending on user input
|
|
81
81
|
|
|
82
|
-
1. **Subsets** (delineates) everything upstream of your point of interest (catchment, gage, flowpath etc) from the hydrofabric. This subset is output as a geopackage (.gpkg).
|
|
83
|
-
2. Calculates **forcings** as a weighted mean of the gridded NWM or AORC forcings. Weights are calculated using [exact extract](https://isciences.github.io/exactextract/) and computed with numpy.
|
|
84
|
-
3. Creates **configuration files** for a default NGIAB model run.
|
|
82
|
+
1. **Subsets** (delineates) everything upstream of your point of interest (catchment, gage, flowpath etc) from the hydrofabric. This subset is output as a geopackage (.gpkg).
|
|
83
|
+
2. Calculates **forcings** as a weighted mean of the gridded NWM or AORC forcings. Weights are calculated using [exact extract](https://isciences.github.io/exactextract/) and computed with numpy.
|
|
84
|
+
3. Creates **configuration files** for a default NGIAB model run.
|
|
85
85
|
- realization.json - ngen model configuration
|
|
86
86
|
- troute.yaml - routing configuration.
|
|
87
87
|
- **per catchment** model configuration
|
|
@@ -136,13 +136,13 @@ curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
|
136
136
|
# Create a virtual environment in the current directory
|
|
137
137
|
uv venv
|
|
138
138
|
|
|
139
|
-
# Install the tool in the virtual environment
|
|
139
|
+
# Install the tool in the virtual environment
|
|
140
140
|
uv pip install ngiab_data_preprocess
|
|
141
141
|
|
|
142
142
|
# To run the cli
|
|
143
143
|
uv run cli --help
|
|
144
144
|
|
|
145
|
-
# To run the map
|
|
145
|
+
# To run the map
|
|
146
146
|
uv run map_app
|
|
147
147
|
```
|
|
148
148
|
|
|
@@ -160,7 +160,7 @@ UV automatically detects any virtual environments in the current directory and w
|
|
|
160
160
|
(notebook) jovyan@jupyter-user:~$ conda deactivate
|
|
161
161
|
jovyan@jupyter-user:~$
|
|
162
162
|
# The interactive map won't work on 2i2c
|
|
163
|
-
```
|
|
163
|
+
```
|
|
164
164
|
|
|
165
165
|
```bash
|
|
166
166
|
# This tool is likely to not work without a virtual environment
|
|
@@ -205,7 +205,7 @@ To install and run the tool, follow these steps:
|
|
|
205
205
|
|
|
206
206
|
Running the `map_app` tool will open the app in a new browser tab.
|
|
207
207
|
|
|
208
|
-
Install-free: `uvx --from ngiab-data-preprocess map_app`
|
|
208
|
+
Install-free: `uvx --from ngiab-data-preprocess map_app`
|
|
209
209
|
Installed with uv: `uv run map_app`
|
|
210
210
|
|
|
211
211
|
## Using the map interface
|
|
@@ -225,7 +225,7 @@ Once all the steps are finished, you can run NGIAB on the folder shown underneat
|
|
|
225
225
|
|
|
226
226
|
## Running the CLI
|
|
227
227
|
|
|
228
|
-
Install-free: `uvx ngiab-prep`
|
|
228
|
+
Install-free: `uvx ngiab-prep`
|
|
229
229
|
Installed with uv: `uv run cli`
|
|
230
230
|
|
|
231
231
|
## Arguments
|
|
@@ -236,6 +236,7 @@ Installed with uv: `uv run cli`
|
|
|
236
236
|
- `-l`, `--latlon`: Use latitude and longitude instead of catid. Expects comma-separated values via the CLI, e.g., `python -m ngiab_data_cli -i 54.33,-69.4 -l -s`.
|
|
237
237
|
- `-g`, `--gage`: Use gage ID instead of catid. Expects a single gage ID via the CLI, e.g., `python -m ngiab_data_cli -i 01646500 -g -s`.
|
|
238
238
|
- `-s`, `--subset`: Subset the hydrofabric to the given feature.
|
|
239
|
+
- `--subset_type`: Specify the subset type. `nexus`: get everything flowing into the downstream nexus of the selected catchment. `catchment`: get everything flowing into the selected catchment.
|
|
239
240
|
- `-f`, `--forcings`: Generate forcings for the given feature.
|
|
240
241
|
- `-r`, `--realization`: Create a realization for the given feature.
|
|
241
242
|
- `--lstm`: Configures the data for the [python lstm](https://github.com/ciroh-ua/lstm/).
|
|
@@ -259,7 +260,7 @@ Installed with uv: `uv run cli`
|
|
|
259
260
|
|
|
260
261
|
1. Prepare everything for an NGIAB run at a given gage:
|
|
261
262
|
```bash
|
|
262
|
-
uvx ngiab-prep -i gage-10154200 -sfr --start 2022-01-01 --end 2022-02-28
|
|
263
|
+
uvx ngiab-prep -i gage-10154200 -sfr --start 2022-01-01 --end 2022-02-28
|
|
263
264
|
# add --run or replace -sfr with --all to run NGIAB, too
|
|
264
265
|
# to name the folder, add -o folder_name
|
|
265
266
|
```
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
data_processing/create_realization.py,sha256=b1a9Wuld9saJ-zzVDPY_kba3-ZOVbRuobyR-QiHLXyY,11550
|
|
2
2
|
data_processing/dask_utils.py,sha256=A2IP94WAz8W9nek3etXKEKTOxGPf0NWSFLh8cZ5S-xU,2454
|
|
3
|
-
data_processing/dataset_utils.py,sha256=
|
|
3
|
+
data_processing/dataset_utils.py,sha256=iLY_3dSRxd8O0wI24IM2zuJru8vtmRlph0O_ZU_mAr4,8597
|
|
4
4
|
data_processing/datasets.py,sha256=_EJ1uZSWTU1HWpvF7TQSikneJqWZFikTrdo9usCV8A0,4665
|
|
5
5
|
data_processing/file_paths.py,sha256=7MpwfIQewLRrDpAw1dxTjTperUwOk3EC_kthmnJSRII,4851
|
|
6
6
|
data_processing/forcings.py,sha256=G_g3VSM_YN-k4FrbnUByrDR4n3fk1GVfv74kamit2CI,21775
|
|
7
|
-
data_processing/gpkg_utils.py,sha256=
|
|
7
|
+
data_processing/gpkg_utils.py,sha256=uERtQAMz9msJib_suffILuhUY8EcrvYw-pqkJOm2s9E,20673
|
|
8
8
|
data_processing/graph_utils.py,sha256=4D72wMSiCRKCPC7JUz7XCoaISRGLuqDx6wpeO_VP8fk,8301
|
|
9
9
|
data_processing/s3fs_utils.py,sha256=ki1EmA0ezV0r26re6dRWIGzL5FudGdwF9Qw1eVLR0Bc,2747
|
|
10
10
|
data_processing/subset.py,sha256=EwDii-EsOiJBaDMjvYWfz7V9wQSXb887w_fk28u8dlw,3789
|
|
@@ -24,20 +24,20 @@ map_app/__main__.py,sha256=5qJGypfesfdWDWRsbTQiMs3uL5zPZKRZQq31l7qXqCc,1649
|
|
|
24
24
|
map_app/views.py,sha256=AxLsXL8ZSnRJzg5zVYDGfVFA_6amgae41AO_E1G7W58,7923
|
|
25
25
|
map_app/static/css/console.css,sha256=xN6G2MMFyKc9YW9HEVpUUTUjx2o2nokBR4nCX5c18UM,803
|
|
26
26
|
map_app/static/css/main.css,sha256=pYIIk-dXW6YMpliSJKATdvgPhFVY6K26NeUuHoYyJqg,8736
|
|
27
|
-
map_app/static/css/toggle.css,sha256=
|
|
27
|
+
map_app/static/css/toggle.css,sha256=aUIe9AL1-_mzKvWir3lJ9W8r2oXsOjkFbtvcrohnV10,4149
|
|
28
28
|
map_app/static/js/console.js,sha256=BnG0pED5B9d563sLWshDNt_q-SyoTY48sETvVoOVJkU,1377
|
|
29
|
-
map_app/static/js/data_processing.js,sha256=
|
|
29
|
+
map_app/static/js/data_processing.js,sha256=F3ahDJabAgmcd9wFL8tThzRxuh6o0fT5M_T2OqLgSyw,8475
|
|
30
30
|
map_app/static/js/main.js,sha256=wtLZ18hPZbnyo28dRGsOf-CAHCGxqe1PWEAGa6-S4tg,10932
|
|
31
31
|
map_app/static/resources/loading.gif,sha256=ggdkZf1AD7rSwIpSJwfiIqANgmVV1WHlxGuKxQKv7uY,72191
|
|
32
32
|
map_app/static/resources/screenshot.jpg,sha256=Ia358aX-OHM9BP4B8lX05cLnguF2fHUIimno9bnFLYw,253730
|
|
33
33
|
map_app/templates/index.html,sha256=qgQxvaJgkU8Ul57dMLX5n0O3BrwMow-CxGPH7_8yjXc,12195
|
|
34
|
-
ngiab_data_cli/__main__.py,sha256=
|
|
35
|
-
ngiab_data_cli/arguments.py,sha256=
|
|
34
|
+
ngiab_data_cli/__main__.py,sha256=FmHxibQtFm15aEUG1BrIIqIWNU_BoXzWCTXoR9EA-YI,11353
|
|
35
|
+
ngiab_data_cli/arguments.py,sha256=Bi_Q6FRXvRxI50Pgk7goyASe-2lfUh-oDdnYkaY4KTc,5262
|
|
36
36
|
ngiab_data_cli/custom_logging.py,sha256=iS2XozaxudcxQj17qAsrCgbVK9LJAYAPmarJuVWJo1k,1280
|
|
37
37
|
ngiab_data_cli/forcing_cli.py,sha256=eIWRxRWUwPqR16fihFDEIV4VzGlNuvcD6lJW5VYjkPU,3635
|
|
38
|
-
ngiab_data_preprocess-4.6.
|
|
39
|
-
ngiab_data_preprocess-4.6.
|
|
40
|
-
ngiab_data_preprocess-4.6.
|
|
41
|
-
ngiab_data_preprocess-4.6.
|
|
42
|
-
ngiab_data_preprocess-4.6.
|
|
43
|
-
ngiab_data_preprocess-4.6.
|
|
38
|
+
ngiab_data_preprocess-4.6.7.dist-info/licenses/LICENSE,sha256=6dMSprwwnsRzEm02mEDbKHD9dUbL8bPIt9Vhrhb0Ulk,1081
|
|
39
|
+
ngiab_data_preprocess-4.6.7.dist-info/METADATA,sha256=3U2P21OHELN_hol-fu43soXXozFw3r6Y57rLwCK2GLc,14513
|
|
40
|
+
ngiab_data_preprocess-4.6.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
41
|
+
ngiab_data_preprocess-4.6.7.dist-info/entry_points.txt,sha256=spwlhKEJ3ZnNETQsJGeTjD7Vwy8O_zGHb9GdX8ACCtw,128
|
|
42
|
+
ngiab_data_preprocess-4.6.7.dist-info/top_level.txt,sha256=CjhYAUZrdveR2fOK6rxffU09VIN2IuPD7hk4V3l3pV0,52
|
|
43
|
+
ngiab_data_preprocess-4.6.7.dist-info/RECORD,,
|
|
File without changes
|
{ngiab_data_preprocess-4.6.5.dist-info → ngiab_data_preprocess-4.6.7.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
{ngiab_data_preprocess-4.6.5.dist-info → ngiab_data_preprocess-4.6.7.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
{ngiab_data_preprocess-4.6.5.dist-info → ngiab_data_preprocess-4.6.7.dist-info}/top_level.txt
RENAMED
|
File without changes
|