Skip to content

Commit f76434d

Browse files
authored
Merge pull request #70 from ecmwf/develop
Release 0.8
2 parents 0d6ddd6 + 9e526c5 commit f76434d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1754
-5047
lines changed

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
*.ipynb filter=strip-notebook-output
1+
*.ipynb filter=strip-notebook-output

.github/workflows/ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ jobs:
1313
steps:
1414
- uses: actions/checkout@v2
1515
- run: pip install ruff
16-
- run: ruff check
16+
- run: ruff check # check linting violations
17+
- run: ruff format --check --exclude *.ipynb # check formatting
1718

1819
docs:
1920
runs-on: ubuntu-latest

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ repos:
77
- repo: https://github.com/charliermarsh/ruff-pre-commit
88
rev: v0.5.6
99
hooks:
10-
- id: ruff
10+
- id: ruff # fix linting violations
1111
args: [ --fix ]
12-
- id: ruff-format
12+
- id: ruff-format # fix formatting
1313
- repo: https://github.com/pre-commit/pre-commit-hooks
1414
rev: v4.4.0
1515
hooks:

.readthedocs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ mkdocs:
1616
# Optionally declare the Python requirements required to build your docs
1717
python:
1818
install:
19-
- requirements: docs/requirements.txt
19+
- requirements: docs/requirements.txt

README.md

Lines changed: 47 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,59 @@
1-
# HAT - Hydrological Analysis Toolkit
1+
# Hydrological Analysis Toolkit (HAT)
2+
3+
<p align="center">
4+
<a href="https://github.com/ecmwf/codex/raw/refs/heads/main/ESEE">
5+
<img src="https://github.com/ecmwf/codex/raw/refs/heads/main/ESEE/foundation_badge.svg" alt="ECMWF Software EnginE">
6+
</a>
7+
<a href="https://github.com/ecmwf/codex/raw/refs/heads/main/Project Maturity">
8+
<img src="https://github.com/ecmwf/codex/raw/refs/heads/main/Project Maturity/emerging_badge.svg" alt="Maturity Level">
9+
</a>
10+
<a href="https://opensource.org/licenses/apache-2-0">
11+
<img src="https://img.shields.io/badge/Licence-Apache 2.0-blue.svg" alt="Licence">
12+
</a>
13+
<a href="https://github.com/ecmwf/hat/releases">
14+
<img src="https://img.shields.io/github/v/release/ecmwf/hat?color=purple&label=Release" alt="Latest Release">
15+
</a>
16+
</p>
17+
18+
<p align="center">
19+
<!-- <a href="#quick-start">Quick Start</a>
20+
-->
21+
<a href="#installation">Installation</a>
22+
23+
<a href="https://hydro-analysis-toolkit.readthedocs.io">Documentation</a>
24+
</p>
25+
26+
> \[!IMPORTANT\]
27+
> This software is **Emerging** and subject to ECMWF's guidelines on [Software Maturity](https://github.com/ecmwf/codex/raw/refs/heads/main/Project%20Maturity).
228
329
The Hydrological Analysis Toolkit (HAT) is a software suite for hydrologists working with simulated and observed river discharge. HAT performs data analysis on hydrological datasets, with its main features being:
430
- mapping station locations into hydrological model grids
5-
- extraction of timeseries
31+
- extraction of timeseries at station locations from gridded model outputs
632
- statistical analysis of hydrological timeseries
733

8-
The documentation can be found at https://hydro-analysis-toolkit.readthedocs.io
9-
10-
**DISCLAIMER**
11-
This project is **BETA** and will be **Experimental** for the foreseeable future.
12-
Interfaces and functionality are likely to change, and the project itself may be scrapped.
13-
**DO NOT** use this software in any project/software that is operational.
14-
1534
### Installation
1635

17-
Clone source code repository
18-
19-
$ git clone https://github.com/ecmwf/hat.git
20-
$ cd hat
21-
22-
Create and activate conda environment
23-
24-
$ conda create -n hat python=3.10
25-
$ conda activate hat
26-
27-
For default installation, run
28-
29-
$ pip install .
30-
31-
For a developer installation (includes linting and test libraries), run
32-
33-
$ pip install -e .[dev]
34-
$ pre-commit install
35-
36-
If you only plan to run the tests, instead run
37-
38-
$ pip install -e .[test]
39-
40-
If you plan to build a source and a wheel distribution, it is additionally required to run
41-
42-
$ pip install build
36+
For a default installation, run
4337

44-
### Usage
38+
```
39+
pip install hydro-analysis-toolkit
40+
```
4541

