Skip to content

Commit 60b5118

Browse files
authored
Merge pull request #15 from uihilab/dev-integrate-s3buckets
New Update for master from new datasources and capabilities
2 parents f4f2c95 + c45e533 commit 60b5118

Some content is hidden

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

99 files changed

+47686
-4177
lines changed

README.md

Lines changed: 102 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -6,113 +6,140 @@
66

77
[**Link to documentation**](https://uihilab.github.io/HydroLang/)
88

9-
* [Introduction](https://github.com/uihilab/HydroLang#Introduction)
10-
* [How to Use](https://github.com/uihilab/HydroLang#How-to-Use)
11-
* [Expansions and Test Cases](https://github.com/uihilab/HydroLang#Expansions-and-Test-Cases)
12-
* [Community](https://github.com/uihilab/HydroLang#Community)
13-
* [Feedback](https://github.com/uihilab/HydroLang#Feedback)
14-
* [Scalability and To Do's](https://github.com/uihilab/HydroLang#Scalability-and-To-Dos)
15-
* [License](https://github.com/uihilab/HydroLang#License)
16-
* [Acknowledgements](https://github.com/uihilab/HydroLang#Acknowledgements)
9+
* [Introduction](#introduction)
10+
* [Modules](#modules)
11+
* [Data](#data)
12+
* [Analyze](#analyze)
13+
* [Visualization](#visualization)
14+
* [Maps](#maps)
15+
* [How to Use](#how-to-use)
16+
* [Examples](#examples)
17+
* [Community](#community)
18+
* [Feedback](#feedback)
19+
* [License](#license)
20+
* [Acknowledgements](#acknowledgements)
1721
* [References](#references)
1822

1923
## Introduction
20-
This project introduces HydroLang, a web-based framework for environmental and hydrological analyses. It contains 4 different modules, each with a specific purpose that can be used either in combination with other modules or separately. The modules are:
21-
* **Data**: used for data retrieval, manipulation, download and upload.
22-
* **Analyze**: contains three different components, each aiming towards a similar purpose:
23-
- *hydro*: functions for precipitation analysis and rainfall-runoff lumped models.
24-
- *stats*: functions for statistical characterization of data.
25-
- *NN*: functions for the creation of feed forward neural network models using [TensorFlow.js](https://www.tensorflow.org/js).
26-
* **Visualization**: used for rendering different types of charts and tables on screen using [Google Charts](https://developers.google.com/chart).
27-
* **Maps**: used for rendering of maps with option of adding/removing/downloading layers of different formats (geoJSON, KML) using two options on map engines [Google Maps](https://developers.google.com/maps/documentation) and [Leaflet](https://leafletjs.com/).
24+
HydroLang is an open-source, web-based framework designed for comprehensive environmental and hydrological analysis. Built with modularity and extensibility in mind, it empowers researchers and developers to perform complex data retrieval, analysis, modeling, and visualization directly within the browser.
2825

29-
The current modular structure serves as a starting point for basic hydrologic and environmental analyses, with further development bringing along new functions and modules that work using the same ontological design.
26+
By leveraging modern web technologies including **GDAL via WebAssembly for raster processing** and **TensorFlow.js for client-side machine learning**, HydroLang enables high-performance computing without the need for backend infrastructure.
27+
28+
## Modules
29+
30+
HydroLang consists of four core modules, each designed to handle specific aspects of the hydrological workflow. These modules can be used independently or chained together for seamless end-to-end analysis.
31+
32+
### Data
33+
The **Data** module facilitates the retrieval, manipulation, and management of hydrological and environmental data. It supports connection to various public APIs and data sources, harmonizing diverse data formats into a unified structure for analysis.
34+
35+
### Analyze
36+
The **Analyze** module is the computational core of HydroLang, subdivided into three specialized components:
37+
* **Hydro & Stats**: Provides essential hydrological functions (e.g., rainfall-runoff lumped models) and robust statistical characterization tools for time-series data.
38+
* **Geoprocessor**: A powerful client-side raster analysis engine powered by **GDAL (WASM)**. It enables advanced geospatial operations such as slope and aspect calculation, hillshading, reclassification, and terrain analysis directly in the browser.
39+
* **NN (Neural Networks)**: A comprehensive machine learning component built on **TensorFlow.js**. It runs in a dedicated Web Worker to ensure UI responsiveness and supports various architectures including:
40+
* **Dense (Feed Forward)**: For general regression and classification.
41+
* **LSTM (Long Short-Term Memory)**: Optimized for time-series forecasting.
42+
* **CNN (Convolutional Neural Networks)**: For spatial pattern recognition.
43+
44+
### Visualization
45+
The **Visualization** module enables the creation of interactive and publication-quality charts and tables. Built on top of **Google Charts**, it offers a wide range of visualization types (Line, Scatter, Bar, Histogram, etc.) and includes utilities for generating comprehensive HTML reports (`generateReport`) to summarize analytical results.
46+
47+
### Maps
48+
The **Maps** module handles geospatial visualization, supporting both **Leaflet** and **Google Maps** engines. It provides tools for:
49+
* Rendering vector data (GeoJSON, KML).
50+
* Visualizing raster data (GeoTIFF) using the `addGeoRasterLayer` function.
51+
* Interactive drawing and spatial querying with the built-in `draw` capabilities.
3052

3153
## How to Use
32-
Please download the library and run `index.html`. If a new html file should be created, the library must be onloaded onto the file as a script
54+
To use HydroLang, simply include the `hydro.js` module in your HTML file. No installation or build process is required.
3355

3456
```html
35-
<script
36-
type = "module"
37-
src= "./hydrolang/hydro.js"
38-
></script>
57+
<script type="module" src="./hydrolang/hydro.js"></script>
3958
```
4059

41-
Once the library is loaded, a new intance of HydroLang is added to the body of the file as:
60+
Initialize the library:
61+
4262
```javascript
43-
var hydro1 = new Hydrolang();
63+
import Hydrolang from './hydrolang/hydro.js';
64+
const hydro = new Hydrolang();
4465
```
4566

46-
Each of the modules is accessed through chainage using the `hydro` class instance. Functions on the third level chainage have been declared as static methods and thus, will not appear as quick access on the browser. Parameter destructuring has been added to most driving function within the framework to create an easier way to declare workflows. The destructuring is driven mainly in the following scope:
67+
HydroLang uses a consistent "params-args-data" pattern for most of its functions, utilizing object destructuring for clarity and flexibility:
4768

4869
```javascript
49-
hydro[module][function]({params:{}, args:{}, data: []})
70+
hydro[module][component][function]({
71+
params: { /* Configuration parameters (e.g., model type, chart options) */ },
72+
args: { /* Execution arguments (e.g., specific flags, keys) */ },
73+
data: [ /* Input data (arrays, typed arrays, or data objects) */ ]
74+
})
5075
```
51-
`params:{}` represents an object with initial drivers for a specific function, `args:{}` is an object with additional parameters required for the function, and `data` is any data representation, usually an `n-D` array, for the function to run. For instance, in the data retrieval function:
76+
77+
### Quick Examples
78+
79+
**1. Data Retrieval**
5280
```javascript
53-
hydro.data.retrieve({params:{source: someSource, dataType: someType}, args:{specificArg: someArg}})
54-
```
55-
The function definition found in the documentation states which parameters are required.
56-
57-
Summary examples for each module:
58-
* Function call for data module
59-
```javascript
60-
var example: hydro1.data.function({params: {}, args:{}, data: []})
61-
```
62-
* Function call for any component on the analyze module
63-
```javascript
64-
var example: hydro1.analyze.component.function({params: {}, args:{}, data: []})
81+
hydro.data.retrieve({
82+
params: { source: 'USGS', dataType: 'streamflow' },
83+
args: { site: '05454500', period: 'P7D' }
84+
})
85+
.then(data => console.log(data));
6586
```
66-
* Function call for visualization module
67-
```javascript
68-
var example: hydro1.visualize.function({params: {}, args:{}, data: []})
69-
```
70-
* Function call for maps module
71-
```javascript
72-
var example: hydro1.map.function({params: {}, args:{}, data: []})
87+
88+
**2. Neural Network Prediction**
89+
```javascript
90+
// Create and train an LSTM model
91+
const model = await hydro.analyze.nn.createModel({
92+
params: { type: 'lstm', units: 50, shape: [7, 1] } // 7-day lookback
93+
});
94+
95+
await model.train({
96+
params: { epochs: 50 },
97+
data: { inputs: xTrain, outputs: yTrain }
98+
});
7399
```
74100

75-
## Expansions and Test Cases
101+
**3. Geoprocessing**
102+
```javascript
103+
// Calculate slope from a DEM
104+
const slopeData = await hydro.analyze.geoprocessor.execute({
105+
params: { action: 'slope' },
106+
data: [{ buffer: demArrayBuffer }]
107+
});
108+
```
76109

77-
### Core library usage
78-
The usage of the library through its core structure can be found within the following files or within each module folder:
79-
* `test-analysis.html`
80-
* `test-data.html`
81-
* `test-maps.html`
82-
* `test-visualization.html`
110+
## Examples
111+
The `examples/` directory contains a comprehensive set of demos illustrating real-world use cases. These are categorized to help you get started quickly:
83112

84-
### Expansions
85-
The current expansions of the framework are the following:
86-
* [BMI specification](https://github.com/uihilab/HydroLang/tree/master/hydrolang/bmi-implementation): CSDMS basic modeling interface through steering files.
87-
* [HL-ML](https://github.com/uihilab/HydroLang-ML): HTML driven web components for hydrology and environmental sciences.
113+
* **Data Sources**:
114+
* `usgs_streamflow.html`: Fetching and visualizing real-time streamflow data.
115+
* `3dep_dem_retrieval.html`: Retrieving elevation data for terrain analysis.
116+
* **Geoprocessing**:
117+
* `terrain_analysis.html`: Performing client-side terrain analysis (Slope, Aspect, Hillshade).
118+
* `watershed_delineation.html`: Delineating watersheds and stream networks.
119+
* **Machine Learning**:
120+
* `lstm_streamflow_forecast.html`: Forecasting streamflow using Deep Learning (LSTM).
121+
* **Statistical Analysis**:
122+
* `correlation_analysis.html`: analyzing relationships between hydrological variables.
88123

89124
## Community
90-
It is possible for the library to expand by becoming a community-based framework with collaborations from research institutes or knowledgeable individuals thanks to the flexibility of employing a modular architecture, open-source libraries, and not requiring installation. Interested parties can adapt and expand HydroLang to fit their unique use cases, development environments, project requirements, and data resources. Everyone is encouraged to contribute to the growth of HydroLang by:
91-
* filing an issue to request certain features, functionality, and data,
92-
* implementing the desired capability on a fork, and submitting a pull request.
93-
Please visit the [contributing](https://github.com/uihilab/HydroLang/blob/master/docs/CONTRIBUTING.md) guidelines for more details.
125+
HydroLang is a community-driven project. We welcome contributions from researchers, developers, and hydrologists. You can contribute by:
126+
* Filing issues for bugs or feature requests.
127+
* Submitting Pull Requests with new modules, data sources, or improvements.
128+
* Sharing your models and case studies on the [HydroLang-Models repository](https://github.com/uihilab/HydroLang-Models).
94129

95-
Furthermore, for community building, we encourage users of HydroLang to share their models, codes, and case studies on [HydroLang-Models repository](https://github.com/uihilab/HydroLang-Models).
130+
Please refer to the [Contributing Guidelines](https://github.com/uihilab/HydroLang/blob/master/docs/CONTRIBUTING.md) for more details.
96131

97132
## Feedback
98-
Please feel free to send feedback to us on any issues found by filing an [issue](https://github.com/uihilab/HydroLang/blob/master/.github/ISSUE_TEMPLATE/feature_request.md).
99-
100-
## Scalability and To-Do's
101-
The framework is not limited to the functions and modules implemented, but rather provides a boilerplate for new features to be added. Nonetheless, the following should be considered:
102-
103-
* The hydro component contains only lumped models.
104-
* The map module is fully available only on Leaflet engine.
133+
We value your feedback. Please report any issues or suggestions via our [GitHub Issues](https://github.com/uihilab/HydroLang/issues) page.
105134

106135
## License
107136
This project is licensed under the MIT License - see the [LICENSE](https://github.com/uihilab/HydroLang/blob/master/LICENSE) file for details.
108137

109138
## Acknowledgements
110-
This project is developed by the University of Iowa Hydroinformatics Lab (UIHI Lab):
139+
Developed by the **University of Iowa Hydroinformatics Lab (UIHI Lab)**:
140+
https://hydroinformatics.uiowa.edu/
111141

112-
https://hydroinformatics.uiowa.edu/.
113-
114-
And with the support of the Cosortium of Universities for the Advancement of Hydrological Science [CUAHSI](https://www.cuahsi.org/) through the [Hydroinformatics Innovation Fellowship](https://www.cuahsi.org/grant-opportunities/hydroinformatics-innovation-fellowship).
142+
Supported by the **Consortium of Universities for the Advancement of Hydrological Science (CUAHSI)** through the Hydroinformatics Innovation Fellowship.
115143

116144
## References
117-
118-
* Erazo Ramirez, C., Sermet, Y., Molkenthin, F., & Demir, I. (2022). HydroLang: An open-source web-based programming framework for hydrological sciences. Environmental Modelling & Software, 157, 105525. [doi:10.1016/j.envsoft.2022.105525](https://www.sciencedirect.com/science/article/pii/S1364815222002250)
145+
* Erazo Ramirez, C., Sermet, Y., Molkenthin, F., & Demir, I. (2022). HydroLang: An open-source web-based programming framework for hydrological sciences. *Environmental Modelling & Software*, 157, 105525. [doi:10.1016/j.envsoft.2022.105525](https://www.sciencedirect.com/science/article/pii/S1364815222002250)

examples/README.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# HydroLang Examples - How to Use
2+
3+
## Quick Start
4+
5+
### Running Examples
6+
7+
**Option 1: Double-click the HTML file**
8+
- Open any `.html` file in your browser
9+
- Open DevTools (F12) to see results
10+
11+
**Option 2: From VS Code**
12+
- Install "Live Server" extension
13+
- Right-click → "Open with Live Server"
14+
15+
**Option 3: Python Server**
16+
```bash
17+
cd HydroLangWP
18+
python -m http.server 8000
19+
# Visit: http://localhost:8000/examples/
20+
```
21+
22+
## What's In Each Folder
23+
24+
### `data-sources/` - Fetching Data
25+
- Retrieve climate, elevation, and streamflow data
26+
- Examples: ECMWF, 3DEP DEM, USGS gauges
27+
28+
### `geoprocessing/` - Terrain & Watershed Analysis
29+
- DEM processing, flow analysis, watershed delineation
30+
- Examples: Flow direction, terrain indices, stream extraction
31+
32+
### `machine-learning/` - Neural Networks
33+
- Time series forecasting, classification, segmentation
34+
- Examples: LSTM streamflow, flood classification, land cover
35+
36+
### `statistical-analysis/` - Hydrological Stats
37+
- Correlation, efficiency metrics, drought indices
38+
- Examples: Flood frequency, NSE calculation, SPI drought index
39+
40+
## 💡 Reading Example Code
41+
42+
All examples follow this pattern:
43+
```javascript
44+
async function runExample() {
45+
// 1. Get data
46+
const data = await hydro.data.retrieve({...});
47+
48+
// 2. Process/analyze
49+
const result = await hydro.analyze.something({...});
50+
51+
// 3. Display results
52+
console.log(result);
53+
}
54+
```
55+
56+
## Notes
57+
58+
- Examples require internet for data retrieval
59+
- Check browser console (F12) for output
60+
- Some examples may take time to download large datasets
61+
62+
## More Help
63+
64+
- See individual example files for detailed comments
65+
- Check HydroLang documentation for API details
66+
- Visit repository for more resources

0 commit comments

Comments
 (0)