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

Release 0.6.0: interactive tool #22

Merged
merged 34 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
ab5f063
added table properties for station, AND cal. statistics, color by st…
dadiyorto-wendi Oct 10, 2023
fb4098e
added another version of visualization module to cater for destinE data
dadiyorto-wendi Oct 10, 2023
bb06dd1
resolved problem when tempdir doesnt exists
dadiyorto-wendi Oct 10, 2023
9c9d14c
reverted back to working station click with less buggy layout
dadiyorto-wendi Oct 10, 2023
fd2d9a4
added common id finder between input files
dadiyorto-wendi Oct 10, 2023
e6941f3
debugging common station index
dadiyorto-wendi Oct 10, 2023
fa7d978
debug notebook vis
corentincarton Oct 10, 2023
d302609
debug notebook
corentincarton Oct 10, 2023
c20c1ff
debug notebook vis
corentincarton Oct 11, 2023
04908ef
update viz notebook, working!
corentincarton Oct 11, 2023
a9ccc12
minor changes
corentincarton Oct 11, 2023
cf2c935
added new parameter for variable name of obs and sim. changed layout,…
dadiyorto-wendi Oct 16, 2023
1efc90c
modified layout, added date picker, added legend, title, diff colorma…
dadiyorto-wendi Oct 18, 2023
11d1840
aligned based on layout, sized sub layout width with %
dadiyorto-wendi Oct 18, 2023
c8bb935
added todo and changed add marker into ipyleaflet class
dadiyorto-wendi Oct 24, 2023
12d17a7
moved generate html legend and display dataframe with scroll to ipyle…
dadiyorto-wendi Oct 24, 2023
9fe9099
attempt to add interactive object and plotly class
dadiyorto-wendi Oct 24, 2023
a22ffef
revampt structure of visualisation script, lack of station property t…
dadiyorto-wendi Oct 26, 2023
daffeeb
Fully functioning restructured attempt, Corentin will do more cleanup
dadiyorto-wendi Oct 26, 2023
ca5481f
added draft template for notebook, currently based on my local pc
dadiyorto-wendi Oct 26, 2023
be9d02d
Update README.md
corentincarton Oct 31, 2023
122e4c3
refactor interactive notebook
corentincarton Oct 31, 2023
919a8e0
Merge pull request #20 from ecmwf/feature/ipyleaflet
dadiyorto-wendi Nov 2, 2023
f786344
update github actions to use mamba
corentincarton Nov 6, 2023
9ecc227
minor fix in github actions
corentincarton Nov 6, 2023
d7b036d
Merge pull request #21 from ecmwf/interactive_visualisation
corentincarton Nov 6, 2023
2bc81c9
add documentation for the interactive objects
corentincarton Nov 14, 2023
e37e8eb
Merge branch 'interactive_visualisation' into develop
corentincarton Nov 14, 2023
fbdc917
debug notebook
corentincarton Nov 14, 2023
55026eb
pdate version
corentincarton Nov 14, 2023
81f777e
add interactive tests
corentincarton Nov 15, 2023
5377c31
update dependencies
corentincarton Nov 15, 2023
8d7eaa3
removing extra notebook
corentincarton Nov 15, 2023
41e690c
update on-push ci
corentincarton Nov 16, 2023
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
7 changes: 1 addition & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: conda-incubator/setup-miniconda@v2
- uses: mamba-org/setup-micromamba@v1
with:
activate-environment: test
environment-file: environment.yml
auto-activate-base: false
- name: conda check
shell: bash -l {0}
run: |
conda info
conda list
- name: install hat package
shell: bash -l {0}
run: pip install .
Expand Down
7 changes: 1 addition & 6 deletions .github/workflows/on-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: conda-incubator/setup-miniconda@v2
- uses: mamba-org/setup-micromamba@v1
with:
activate-environment: test
environment-file: environment.yml
auto-activate-base: false
- name: Conda check
shell: bash -l {0}
run: |
conda info
conda list
- name: install hat package
shell: bash -l {0}
run: pip install .
Expand Down
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ repos:
rev: 23.3.0
hooks:
- id: black
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
hooks:
- id: flake8
# - repo: https://github.com/PyCQA/flake8
# rev: 6.0.0
# hooks:
# - id: flake8
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Interfaces and functionality are likely to change, and the project itself may be

Clone source code repository

