-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLapseRateCalculator.Rmd
60 lines (39 loc) · 4.18 KB
/
LapseRateCalculator.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
---
title: "LapseRateCalculator"
output: github_document
---
# Title: "LapseRateCalculator"
## Introduction
The R script LapseRateCalculator.R in folder *inst* provide an example of usage of lapse rate calculator using as test variable Dew point temperature (Tdew). Tdew is calculated from Air Temperature and Relative Humidity using GEOtop formulas(1) [[Link]](https://github.com/geotopmodel/geotop/blob/master/src/geotop/meteo.cc).
After a selection of variable to examine the script apply a linear model to extract lapse rate. The output is a file csv containing,for each timestamp, the time series of number of station available , the lapse rate and the r-squared of linear fitting model.
Note: Thi script work for data having column structure and format as LTER standard, not for GEOtop (possible update!)
## Description
1. In **Section 1** import functions used in script, files available in folder */data/Input* after the selection of git folder (**INPUT 1**), and the file of elevation (**INPUT 2**) of stations in folder */data/Support files*. This file has 2 columns: the first, called **name** should cointain the file name of station **without .csv**. The second, called **elevation** should cointain the elevation of the station in m a.s.l.
2. In **Section 2** the script calculate dew point temperature from Air temperature and Relative Humidity. In this section you have to fill the following inputs:
+ **INPUT 3**: Select which VARIABLE in your data measure Air Temperature
+ **INPUT 4**: Select which VARIABLE in your data measure Relative Humidity
3. In **Section 3** the lapse rate is calculated using a linear fitting models.For example the linear fit is between Dew point Temperature (y axis) and Elevation (x axis). You shuould select (**INPUT 5**) which dataset use for lapse rate calculator (in the example Dew_point, but it could be another, for example only Air Temperature imported with function *fun_read_all_stations*. This function read all files in folder data/Input/ and read the variable select from every file), and an elevation vector (**INPUT 6**) that cointain the only the elevation of station in the same order that they appear in the dataset.
4. In **Section 4** the script save output in folder */data/Output/*, as a file VARIABLE_FOR_LAPSERATE.csv (where VARIABLE_FOR_LAPSERATE is the string of name of variable analyzed with lapse rate calculator), containing 4 column:
+ **TIMESTAMP**: date and time of observation
+ **n_station**: the number of station available in linear fit for each timestamp
+ **lapes_rate**: the lapse rate obtained as slope of fitting line
+ **r_squared**: the r_squared extract from infomation of linare fit
## Dataset
**INPUT**:
1. **git_folder**: source of package **LapseRateCalculator**
2. **ELEVATION_PATH**: path of elevation file
3. **FILES**: vector of names of files available in */data/Input data*. **(don't edit this path)**. Option: You can also subset this vector excluding some stations
4. **VARIABLE_1**: variable 1 to import for dew point temperature. In the exmaple "T_Air"
5. **VARIABLE_2**: variable 2 to import for dew point temperature. In the exmaple "RH"
6. **DATA_FOR_LAPSERATE**: data.frame containing the same variable for all stations in vector FILES (You can alse create a subset of station to process excluding some elements from FILES. *See in the script FILES_NEW*)
7. **ELEVATION_VECTOR**: vector of elevations of station. In the example we assign to this vector an extraction of elevation file.
8. **VARIABLE_FOR_LAPSERATE**: string containing the name of variable which the laspe rate is applied. We use this string to define the name of output file.
**OUTPUT**:
Outptuts are in **K/1000 m** - negative values mean a decrease with elevation
1. **VARIABLE_FOR_LAPSERATE.csv** in folder */data/Output/* a .csv file which contains 4 columns:
+ **TIMESTAMP**: date and time of observation
+ **n_station**: the number of station available in linear fit for each timestamp
+ **lapes_rate**: the lapse rate obtained as slope of fitting line
+ **r_squared**: the r_squared extract from infomation of linare fit
## References
(1) https://github.com/geotopmodel/geotop/blob/master/src/geotop/meteo.cc