46-
Run a command line tool
42+
For a developer setup, run
4743

48-
$ hat-extract-timeseries --help
44+
```
45+
conda create -n hat python=3.12
46+
conda activate hat
47+
git clone https://github.com/ecmwf/hat.git
48+
cd hat
49+
pip install -e .[dev]
50+
pre-commit install
51+
```
4952

50-
### Running the tests
53+
## Licence
5154

52-
Tests are stored in the `tests/` folder and can be run with
53-
54-
$ pytest
55-
56-
### Deployment
57-
58-
To build a source and a wheel distribution, run
59-
60-
$ python build
61-
62-
### Contributing
63-
64-
The main repository is hosted on [GitHub](https://github.com/ecmwf/hat). Testing, bug reports and contributions are highly welcomed and appreciated.
65-
66-
Please report [bug](https://github.com/ecmwf/hat/issues) reports or [pull-requests](https://github.com/ecmwf/hat/pulls) on [GitHub](https://github.com/ecmwf/hat).
67-
68-
We want your feedback, please e-mail: user-services@ecmwf.int
69-
70-
### License
71-
72-
Copyright 2023 European Centre for Medium-Range Weather Forecasts (ECMWF)
55+
```
56+
Copyright 2023, European Centre for Medium Range Weather Forecasts.
7357
7458
Licensed under the Apache License, Version 2.0 (the "License");
7559
you may not use this file except in compliance with the License.
@@ -84,10 +68,6 @@ See the License for the specific language governing permissions and
8468
limitations under the License.
8569
8670
In applying this licence, ECMWF does not waive the privileges and immunities
87-
granted to it by virtue of its status as an intergovernmental organisation nor
88-
does it submit to any jurisdiction.
89-
90-
91-
### Citing
92-
93-
In publications, please use a link to this repository (https://github.com/ecmwf/hat) and its documentation (https://hydro-analysis-toolkit.readthedocs.io)
71+
granted to it by virtue of its status as an intergovernmental organisation
72+
nor does it submit to any jurisdiction.
73+
```

docs/hat_extract-timeseries.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
`hat-extract-timeseries` documentation
22
===============================
33

4-
Extract timeseries from a collection of simulation raster files.
4+
Extract timeseries from a collection of simulation raster files.
55

66
How to use
77
-----
@@ -27,4 +27,4 @@ To create your own configuration json file you might want to start with the defa
2727
"station_id_column_name": "obsid",
2828
"station_filters":"",
2929
"station_coordinates": ["Lon", "Lat"]
30-
}
30+
}

docs/hat_hydrostats.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
`hat-hydrostats` documentation
22
==============================
33

4-
Command line tool to calculate hydrological statistics on timeseries.
4+
Command line tool to calculate hydrological statistics on timeseries.
55