$ git clone git@github.com:ecmwf-projects/hat.git
$ git clone https://github.com/ecmwf/hat.git

Create conda python environment

Expand Down Expand Up @@ -63,4 +63,4 @@ does it submit to any jurisdiction.

### Citing

In publications, please use a link to this repository (https://github.com/ecmwf/hat) and its documentation (https://hydro-analysis-toolkit.readthedocs.io)
In publications, please use a link to this repository (https://github.com/ecmwf/hat) and its documentation (https://hydro-analysis-toolkit.readthedocs.io)
8 changes: 4 additions & 4 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ name: hat
channels:
- conda-forge
dependencies:
- python=3.10
- python<=3.10
- netCDF4
- eccodes
- cfgrib
- cftime
- geopandas
- xarray
- plotly
- matplotlib
- jupyterlab
- jupyter
- tqdm
- typer
- humanize
- folium
- typer
- ipyleaflet
- ipywidgets
- pip
# - pytest
# - mkdocs
Expand Down
71 changes: 0 additions & 71 deletions hat/clock.py

This file was deleted.

7 changes: 5 additions & 2 deletions hat/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ def get_tmpdir():
else:
tmpdir = TemporaryDirectory().name

# Ensure the directory exists
os.makedirs(tmpdir, exist_ok=True)

return tmpdir


Expand Down Expand Up @@ -257,8 +260,8 @@ def save_dataset_to_netcdf(ds: xr.Dataset, fpath: str):
ds.to_netcdf(fpath)


def find_main_var(ds):
variable_names = [k for k in ds.variables if len(ds.variables[k].dims) >= 3]
def find_main_var(ds, min_dim=3):
variable_names = [k for k in ds.variables if len(ds.variables[k].dims) >= min_dim]
if len(variable_names) > 1:
raise Exception("More than one variable in dataset")
elif len(variable_names) == 0:
Expand Down
30 changes: 18 additions & 12 deletions hat/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def filter_dataframe(df, filters: str):
return df


def filter_timeseries(sims_ds: xr.Dataset, obs_ds: xr.Dataset, threshold=80):
def filter_timeseries(sims_ds: xr.DataArray, obs_ds: xr.DataArray, threshold=80):
"""Clean the simulation and observation timeseries

Only keep..
Expand All @@ -159,30 +159,36 @@ def filter_timeseries(sims_ds: xr.Dataset, obs_ds: xr.Dataset, threshold=80):
matching_stations = sorted(
set(sims_ds.station.values).intersection(obs_ds.station.values)
)
print(len(matching_stations))
sims_ds = sims_ds.sel(station=matching_stations)
obs_ds = obs_ds.sel(station=matching_stations)
obs_ds = obs_ds.sel(time=sims_ds.time)

obs_ds = obs_ds.dropna(dim="station", how="all")
sims_ds = sims_ds.sel(station=obs_ds.station)

# Only keep observations in the same time period as the simulations
obs_ds = obs_ds.where(sims_ds.time == obs_ds.time, drop=True)
# obs_ds = obs_ds.where(sims_ds.time == obs_ds.time, drop=True)

# Only keep obsevations with enough valid data in this timeperiod

# discharge data
dis = obs_ds.obsdis
print(sims_ds)
print(obs_ds)

# Replace negative values with NaN
dis = dis.where(dis >= 0)
# dis = dis.where(dis >= 0)

# Percentage of valid discharge data at each point in time
valid_percent = dis.notnull().mean(dim="time") * 100
# # Percentage of valid discharge data at each point in time
# valid_percent = dis.notnull().mean(dim="time") * 100

# Boolean index of where there is enough valid data
enough_observation_data = valid_percent > threshold
# # Boolean index of where there is enough valid data
# enough_observation_data = valid_percent > threshold

# keep where there is enough observation data
obs_ds = obs_ds.where(enough_observation_data, drop=True)
# # keep where there is enough observation data
# obs_ds = obs_ds.where(enough_observation_data, drop=True)

# keep simulation that match remaining observations
sims_ds = sims_ds.where(enough_observation_data, drop=True)
# # keep simulation that match remaining observations
# sims_ds = sims_ds.where(enough_observation_data, drop=True)

return (sims_ds, obs_ds)
30 changes: 0 additions & 30 deletions hat/graphs.py

This file was deleted.

Loading