|
| 1 | +//Declaring the HydroLang library instance and using the retrieval functions. The retrieved data contains daily values for both datasets. |
| 2 | +var hydro = new Hydrolang(), |
| 3 | + general_config = { |
| 4 | + source: "waterOneFlow", |
| 5 | + datatype: "GetValuesObject", |
| 6 | + proxyServer: "local-proxy", |
| 7 | + }, |
| 8 | + args_1 = { |
| 9 | + sourceType: "MOPEX", |
| 10 | + location: "02414500", |
| 11 | + variable: "Clim_PE", |
| 12 | + startDate: "2003-01-01", |
| 13 | + endDate: "2003-11-30", |
| 14 | + }, |
| 15 | + response_1 = hydro.data.retrieve({ params: general_config, args: args_1 }), |
| 16 | + args_2 = { |
| 17 | + sourceType: "MOPEX", |
| 18 | + location: "02456500", |
| 19 | + variable: "Clim_PE", |
| 20 | + startDate: "2003-01-01", |
| 21 | + endDate: "2003-11-30", |
| 22 | + }, |
| 23 | + response_2 = hydro.data.retrieve({ params: general_config, args: args_2 }); |
| 24 | + |
| 25 | +//Stripping the values from the dataset |
| 26 | +var clean_1 = |
| 27 | + response_1[0].TimeSeriesResponse.timeSeriesResponse.timeSeries.values.value.map( |
| 28 | + (x) => JSON.parse(x) |
| 29 | + ), |
| 30 | + clean_2 = |
| 31 | + response_2[0].TimeSeriesResponse.timeSeriesResponse.timeSeries.values.value.map( |
| 32 | + (x) => JSON.parse(x) |
| 33 | + ); |
| 34 | + |
| 35 | +//Visualizing the raw datasets. Notice that the data does not contain information about the dates |
| 36 | +var chart_1 = [Array.from(Array(clean_1.length).keys()), clean_1], |
| 37 | + chart_2 = [Array.from(Array(clean_2.length).keys()), clean_2]; |
| 38 | +hydro.visualize.draw({ |
| 39 | + params: { type: "chart", divID: "data_1_chart" }, |
| 40 | + args: { charttype: "column" }, |
| 41 | + data: chart_1, |
| 42 | +}); |
| 43 | +hydro.visualize.draw({ |
| 44 | + params: { type: "chart", divID: "data_2_chart" }, |
| 45 | + args: { charttype: "column" }, |
| 46 | + data: chart_2, |
| 47 | +}); |
| 48 | + |
| 49 | +//Visualizing the basic statistics of the datasets |
| 50 | +hydro.visualize.draw({ |
| 51 | + params: { type: "table", divID: "data_1_stats" }, |
| 52 | + data: hydro.analyze.stats.basicstats({ data: clean_1 }), |
| 53 | +}); |
| 54 | +hydro.visualize.draw({ |
| 55 | + params: { type: "table", divID: "data_2_stats" }, |
| 56 | + data: hydro.analyze.stats.basicstats({ data: clean_2 }), |
| 57 | +}); |
| 58 | + |
| 59 | +//Calculate the KS-two sided test |
| 60 | +var KS_P = hydro.analyze.stats.KS_computePValue({ data: [clean_1, clean_2] }); |
0 commit comments