Skip to content

Commit bad4b55

Browse files
Merge pull request #11 from CIROH-UA/post_filter_shuffle
organize into more standard python package directory layout
2 parents 1c3c798 + d5eb488 commit bad4b55

31 files changed

+41
-83
lines changed

.github/workflows/forcingprocessor_aws_sources.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,11 @@ jobs:
3838
- name: Install dependencies
3939
run: |
4040
python -m pip install --upgrade pip
41-
pip install -e ./forcingprocessor
41+
pip install -e .
4242
pip install pytest
4343
4444
- name: Test with pytest
4545
run: |
46-
cd forcingprocessor
4746
python -m pytest -vv -k test_noaa_nwm_pds_https
4847
python -m pytest -vv -k test_noaa_nwm_pds_https_short_range
4948
python -m pytest -vv -k test_noaa_nwm_pds_https_medium_range

.github/workflows/forcingprocessor_gcs_sources.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,11 @@ jobs:
3838
- name: Install dependencies
3939
run: |
4040
python -m pip install --upgrade pip
41-
pip install -e ./forcingprocessor
41+
pip install -e .
4242
pip install pytest
4343
4444
- name: Test with pytest
4545
run: |
46-
cd forcingprocessor
4746
python -m pytest -vv -k test_google_cloud_storage
4847
python -m pytest -vv -k test_gs
4948
python -m pytest -vv -k test_gcs

.github/workflows/forcingprocessor_nrds.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,9 @@ jobs:
4747
- name: Install dependencies
4848
run: |
4949
python -m pip install --upgrade pip
50-
pip install -e ./forcingprocessor
50+
pip install -e .
5151
pip install pytest
5252
5353
- name: Test with pytest
5454
run: |
55-
cd forcingprocessor
5655
python -m pytest -vv tests/test_nrds_fp.py

.github/workflows/forcingprocessor_output_opts.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,11 @@ jobs:
3838
- name: Install dependencies
3939
run: |
4040
python -m pip install --upgrade pip
41-
pip install -e ./forcingprocessor
41+
pip install -e .
4242
pip install pytest
4343
4444
- name: Test with pytest
4545
run: |
46-
cd forcingprocessor
47-
# netcdf already tested
4846
python -m pytest -vv -k test_csv_output_type
4947
python -m pytest -vv -k test_parquet_output_type
5048

.github/workflows/forcingprocessor_plotting.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,11 @@ jobs:
3838
- name: Install dependencies
3939
run: |
4040
python -m pip install --upgrade pip
41-
pip install -e ./forcingprocessor
41+
pip install -e .
4242
pip install pytest
4343
4444
- name: Test with pytest
4545
run: |
46-
cd forcingprocessor
4746
python -m pytest -vv tests/test_plotter.py
4847
python -m pytest -vv -k test_plotting
4948

.github/workflows/forcingprocessor_weights.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,9 @@ jobs:
3838
- name: Install dependencies
3939
run: |
4040
python -m pip install --upgrade pip
41-
pip install -e ./forcingprocessor
41+
pip install -e .
4242
pip install pytest
4343
4444
- name: Test with hf2ds
4545
run: |
46-
cd forcingprocessor
4746
python -m pytest -vv tests/test_hf2ds.py

CREDITS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The following software libraries and other references are utilized in the creation this repository.
22

