Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
20 changes: 10 additions & 10 deletions src/Assimilate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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())
{
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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());
}
Expand All @@ -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){
Expand Down
2 changes: 1 addition & 1 deletion src/DemandOptimization.h
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions src/EnKF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/Flush.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/ForcingGrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions src/LatFlush.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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]<<endl;
q++;
Expand Down
4 changes: 2 additions & 2 deletions src/Model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ CModel::CModel(const int nsoillayers,
_nTransParams=0; _pTransParams=NULL;
_nClassChanges=0; _pClassChanges=NULL;
_nParamOverrides=0; _pParamOverrides=NULL;
_nStateVarOverrides=0;_pStateVarOverrides=NULL;
_nStateVarOverrides=0;_pStateVarOverrides=NULL;
_nObservedTS=0; _pObservedTS=NULL; _pModeledTS=NULL; _aObsIndex=NULL;
_nObsWeightTS =0; _pObsWeightTS=NULL;
_nDiagnostics=0; _pDiagnostics=NULL;
Expand Down Expand Up @@ -2767,7 +2767,7 @@ void CModel::RecalculateHRUDerivedParams(const optStruct &Options,
void CModel::PrepareForcingPerturbation(const optStruct &Options, const time_struct &tt)
{
if (_nPerturbations==0){return;}

double partday = Options.julian_start_day-floor(Options.julian_start_day+TIME_CORRECTION);
int nn = (int)(rvn_round((tt.model_time+partday-floor(tt.model_time+partday+TIME_CORRECTION))/Options.timestep));
bool start_of_day = ((nn==0) || tt.day_changed); //nn==0 corresponds to midnight
Expand Down
2 changes: 1 addition & 1 deletion src/Model.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class CModel: public CModelABC
sv_type *_aStateVarType; ///< type of state variable in unit i [size:_nStateVars]
int *_aStateVarLayer; ///< index of state variable for multilayer variables (e.g., SOIL); [size:_nStateVars] value=DOESNT_EXIST(-1) for unique variables (e.g. SURFACE_WATER)
int _aStateVarIndices[MAX_STATE_VAR_TYPES][MAX_SV_LAYERS]; ///< lookup table for state variable indices; the index of SOIL[1] in a state_var[] array may be returned by aStateVarIndices[(int)(SOIL)][1]

sv_over **_pStateVarOverrides; ///< array of pointers to state variable override time series
int _nStateVarOverrides; ///< number of state variable overrides

Expand Down
6 changes: 3 additions & 3 deletions src/ModelForcingGrids.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ CForcingGrid *CModel::ForcingCopyCreate(const CForcingGrid *pGrid,
GridDims[0] = pGrid->GetCols();
GridDims[1] = pGrid->GetRows();
GridDims[2] = nVals;
}
}
else {
GridDims[0] = pGrid->GetCols();
GridDims[1] = nVals;
Expand Down Expand Up @@ -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
//
Expand Down Expand Up @@ -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; it<chunk_size; it++) { // loop over time points in buffer
Expand Down
20 changes: 10 additions & 10 deletions src/ParseFEWSRunInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ void GetNetCDFStationArray(const int ncid, const string filename,int &stat_dimid
///
/// \param *&pModel [in/out] Reference to model object
/// \param &Options [in/out] Global model options information
/// \param runname_overridden [in] true if runname specified from command line
/// \param runname_overridden [in] true if runname specified from command line
/// \param mode_overridden [in] true if mode specified from command line
/// \param optionsonly [in] true if model is not yet created and only options content should be read
/// \return True if operation is successful
Expand Down Expand Up @@ -149,8 +149,8 @@ bool ParseNetCDFRunInfoFile(CModel *&pModel, optStruct &Options, bool runname_ov
// Ingest properties =====================================================================
int varid_props;
retval = nc_inq_varid(ncid,"properties",&varid_props);
if (retval != NC_ENOTVAR)

if (retval != NC_ENOTVAR)
{
HandleNetCDFErrors(retval);

Expand All @@ -174,9 +174,9 @@ bool ParseNetCDFRunInfoFile(CModel *&pModel, optStruct &Options, bool runname_ov
}
}
// SuppressWarnings
if (optionsonly) {
if (optionsonly) {
retval = nc_inq_attlen(ncid,varid_props,"BlockRavenWarnings",&att_len);
if (retval != NC_ENOTATT)
if (retval != NC_ENOTATT)
{
HandleNetCDFErrors(retval);
char* boolean=new char[att_len+1];
Expand All @@ -192,7 +192,7 @@ bool ParseNetCDFRunInfoFile(CModel *&pModel, optStruct &Options, bool runname_ov
//Block custom output
if (!optionsonly) {
retval = nc_inq_attlen(ncid,varid_props,"BlockRavenCustomOutput",&att_len);
if (retval != NC_ENOTATT)
if (retval != NC_ENOTATT)
{
HandleNetCDFErrors(retval);
char* boolean=new char[att_len+1];
Expand All @@ -210,7 +210,7 @@ bool ParseNetCDFRunInfoFile(CModel *&pModel, optStruct &Options, bool runname_ov
//NoisyMode
if (optionsonly) {
retval = nc_inq_attlen(ncid, varid_props, "NoisyMode", &att_len);
if (retval != NC_ENOTATT)
if (retval != NC_ENOTATT)
{
HandleNetCDFErrors(retval);
char* boolean = new char[att_len + 1];
Expand All @@ -227,7 +227,7 @@ bool ParseNetCDFRunInfoFile(CModel *&pModel, optStruct &Options, bool runname_ov
//SilentMode
if (optionsonly) {
retval = nc_inq_attlen(ncid, varid_props, "SilentMode", &att_len);
if (retval != NC_ENOTATT)
if (retval != NC_ENOTATT)
{
HandleNetCDFErrors(retval);
char* boolean = new char[att_len + 1];
Expand Down Expand Up @@ -261,7 +261,7 @@ bool ParseNetCDFRunInfoFile(CModel *&pModel, optStruct &Options, bool runname_ov
// EnKFMode
if (!optionsonly) {
retval = nc_inq_attlen(ncid, varid_props, "EnKFMode", &att_len);
if(retval != NC_ENOTATT)
if(retval != NC_ENOTATT)
{
HandleNetCDFErrors(retval);
char* modestr = new char[att_len];
Expand Down Expand Up @@ -290,7 +290,7 @@ bool ParseNetCDFRunInfoFile(CModel *&pModel, optStruct &Options, bool runname_ov
// AssimilateStreamflow
if (optionsonly) {
retval = nc_inq_attlen(ncid,varid_props,"AssimilateStreamflow",&att_len);
if (retval != NC_ENOTATT)
if (retval != NC_ENOTATT)
{
HandleNetCDFErrors(retval);
char* boolean = new char[att_len + 1];
Expand Down
2 changes: 1 addition & 1 deletion src/ParseInitialConditionFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ bool ParseInitialConditionsFile(CModel *&pModel, const optStruct &Options)

if (typ==UNRECOGNIZED_SVTYPE){
WriteWarning(":UniformInitialConditions: unrecognized state variable type "+to_string(s[1]),Options.noisy);break;
}
}
else {
SVind=pModel->GetStateVarIndex(typ,layer_ind);

Expand Down
2 changes: 1 addition & 1 deletion src/ParseInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)){
Expand Down
4 changes: 2 additions & 2 deletions src/ParsePropertyFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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" ));

Expand Down
2 changes: 1 addition & 1 deletion src/ParseTimeSeriesFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)://----------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions src/RavenInclude.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
};

///////////////////////////////////////////////////////////////////
Expand Down
6 changes: 3 additions & 3 deletions src/SubBasin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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]
///
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/TimeSeries.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
Expand Down Expand Up @@ -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"){
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/TimeSeries.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading
Loading