Skip to content

Commit d15c1cf

Browse files
committed
v534 - fixes for backpropagation when blank data in assimilation
issue found by City of Calgary
1 parent ca8cc28 commit d15c1cf

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/Assimilate.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ void CModel::AssimilationOverride(const int p,const optStruct& Options,const tim
8787
Qobs2 = _aDAobsQ2[p];
8888
Qmod = _pSubBasins[p]->GetOutflowRate();
8989
Qmodlast= _pSubBasins[p]->GetLastOutflowRate();
90-
if(Qmod>PRETTY_SMALL) {
90+
if((Qmod>PRETTY_SMALL) && (Qobs!=RAV_BLANK_DATA)){
9191
_aDAscale [p]=1.0+alpha*((Qobs-Qmod)/Qmod); //if alpha = 1, Q=Qobs in observation basin
9292
//_aDAQadjust[p]=alpha*(Qobs-Qmod); //Option A: end of time step flow
9393
//_aDAQadjust[p]=0.5*alpha*(2.0*Qobs-Qmodlast-Qmod);//Option B: mean flow - rapidly oscillatory Q - Qmean is perfect
@@ -189,7 +189,9 @@ void CModel::PrepareAssimilation(const optStruct &Options,const time_struct &tt)
189189
else
190190
{ //found a blank or zero flow value
191191
_aDAscale [p]=_aDAscale[p];//same adjustment as before - scaling persists
192-
_aDAlength [p]=0.0;
192+
if(pdown!=DOESNT_EXIST) {
193+
_aDAlength [p]+=_pSubBasins [pdown]->GetReachLength(); //length propagates from below
194+
}
193195
_aDAtimesince[p]+=Options.timestep;
194196
_aDAoverride [p]=false;
195197
_aDAobsQ [p]=0.0;
@@ -292,7 +294,6 @@ void CModel::AssimilationBackPropagate(const optStruct &Options,const time_struc
292294

293295
if(!_aDAoverride[p]) { //observations may be downstream, get scaling from downstream
294296
if( (pdown!=DOESNT_EXIST ) &&
295-
(!_aDAoverride[p] ) &&
296297
(_pSubBasins[p]->GetReservoir()==NULL) &&
297298
(_pSubBasins[p]->IsEnabled()) && (_pSubBasins[pdown]->IsEnabled()))
298299
{
@@ -314,7 +315,7 @@ void CModel::AssimilationBackPropagate(const optStruct &Options,const time_struc
314315
{
315316
pdown=GetDownstreamBasin(p);
316317
if (pdown!=DOESNT_EXIST){
317-
_aDAQadjust[p] *=exp(-distfact*_aDAlength[pdown]);
318+
_aDAQadjust[p] *=exp(-distfact*_aDAlength[p]);
318319
}
319320

320321
ECCCwt=1.0;

src/StandardOutput.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3103,7 +3103,7 @@ void WriteNetCDFBasinList(const int ncid,const int varid,const int varid_name,co
31033103
current_basin_name[0]=new char[200];
31043104
for(int p=0;p<pModel->GetNumSubBasins();p++) {
31053105
if(pModel->GetSubBasin(p)->IsGauged() && (pModel->GetSubBasin(p)->IsEnabled())) {
3106-
if (!( (is_res) && (pModel->GetSubBasin(p)->GetReservoir()==NULL))){
3106+
if (!( (is_res) && (pModel->GetSubBasin(p)->GetReservoir()==NULL))){//only write IDs of reservoir basins if is_res
31073107
string bID,bname;
31083108
bID = to_string(pModel->GetSubBasin(p)->GetID());
31093109
bname = pModel->GetSubBasin(p)->GetName();

0 commit comments

Comments
 (0)