R10424/Snow_Analyzerdb97b68e7e43master
README.md
ReadMe for Snow_Analyzer
Created by Alain Foehn on April 28 2020
Last modification by Alain Foehn on April 28 2020
This folder contains the tools SWE_Analyzer and Snow_Analyzer.
Table of Contents
- Code preparation
- Remark about SnowAnalyzer
- API Inputs/Outputs
Code preparation
To work properly, SnowAnalyzer requires the followings :
- RS MINERVE installed on the machine or available portable version
- JAVA JRE x64 installed on the machine (for one of the R package used in the code)
- A folder DATA with the required GIS files
- A file INI/API-research with the request functions (not given in the template file) and with login and password provided.
- The following additional files for the folder RSMINERVE : All_warm-up_at_0.xlsx, All_warm-up_at_365.xlsx and the .rsm files for the catchments of interest
- Configure a minerve-d3\global_config.ini file (to define Output and Temporaty folders ; template given in minerve-d3\Templates\Global_config_Templates.ini).
- Provide a folder config with config files (copy them from INI\Templates)
To start the SnowAnalyzer tool (over a sub basin)
- Configure a file SnowAnalyzer.ini (copy it from INI\Templates\....)
- Run SNOW_Analyzer.R
To start the SWEAnalyzer tool (over a list of locations)
- Configure a file SWEAnalyzer.ini (copy them from INI\Templates\SWEAnalyzer)
- Run SWE_Analyzer.R
Remark about SnowAnalyzer
IMPORTANT : The current version of the code acquires discharge data in UTC+1 but the code then requires data in UTC for the computation.
A preliminary solution used for the time being is to modify manually the downloaded file. Future users are invited to modify the code adequatly to avoid the need of this manual correction. In advance, thanks ! :)
API INPUTS/OUTPUS
This part provides the data structure required to use the CombiValais tool with other APIs than the one of the minerve-d3 project. The data structure of each argument of the INI API file is given.
- First, the inputs arguments are given. When indicated with {}, this indicates a variable that will be replaced. When not indicated with {}, this indicates fix arguments in the request.
- Second, the structure of the API output file is given.
List of functions :
- valuesoverclipraster (only for Snow_Analyzer)
- valuesatcoordinates (only for SWE_Analyzer)
- get_pixel_altitude
- get_metadata
- token_path
1. valuesoverclipraster
INPUT (arguments)
The following arguments must appear in the base request (modified during the code execution):
- {productId}
- {catchmentId}
- {ENDDATE}
OUTPUT
content-type: application/json; charset=utf-8
Response body (example with two pixels contained in the catchment :
{ "productId":3, "productName":"combiprecip", "catchmentId":39, "catchmentName":"Vallée de Conches", "event":"2017-01-01T01:00:00.000Z", "pixels":[ {"e":2673500,"n":1166500,"value":0}, {"e":2674500,"n":1166500,"value":0}, ] }
2. valuesatcoordinates
INPUT (arguments)
The following arguments must appear in the base request (modified during the code execution):
- {productId}
- {list_of_coords}
- {ENDDATE}
OUTPUT
content-type: application/json; charset=utf-8
Response body (example with a list of two pixels :
{ "productId":3, "productName":"combiprecip", "event":"2017-01-01T00:00:00.000Z", "pixels":[ {"e":2600000,"n":1113000,"value":0}, {"e":2600000,"n":1116000,"value":0}] }
3. get_pixel_altitude
INPUT (arguments)
- {prod_id}
- {X_val}
- {Y_val}
OUTPUT
content-type: application/json; charset=utf-8
Response body : 1126
4. get_metadata
INPUT (arguments)
None.
OUTPUT
content-type: text/csv
The returned CSV, without header, must have at least the following arguments for each product in the database :
- Product ID [ID]
- Product temporal resolution [Temp_res_before]
- Product spatial resolution [sp_res_X]
In the current code version, the CSV has the following structure (line 40 of file minerve-d3/Code/fc_API-REST.R):
colnames(metadata) <- c("ID","Name","Type","Temp_res_before","Temp_res_after","Upper_left_X","Upper_left_Y","Width","Height","sp_res_X","sp_res_Y","data_format")
Hereafter is an example of response body with the 2 first lines of the output used in the minerve-d3 project.
1;acquire;observation;3600;0;2518000;1204000;192;172;1000;1000;64BF;mm/h 2;azc;observation;3600;0;2518000;1204000;192;172;1000;1000;64BF;mm/h
If the CSV file has a different columns structure, simply modify the above code line [BUT ensure to have the 3 variables ID, Temp_res_before and sp_res_X !
5. token_path
INPUT (arguments)
The following arguments must appear in the base request (modified during the code execution):
- {user}
- {login}
OUTPUT
content-type: application/json; charset=utf-8
Response body :
{ "token": "rtJhbGciOiJIUzI1NiIsInR5cCI6IkpXV.eyJ1c2VyIjp7ImlkI..." }