66
How to use
77
-----
@@ -39,4 +39,4 @@ You can calculate more than one function at once using commas with the `--functi
3939

4040
(Optionally) define the minimum percentage of observations required for timeseries to be valid using the `--obs_threshold` option (default is 80%)
4141

42-
`hat-hydrostats --functions kge --sims $SIMS --obs $OBS --obs_threshold 70`
42+
`hat-hydrostats --functions kge --sims $SIMS --obs $OBS --obs_threshold 70`

docs/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
mkdocs
1+
mkdocs

docs/station_mapping.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
The `station_mapping` library is designed for mapping the location of hydrological station data onto the optimum location of a hydrological model grid (netcdf).
66
This tool is available as both [command line](#station-mapping-with-command-line) and [Python API](#station-mapping-as-python-script-eg-called-within-jupyter-notebook-or-python-file)
77

8-
The optimum grid cell location is searched through optimising the upstream area error and the cell distance(s) from the station nearest grid cells. In this tool, users can define their <b>acceptable area difference/ error</b> using the parameter `max_area_difference` (%) and <b>the maximum cell radius</b> parameter: `max_neighboring_cell` (number of cells) to search for this optimum grid. The tool can also be parameterised to ignore further searching of optimum cells when upstream area difference of a station nearest grid is below, i.e. when the uspteam area of the nearest cell to the station is already deemed acceptable by defining `min_area_diff`(%).
8+
The optimum grid cell location is searched through optimising the upstream area error and the cell distance(s) from the station nearest grid cells. In this tool, users can define their <b>acceptable area difference/ error</b> using the parameter `max_area_difference` (%) and <b>the maximum cell radius</b> parameter: `max_neighboring_cell` (number of cells) to search for this optimum grid. The tool can also be parameterised to ignore further searching of optimum cells when upstream area difference of a station nearest grid is below, i.e. when the uspteam area of the nearest cell to the station is already deemed acceptable by defining `min_area_diff`(%).
99

10-
For instance, refer to illustration example below, if the specified `max_area_difference` is 10%, then the optimum grid to be returned when specified `max_neighboring_cell` = 1 cell, is the one with 7% upstream area difference (blue). While if the `max_neighboring_cell` = 2 cell, then the cell with 5% upstream area difference will be returned as the optimum grid instead.
10+
For instance, refer to illustration example below, if the specified `max_area_difference` is 10%, then the optimum grid to be returned when specified `max_neighboring_cell` = 1 cell, is the one with 7% upstream area difference (blue). While if the `max_neighboring_cell` = 2 cell, then the cell with 5% upstream area difference will be returned as the optimum grid instead.
1111

1212
<img src="station_mapping_search_algo.svg" alt="illustration of optimum grid search algorithm" width="450"/>
1313

@@ -21,11 +21,11 @@ To use the `station_mapping` as command line, follow these steps:
2121

2222
1. Prepare your data input: station data and grid data in the appropriate format. Station data should be in a CSV file, and grid data should be in a NetCDF file.
2323
PLease ensure all lattitudes and longitude values in [<b> decimal degree format/ DD</b>](https://en.wikipedia.org/wiki/Decimal_degrees).
24-
24+
2525
2. Create a [JSON configuration](https://github.com/ecmwf/hat/tree/main/notebooks/examples/station_mapping_config_example.json) file specifying the paths to your data files, column names, and other relevant parameters.
26-
26+
2727
3. Run the `station_mapping.py` script with the path to your configuration file:
28-
28+
2929
`./station_mapping.py path/to/your/config.json`
3030

3131

@@ -48,7 +48,7 @@ config = {
4848
"csv_ups_col": "DrainingArea.km2.Provider", # column name for metadata of upstream (string)
4949
5050
# Mapping parameters (3x)
51-
"max_neighboring_cells": 5, # Parameter 1: maximum radius to search for best cells (no. of cells)
51+
"max_neighboring_cells": 5, # Parameter 1: maximum radius to search for best cells (no. of cells)
5252
"max_area_diff": 20, # Parameter 2: acceptable/ optimum upstream area difference (%)
5353
"min_area_diff": 0, # Parameter 3: minimum upstream area difference (%) between nearest grid and the station metadata
5454
@@ -59,15 +59,15 @@ config = {
5959
6060
# if Output directory is provided, it will save the geodataframe outputs to geojson and csv readable by GIS or jupyter interactive
6161
# "out_directory": None # put none if you don't want to save the output
62-
"out_directory": "output"
62+
"out_directory": "output"
6363
}
6464
```
6565
3. Run the `station_mapping` function with the config dictionary input and store result as dataframe (df)
6666
Since in the above example, the out_directory is not empty/ None, i.e. hence geojson and csv output of the station mapping tool will be saved in the specified directory.
6767

6868
```
69-
# import station mapping
70-
from hat.mapping.station_mapping import station_mapping
69+
# import station mapping
70+
from hat.mapping.station_mapping import station_mapping
7171
# call station_mapping function and apply on the created config dictionary
7272
df = station_mapping(config)
7373
```
@@ -87,7 +87,7 @@ Outputs
8787
------
8888

8989
The following elements (column) will be written as dataframe as the expected `station_mapping` output.
90-
Note: `_lat` and `_lon` refer to the actual lattitude and longitude of the location, while `_lat_idx` and `_lon_idx` refer to the lat and lon grid ID.
90+
Note: `_lat` and `_lon` refer to the actual lattitude and longitude of the location, while `_lat_idx` and `_lon_idx` refer to the lat and lon grid ID.
9191

9292
* Station data
9393
`station_name`, `station_lat`, `station_lon`, `station_area`
@@ -101,7 +101,7 @@ Note: `_lat` and `_lon` refer to the actual lattitude and longitude of the locat
101101
* Manually mapped variable
102102
`manual_lat`, `manual_lon`, `manual_lat_idx`, `manual_lon_idx`, `manual_area`
103103

104-
* GIS compatble output files (optional)
104+
* GIS compatble output files (optional)
105105
if the "out_directory" in the `configuration` is specified, then the following files will be written in the directory:
106106

107107
1. `stations.geojson`: stations point vector in geojson (readable in GIS)

0 commit comments

Comments
 (0)