diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f18161f..5bb528c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,7 +3,7 @@ default_language_version: repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v5.0.0 + rev: v6.0.0 hooks: - id: check-json - id: pretty-format-json @@ -26,7 +26,7 @@ repos: # - id: include-what-you-use - repo: https://github.com/python-jsonschema/check-jsonschema - rev: 0.33.2 + rev: 0.34.0 hooks: - id: check-github-workflows - repo: meta diff --git a/src/Assimilate.cpp b/src/Assimilate.cpp index bf26480..8b99863 100644 --- a/src/Assimilate.cpp +++ b/src/Assimilate.cpp @@ -89,7 +89,7 @@ void CModel::AssimilationOverride(const int p,const optStruct& Options,const tim Qmodlast= _pSubBasins[p]->GetLastOutflowRate(); if(Qmod>PRETTY_SMALL) { _aDAscale [p]=1.0+alpha*((Qobs-Qmod)/Qmod); //if alpha = 1, Q=Qobs in observation basin - //_aDAQadjust[p]=alpha*(Qobs-Qmod); //Option A: end of time step flow + //_aDAQadjust[p]=alpha*(Qobs-Qmod); //Option A: end of time step flow //_aDAQadjust[p]=0.5*alpha*(2.0*Qobs-Qmodlast-Qmod);//Option B: mean flow - rapidly oscillatory Q - Qmean is perfect if (Qobs2 == RAV_BLANK_DATA) { //Option C: aim for midpoint of two observation flows (this is the way) _aDAQadjust[p]=alpha*(Qobs-Qmod); @@ -155,7 +155,7 @@ void CModel::PrepareAssimilation(const optStruct &Options,const time_struct &tt) pdown=GetDownstreamBasin(p); - ObsExists=false; + ObsExists=false; if(_pSubBasins[p]->UseInFlowAssimilation()) { @@ -202,9 +202,9 @@ void CModel::PrepareAssimilation(const optStruct &Options,const time_struct &tt) else if(!ObsExists) //observations may be downstream, propagate scaling upstream { //if ((pdown!=DOESNT_EXIST) && (!_aDAoverride[pdown])){ //alternate - allow information to pass through reservoirs - if( (pdown!=DOESNT_EXIST) && - (_pSubBasins[p]->GetReservoir()==NULL) && - (!_aDAoverride[p]) && + if( (pdown!=DOESNT_EXIST) && + (_pSubBasins[p]->GetReservoir()==NULL) && + (!_aDAoverride[p]) && (_pSubBasins[p]->IsEnabled()) && (_pSubBasins[pdown]->IsEnabled())) { _aDAscale [p]= _aDAscale [pdown]; _aDAlength [p]+=_pSubBasins [pdown]->GetReachLength(); @@ -291,10 +291,10 @@ void CModel::AssimilationBackPropagate(const optStruct &Options,const time_struc pdown=GetDownstreamBasin(p); if(!_aDAoverride[p]) { //observations may be downstream, get scaling from downstream - if( (pdown!=DOESNT_EXIST ) && - (!_aDAoverride[p] ) && - (_pSubBasins[p]->GetReservoir()==NULL) && - (_pSubBasins[p]->IsEnabled()) && (_pSubBasins[pdown]->IsEnabled())) + if( (pdown!=DOESNT_EXIST ) && + (!_aDAoverride[p] ) && + (_pSubBasins[p]->GetReservoir()==NULL) && + (_pSubBasins[p]->IsEnabled()) && (_pSubBasins[pdown]->IsEnabled())) { _aDAQadjust[p]= _aDAQadjust [pdown] * (_pSubBasins[p]->GetDrainageArea() / _pSubBasins[pdown]->GetDrainageArea()); } @@ -310,7 +310,7 @@ void CModel::AssimilationBackPropagate(const optStruct &Options,const time_struc double ECCCwt; for(p=0; p<_nSubBasins; p++) { - if(!_aDAoverride[p]) + if(!_aDAoverride[p]) { pdown=GetDownstreamBasin(p); if (pdown!=DOESNT_EXIST){ diff --git a/src/DemandOptimization.h b/src/DemandOptimization.h index 358171b..e551a57 100644 --- a/src/DemandOptimization.h +++ b/src/DemandOptimization.h @@ -261,7 +261,7 @@ class CDemandOptimizer double **_aDhist; //< history of actual delivery [size: _nEnabledSBs * _nHistoryItems] double **_aIhist; //< history of reservoir inflows [size: _nEnabledSBs * _nHistoryItems] double **_ahhist; //< history of actual reservoir stages (or 0 for non-reservoir basins) [size: _nEnabledSBs * _nHistoryItems] - double **_aAhist; //< history of actual reservoir areas [size: _nEnabledSBs * _nHistoryItems] + double **_aAhist; //< history of actual reservoir areas [size: _nEnabledSBs * _nHistoryItems] int _nSolverResiduals; //< number of residuals of solution (equal to lp_lib::nRows) double *_aSolverResiduals; //< vector of residuals of solution [size: _nSolverResiduals] diff --git a/src/EnKF.cpp b/src/EnKF.cpp index f42c324..45c5a55 100644 --- a/src/EnKF.cpp +++ b/src/EnKF.cpp @@ -188,10 +188,10 @@ EnKF_mode CEnKFEnsemble::GetEnKFMode() const ////////////////////////////////////////////////////////////////// /// \brief initializes EnKF assimilation run -/// - performs QA/QC on inputs +/// - performs QA/QC on inputs /// - gets #s and names of state variables adjusted during assimilation /// - allocate & populate _output_matrix, _obs_matrix, _noise_matrix -/// - open blank EnKFOutput.csv file +/// - open blank EnKFOutput.csv file /// \param &Options [out] Global model options information // void CEnKFEnsemble::Initialize(const CModel* pModel,const optStruct &Options) diff --git a/src/Flush.cpp b/src/Flush.cpp index f087084..59f8edf 100644 --- a/src/Flush.cpp +++ b/src/Flush.cpp @@ -77,7 +77,7 @@ void CmvFlush::GetRatesOfChange( const double *storage, const optStruct &Options, const time_struct &tt, double *rates) const -{ +{ double mult=_percentage; if (_percentage==BY_SUBBASIN_FLAG){ int p=pHRU->GetSubBasinIndex(); diff --git a/src/ForcingGrid.cpp b/src/ForcingGrid.cpp index 040842b..5f96ce7 100644 --- a/src/ForcingGrid.cpp +++ b/src/ForcingGrid.cpp @@ -431,7 +431,7 @@ void CForcingGrid::ForcingGridInit(const optStruct &Options) double time_zone=0; GetTimeInfoFromNetCDF(unit_t,calendar,my_time,ntime,_filename,_interval,_start_day,_start_year,time_zone); _steps_per_day=(int)(rvn_round(1.0/_interval)); //pre-calculate for speed. - + /* printf("ForcingGrid: unit_t: %s\n",unit_t_str.c_str()); printf("ForcingGrid: tt.julian_day: %f\n",tt.julian_day); diff --git a/src/LatFlush.cpp b/src/LatFlush.cpp index 55ae435..934771f 100644 --- a/src/LatFlush.cpp +++ b/src/LatFlush.cpp @@ -106,19 +106,19 @@ void CmvLatFlush::Initialize() for(int p=0;p<_pModel->GetNumSubBasins();p++) { if (_pModel->GetSubBasin(p)->IsEnabled()) { - + for(int ks=0; ks<_pModel->GetSubBasin(p)->GetNumHRUs(); ks++) //sources { k1=_pModel->GetSubBasin(p)->GetHRU(ks)->GetGlobalIndex(); Asum=0.0; nRecipients=0; if (fromHRUGrp->IsInGroup(k1)) { - + for(int ks2=0; ks2<_pModel->GetSubBasin(p)->GetNumHRUs(); ks2++) //recipients { k2=_pModel->GetSubBasin(p)->GetHRU(ks2)->GetGlobalIndex(); - if (toHRUGrp->IsInGroup(k2)) + if (toHRUGrp->IsInGroup(k2)) { if (k1!=k2){ kFrom[q]=k1; @@ -127,7 +127,7 @@ void CmvLatFlush::Initialize() _aFrac[q]=area; Asum+=area;//sum of recipient areas nRecipients++; - + //cout << "ADDING CONNECTION " << q << " in subbasin "<< _pModel->GetSubBasin(p)->GetName() << ": " // << _pModel->GetHydroUnit(kFrom[q])->GetHRUID() << " To " <<_pModel->GetHydroUnit(kTo[q])->GetHRUID() <<" "<<_aFrac[q]<GetCols(); GridDims[1] = pGrid->GetRows(); GridDims[2] = nVals; - } + } else { GridDims[0] = pGrid->GetCols(); GridDims[1] = nVals; @@ -128,7 +128,7 @@ void CModel::GenerateGriddedPrecipVars(const optStruct &Options) /// \brief Creates all missing gridded temperature data based on gridded information available, /// e.g when only sub-daily temperature is provided estimate daily average, minimum and maximum temperature. /// data are assumed to have the same resolution and hence can be initialized together. -/// called with each new chunk of data +/// called with each new chunk of data /// /// \param Options [in] major options of the model // @@ -226,7 +226,7 @@ void CModel::GenerateAveSubdailyTempFromMinMax(const optStruct &Options) pTave_daily = ForcingCopyCreate(pTmin,F_TEMP_DAILY_AVE,1.0,nVals,Options); double time_shift=Options.julian_start_day-floor(Options.julian_start_day+TIME_CORRECTION); - double t=0.0; + double t=0.0; int chunk_size =pTave_daily->GetChunkSize(); int nNonZero =pTave_daily->GetNumberNonZeroGridCells(); for(int it=0; itGetStateVarIndex(typ,layer_ind); diff --git a/src/ParseInput.cpp b/src/ParseInput.cpp index f21feef..7841b32 100644 --- a/src/ParseInput.cpp +++ b/src/ParseInput.cpp @@ -115,7 +115,7 @@ bool ParseInputFiles (CModel *&pModel, ExitGracefullyIf(Options.julian_start_year==1666, "ParseMainInputFile:: no :StartDate supplied in .rvi or runinfo.nc file.",BAD_DATA_WARN); } - + // Class Property file (.rvp) //-------------------------------------------------------------------------------- if (!ParseClassPropertiesFile (pModel,Options,terr_reqd)){ diff --git a/src/ParsePropertyFile.cpp b/src/ParsePropertyFile.cpp index 1484e62..00a60aa 100644 --- a/src/ParsePropertyFile.cpp +++ b/src/ParsePropertyFile.cpp @@ -461,9 +461,9 @@ bool ParseClassPropertiesFile(CModel *&pModel, ExitGracefullyIf(Len!=(nhoriz*2+2), "ParseClassPropertiesFile: :SoilProfiles invalid command length",BAD_DATA); bool is_special= (!string(s[0]).substr(0,4).compare("LAKE" )) || - (!string(s[0]).substr(0,5).compare("WATER" )) || + (!string(s[0]).substr(0,5).compare("WATER" )) || (!string(s[0]).substr(0,7).compare("GLACIER" )) || - (!string(s[0]).substr(0,4).compare("ROCK" )) || + (!string(s[0]).substr(0,4).compare("ROCK" )) || (!string(s[0]).substr(0,8).compare("PAVEMENT")) || (!string(s[0]).substr(0,7).compare("WETLAND" )); diff --git a/src/ParseTimeSeriesFile.cpp b/src/ParseTimeSeriesFile.cpp index d41cada..9727f4b 100644 --- a/src/ParseTimeSeriesFile.cpp +++ b/src/ParseTimeSeriesFile.cpp @@ -1315,7 +1315,7 @@ bool ParseTimeSeriesFile(CModel *&pModel, const optStruct &Options) int i=pModel->GetStateVarIndex(typ,layer_ind); sv_over *pSO=new sv_over(pTimeSer,kk,i); pModel->AddStateVarOverride(pSO); - + break; } case (300)://---------------------------------------------- diff --git a/src/RavenInclude.h b/src/RavenInclude.h index 4698999..63903a2 100644 --- a/src/RavenInclude.h +++ b/src/RavenInclude.h @@ -866,7 +866,7 @@ enum assimtype // enum sv_type { - // Water Storage Compartments + // Water Storage Compartments SURFACE_WATER, ///< [mm] Streams & rivers: see surface_struct (REQUIRED) ATMOSPHERE, ///< [mm] atmosphere : recieves water only!! (REQUIRED) ATMOS_PRECIP, ///< [mm] atmosphere : provides water only!! (REQUIRED) @@ -1194,7 +1194,7 @@ struct optStruct int nNetCDFattribs; ///< size of array of NetCDF attributes int NetCDF_chunk_mem; ///< [MB] size of memory chunk for each forcing grid bool in_bmi_mode; ///< true if in BMI mode (no rvt files, no end time) - double sv_override_endtime; ///< model time [d] after which state variable overrides are disabled (default: 1e99) + double sv_override_endtime; ///< model time [d] after which state variable overrides are disabled (default: 1e99) }; /////////////////////////////////////////////////////////////////// diff --git a/src/SubBasin.cpp b/src/SubBasin.cpp index ba1678e..b2ccd83 100644 --- a/src/SubBasin.cpp +++ b/src/SubBasin.cpp @@ -1222,7 +1222,7 @@ bool CSubBasin::SetBasinProperties(const string label, }; double CSubBasin::GetBasinProperties(const basin_props prop) { - switch (prop) + switch (prop) { case BP_TIME_CONC: return _t_conc; case BP_TIME_TO_PEAK: return _t_peak; @@ -1544,7 +1544,7 @@ double CSubBasin::ScaleAllFlows(const double &scale, const bool overriding, cons /// \remark Messes with mass balance something fierce! /// \param &Qadjust [in] Qadjust /// \param overriding [in] false if in backpropagation mode -/// \param assimsitte [in] true if this is an assimilation site with data +/// \param assimsitte [in] true if this is an assimilation site with data /// \param &tstep [in] time step [d] /// \return volume added to system [m3] /// @@ -1573,7 +1573,7 @@ double CSubBasin::AdjustAllFlows(const double &adjust, const bool overriding,con } } else if ((!overriding) && (assimsite)){ //Just QinHist - for(int n=1;n<_nQinHist; n++) { + for(int n=1;n<_nQinHist; n++) { _aQinHist[n]+=adjust*(_drainage_area-_basin_area)/_drainage_area*corr; upperswap(_aQinHist[n],0.0); va+=adjust*tstep*SEC_PER_DAY; diff --git a/src/TimeSeries.cpp b/src/TimeSeries.cpp index bb8f1cf..ccb8729 100644 --- a/src/TimeSeries.cpp +++ b/src/TimeSeries.cpp @@ -413,7 +413,7 @@ double CTimeSeries::GetAvgValue(const double &t, const double &tstep) const } } else{ - if (n1 == n2){ + if (n1 == n2){ if (n1==_nPulses-1){return _aVal[n1];} return _aVal[n1]+(t_loc+0.5*tstep-(double)(n1)*_interval)/(_interval)*(_aVal[n1+1]-_aVal[n1]); } @@ -826,7 +826,7 @@ CTimeSeries *CTimeSeries::Parse(CParser *p, bool is_pulse, string name, long lon LinTrans_a, // linear transformation: a in new = a*data+b LinTrans_b // linear transformation: b in new = a*data+b ); - + p->Tokenize(s,Len);//read closing term (e.g., ":EndData") if(string(s[0]).substr(0,4)!=":End"){ @@ -1070,7 +1070,7 @@ CTimeSeries *CTimeSeries::Parse(CParser *p, bool is_pulse, string name, long lon ExitGracefully("CTimeSeries: Parse: exceeded specified number of time series points in sequence or no :EndData command used. ",BAD_DATA); } - + pTimeSeries=new CTimeSeries(name,loc_ID,p->GetFilename(),start_day,start_yr,tstep,aVal,n,is_pulse); delete [] aVal; aVal =NULL; return pTimeSeries; diff --git a/src/TimeSeries.h b/src/TimeSeries.h index 625202f..908cb9f 100644 --- a/src/TimeSeries.h +++ b/src/TimeSeries.h @@ -128,7 +128,7 @@ class CTimeSeries: public CTimeSeriesABC string name, // forcing type long long loc_ID, // critical information about timeseries, e.g. subbasin ID or HRU ID string gauge_name, // gauge name if gauge-linked data ("none" otherwise) - bool is_pulse, // step format of data + bool is_pulse, // step format of data bool shift_to_per_ending, // true if data are period starting and need to be shifted (HYDROGRAPH?) bool shift_from_per_ending,// true if data are period-ending and need to be shifted string FileNameNC, // file name of NetCDF diff --git a/src/UnitTesting.cpp b/src/UnitTesting.cpp index e0bee53..426b1db 100644 --- a/src/UnitTesting.cpp +++ b/src/UnitTesting.cpp @@ -624,4 +624,4 @@ void TestRandomSampling() { TEST<