geoglows
Version:
This is an npm package that helps to use the Geoglows API
168 lines (117 loc) • 10.6 kB
Markdown
\|
<img alt="NPM" src="https://img.shields.io/npm/l/geoglows">
<img alt="npm" src="https://img.shields.io/npm/dm/geoglows">
<img alt="npm" src="https://img.shields.io/npm/v/geoglows">
<img alt="GitHub forks" src="https://img.shields.io/github/forks/romer8/GEOGloWS-JavaScript-Package?style=social">
<img alt="Coveralls github" src="https://img.shields.io/coveralls/github/romer8/GEOGloWS-JavaScript-Package">
This is a version for the npm package for the API that is held for the GEOGloWS project, which uses the ERA-5 dataset from ECMWF. The application retrieves different plots using Plotly.js.
This plots belong to a particular reach_id from a river, so plots are linked to a reach_id. The provided plots are:
<ol>
<li>Forecast Records</li>
<li>52 Forecast Ensembles(Ensemble 52 is in high resolution)</li>
<li>Forecast Statistics with return periods</li>
<li>Historical Records with return periods</li>
<li>Seasonal Flow</li>
</ol>
A demo application was prepared to show that the forecast, historical and seasonal data plots can be retrieved for any reach_id.
The following codePen shows an application that contains all the streams for the country of Peru. The plots are retrieved when one
clicks on an stream.
[Hydroviewer Peru](https://codepen.io/ElkinGio/pen/vYNWLay)
# Documentation-use
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
## GEOGloWS
The GEOGloWS object contains the functions that retrieve plots for the forecast, historical, seasonal average of a reach_id of a given stream.
Therefore, it contains three Properties: Forecast, Historical, and Seasonal.
In order to invoke the GEOGloWS object, you can do it in two ways: using the CDN in the HTML or installing it via NPM.
<pre>
The CDN for the use of the package is:
</pre>
<pre>
https://unpkg.com/geoglows@2.0.2/dist/geoglows.min.js
</pre>
If the CDN link is going to be used it is necesarry to use the following structure: GEOGloWS.forecast, GEOGloWS.historical, GEOGloWS.seasonal. After, the methods for
each one of the different objects can be used. For example, GEOGloWS.forecast.graph_fr() will call the function graph_fr that will retrieve the forecast records.
<pre>
The NPM command to install the package is
</pre>
<pre>
npm i geoglows
</pre>
If the NPM isntallation is going to be use then a simple require will work.
<pre>
var foo = require("geoglows");
foo.GEOGLOWS.forecast.graph_fr();
</pre>
The FORECAST object contains the functions that are realted to the forcast of a reach_id of a given stream.
Type: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)
- `graph_fr` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** Gives a Plot of the forecast Records for a given reach_id of an stream
- `graph_emsembles` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** Gives a Plot of the forecast ensembles for a given reach_id of an stream. It gives 52 ensembles.
- `graph_stats` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** Gives a Plot of the forecsast statistics and the last week of the forecast records.
Retrieves a plot of the forecast Records for a given reach_id of an stream. It gives 2 weeks of the forecst records.
In addition, the function lets customize the width, heigh, and title of the graph if needed.
The retrieved plots are plotted using Plotly, so a button to download data has been added to the plots
- `reachid` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** reach_id of an specific stream
- `htmlElement` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** It is the id of the HTML element.
- `title` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** it is the title of the grah (optional).
- `rp` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** \-Tells the function to add the return periods to the plot of the Forecast Records.(optional).
- `width` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Especifies the width of the plot.(optional).
- `height` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Especifies the height of the plot.(optional).
Retrieves a plot of the forecast ensembles for a given reach_id of an stream. It gives 52 ensembles. The ensemble 52 is the only one that comes in high resolution.
In addition, You can especify which ensembles do you want. For exmaple, the array [2,4,6,7] will give you the ensembles 2,4,6, and 7. The default is to give all
all the ensembles. The function also lets customize the width, heigh, and title of the graph if needed.
The retrieved plots are plotted using Plotly, so a button to download data has been added to the plots
- `reachid` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** reach_id of an specific stream
- `htmlElement` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** It is the id of the HTML element.
- `arrayEnsemble` **[array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** It is the array that contains the number of ensembles that will be given (optional).
- `title` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** it is the title of the grah (optional).
- `width` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Especifies the width of the plot.(optional).
- `height` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Especifies the height of the plot.(optional).
Retrieves a plot of the forecast statisitics of the given reach_id. These statistcis are Maximun, Minimun, 25% percentile, 75% percentile, and Mean.
The function also lets customize the width, heigh, and title of the graph if needed.
The retrieved plots are plotted using Plotly, so a button to download data has been added to the plots
- `reachid` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** reach_id of an specific stream
- `htmlElement` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** It is the id of the HTML element.
- `title` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** it is the title of the grah (optional).
- `rp` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** \-Tells the function to add the return periods to the plot of the Forecast Records.(optional).
- `width` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Especifies the width of the plot.(optional).
- `height` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Especifies the height of the plot.(optional).
The HISTORICAL object contains the functions that are related to the Historical data of a reach_id of a given stream.
Type: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)
- `graph` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** Retrieves a plot of the historical data of the given reach_id.
Retrieves the plot related to the Historical Records for a given reach_id of an stream.
In addition, the function lets customize the width, heigh, and title of the graph if needed.
The retrieved plots are plotted using Plotly, so a button to download data has been added to the plots
- `reachid` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** reach_id of an specific stream
- `htmlElement` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** It is the id of the HTML element.
- `title` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** it is the title of the grah (optional).
- `rp` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** \-Tells the function to add the return periods to the plot of the Forecast Records.(optional).
- `width` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Especifies the width of the plot.(optional).
- `height` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Especifies the height of the plot.(optional).
The SEASONAL object contains the functions that are related to the plots of the Seasonal average data of a reach_id of a given stream.
Type: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)
- `graph` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** Retrieves a plot of the historical data of the given reach_id.
Retrieves the plot related to the Seasonal Average Data for a given reach_id of an stream.
In addition, the function lets customize the width, heigh, and title of the graph if needed.
The retrieved plots are plotted using Plotly, so a button to download data has been added to the plots
- `reachid` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** reach_id of an specific stream
- `htmlElement` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** It is the id of the HTML element.
- `title` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** it is the title of the grah (optional).
- `width` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Especifies the width of the plot.(optional).
- `height` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Especifies the height of the plot.(optional).