ngiab-data-preprocess 4.3.0__tar.gz → 4.3.2__tar.gz
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.
- {ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/PKG-INFO +2 -1
- {ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/data_processing/dataset_utils.py +40 -7
- {ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/ngiab_data_cli/__main__.py +3 -3
- {ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/ngiab_data_preprocess.egg-info/PKG-INFO +2 -1
- {ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/ngiab_data_preprocess.egg-info/requires.txt +1 -0
- {ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/ngiab_data_preprocess.egg-info/top_level.txt +1 -0
- {ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/pyproject.toml +3 -4
- {ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/.github/workflows/build_only.yml +0 -0
- {ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/.github/workflows/publish.yml +0 -0
- {ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/.gitignore +0 -0
- {ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/LICENSE +0 -0
- {ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/README.md +0 -0
- {ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/data_processing/create_realization.py +0 -0
- {ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/data_processing/dask_utils.py +0 -0
- {ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/data_processing/datasets.py +0 -0
- {ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/data_processing/file_paths.py +0 -0
- {ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/data_processing/forcings.py +0 -0
- {ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/data_processing/gpkg_utils.py +0 -0
- {ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/data_processing/graph_utils.py +0 -0
- {ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/data_processing/s3fs_utils.py +0 -0
- {ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/data_processing/subset.py +0 -0
- {ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/data_sources/cfe-nowpm-realization-template.json +0 -0
- {ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/data_sources/cfe-template.ini +0 -0
- {ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/data_sources/em-catchment-template.yml +0 -0
- {ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/data_sources/em-config.yml +0 -0
- {ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/data_sources/em-realization-template.json +0 -0
- {ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/data_sources/forcing_template.nc +0 -0
- {ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/data_sources/ngen-routing-template.yaml +0 -0
- {ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/data_sources/noah-owp-modular-init.namelist.input +0 -0
- {ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/data_sources/source_validation.py +0 -0
- {ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/data_sources/template.sql +0 -0
- {ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/data_sources/triggers.sql +0 -0
- {ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/map_app/__init__.py +0 -0
- {ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/map_app/__main__.py +0 -0
- {ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/map_app/static/css/console.css +0 -0
- {ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/map_app/static/css/main.css +0 -0
- {ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/map_app/static/css/toggle.css +0 -0
- {ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/map_app/static/js/console.js +0 -0
- {ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/map_app/static/js/data_processing.js +0 -0
- {ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/map_app/static/js/main.js +0 -0
- {ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/map_app/static/resources/loading.gif +0 -0
- {ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/map_app/static/resources/screenshot.jpg +0 -0
- {ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/map_app/templates/index.html +0 -0
- {ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/map_app/views.py +0 -0
- {ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/ngiab_data_cli/arguments.py +0 -0
- {ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/ngiab_data_cli/custom_logging.py +0 -0
- {ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/ngiab_data_cli/forcing_cli.py +0 -0
- {ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/ngiab_data_preprocess.egg-info/SOURCES.txt +0 -0
- {ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/ngiab_data_preprocess.egg-info/dependency_links.txt +0 -0
- {ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/ngiab_data_preprocess.egg-info/entry_points.txt +0 -0
- {ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/setup.cfg +0 -0
- {ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/tests/test_nan_impute.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ngiab_data_preprocess
|
|
3
|
-
Version: 4.3.
|
|
3
|
+
Version: 4.3.2
|
|
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
|
|
@@ -32,6 +32,7 @@ Requires-Dist: colorama==0.4.6
|
|
|
32
32
|
Requires-Dist: bokeh==3.5.1
|
|
33
33
|
Requires-Dist: boto3
|
|
34
34
|
Requires-Dist: numcodecs<0.16.0
|
|
35
|
+
Requires-Dist: scipy>=1.15.3
|
|
35
36
|
Provides-Extra: eval
|
|
36
37
|
Requires-Dist: ngiab_eval; extra == "eval"
|
|
37
38
|
Provides-Extra: plot
|
{ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/data_processing/dataset_utils.py
RENAMED
|
@@ -7,9 +7,9 @@ from typing import List, Literal, Optional, Tuple, Union
|
|
|
7
7
|
import geopandas as gpd
|
|
8
8
|
import numpy as np
|
|
9
9
|
import xarray as xr
|
|
10
|
+
from dask.distributed import Client, Future, progress
|
|
11
|
+
from data_processing.dask_utils import no_cluster, use_cluster
|
|
10
12
|
from xarray.core.types import InterpOptions
|
|
11
|
-
from dask.distributed import Client, progress, Future
|
|
12
|
-
from data_processing.dask_utils import use_cluster
|
|
13
13
|
|
|
14
14
|
logger = logging.getLogger(__name__)
|
|
15
15
|
|
|
@@ -117,13 +117,14 @@ def clip_dataset_to_bounds(
|
|
|
117
117
|
return dataset
|
|
118
118
|
|
|
119
119
|
|
|
120
|
+
@no_cluster
|
|
120
121
|
def interpolate_nan_values(
|
|
121
122
|
dataset: xr.Dataset,
|
|
122
123
|
variables: Optional[List[str]] = None,
|
|
123
124
|
dim: str = "time",
|
|
124
125
|
method: InterpOptions = "nearest",
|
|
125
126
|
fill_value: str = "extrapolate",
|
|
126
|
-
) ->
|
|
127
|
+
) -> bool:
|
|
127
128
|
"""
|
|
128
129
|
Interpolates NaN values in specified (or all numeric time-dependent)
|
|
129
130
|
variables of an xarray.Dataset. Operates inplace on the dataset.
|
|
@@ -145,6 +146,7 @@ def interpolate_nan_values(
|
|
|
145
146
|
Set to "extrapolate" to fill with the nearest valid value when using 'nearest' or 'linear'.
|
|
146
147
|
Default is "extrapolate".
|
|
147
148
|
"""
|
|
149
|
+
interpolation_used = False
|
|
148
150
|
for name, var in dataset.data_vars.items():
|
|
149
151
|
# if the variable is non-numeric, skip
|
|
150
152
|
if not np.issubdtype(var.dtype, np.number):
|
|
@@ -158,6 +160,32 @@ def interpolate_nan_values(
|
|
|
158
160
|
method=method,
|
|
159
161
|
fill_value=fill_value if method in ["nearest", "linear"] else None,
|
|
160
162
|
)
|
|
163
|
+
interpolation_used = True
|
|
164
|
+
return interpolation_used
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
@no_cluster
|
|
168
|
+
def save_dataset_no_cluster(
|
|
169
|
+
ds_to_save: xr.Dataset,
|
|
170
|
+
target_path: Path,
|
|
171
|
+
engine: Literal["netcdf4", "scipy", "h5netcdf"] = "h5netcdf",
|
|
172
|
+
):
|
|
173
|
+
"""
|
|
174
|
+
This explicitly does not use dask distributed.
|
|
175
|
+
Helper function to compute and save an xarray.Dataset to a NetCDF file.
|
|
176
|
+
Uses a temporary file and rename for avoid leaving a half written file.
|
|
177
|
+
"""
|
|
178
|
+
if not target_path.parent.exists():
|
|
179
|
+
target_path.parent.mkdir(parents=True, exist_ok=True)
|
|
180
|
+
|
|
181
|
+
temp_file_path = target_path.with_name(target_path.name + ".saving.nc")
|
|
182
|
+
if temp_file_path.exists():
|
|
183
|
+
os.remove(temp_file_path)
|
|
184
|
+
|
|
185
|
+
ds_to_save.to_netcdf(temp_file_path, engine=engine, compute=True)
|
|
186
|
+
|
|
187
|
+
os.rename(str(temp_file_path), str(target_path))
|
|
188
|
+
logger.info(f"Successfully saved data to: {target_path}")
|
|
161
189
|
|
|
162
190
|
|
|
163
191
|
@use_cluster
|
|
@@ -206,13 +234,18 @@ def save_to_cache(
|
|
|
206
234
|
|
|
207
235
|
# save dataset locally before manipulating it
|
|
208
236
|
save_dataset(stores, cached_nc_path)
|
|
209
|
-
stores = xr.open_mfdataset(cached_nc_path, parallel=True, engine="h5netcdf")
|
|
210
237
|
|
|
211
238
|
if interpolate_nans:
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
239
|
+
stores = xr.open_mfdataset(
|
|
240
|
+
cached_nc_path,
|
|
241
|
+
parallel=True,
|
|
242
|
+
engine="h5netcdf",
|
|
243
|
+
)
|
|
244
|
+
was_interpolated = interpolate_nan_values(dataset=stores)
|
|
245
|
+
if was_interpolated:
|
|
246
|
+
save_dataset_no_cluster(stores, cached_nc_path)
|
|
215
247
|
|
|
248
|
+
stores = xr.open_mfdataset(cached_nc_path, parallel=True, engine="h5netcdf")
|
|
216
249
|
return stores
|
|
217
250
|
|
|
218
251
|
|
{ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/ngiab_data_cli/__main__.py
RENAMED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
from typing import Tuple
|
|
2
|
+
|
|
2
3
|
import rich.status
|
|
3
4
|
|
|
4
5
|
# add a status bar for these imports so the cli feels more responsive
|
|
5
|
-
with rich.status.Status("
|
|
6
|
+
with rich.status.Status("loading") as status:
|
|
6
7
|
import argparse
|
|
7
8
|
import logging
|
|
8
9
|
import subprocess
|
|
9
10
|
import time
|
|
10
|
-
from typing import List
|
|
11
11
|
|
|
12
12
|
import geopandas as gpd
|
|
13
13
|
from data_processing.create_realization import create_em_realization, create_realization
|
|
@@ -19,7 +19,7 @@ with rich.status.Status("Initializing...") as status:
|
|
|
19
19
|
from data_processing.gpkg_utils import get_cat_from_gage_id, get_catid_from_point
|
|
20
20
|
from data_processing.graph_utils import get_upstream_cats
|
|
21
21
|
from data_processing.subset import subset, subset_vpu
|
|
22
|
-
from data_sources.source_validation import
|
|
22
|
+
from data_sources.source_validation import validate_hydrofabric, validate_output_dir
|
|
23
23
|
from ngiab_data_cli.arguments import parse_arguments
|
|
24
24
|
from ngiab_data_cli.custom_logging import set_logging_to_critical_only, setup_logging
|
|
25
25
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ngiab_data_preprocess
|
|
3
|
-
Version: 4.3.
|
|
3
|
+
Version: 4.3.2
|
|
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
|
|
@@ -32,6 +32,7 @@ Requires-Dist: colorama==0.4.6
|
|
|
32
32
|
Requires-Dist: bokeh==3.5.1
|
|
33
33
|
Requires-Dist: boto3
|
|
34
34
|
Requires-Dist: numcodecs<0.16.0
|
|
35
|
+
Requires-Dist: scipy>=1.15.3
|
|
35
36
|
Provides-Extra: eval
|
|
36
37
|
Requires-Dist: ngiab_eval; extra == "eval"
|
|
37
38
|
Provides-Extra: plot
|
|
@@ -14,12 +14,10 @@ exclude = ["tests*"]
|
|
|
14
14
|
minversion = "6.0"
|
|
15
15
|
addopts = "-ra -q"
|
|
16
16
|
testpaths = ["tests"]
|
|
17
|
-
filterwarnings = [
|
|
18
|
-
'ignore::DeprecationWarning:geopandas._compat'
|
|
19
|
-
]
|
|
17
|
+
filterwarnings = ['ignore::DeprecationWarning:geopandas._compat']
|
|
20
18
|
[project]
|
|
21
19
|
name = "ngiab_data_preprocess"
|
|
22
|
-
version = "
|
|
20
|
+
version = "4.3.2"
|
|
23
21
|
authors = [{ name = "Josh Cunningham", email = "jcunningham8@ua.edu" }]
|
|
24
22
|
description = "Graphical Tools for creating Next Gen Water model input data."
|
|
25
23
|
readme = "README.md"
|
|
@@ -51,6 +49,7 @@ dependencies = [
|
|
|
51
49
|
"bokeh==3.5.1",
|
|
52
50
|
"boto3",
|
|
53
51
|
"numcodecs<0.16.0",
|
|
52
|
+
"scipy>=1.15.3",
|
|
54
53
|
]
|
|
55
54
|
|
|
56
55
|
[project.optional-dependencies]
|
{ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/.github/workflows/build_only.yml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/data_processing/dask_utils.py
RENAMED
|
File without changes
|
{ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/data_processing/datasets.py
RENAMED
|
File without changes
|
{ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/data_processing/file_paths.py
RENAMED
|
File without changes
|
{ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/data_processing/forcings.py
RENAMED
|
File without changes
|
{ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/data_processing/gpkg_utils.py
RENAMED
|
File without changes
|
{ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/data_processing/graph_utils.py
RENAMED
|
File without changes
|
{ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/data_processing/s3fs_utils.py
RENAMED
|
File without changes
|
{ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/data_processing/subset.py
RENAMED
|
File without changes
|
|
File without changes
|
{ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/data_sources/cfe-template.ini
RENAMED
|
File without changes
|
|
File without changes
|
{ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/data_sources/em-config.yml
RENAMED
|
File without changes
|
|
File without changes
|
{ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/data_sources/forcing_template.nc
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/data_sources/template.sql
RENAMED
|
File without changes
|
{ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/data_sources/triggers.sql
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/map_app/static/css/console.css
RENAMED
|
File without changes
|
{ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/map_app/static/css/main.css
RENAMED
|
File without changes
|
{ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/map_app/static/css/toggle.css
RENAMED
|
File without changes
|
{ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/map_app/static/js/console.js
RENAMED
|
File without changes
|
|
File without changes
|
{ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/map_app/static/js/main.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/map_app/templates/index.html
RENAMED
|
File without changes
|
|
File without changes
|
{ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/ngiab_data_cli/arguments.py
RENAMED
|
File without changes
|
{ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/ngiab_data_cli/custom_logging.py
RENAMED
|
File without changes
|
{ngiab_data_preprocess-4.3.0 → ngiab_data_preprocess-4.3.2}/modules/ngiab_data_cli/forcing_cli.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|