3-
[hfsubset](https://github.com/LynkerIntel/hfsubset/tree/main) - distributed by LynkerIntel under [GPL-3.0](https://github.com/CIROH-UA/ngen-datastream/blob/main/LICENSE.md)
3+
[hfsubset](https://github.com/LynkerIntel/hfsubset/tree/main) - distributed by LynkerIntel under [GPL-3.0](https://github.com/CIROH-UA/forcingprocessor/blob/main/LICENSE.md)
44

55
[Lynker Spatial](https://www.lynker-spatial.com/) - distributed under the Open Database License, [copyright](https://lynker-spatial.s3.amazonaws.com/copyright.html)
66

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
# Forcing Processor
2-
Forcingprocessor converts National Water Model (NWM) forcing data into Next Generation National Water Model (NextGen) forcing data. The motivation for this tool is NWM data is gridded and stored within netCDFs for each forecast hour. Ngen inputs this same forcing data, but in the format of per-catchment csv files that hold time series data. Forcingprocessor is driven by a configuration file that is explained, with an example, in detail below. The config argument accepts an s3 URL.
2+
Forcingprocessor converts National Water Model (NWM) forcing data into Next Generation National Water Model (NextGen) forcing data. This tool provides the forcing pre-processing for the [NextGen Research DataStream](https://github.com/CIROH-UA/ngen-datastream).
33

4-
![forcing_gif](../docs/gifs/T2D_2_TMP_2maboveground_cali.gif)
4+
The motivation for this tool is NWM data is gridded and stored within netCDFs for each forecast hour. Ngen inputs this same forcing data, but in the format of catchment averaged data time series data.
5+
6+
![forcing_gif](docs/gifs/T2D_2_TMP_2maboveground_cali.gif)
57

68
## Install
9+
From root
710
```
8-
cd /ngen-datastream/forcingprocessor/ && pip install -e .
11+
pip install -e .
912
```
1013

1114
## Run the forcingprocessor
1215
```
13-
python ./src/forcingprocessor/processor.py ./configs/conf.json
16+
python src/forcingprocessor/processor.py ./configs/conf.json
1417
```
15-
Prior to executing the processor, the user will need to obtain a geopackage file to define the spatial domain. [hfsubset](https://github.com/lynker-spatial/hfsubsetCLI) will provide a geopackage which contains a necessary layer, `forcing-weights`, for `processor.py`. The user will define the time domain by generating the forcing filenames for `processor.py` via `nwm_filenames_generator.py`, which is explained [here](#nwm_file).
18+
Prior to executing the processor, the user will need to obtain a geopackage file to define the spatial domain. The user will define the time domain by generating the forcing filenames for `processor.py` via `nwm_filenames_generator.py`, which is explained [here](#nwm_file). Note that `forcingprocessor` will calcuate weights if not found within the geopackage file.
1619

1720
## Example `conf.json`
1821
```
@@ -50,14 +53,14 @@ Prior to executing the processor, the user will need to obtain a geopackage file
5053
| Field | Description | Required |
5154
|-------------------|--------------------------|----------|
5255
| nwm_file | Path to a text file containing nwm file names. One filename per line. [Tool](#nwm_file) to create this file | :white_check_mark: |
53-
| gpkg_file | Geopackage file to define spatial domain. Use [hfsubset](https://github.com/lynker-spatial/hfsubsetCLI) to generate a geopackage with a `forcing-weights` layer. Accepts local absolute path, s3 URI or URL. Also acceptable is a weights parquet generated with [weights_hf2ds.py](https://github.com/CIROH-UA/ngen-datastream/blob/main/forcingprocessor/src/forcingprocessor/weights_hf2ds.py), though the plotting option will no longer be available. | :white_check_mark: |
56+
| gpkg_file | Geopackage file to define spatial domain. Use [hfsubset](https://github.com/lynker-spatial/hfsubsetCLI) to generate a geopackage with a `forcing-weights` layer. Accepts local absolute path, s3 URI or URL. Also acceptable is a weights parquet generated with [weights_hf2ds.py](https://github.com/CIROH-UA/forcingprocessor/blob/main/src/forcingprocessor/weights_hf2ds.py), though the plotting option will no longer be available. | :white_check_mark: |
5457

5558
### 2. Storage
5659

5760
| Field | Description | Required |
5861
|-------------------|-----------------------------------|----------|
59-
| storage_type | Type of storage (local or s3) | :white_check_mark: |
60-
| output_path | Path to write data to. Accepts local path or s3 | :white_check_mark: |
62+
| storage_type | Type of storage (local or s3 URI) | :white_check_mark: |
63+
| output_path | Path to write data to. Accepts local path or s3 URI | :white_check_mark: |
6164
| output_file_type | List of output file types, e.g. ["tar","parquet","csv","netcdf"] | :white_check_mark: |
6265

6366
### 3. Run
@@ -88,7 +91,7 @@ ngen_variables = [
8891
```
8992

9093
## nwm_file
91-
A text file given to forcingprocessor that contains each nwm forcing file name. These can be URLs or local paths. This file can be generated with the [nwmurl tool](https://github.com/CIROH-UA/nwmurl) and a [generator script](https://github.com/CIROH-UA/ngen-datastream/blob/main/forcingprocessor/src/forcingprocessor/nwm_filenames_generator.py) has been provided within this repo. The config argument accepts an s3 URL.
94+
A text file given to forcingprocessor that contains each nwm forcing file name. These can be URLs or local paths. This file can be generated with the [nwmurl tool](https://github.com/CIROH-UA/nwmurl) and a [generator script](https://github.com/CIROH-UA/forcingprocessor/blob/main/src/forcingprocessor/nwm_filenames_generator.py) has been provided within this repo. The config argument accepts an s3 URL.
9295
```
9396
python nwm_filenames_generator.py conf_nwm_files.json
9497
```
@@ -109,13 +112,13 @@ A text file given to forcingprocessor that contains each nwm forcing file name.
109112
```
110113

111114
## Weights
112-
To calculate NextGen forcings, "weights" must be calculated to extract polygon averaged data from gridded data. The weights are made up of two parts, the `cell_id` and `coverage`. These are calculated via [exactextract](https://github.com/isciences/exactextract) within [weights_hf2ds.py](https://github.com/CIROH-UA/ngen-datastream/blob/main/forcingprocessor/src/forcingprocessor/weights_hf2ds.py), which is optionally called from forcingprocessor.
115+
To calculate NextGen forcings, "weights" must be calculated to extract polygon averaged data from gridded data. The weights are made up of two parts, the `cell_id` and `coverage`. These are calculated via [exactextract](https://github.com/isciences/exactextract) within [weights_hf2ds.py](https://github.com/CIROH-UA/forcingprocessor/blob/main/src/forcingprocessor/weights_hf2ds.py), which is optionally called from forcingprocessor.
113116

114-
If a geopackage is supplied to forcingprocessor, it will be searched for the layer `forcings-weights`. If this layer is found, these weights are used during processing. If not, forcingprocessor will call [weights_hf2ds.py](https://github.com/CIROH-UA/ngen-datastream/blob/main/forcingprocessor/src/forcingprocessor/weights_hf2ds.py) to calculate the weights (cell_id and coverage) for every divide-id in the geopackage. This can take time, so forcingprocessor will write a parquet of weights out in the metadata, that can be reused in future forcingprocessor executions.
117+
If a geopackage is supplied to forcingprocessor, it will be searched for the layer `forcings-weights`. If this layer is found, these weights are used during processing. If not, forcingprocessor will call [weights_hf2ds.py](https://github.com/CIROH-UA/forcingprocessor/blob/main/src/forcingprocessor/weights_hf2ds.py) to calculate the weights (cell_id and coverage) for every divide-id in the geopackage. This can take time, so forcingprocessor will write a parquet of weights out in the metadata, that can be reused in future forcingprocessor executions.
115118

116119
Example of direct call
117120
```
118-
python3 /ngen-datastream/forcingprocessor/src/forcingprocessor/weights_hf2ds.py \
121+
python3 forcingprocessor/src/forcingprocessor/weights_hf2ds.py \
119122
--outname ./weights.parquet \
120123
--input_file ./nextgen_VPU_03W.gpkg
121124
```

STATUS.md

Lines changed: 11 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,11 @@
1-
# Research DataStream
2-
* ![](https://github.com/CIROH-UA/ngen-datastream/actions/workflows/research_datastream_terraform.yaml/badge.svg)
3-
* ![](https://github.com/CIROH-UA/ngen-datastream/actions/workflows/test_research_datastream_fp.yaml/badge.svg)
4-
* ![](https://github.com/CIROH-UA/ngen-datastream/actions/workflows/test_research_datastream_vpu_01.yaml/badge.svg)
5-
* ![](https://github.com/CIROH-UA/ngen-datastream/actions/workflows/test_research_datastream_vpu_02.yaml/badge.svg)
6-
* ![](https://github.com/CIROH-UA/ngen-datastream/actions/workflows/test_research_datastream_vpu_03W.yaml/badge.svg)
7-
* ![](https://github.com/CIROH-UA/ngen-datastream/actions/workflows/test_research_datastream_vpu_03N.yaml/badge.svg)
8-
* ![](https://github.com/CIROH-UA/ngen-datastream/actions/workflows/test_research_datastream_vpu_03S.yaml/badge.svg)
9-
* ![](https://github.com/CIROH-UA/ngen-datastream/actions/workflows/test_research_datastream_vpu_04.yaml/badge.svg)
10-
* ![](https://github.com/CIROH-UA/ngen-datastream/actions/workflows/test_research_datastream_vpu_05.yaml/badge.svg)
11-
* ![](https://github.com/CIROH-UA/ngen-datastream/actions/workflows/test_research_datastream_vpu_06.yaml/badge.svg)
12-
* ![](https://github.com/CIROH-UA/ngen-datastream/actions/workflows/test_research_datastream_vpu_07.yaml/badge.svg)
13-
* ![](https://github.com/CIROH-UA/ngen-datastream/actions/workflows/test_research_datastream_vpu_08.yaml/badge.svg)
14-
* ![](https://github.com/CIROH-UA/ngen-datastream/actions/workflows/test_research_datastream_vpu_09.yaml/badge.svg)
15-
* ![](https://github.com/CIROH-UA/ngen-datastream/actions/workflows/test_research_datastream_vpu_10L.yaml/badge.svg)
16-
* ![](https://github.com/CIROH-UA/ngen-datastream/actions/workflows/test_research_datastream_vpu_10U.yaml/badge.svg)
17-
* ![](https://github.com/CIROH-UA/ngen-datastream/actions/workflows/test_research_datastream_vpu_11.yaml/badge.svg)
18-
* ![](https://github.com/CIROH-UA/ngen-datastream/actions/workflows/test_research_datastream_vpu_12.yaml/badge.svg)
19-
* ![](https://github.com/CIROH-UA/ngen-datastream/actions/workflows/test_research_datastream_vpu_13.yaml/badge.svg)
20-
* ![](https://github.com/CIROH-UA/ngen-datastream/actions/workflows/test_research_datastream_vpu_14.yaml/badge.svg)
21-
* ![](https://github.com/CIROH-UA/ngen-datastream/actions/workflows/test_research_datastream_vpu_15.yaml/badge.svg)
22-
* ![](https://github.com/CIROH-UA/ngen-datastream/actions/workflows/test_research_datastream_vpu_16.yaml/badge.svg)
23-
* ![](https://github.com/CIROH-UA/ngen-datastream/actions/workflows/test_research_datastream_vpu_17.yaml/badge.svg)
24-
* ![](https://github.com/CIROH-UA/ngen-datastream/actions/workflows/test_research_datastream_vpu_18.yaml/badge.svg)
25-
26-
# DataStreamCLI
27-
* ![](https://github.com/CIROH-UA/ngen-datastream/actions/workflows/test_datastream_ngiab.yaml/badge.svg)
28-
* ![](https://github.com/CIROH-UA/ngen-datastream/actions/workflows/test_datastream_options.yaml/badge.svg)
29-
30-
# DataStreamCLI Integrations
31-
* ![](https://github.com/CIROH-UA/ngen-datastream/actions/workflows/test_datastream_ngiab_troute_v2_1.yaml/badge.svg)
32-
* ![](https://github.com/CIROH-UA/ngen-datastream/actions/workflows/test_datastream_ngiab_troute_v2_2.yaml/badge.svg)
33-
* ![](https://github.com/CIROH-UA/ngen-datastream/actions/workflows/test_hfsubset_v2_1.yaml/badge.svg)
34-
* ![](https://github.com/CIROH-UA/ngen-datastream/actions/workflows/test_hfsubset_v2_2.yaml/badge.svg)
35-
* ![](https://github.com/CIROH-UA/ngen-datastream/actions/workflows/test_teehr_integration.yaml/badge.svg)
36-
37-
# DataStreamCLI ForcingProcessor Tools
38-
* ![](https://github.com/CIROH-UA/ngen-datastream/actions/workflows/forcingprocessor_aws_sources.yaml/badge.svg)
39-
* ![](https://github.com/CIROH-UA/ngen-datastream/actions/workflows/forcingprocessor_gcs_sources.yaml/badge.svg)
40-
* ![](https://github.com/CIROH-UA/ngen-datastream/actions/workflows/forcingprocessor_plotting.yaml/badge.svg)
41-
* ![](https://github.com/CIROH-UA/ngen-datastream/actions/workflows/forcingprocessor_weights.yaml/badge.svg)
42-
43-
# DataStreamCLI Python Tools
44-
* ![](https://github.com/CIROH-UA/ngen-datastream/actions/workflows/datastream_python.yaml/badge.svg)
45-
46-
# Docker
47-
* ![](https://github.com/CIROH-UA/ngen-datastream/actions/workflows/build_test_docker_x86.yaml/badge.svg)
48-
* ![](https://github.com/CIROH-UA/ngen-datastream/actions/workflows/build_test_push_docker_x86.yaml/badge.svg)
49-
* ![](https://github.com/CIROH-UA/ngen-datastream/actions/workflows/build_test_push_docker_arm.yaml/badge.svg)
1+
# Forcingprocessor Unit Tests
2+
* ![](https://github.com/CIROH-UA/forcingprocessor/actions/workflows/forcingprocessor_aws_sources.yaml/badge.svg)
3+
* ![](https://github.com/CIROH-UA/forcingprocessor/actions/workflows/forcingprocessor_gcs_sources.yaml/badge.svg)
4+
* ![](https://github.com/CIROH-UA/forcingprocessor/actions/workflows/forcingprocessor_nrds.yaml/badge.svg)
5+
* ![](https://github.com/CIROH-UA/forcingprocessor/actions/workflows/forcingprocessor_output_opts.yaml/badge.svg)
6+
* ![](https://github.com/CIROH-UA/forcingprocessor/actions/workflows/forcingprocessor_plotting.yaml/badge.svg)
7+
* ![](https://github.com/CIROH-UA/forcingprocessor/actions/workflows/forcingprocessor_weights.yaml/badge.svg)
8+
9+
# Forcingprocessor Build Tests
10+
* ![](https://github.com/CIROH-UA/forcingprocessor/actions/workflows/built_test_fp.yaml/badge.svg)
11+
* ![](https://github.com/CIROH-UA/forcingprocessor/actions/workflows/build_test_push_docker_fp_X86_arm_version_aware.yaml/badge.svg)

0 commit comments

Comments
 (0)