Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Many improvements #32

Merged
merged 24 commits into from
Aug 29, 2022
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
3fcf4ac
use parquet, streamline functions
rileyhales Aug 15, 2022
15c837e
improve paths
rileyhales Aug 15, 2022
8b96df3
misc code clean up
rileyhales Aug 18, 2022
98c0e18
increment version number
rileyhales Aug 18, 2022
b3d028a
rename distribution saberbc
rileyhales Aug 18, 2022
61c41f3
partial commit
rileyhales Aug 21, 2022
f62ee08
split clustering functions
rileyhales Aug 21, 2022
ac3392f
plot cluster figures in separate function
rileyhales Aug 21, 2022
8b60508
remove gauge clustering
rileyhales Aug 24, 2022
a63de91
delete example scripts
rileyhales Aug 24, 2022
13d0f5d
new example script
rileyhales Aug 24, 2022
b22d6de
drop tslearn, fdc calculated in 1 percent intervals
rileyhales Aug 25, 2022
b7f3402
drop geoglows dependency
rileyhales Aug 25, 2022
14c24a0
split cluster functions, code formatting, mark todo's
rileyhales Aug 25, 2022
b03b98a
add silhouette plots
rileyhales Aug 26, 2022
0fffc2c
merge assign and table modules
rileyhales Aug 26, 2022
c57a5fd
add joblib to dependency lists
rileyhales Aug 26, 2022
5198270
drop analysis module with outdated plot function
rileyhales Aug 26, 2022
1578cc7
use the vocab module for table names, paths, formats
rileyhales Aug 28, 2022
0670441
turn _vocab into io and merge scaffold functions
rileyhales Aug 28, 2022
e20159d
more compliance using the io module
rileyhales Aug 29, 2022
610044d
organize and debug calibration function
rileyhales Aug 29, 2022
d43f38d
rename for pypi
rileyhales Aug 29, 2022
79e9df9
remove python from requirements.txt
rileyhales Aug 29, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
new example script
  • Loading branch information
rileyhales committed Aug 24, 2022
commit 13d0f5d97894ec952a6dcd76e5c3885267bfe312
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -104,7 +104,7 @@ Your table should look like this:
| unique_stream_# | unique_stream_# | area in km^2 | stream_order | ## | ## |
| ... | ... | ... | ... | ... | ... |

2. Prepare a csv of the attribute table of the gauge locations shapefile.
1. Prepare a csv of the attribute table of the gauge locations shapefile.
- You need the columns:
- model_id
- gauge_id
@@ -157,7 +157,7 @@ looks like this:
```python
import saber as saber
workdir = '/path/to/project/directory/'
saber.prep.gen_assignments_table(workdir)
saber.table.gen(workdir)
```

Your project's working directory now looks like
@@ -230,10 +230,6 @@ saber.prep.hindcast(
workdir,
'/path/to/historical/simulation/netcdf.nc' # optional - if nc not stored in data_inputs folder
)
saber.prep.hist_sim_table(
workdir,
'/path/to/historical/simulation/netcdf.nc' # optional - if nc not stored in data_inputs folder
)
saber.prep.observed_data(
workdir,
'/path/to/obs/csv/directory' # optional - if csvs not stored in workdir/data_inputs/obs_csvs
43 changes: 43 additions & 0 deletions examples/saber_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import os

import numpy as np
import saber


np.seterr(all="ignore")

workdir = ''
hist_sim_nc = os.path.join(workdir, '')
obs_data_dir = os.path.join(workdir, '')
drain_gis = os.path.join(workdir, '')
gauge_gis = os.path.join(workdir, '')

print('Prepare inputs')
saber.prep.gis_tables(workdir, drain_gis=drain_gis, gauge_gis=gauge_gis)
saber.prep.hindcast(workdir)

# Generate the assignments table
print('Generate Assignment Table')
assign_table = saber.table.gen(workdir)
saber.table.cache(workdir, assign_table)

# Generate clusters using the historical simulation data
print('Generate Clusters')
saber.cluster.generate(workdir)
saber.cluster.plot(workdir)
saber.cluster.summarize(workdir, assign_table)

# Assign basins which are gauged and propagate those gauges
print('Making Assignments')
assign_table = saber.assign.gauged(assign_table)
assign_table = saber.assign.propagation(assign_table)
assign_table = saber.assign.clusters_by_dist(assign_table)

# Cache the assignments table with the updates
saber.table.cache(workdir, assign_table)

# Generate GIS files to explore your progress graphically
print('Generate GIS files')
saber.gis.clip_by_assignment(workdir, assign_table, drain_gis)
saber.gis.clip_by_cluster(workdir, assign_table, drain_gis)
saber.gis.clip_by_unassigned(workdir, assign_table, drain_gis)