-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSJHydroPointModel.cpp
98 lines (76 loc) · 3.19 KB
/
SJHydroPointModel.cpp
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include <algorithm>
#include "SJHydroPointModel.h"
#include <measure/Inds.h>
#include <memory/Transients.h>
#include <utils/Timer.h>
SJHydroPointModel::SJHydroPointModel(Indicator timeind, double meltDegreeDayFactor, double meltDegreeDaySlope, double rainRunoffCoefficient, double meltRunoffCoefficient, double groundCoefficient, double groundToBaseflowDay, double rainOnSnowCoefficient, double surfaceEvaporationFactor, double riverEvaporationFactor, double mmdayToVolume)
: SJHydroModel(timeind, meltDegreeDayFactor, meltDegreeDaySlope, rainRunoffCoefficient, meltRunoffCoefficient, groundCoefficient, groundToBaseflowDay, rainOnSnowCoefficient, surfaceEvaporationFactor, riverEvaporationFactor) {
precipitation = NULL;
surfaceTemp = NULL;
snowModel = NULL;
elevation = 0;
currentGroundRainVolume = 0;
currentGroundMeltVolume = 0;
currentGroundConf = 0;
this->mmdayToVolume = mmdayToVolume;
}
SJHydroPointModel::SJHydroPointModel(SJHydroPointModel& copy)
: SJHydroModel(copy) {
precipitation = copy.precipitation->clone();
surfaceTemp = copy.surfaceTemp->clone();
snowModel = copy.snowModel->clone();
elevation = copy.elevation;
mmdayToVolume = copy.mmdayToVolume;
currentGroundRainVolume = copy.currentGroundRainVolume;
currentGroundMeltVolume = copy.currentGroundMeltVolume;
currentGroundConf = copy.currentGroundConf;
outFlowRain = copy.outFlowRain;
outFlowMelt = copy.outFlowMelt;
}
SJHydroPointModel::~SJHydroPointModel() {
delete precipitation;
delete surfaceTemp;
delete snowModel;
}
void SJHydroPointModel::setPrecipitation(PartialConfidenceTimeSeries<double>* precipitation) {
this->precipitation = precipitation;
}
void SJHydroPointModel::setTemperature(PartialConfidenceTimeSeries<double>* surfaceTemp) {
this->surfaceTemp = surfaceTemp;
}
void SJHydroPointModel::setSnowModel(SnowPointModel* snowModel) {
this->snowModel = snowModel;
}
void SJHydroPointModel::stepDay() {
cout << "Beginning step" << endl;
if (now.getValue() == 0) {
// What is the earliest time we can handle?
cout << "Start time: " << precipitation->getTimes().getMin() << ", " << surfaceTemp->getTimes().getMin() << ", " << snowModel->getTimes().getMin() << endl;
now = max(max(precipitation->getTimes().getMin(), surfaceTemp->getTimes().getMin()), snowModel->getTimes().getMin());
cout << "Starting at " << now << endl;
} else if (timeind == Inds::unixtime)
now += DividedRange::toTimespan(1);
else
now += 1/360.0;
cout << "Rescaling maps" << endl;
double nowPrecipitation = precipitation[now];
double nowSurfaceTemp = surfaceTemp[now];
double nowSnowCover = snowModel[now];
internalStepDay(nowPrecipitation, nowSurfaceTemp, nowSnowCover);
time_t now_time = now.getValue();
struct tm* ptm = gmtime(&now_time);
double fracyear = ptm->tm_yday / 365.0;
outFlowRain.push_back(nowRainVolume);
outFlowMelt.push_back(nowMeltVolume);
cout << "Flows: " << nowRainVolume << ", " << nowMeltVolume << endl;
Transients::clean();
}
list<double> SJHydroPointModel::getOutFlowsRain() {
return outFlowRain;
}
list<double> SJHydroPointModel::getOutFlowsMelt() {
return outFlowMelt;
}
unsigned SJHydroPointModel::getOutFlowsCount() {
return outFlowRain.size();
}