Alpine3D

Alpine3D Svn Source Tree

Root/trunk/alpine3d/DataAssimilation.cc

1/***********************************************************************************/
2/* Copyright 2009-2015 WSL Institute for Snow and Avalanche Research SLF-DAVOS */
3/***********************************************************************************/
4/* This file is part of Alpine3D.
5 Alpine3D is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 Alpine3D is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with Alpine3D. If not, see <http://www.gnu.org/licenses/>.
17*/
18#include <alpine3d/DataAssimilation.h>
19
20using namespace std;
21
22DataAssimilation::DataAssimilation(mio::IOManager& myio)
23 : data(), io(&myio), snowpack(NULL), eb(NULL)
24{
25 Initialize();
26 printf("DataAssimilation created\n");
27}
28
29DataAssimilation::~DataAssimilation() {
30Destroy();
31}
32
33DataAssimilation& DataAssimilation::operator=(const DataAssimilation& source) {
34if (this != &source) {
35data = source.data;
36io = source.io;
37snowpack = source.snowpack;
38eb = source.eb;
39}
40return *this;
41}
42
43void DataAssimilation::Destroy() {}
44
45std::string DataAssimilation::getGridsRequirements() const
46{
47return "";
48}
49
50void DataAssimilation::Initialize()
51{
52if (io==NULL){
53printf("No Input object. Ignore initialization\n");
54return;
55}
56}
57
58void DataAssimilation::setSnowPack(SnowpackInterface& mysnowpack)
59{
60 snowpack=&mysnowpack;
61}
62
63void DataAssimilation::SetEnergyBalance(EnergyBalance& myeb)
64{
65 eb=&myeb;
66}
67
68
69void DataAssimilation::Compute(mio::Date julian)
70{
71
72printf("Try to read assimilation data...\n");
73try {
74io->readAssimilationData(julian,data);
75cout << "Size of DA-fields: nx=" << data.getNx() << ", ny=" << data.getNy() << "\n";
76
77if ( snowpack!=NULL ) {
78snowpack->assimilate(data, julian);
79cout <<"Data assimilation done at time " << julian.toString(mio::Date::ISO) << "\n";
80}
81}
82
83//in fact, GetAssimilationData throws a string exception, but catch anything here
84catch (...) {
85cout << "No assimilation data at time " << julian.toString(mio::Date::ISO) << "\n";
86}
87}

Archive Download this file

Revision: HEAD