Failed to fetch fork details. Try again later.
-
Delaigue Olivier authoredddf30bac
Forked from
HYCAR-Hydro / airGR
Source project has a limited visibility.
DataAltiExtrapolation_Valery <- function(DatesR,Precip,TempMean,TempMin=NULL,TempMax=NULL,ZInputs,HypsoData,NLayers, verbose = TRUE){
##Altitudinal_gradient_functions_______________________________________________________________
##unique_gradient_for_precipitation
GradP_Valery2010 <- function(){
return(0.00041); ### value from Val? PhD thesis page 126
}
##daily_gradients_for_mean_min_and_max_air_temperature
GradT_Valery2010 <- function(){
RESULT <- matrix(c(
1, 1, 0.434, 0.366, 0.498,
2, 1, 0.434, 0.366, 0.500,
3, 1, 0.435, 0.367, 0.501,
4, 1, 0.436, 0.367, 0.503,
5, 1, 0.437, 0.367, 0.504,
6, 1, 0.439, 0.367, 0.506,
7, 1, 0.440, 0.367, 0.508,
8, 1, 0.441, 0.368, 0.510,
9, 1, 0.442, 0.368, 0.512,
10, 1, 0.444, 0.368, 0.514,
11, 1, 0.445, 0.368, 0.517,
12, 1, 0.446, 0.368, 0.519,
13, 1, 0.448, 0.369, 0.522,
14, 1, 0.450, 0.369, 0.525,
15, 1, 0.451, 0.369, 0.527,
16, 1, 0.453, 0.370, 0.530,
17, 1, 0.455, 0.370, 0.533,
18, 1, 0.456, 0.370, 0.537,
19, 1, 0.458, 0.371, 0.540,
20, 1, 0.460, 0.371, 0.543,
21, 1, 0.462, 0.371, 0.547,
22, 1, 0.464, 0.372, 0.550,
23, 1, 0.466, 0.372, 0.554,
24, 1, 0.468, 0.373, 0.558,
25, 1, 0.470, 0.373, 0.561,
26, 1, 0.472, 0.374, 0.565,
27, 1, 0.474, 0.374, 0.569,
28, 1, 0.476, 0.375, 0.573,
29, 1, 0.478, 0.375, 0.577,
30, 1, 0.480, 0.376, 0.582,
31, 1, 0.483, 0.376, 0.586,
1, 2, 0.485, 0.377, 0.590,
2, 2, 0.487, 0.377, 0.594,
3, 2, 0.489, 0.378, 0.599,
4, 2, 0.492, 0.379, 0.603,
5, 2, 0.494, 0.379, 0.607,
6, 2, 0.496, 0.380, 0.612,
7, 2, 0.498, 0.381, 0.616,
8, 2, 0.501, 0.381, 0.621,
9, 2, 0.503, 0.382, 0.625,
10, 2, 0.505, 0.383, 0.630,
11, 2, 0.508, 0.384, 0.634,
12, 2, 0.510, 0.384, 0.639,
13, 2, 0.512, 0.385, 0.643,
14, 2, 0.515, 0.386, 0.648,
15, 2, 0.517, 0.387, 0.652,
16, 2, 0.519, 0.387, 0.657,
17, 2, 0.522, 0.388, 0.661,
18, 2, 0.524, 0.389, 0.666,
19, 2, 0.526, 0.390, 0.670,
20, 2, 0.528, 0.391, 0.674,
21, 2, 0.530, 0.392, 0.679,
22, 2, 0.533, 0.393, 0.683,
23, 2, 0.535, 0.393, 0.687,
24, 2, 0.537, 0.394, 0.691,
25, 2, 0.539, 0.395, 0.695,
26, 2, 0.541, 0.396, 0.699,
27, 2, 0.543, 0.397, 0.703,
28, 2, 0.545, 0.398, 0.707,
7172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
29, 2, 0.546, 0.399, 0.709,
1, 3, 0.547, 0.399, 0.711,
2, 3, 0.549, 0.400, 0.715,
3, 3, 0.551, 0.401, 0.718,
4, 3, 0.553, 0.402, 0.722,
5, 3, 0.555, 0.403, 0.726,
6, 3, 0.557, 0.404, 0.729,
7, 3, 0.559, 0.405, 0.732,
8, 3, 0.560, 0.406, 0.736,
9, 3, 0.562, 0.406, 0.739,
10, 3, 0.564, 0.407, 0.742,
11, 3, 0.566, 0.408, 0.745,
12, 3, 0.567, 0.409, 0.748,
13, 3, 0.569, 0.410, 0.750,
14, 3, 0.570, 0.411, 0.753,
15, 3, 0.572, 0.412, 0.756,
16, 3, 0.573, 0.413, 0.758,
17, 3, 0.575, 0.414, 0.761,
18, 3, 0.576, 0.415, 0.763,
19, 3, 0.577, 0.416, 0.765,
20, 3, 0.579, 0.417, 0.767,
21, 3, 0.580, 0.417, 0.769,
22, 3, 0.581, 0.418, 0.771,
23, 3, 0.582, 0.419, 0.773,
24, 3, 0.583, 0.420, 0.774,
25, 3, 0.584, 0.421, 0.776,
26, 3, 0.585, 0.422, 0.777,
27, 3, 0.586, 0.422, 0.779,
28, 3, 0.587, 0.423, 0.780,
29, 3, 0.588, 0.424, 0.781,
30, 3, 0.589, 0.425, 0.782,
31, 3, 0.590, 0.425, 0.783,
1, 4, 0.591, 0.426, 0.784,
2, 4, 0.591, 0.427, 0.785,
3, 4, 0.592, 0.427, 0.785,
4, 4, 0.593, 0.428, 0.786,
5, 4, 0.593, 0.429, 0.787,
6, 4, 0.594, 0.429, 0.787,
7, 4, 0.595, 0.430, 0.787,
8, 4, 0.595, 0.431, 0.788,
9, 4, 0.596, 0.431, 0.788,
10, 4, 0.596, 0.432, 0.788,
11, 4, 0.597, 0.432, 0.788,
12, 4, 0.597, 0.433, 0.788,
13, 4, 0.597, 0.433, 0.788,
14, 4, 0.598, 0.434, 0.788,
15, 4, 0.598, 0.434, 0.788,
16, 4, 0.598, 0.435, 0.787,
17, 4, 0.599, 0.435, 0.787,
18, 4, 0.599, 0.436, 0.787,
19, 4, 0.599, 0.436, 0.786,
20, 4, 0.599, 0.436, 0.786,
21, 4, 0.600, 0.437, 0.785,
22, 4, 0.600, 0.437, 0.785,
23, 4, 0.600, 0.437, 0.784,
24, 4, 0.600, 0.438, 0.784,
25, 4, 0.600, 0.438, 0.783,
26, 4, 0.601, 0.438, 0.783,
27, 4, 0.601, 0.438, 0.782,
28, 4, 0.601, 0.439, 0.781,
29, 4, 0.601, 0.439, 0.781,
30, 4, 0.601, 0.439, 0.780,
1, 5, 0.601, 0.439, 0.779,
2, 5, 0.601, 0.439, 0.778,
3, 5, 0.601, 0.439, 0.778,
4, 5, 0.601, 0.440, 0.777,
5, 5, 0.601, 0.440, 0.776,
6, 5, 0.601, 0.440, 0.775,
7, 5, 0.601, 0.440, 0.775,
8, 5, 0.601, 0.440, 0.774,
141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
9, 5, 0.601, 0.440, 0.773,
10, 5, 0.602, 0.440, 0.772,
11, 5, 0.602, 0.440, 0.772,
12, 5, 0.602, 0.440, 0.771,
13, 5, 0.602, 0.440, 0.770,
14, 5, 0.602, 0.440, 0.770,
15, 5, 0.602, 0.440, 0.769,
16, 5, 0.602, 0.440, 0.768,
17, 5, 0.602, 0.440, 0.768,
18, 5, 0.602, 0.440, 0.767,
19, 5, 0.602, 0.440, 0.767,
20, 5, 0.602, 0.440, 0.766,
21, 5, 0.602, 0.440, 0.766,
22, 5, 0.602, 0.440, 0.765,
23, 5, 0.602, 0.440, 0.765,
24, 5, 0.602, 0.440, 0.764,
25, 5, 0.602, 0.440, 0.764,
26, 5, 0.602, 0.440, 0.764,
27, 5, 0.602, 0.439, 0.763,
28, 5, 0.602, 0.439, 0.763,
29, 5, 0.602, 0.439, 0.763,
30, 5, 0.602, 0.439, 0.762,
31, 5, 0.602, 0.439, 0.762,
1, 6, 0.602, 0.439, 0.762,
2, 6, 0.602, 0.439, 0.762,
3, 6, 0.602, 0.439, 0.762,
4, 6, 0.602, 0.439, 0.762,
5, 6, 0.602, 0.439, 0.762,
6, 6, 0.602, 0.438, 0.761,
7, 6, 0.602, 0.438, 0.761,
8, 6, 0.602, 0.438, 0.761,
9, 6, 0.602, 0.438, 0.761,
10, 6, 0.602, 0.438, 0.761,
11, 6, 0.602, 0.438, 0.762,
12, 6, 0.602, 0.438, 0.762,
13, 6, 0.602, 0.438, 0.762,
14, 6, 0.602, 0.438, 0.762,
15, 6, 0.602, 0.437, 0.762,
16, 6, 0.602, 0.437, 0.762,
17, 6, 0.602, 0.437, 0.762,
18, 6, 0.602, 0.437, 0.762,
19, 6, 0.602, 0.437, 0.763,
20, 6, 0.602, 0.437, 0.763,
21, 6, 0.602, 0.437, 0.763,
22, 6, 0.602, 0.436, 0.763,
23, 6, 0.602, 0.436, 0.763,
24, 6, 0.602, 0.436, 0.764,
25, 6, 0.602, 0.436, 0.764,
26, 6, 0.601, 0.436, 0.764,
27, 6, 0.601, 0.436, 0.764,
28, 6, 0.601, 0.436, 0.764,
29, 6, 0.601, 0.435, 0.765,
30, 6, 0.601, 0.435, 0.765,
1, 7, 0.601, 0.435, 0.765,
2, 7, 0.600, 0.435, 0.765,
3, 7, 0.600, 0.435, 0.765,
4, 7, 0.600, 0.434, 0.766,
5, 7, 0.600, 0.434, 0.766,
6, 7, 0.599, 0.434, 0.766,
7, 7, 0.599, 0.434, 0.766,
8, 7, 0.599, 0.434, 0.766,
9, 7, 0.598, 0.433, 0.766,
10, 7, 0.598, 0.433, 0.766,
11, 7, 0.598, 0.433, 0.766,
12, 7, 0.597, 0.433, 0.766,
13, 7, 0.597, 0.432, 0.767,
14, 7, 0.597, 0.432, 0.767,
15, 7, 0.596, 0.432, 0.767,
16, 7, 0.596, 0.432, 0.766,
17, 7, 0.595, 0.431, 0.766,
211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
18, 7, 0.595, 0.431, 0.766,
19, 7, 0.594, 0.431, 0.766,
20, 7, 0.594, 0.430, 0.766,
21, 7, 0.593, 0.430, 0.766,
22, 7, 0.593, 0.430, 0.766,
23, 7, 0.592, 0.429, 0.765,
24, 7, 0.592, 0.429, 0.765,
25, 7, 0.591, 0.428, 0.765,
26, 7, 0.590, 0.428, 0.765,
27, 7, 0.590, 0.428, 0.764,
28, 7, 0.589, 0.427, 0.764,
29, 7, 0.588, 0.427, 0.764,
30, 7, 0.588, 0.426, 0.763,
31, 7, 0.587, 0.426, 0.763,
1, 8, 0.586, 0.425, 0.762,
2, 8, 0.586, 0.425, 0.762,
3, 8, 0.585, 0.424, 0.761,
4, 8, 0.584, 0.424, 0.761,
5, 8, 0.583, 0.423, 0.760,
6, 8, 0.583, 0.423, 0.760,
7, 8, 0.582, 0.422, 0.759,
8, 8, 0.581, 0.421, 0.758,
9, 8, 0.580, 0.421, 0.758,
10, 8, 0.579, 0.420, 0.757,
11, 8, 0.578, 0.420, 0.756,
12, 8, 0.578, 0.419, 0.755,
13, 8, 0.577, 0.418, 0.754,
14, 8, 0.576, 0.418, 0.754,
15, 8, 0.575, 0.417, 0.753,
16, 8, 0.574, 0.416, 0.752,
17, 8, 0.573, 0.415, 0.751,
18, 8, 0.572, 0.415, 0.750,
19, 8, 0.571, 0.414, 0.749,
20, 8, 0.570, 0.413, 0.748,
21, 8, 0.569, 0.413, 0.747,
22, 8, 0.569, 0.412, 0.746,
23, 8, 0.568, 0.411, 0.745,
24, 8, 0.567, 0.410, 0.744,
25, 8, 0.566, 0.409, 0.743,
26, 8, 0.565, 0.409, 0.742,
27, 8, 0.564, 0.408, 0.741,
28, 8, 0.563, 0.407, 0.740,
29, 8, 0.562, 0.406, 0.738,
30, 8, 0.561, 0.405, 0.737,
31, 8, 0.560, 0.405, 0.736,
1, 9, 0.558, 0.404, 0.735,
2, 9, 0.557, 0.403, 0.734,
3, 9, 0.556, 0.402, 0.732,
4, 9, 0.555, 0.401, 0.731,
5, 9, 0.554, 0.401, 0.730,
6, 9, 0.553, 0.400, 0.728,
7, 9, 0.552, 0.399, 0.727,
8, 9, 0.551, 0.398, 0.725,
9, 9, 0.550, 0.397, 0.724,
10, 9, 0.549, 0.396, 0.723,
11, 9, 0.548, 0.396, 0.721,
12, 9, 0.546, 0.395, 0.720,
13, 9, 0.545, 0.394, 0.718,
14, 9, 0.544, 0.393, 0.717,
15, 9, 0.543, 0.392, 0.715,
16, 9, 0.542, 0.391, 0.713,
17, 9, 0.541, 0.391, 0.712,
18, 9, 0.540, 0.390, 0.710,
19, 9, 0.538, 0.389, 0.709,
20, 9, 0.537, 0.388, 0.707,
21, 9, 0.536, 0.388, 0.705,
22, 9, 0.535, 0.387, 0.703,
23, 9, 0.533, 0.386, 0.702,
24, 9, 0.532, 0.385, 0.700,
25, 9, 0.531, 0.385, 0.698,
281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
26, 9, 0.530, 0.384, 0.696,
27, 9, 0.528, 0.383, 0.694,
28, 9, 0.527, 0.383, 0.692,
29, 9, 0.526, 0.382, 0.690,
30, 9, 0.525, 0.381, 0.688,
1, 10, 0.523, 0.381, 0.686,
2, 10, 0.522, 0.380, 0.684,
3, 10, 0.521, 0.379, 0.682,
4, 10, 0.519, 0.379, 0.680,
5, 10, 0.518, 0.378, 0.678,
6, 10, 0.517, 0.377, 0.676,
7, 10, 0.515, 0.377, 0.674,
8, 10, 0.514, 0.376, 0.671,
9, 10, 0.512, 0.376, 0.669,
10, 10, 0.511, 0.375, 0.667,
11, 10, 0.510, 0.375, 0.664,
12, 10, 0.508, 0.374, 0.662,
13, 10, 0.507, 0.374, 0.659,
14, 10, 0.505, 0.373, 0.657,
15, 10, 0.504, 0.373, 0.654,
16, 10, 0.502, 0.372, 0.652,
17, 10, 0.501, 0.372, 0.649,
18, 10, 0.499, 0.372, 0.647,
19, 10, 0.498, 0.371, 0.644,
20, 10, 0.496, 0.371, 0.641,
21, 10, 0.495, 0.371, 0.639,
22, 10, 0.493, 0.370, 0.636,
23, 10, 0.492, 0.370, 0.633,
24, 10, 0.490, 0.370, 0.630,
25, 10, 0.489, 0.369, 0.628,
26, 10, 0.487, 0.369, 0.625,
27, 10, 0.485, 0.369, 0.622,
28, 10, 0.484, 0.368, 0.619,
29, 10, 0.482, 0.368, 0.616,
30, 10, 0.481, 0.368, 0.613,
31, 10, 0.479, 0.368, 0.610,
1, 11, 0.478, 0.368, 0.607,
2, 11, 0.476, 0.367, 0.604,
3, 11, 0.475, 0.367, 0.601,
4, 11, 0.473, 0.367, 0.598,
5, 11, 0.471, 0.367, 0.595,
6, 11, 0.470, 0.367, 0.592,
7, 11, 0.468, 0.367, 0.589,
8, 11, 0.467, 0.366, 0.586,
9, 11, 0.465, 0.366, 0.583,
10, 11, 0.464, 0.366, 0.580,
11, 11, 0.462, 0.366, 0.577,
12, 11, 0.461, 0.366, 0.574,
13, 11, 0.459, 0.366, 0.571,
14, 11, 0.458, 0.366, 0.568,
15, 11, 0.456, 0.366, 0.565,
16, 11, 0.455, 0.366, 0.562,
17, 11, 0.454, 0.366, 0.559,
18, 11, 0.452, 0.365, 0.556,
19, 11, 0.451, 0.365, 0.553,
20, 11, 0.450, 0.365, 0.550,
21, 11, 0.448, 0.365, 0.547,
22, 11, 0.447, 0.365, 0.544,
23, 11, 0.446, 0.365, 0.542,
24, 11, 0.445, 0.365, 0.539,
25, 11, 0.443, 0.365, 0.536,
26, 11, 0.442, 0.365, 0.533,
27, 11, 0.441, 0.365, 0.531,
28, 11, 0.440, 0.365, 0.528,
29, 11, 0.439, 0.365, 0.526,
30, 11, 0.438, 0.365, 0.523,
1, 12, 0.437, 0.365, 0.521,
2, 12, 0.436, 0.365, 0.519,
3, 12, 0.435, 0.365, 0.517,
4, 12, 0.434, 0.365, 0.515,
351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
5, 12, 0.434, 0.365, 0.513,
6, 12, 0.433, 0.365, 0.511,
7, 12, 0.432, 0.365, 0.509,
8, 12, 0.431, 0.365, 0.507,
9, 12, 0.431, 0.365, 0.505,
10, 12, 0.430, 0.365, 0.504,
11, 12, 0.430, 0.365, 0.502,
12, 12, 0.429, 0.365, 0.501,
13, 12, 0.429, 0.365, 0.500,
14, 12, 0.429, 0.365, 0.498,
15, 12, 0.428, 0.365, 0.497,
16, 12, 0.428, 0.365, 0.496,
17, 12, 0.428, 0.365, 0.496,
18, 12, 0.428, 0.365, 0.495,
19, 12, 0.428, 0.365, 0.494,
20, 12, 0.428, 0.365, 0.494,
21, 12, 0.428, 0.365, 0.494,
22, 12, 0.428, 0.365, 0.493,
23, 12, 0.429, 0.365, 0.493,
24, 12, 0.429, 0.366, 0.493,
25, 12, 0.429, 0.366, 0.493,
26, 12, 0.430, 0.366, 0.494,
27, 12, 0.430, 0.366, 0.494,
28, 12, 0.431, 0.366, 0.495,
29, 12, 0.431, 0.366, 0.495,
30, 12, 0.432, 0.366, 0.496,
31, 12, 0.433, 0.366, 0.497),ncol=5,byrow=TRUE);
dimnames(RESULT) <- list(1:366,c("day","month","grad_Tmean","grad_Tmin","grad_Tmax"));
return(RESULT);
}
##Format_______________________________________________________________________________________
HypsoData <- as.double(HypsoData);
ZInputs <- as.double(ZInputs);
##ElevationLayers_Creation_____________________________________________________________________
ZLayers <- as.double(rep(NA,NLayers));
if(!identical(HypsoData,as.double(rep(NA,101)))){
nmoy <- 100 %/% NLayers;
nreste <- 100 %% NLayers;
ncont <- 0;
for(iLayer in 1:NLayers){
if(nreste > 0){ nn <- nmoy+1; nreste <- nreste-1; } else { nn <- nmoy; }
if(nn==1){ ZLayers[iLayer] <- HypsoData[ncont+1]; }
if(nn==2){ ZLayers[iLayer] <- 0.5 * (HypsoData[ncont+1] + HypsoData[ncont+2]); }
if(nn>2 ){ ZLayers[iLayer] <- HypsoData[ncont+nn/2]; }
ncont <- ncont+nn;
}
}
##Precipitation_extrapolation__________________________________________________________________
##Initialisation
LayerPrecip <- list();
if(identical(ZInputs,HypsoData[51]) & NLayers==1){
LayerPrecip[[1]] <- as.double(Precip);
} else {
##Elevation_gradients_for_daily_mean_precipitation
GradP <- GradP_Valery2010(); ### single value
TabGradP <- rep(GradP,length(Precip));
##Extrapolation
##Thresold_of_inputs_median_elevation
Zthreshold <- 4000;
##_On_each_elevation_layer...
for(iLayer in 1:NLayers){
##If_layer_elevation_smaller_than_Zthreshold
if(ZLayers[iLayer] <= Zthreshold){
421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
LayerPrecip[[iLayer]] <- as.double(Precip*exp(TabGradP*(ZLayers[iLayer]-ZInputs)));
##If_layer_elevation_greater_than_Zthreshold
} else {
##If_inputs_median_elevation_smaller_than_Zthreshold
if(ZInputs <= Zthreshold){ LayerPrecip[[iLayer]] <- as.double(Precip*exp(TabGradP*(Zthreshold-ZInputs)));
##If_inputs_median_elevation_greater_then_Zthreshold
} else { LayerPrecip[[iLayer]] <- as.double(Precip); }
}
}
}
##Temperature_extrapolation____________________________________________________________________
##Initialisation
LayerTempMean <- list(); LayerTempMin <- list(); LayerTempMax <- list();
if(identical(ZInputs,HypsoData[51]) & NLayers==1){
LayerTempMean[[1]] <- as.double(TempMean);
if(!is.null(TempMin) & !is.null(TempMax)){ LayerTempMin[[1]] <- as.double(TempMin); LayerTempMax[[1]] <- as.double(TempMax); }
} else {
##Elevation_gradients_for_daily_mean_min_and_max_temperature
GradT <- GradT_Valery2010(); ### Day, Month, GradTmean, GradTmin and GradTmax for iCol=1,2,3,4,5, respectively
TabGradT <- matrix(NA,nrow=length(Precip),ncol=3);
for(iday in 1:366){
ind <- which(as.numeric(format(DatesR,format="%d"))==GradT[iday,1] & as.numeric(format(DatesR,format="%m"))==GradT[iday,2]);
TabGradT[ind,1:3] <- GradT[iday,3:5];
}
##Extrapolation
##On_each_elevation_layer...
for(iLayer in 1:NLayers){
LayerTempMean[[iLayer]] <- as.double(TempMean + (ZInputs-ZLayers[iLayer])*abs(TabGradT[,1])/100);
if(!is.null(TempMin) & !is.null(TempMax)){
LayerTempMin[[iLayer]] <- as.double(TempMin + (ZInputs-ZLayers[iLayer])*abs(TabGradT[,2])/100);
LayerTempMax[[iLayer]] <- as.double(TempMax + (ZInputs-ZLayers[iLayer])*abs(TabGradT[,3])/100);
}
}
}
##Solid_Fraction_for_each_elevation_layer______________________________________________________
LayerFracSolidPrecip <- list();
##Thresold_of_inputs_median_elevation
Zthreshold <- 1500;
##On_each_elevation_layer...
for(iLayer in 1:NLayers){
Option <- "USACE";
if(!is.na(ZInputs)){ if(ZInputs < Zthreshold & !is.null(TempMin) & !is.null(TempMax)){ Option <- "Hydrotel"; } }
##Turcotte_formula_from_Hydrotel
if(Option=="Hydrotel"){
TempMin <- LayerTempMin[[iLayer]];
TempMax <- LayerTempMax[[iLayer]];
SolidFraction <- 1 - TempMax/(TempMax - TempMin);
SolidFraction[TempMin >= 0] <- 0;
SolidFraction[TempMax <= 0] <- 1;
}
##USACE_formula
if(Option=="USACE"){
USACE_Tmin <- -1.0;
USACE_Tmax <- 3.0;
TempMean <- LayerTempMean[[iLayer]];
SolidFraction <- 1- (TempMean - USACE_Tmin)/(USACE_Tmax - USACE_Tmin);
SolidFraction[TempMean > USACE_Tmax] <- 0;
SolidFraction[TempMean < USACE_Tmin] <- 1;
}
LayerFracSolidPrecip[[iLayer]] <- as.double(SolidFraction);
}
491492493494495496497498499
##END__________________________________________________________________________________________
return(list(LayerPrecip=LayerPrecip,LayerTempMean=LayerTempMean,LayerTempMin=LayerTempMin,LayerTempMax=LayerTempMax,
LayerFracSolidPrecip=LayerFracSolidPrecip,ZLayers=ZLayers));
}