Skip to content

Commit

Permalink
Script runs without error
Browse files Browse the repository at this point in the history
  • Loading branch information
thodson-usgs committed Aug 8, 2024
1 parent d8bd6cb commit cfb29a8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
5 changes: 4 additions & 1 deletion demos/nawqa_data_pull/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Retrieva data from the National Water Quality Assessment Program (NAWQA)

This examples walks through using lithops to retrieve data from every NAWQA monitoring site, then write the results to a parquet filel on s3.
This examples walks through using lithops to retrieve data from every NAWQA
monitoring site, then write the results to a parquet filel on s3. Also
searches the NLDI for neighboring sites with NAWQA data and merges those
data assuming the monitoring site was relocated.

1. Set up a Python environment
```bash
Expand Down
2 changes: 1 addition & 1 deletion demos/nawqa_data_pull/lithops.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ aws:

aws_lambda:
execution_role: arn:aws:iam::807615458658:role/lambdaLithopsExecutionRole
runtime: discontinuum-runtime
runtime: dataretrieval-runtime
runtime_memory: 2000

aws_s3:
Expand Down
11 changes: 7 additions & 4 deletions demos/nawqa_data_pull/retrieve_nawqa_with_lithops.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,24 @@ def find_neighboring_sites(site, search_factor=0.05):
"""
site_df, _ = nwis.get_info(sites=site)
drain_area_sq_mi = site_df["drain_area_va"].values[0]
distance = _estimate_watershed_length_km(drain_area_sq_mi)
length = _estimate_watershed_length_km(drain_area_sq_mi)
search_distance = length * search_factor
# clip between 1 and 9999km
search_distance = max(1.0, min(9999.0, search_distance))

upstream_gdf = nldi.get_features(
feature_source="WQP",
feature_id=f"USGS-{site}",
navigation_mode="UM",
distance=distance * search_factor,
distance=search_distance,
data_source="nwissite",
)

downstream_gdf = nldi.get_features(
feature_source="WQP",
feature_id=f"USGS-{site}",
navigation_mode="DM",
distance=distance * search_factor,
distance=search_distance,
data_source="nwissite",
)

Expand Down Expand Up @@ -101,7 +104,7 @@ def _estimate_watershed_length_km(drain_area_sq_mi):
)

site_list = site_df['SITE_QW_ID'].to_list()
site_list = site_list[:4] # prune for testing
# site_list = site_list[:4] # prune for testing

fexec = lithops.FunctionExecutor(config_file="lithops.yaml")
futures = fexec.map(map_retrieval, site_list)
Expand Down

0 comments on commit cfb29a8

Please sign in to comment.