Skip to content

Commit

Permalink
Bugfix/list of river numbers (#31)
Browse files Browse the repository at this point in the history
* get many rivids at once from aws

* update dependency list min versions
  • Loading branch information
rileyhales authored Apr 10, 2024
1 parent 22c681c commit 24e2c10
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
23 changes: 11 additions & 12 deletions environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@ channels:
- conda-forge
dependencies:
- python>=3
- dask
- dask >=2024
- fastparquet
- requests
- pandas
- plotly>=5
- jinja2
- shapely>=2
- scipy>=1
- s3fs
- numpy>=1
- hydrostats
- HydroErr
- xarray
- zarr
- hydrostats
- numpy >=1
- pandas >=1
- plotly >=5
- requests
- s3fs >=2024
- scipy >=1
- shapely >=2
- xarray >=2024
- zarr
2 changes: 1 addition & 1 deletion geoglows/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
'bias', 'plots', 'data', 'analyze', 'streams', 'tables',
'METADATA_TABLE_PATH'
]
__version__ = '1.0.3'
__version__ = '1.0.4'
__author__ = 'Riley Hales'
__license__ = 'BSD 3-Clause Clear License'
9 changes: 5 additions & 4 deletions geoglows/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ def from_aws(*args, **kwargs):
warnings.warn('forecast_records are not available from the AWS Open Data Program.')
return from_rest(*args, **kwargs)

reach_id = kwargs.get('reach_id', '')
reach_id = args[0] if len(args) > 0 else None
reach_id = kwargs.get('reach_id', '') if not reach_id else reach_id

s3 = s3fs.S3FileSystem(anon=True, client_kwargs=dict(region_name=ODP_S3_BUCKET_REGION))
if kwargs.get('date', '') and not product_name == 'dates':
Expand All @@ -71,10 +71,11 @@ def from_aws(*args, **kwargs):
df = xr.open_zarr(s3store).sel(rivid=reach_id).to_dataframe().round(2).reset_index()

# rename columns to match the REST API
if isinstance(reach_id, list):
df = df.pivot(columns='ensemble', index=['time', 'rivid'], values='Qout')
else:
if isinstance(reach_id, int):
df = df.pivot(index='time', columns='ensemble', values='Qout')
else:
df = df.pivot(index=['time', 'rivid'], columns='ensemble', values='Qout')
df.index.names = ['time', 'LINKNO']
df = df[sorted(df.columns)]
df.columns = [f'ensemble_{str(x).zfill(2)}' for x in df.columns]

Expand Down
8 changes: 4 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
dask
dask>=2024
fastparquet
requests
pandas
pandas>=1
plotly>=5
scipy>=1
s3fs
s3fs>=2024
numpy>=1
hydrostats
HydroErr
xarray
xarray>=2024
zarr

0 comments on commit 24e2c10

Please sign in to comment.