Skip to content

Commit c78f560

Browse files
committed
Updates on demos and example UI
1 parent ba82df4 commit c78f560

File tree

4 files changed

+137
-8
lines changed

4 files changed

+137
-8
lines changed

README.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ HydroLang users are encouraged to build and share predictive models suitable for
2828
* **Other**
2929

3030
Models can be developed in HydroLang through two ways:
31-
* Using the framework as it is through its API within a JavaScript file.
32-
* Using the BMI specification steering files for running a model.
31+
* The native API.
32+
* BMI specification steering files.
33+
* HTML driven applications.
3334

3435
Please refer to the [models page](https://github.com/uihilab/HydroLang-Models/tree/main/models) for more information.
3536

@@ -49,8 +50,6 @@ https://hydroinformatics.uiowa.edu/.
4950

5051
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).
5152

52-
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).
53-
5453
## References
5554

5655
* Ramirez, C.E., Sermet, Y., Molkenthin, F. and Demir, I., 2021. HydroLang: An Open-Source Web-Based Programming Framework for Hydrological Sciences. https://doi.org/10.31223/X5M31D

data/img/hydroLang_UI_demo.gif

7.79 MB
Loading

models/README.md

+10-4
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@ Using pure client side development environments, we recommend using [VSCode Live
1414
The script tag enables the HydroLang library globaly throughout the window space the HTML file is running on. This means that all the functionalities of HydroLang can be run using the developer console from the web browser as shown in the following example:
1515

1616
<p align="center">
17-
<img src = "https://github.com/uihilab/HydroLang-Models/blob/main/data/img/hydroLang_api_demo.gif" alt="animated" />
17+
<img src = "https://github.com/uihilab/HydroLang-Models/blob/main/data/img/hydroLang_api_demo.gif" alt="animated" size="60%" />
1818
</p>
1919

20-
From there onwards, the developer can use the library in whichever means they see fit. There are two ways to run HydroLang models:
20+
From there onwards, the developer can use the library in whichever means they see fit. There are three ways to run HydroLang:
2121

22-
* Using the API within a JavaScript file to access the framework's features, or
22+
* Using the API directly.
2323
* Using the BMI compliant version for simulations.
24+
* Using the HTML driven applications from HL-ML.
2425

2526
## Using the API directly
2627

@@ -32,7 +33,12 @@ const hydro = new HydroLang();
3233
var retrieveData = hydro.data.retrieve({params: {param1: "someVal", param2: "someVal"}, args:{arg1: "someVal", arg2: "someVal"})
3334
```
3435
35-
Running the script through the HTML file might run the requested function execution as expected since some of the functions run asynchronously (e.g. most functions of the data and maps module). If you want to build a specific application, you can use the functions embedded a sourcee for running code in buttons, tags,UI aiding
36+
Running the script through the HTML file might run the requested function execution as expected since some of the functions run asynchronously (e.g. most functions of the data and maps module). If you want to build a specific application, there are many ways in which you can explore HydroLang's functionalities. For example, through the use of the browser's UI you can declare buttons that attach the require functions coorrectly declared into the HTML script.
37+
38+
<p align="center">
39+
<img src = "https://github.com/uihilab/HydroLang-Models/blob/main/data/img/hydroLang_UI_demo.gif" alt="animated" size="60%" />
40+
</p>
41+
3642
3743
## Using the BMI compliant version
3844

models/example_UI.html

+124
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<link
5+
rel="stylesheet"
6+
href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css"
7+
/>
8+
<meta charset="UTF-8" />
9+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
10+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
11+
<script
12+
type="module"
13+
onload="initHydrolang()"
14+
src="./hydrolang/hydro.js"
15+
></script>
16+
<title>HydroLang Example Page</title>
17+
</head>
18+
<body>
19+
<h2>HydroLang General Example</h2>
20+
<button onclick="retrieveDataUSGS()">Retrieve USGS Gauge</button>
21+
<button onclick="cleaner()">Clean Data</button>
22+
<button onclick="visualize()">Visualize Data</button>
23+
<button onclick="Stats()">Basic Stats on Data</button>
24+
<button onclick="downloadClean()">Download Clean Data</button>
25+
<button onclick="downloadRaw()">Download Raw Data</button>
26+
<script>
27+
var res, clean;
28+
//Scripts needs to be onloaded by the first click of a function
29+
function initHydrolang() {
30+
//hydrolang instance available as a global variable
31+
window.hydro = new Hydrolang();
32+
}
33+
34+
const retrieveDataUSGS = () => {
35+
res = window.hydro.data.retrieve({
36+
params: {
37+
source: "usgs",
38+
datatype: "instant-values",
39+
proxyurl: "local-proxy",
40+
},
41+
args: {
42+
site: "USGS:05454500",
43+
startDt: "2008-04-02",
44+
endDt: "2010-06-30",
45+
format: "json",
46+
},
47+
});
48+
alert("Your data has been retrieved!");
49+
console.log(res);
50+
};
51+
52+
const cleaner = () => {
53+
if (res === undefined) {
54+
alert("Please press the retrieve button first!");
55+
return;
56+
}
57+
clean = window.hydro.data.transform({
58+
params: {
59+
save: "value",
60+
},
61+
args: {
62+
type: "ARR",
63+
keep: '["datetime", "value"]',
64+
},
65+
data: res,
66+
});
67+
alert("If you want to see your data, please run the visualize button!");
68+
alert("You can also find it prompted in your console.");
69+
console.log(clean);
70+
};
71+
72+
const visualize = () => {
73+
if (res === undefined) {
74+
alert("Please press the retrieve button or clean button first!");
75+
return;
76+
}
77+
window.hydro.visualize.draw({
78+
params: { type: "chart", divID: "USGS_Data" },
79+
args: { charttype: "line" },
80+
data: clean,
81+
});
82+
};
83+
84+
const Stats = () => {
85+
if (res === undefined) {
86+
alert("Please press the retrieve button or clean button first!");
87+
return;
88+
}
89+
var basic = window.hydro.analyze.stats.basicstats({
90+
data: clean
91+
})
92+
window.hydro.visualize.draw({
93+
params: { type: "table", divID: "USGS_Data_Stats" },
94+
data: basic,
95+
});
96+
}
97+
98+
const downloadClean = () => {
99+
if (res === undefined) {
100+
alert("Please make sure you retrieved and cleaned the data!");
101+
return;
102+
}
103+
window.hydro.data.download({
104+
params: { input: "USGS_Data" },
105+
args: { type: "CSV" },
106+
data: clean,
107+
});
108+
};
109+
110+
//Raw data cannto be changde into a CSV format, only the raw datatype it was retrieved in (JSON)
111+
const downloadRaw = () => {
112+
if (res === undefined) {
113+
alert("Please make sure you retrieved and cleaned the data!");
114+
return;
115+
}
116+
window.hydro.data.download({
117+
params: { input: "USGS_Data" },
118+
args: { type: "JSON" },
119+
data: res,
120+
});
121+
};
122+
</script>
123+
</body>
124+
</html>

0 commit comments

Comments
 (0)