示例#1
0
void SUR_GA::SetValue(const char *key, float value)
{
    string sk(key);

    if (StringMatch(sk, "ThreadNum"))
    {
        omp_set_num_threads((int) value);
    }
    else if (StringMatch(sk, "TimeStep"))
    {
        m_TimeStep = value * 60; //hour -> mimute
    }
    else if (StringMatch(sk, "T_snow"))
    {
        m_Tsnow = value;
    }
    else if (StringMatch(sk, "t_soil"))
    {
        m_Tsoil = value;
    }
    else if (StringMatch(sk, "T0"))
    {
        m_T0 = value;
    }
    else if (StringMatch(sk, "s_frozen"))
    {
        this->m_Sfrozen = value;
    }
    else
        throw ModelException("SUR_GA", "SetValue", "Parameter " + sk
                                                   +
                                                   " does not exist in SUR_GA method. Please contact the module developer.");

}
示例#2
0
void Model::pushCommandOnUndoStack(UndoCommand* command)
{
	if ( !modificationInProgress )
		throw ModelException("Changing the application tree without calling Model.beginModification() first");
	if ( performedUndoRedo )
		throw ModelException("Trying to execute new commands after performing an Undo or a Redo operation.");

	if ( pushedNewCommandsOnTheStack == false )
	{
		pushedNewCommandsOnTheStack = true;
		commands.beginMacro(modificationText);
	}

	commands.push(command);
	if (command->target()) commands.push(new AddModifiedNode(modifiedTargets, command->target()));
}
示例#3
0
void Integer::load(PersistentStore &store)
{
	if (store.currentNodeType() != typeName())
		throw ModelException("Trying to load an Integer node from an incompatible node type " + store.currentNodeType());

	set(store.loadIntValue());
}
示例#4
0
void SUR_GA::initalOutputs()
{
    if (m_cellSize <= 0)
        throw ModelException("SUR_GA", "CheckInputData", "The dimension of the input data can not be less than zero.");
    // allocate the output variables
    if (this->m_PE == NULL)
    {
        this->m_PE = new float[this->m_cellSize];
    }
    if (this->m_INFIL == NULL)
    {
        this->m_INFIL = new float[this->m_cellSize];
    }
    // initialization
    for (int i = 0; i < m_cellSize; i++)
    {
        m_PE[i] = 0.0f;
        m_INFIL[i] = 0.0f;
    }

    if (this->m_w1 == NULL) initalW1W2();
    if (this->m_wfmp == NULL) this->initialWFMP();
    if (this->m_INFRate == NULL)
    {
        this->m_INFRate = new float[this->m_cellSize];
        for (int iCell = 0; iCell < m_cellSize; iCell++)
            this->m_INFRate[iCell] = 0.0f;
    }
}
示例#5
0
void Float::load(PersistentStore &store)
{
	if (store.currentNodeType() != typeName())
		throw ModelException("Trying to load a Float node from an incompatible node type " + store.currentNodeType());

	set(store.loadDoubleValue());
}
示例#6
0
Character::Character(Node *parent, PersistentStore &store, bool) :
	Node(parent)
{
	QString t = store.loadStringValue();
	if (t.size() != 1) throw ModelException("Creating character node failed. Invalid persistent store data: " + t);

	value = t[0];
}
示例#7
0
void Model::changeModificationTarget(Node* modificationTarget)
{
	if ( !modificationInProgress )
		throw ModelException("Switching modification targets without calling Model.beginModification() first");

	pushCommandOnUndoStack( new SetModificationTarget(currentModificationTarget, currentModificationLock,
			modifiedTargets, modificationTarget));
}
示例#8
0
bool UnsaturatedFlow::CheckInputSize(const char *key, int n) {
    if (n <= 0) {
        throw ModelException("UnsaturatedFlow", "CheckInputSize",
                             "Input data for " + string(key) + " is invalid. The size could not be less than zero.");
        return false;
    }
    if (this->m_cellSize != n) {
        if (this->m_cellSize <= 0) { this->m_cellSize = n; }
        else {
            throw ModelException("UnsaturatedFlow", "CheckInputSize", "Input data for " + string(key) +
                " is invalid. All the input data should have same size.");
            return false;
        }
    }

    return true;
}
示例#9
0
void Boolean::load(PersistentStore &store)
{
	if (store.currentNodeType() != typeName())
		throw ModelException("Trying to load an Boolean node from an incompatible node type " + store.currentNodeType());

	bool val = store.loadIntValue();
	set(val);
}
示例#10
0
bool ReservoirMethod::CheckInputSize(const char* key, int n)
{
	if(n<=0)
		throw ModelException("GWA_RE","CheckInputSize","Input data for "+string(key) +" is invalid. The size could not be less than zero.");

	if(m_nCells != n)
	{
		if(m_nCells <= 0) 
			m_nCells = n;
		else
		{
			throw ModelException("GWA_RE","CheckInputSize","Input data for "+string(key) +" is invalid. All the input data should have same size.");
		}
	}

	return true;
}
示例#11
0
void DepressionFSDaily::SetValue(const char *key, float data)
{
    string sk(key);
    if (StringMatch(sk, VAR_DEPREIN)) m_depCo = data;
    else if (StringMatch(sk, VAR_OMP_THREADNUM))omp_set_num_threads((int) data); 
    else
        throw ModelException(MID_DEP_LINSLEY, "SetValue", "Parameter " + sk + " does not exist.");
}
示例#12
0
文件: SOL_WB.cpp 项目: fannq/SEIMS
void SOL_WB::Set1DData(const char* key, int nRows, float* data)
{
	string s(key);
	if(StringMatch(s, Tag_SubbasinSelected))
	{
		m_subbasinSelected = data;
		m_subbasinSelectedCount = nRows;
		return;
	}

	if(StringMatch(s, VAR_T_RG))
	{
		m_RG = data;
		m_subbasinTotalCount = nRows;		

		return;
	}

	CheckInputSize(key,nRows);

	if(StringMatch(s, VAR_INLO))				
		m_Interception = data;
	else if(StringMatch(s, VAR_PRECI))			
		m_Precipitation = data;
	else if(StringMatch(s, VAR_INET))		
		m_EI = data;
	else if(StringMatch(s, VAR_DPST))		
		m_Depression = data;
	else if(StringMatch(s, VAR_DEET))		
		m_ED = data;	
	else if(StringMatch(s, VAR_INFIL))
		m_Infil = data;
	else if(StringMatch(s, VAR_SOET))	
		m_ES = data;
	else if(StringMatch(s, VAR_REVAP))		
		m_Revap = data;	
	else if(StringMatch(s, VAR_SURU))		
		m_RS = data;
	else if(StringMatch(s, VAR_T_RG))			
		m_RG = data;
	else if(StringMatch(s, VAR_SNSB))		
		m_SE = data;
	else if(StringMatch(s, VAR_TMIN))		
		m_tMin = data;	
	else if(StringMatch(s, VAR_TMAX))		
		m_tMax = data;	
	else if(StringMatch(s, VAR_SOTE))		
		m_SoilT = data;
	else if(StringMatch(s, VAR_SUBBSN))		
		m_subbasin = data;
	else if(StringMatch(s, VAR_SOILDEPTH))		
		m_Rootdepth = data;	
	else if(StringMatch(s, VAR_NEPR))	
		m_pNet = data;
	else
		throw ModelException("SOL_WB", "Set1DData", "Parameter " + s + " does not exist in the SOL_WB module.");

}
示例#13
0
文件: PER_PI.cpp 项目: fannq/SEIMS
bool PER_PI::CheckInputSize(const char* key, int n)
{
	if(n<=0)
	{
		throw ModelException(MID_PER_PI,"CheckInputSize","Input data for "+string(key) +" is invalid. The size could not be less than zero.");
		return false;
	}
	if(this->m_nCells != n)
	{
		if(this->m_nCells <=0) this->m_nCells = n;
		else
		{
			throw ModelException(MID_PER_PI,"CheckInputSize","Input data for "+string(key) +" is invalid. All the input data should have same size.");
			return false;
		}
	}
	return true;
}
示例#14
0
文件: IUH_OL.cpp 项目: crazyzlj/SEIMS
void IUH_OL::Set1DData(const char* key, const int n, float* data) {
    CheckInputSize(key, n);
    string sk(key);
    if (StringMatch(sk, VAR_SUBBSN)) m_subbsnID = data;
    else if (StringMatch(sk, VAR_SURU)) m_surfRf = data;
    else {
        throw ModelException(MID_IUH_OL, "Set1DData", "Parameter " + sk + " does not exist.");
    }
}
示例#15
0
文件: PER_PI.cpp 项目: fannq/SEIMS
void PER_PI::SetValue(const char* key, float data)
{
	string s(key);
	if(StringMatch(s, Tag_TimeStep))		m_dt = int(data);	
	else if(StringMatch(s, VAR_T_SOIL))		m_frozenT = data;
	else if (StringMatch(s, VAR_OMP_THREADNUM))omp_set_num_threads((int)data);
	else									
		throw ModelException(MID_PER_PI,"SetValue",
		    "Parameter " + s + " does not exist in current module. Please contact the module developer.");
}
示例#16
0
文件: SNO_SP.cpp 项目: crazyzlj/SEIMS
void SNO_SP::Get1DData(const char* key, int* n, float** data) {
    InitialOutputs();
    string s(key);
    if (StringMatch(s, VAR_SNME)) *data = m_snowMelt;
    else if (StringMatch(s, VAR_SNAC)) *data = m_snowAccum;
    else {
        throw ModelException(MID_SNO_SP, "Get1DData", "Result " + s + " does not exist.");
    }
    *n = m_nCells;
}
示例#17
0
文件: PER_PI.cpp 项目: fannq/SEIMS
void PER_PI::Get2DData(const char* key, int *nRows, int *nCols, float*** data)
{
	string sk(key);
	*nRows = m_nCells;
	*nCols = m_nSoilLayers;
	if (StringMatch(sk, VAR_PERCO))   *data = m_perc;
	else
		throw ModelException(MID_PER_PI, "Get2DData", "Output " + sk 
		+ " does not exist. Please contact the module developer.");
}
示例#18
0
文件: IUH_OL.cpp 项目: crazyzlj/SEIMS
void IUH_OL::Set2DData(const char* key, const int nRows, const int nCols, float** data) {
    string sk(key);
    if (StringMatch(sk, VAR_OL_IUH)) {
        CheckInputSize(VAR_OL_IUH, nRows);
        m_iuhCell = data;
        m_iuhCols = nCols;
    } else {
        throw ModelException(MID_IUH_OL, "Set2DData", "Parameter " + sk + " does not exist.");
    }
}
示例#19
0
void UnsaturatedFlow::SetValue(const char* key, float data)
{
	string s(key);
	if(StringMatch(s,"T_Soil"))				this->m_ForzenT = data;
	else if (StringMatch(s, "ThreadNum"))
	{
		omp_set_num_threads((int)data);
	}
	else									throw ModelException("UnsaturatedFlow","SetValue","Parameter " + s + " does not exist in UnsaturatedFlow method. Please contact the module developer.");
}
示例#20
0
文件: SNO_SP.cpp 项目: crazyzlj/SEIMS
void SNO_SP::Set1DData(const char* key, const int n, float* data) {
    CheckInputSize(key, n);
    string s(key);
    if (StringMatch(s, VAR_TMEAN)) m_meanTemp = data;
    else if (StringMatch(s, VAR_TMAX)) m_maxTemp = data;
    else if (StringMatch(s, VAR_NEPR)) m_netPcp = data;
    else {
        throw ModelException(MID_SNO_SP, "Set1DData", "Parameter " + s + " does not exist.");
    }
}
示例#21
0
文件: IUH_OL.cpp 项目: crazyzlj/SEIMS
void IUH_OL::GetValue(const char* key, float* value) {
    InitialOutputs();
    string sk(key);
    if (StringMatch(sk, VAR_SBOF) && m_inputSubbsnID > 0) {
        /// For MPI version to transfer data across subbasins
        *value = m_Q_SBOF[m_inputSubbsnID];
    } else {
        throw ModelException(MID_IUH_OL, "GetValue", "Result " + sk + " does not exist.");
    }
}
示例#22
0
bool clsPI_MSM::CheckInputData()
{
	if(this->m_date == -1)
	{
		throw ModelException("PI_MSM","CheckInputData","You have not set the time.");
		return false;
	}

	if(m_cellSize <= 0)
	{
		throw ModelException("PI_MSM","CheckInputData","The dimension of the input data can not be less than zero.");
		return false;
	}

	if(this->m_P == NULL)
	{
		throw ModelException("PI_MSM","CheckInputData","The precipitation data can not be NULL.");
		return false;
	}

	if(this->m_PET == NULL)
	{
		throw ModelException("PI_MSM","CheckInputData","The PET data can not be NULL.");
		return false;
	}

	if(this->m_maxSt == NULL)
	{
		throw ModelException("PI_MSM","CheckInputData","The maximum interception storage capacity can not be NULL.");
		return false;
	}

	if(this->m_minSt == NULL)
	{
		throw ModelException("PI_MSM","CheckInputData","The minimum interception storage capacity can not be NULL.");
		return false;
	}

	if(this->m_Pi_b > 1.5 || this->m_Pi_b < 0.5)
	{
		throw ModelException("PI_MSM","CheckInputData","The interception storage capacity exponent can not be " + clsPI_MSM::toString(this->m_Pi_b) + ". It should between 0.5 and 1.5.");
		return false;
	}

	if(this->m_Init_IS > 1 || this->m_Init_IS < 0)
	{
		throw ModelException("PI_MSM","CheckInputData","The Initial interception storage can not be " + clsPI_MSM::toString(this->m_Init_IS) + ". It should between 0 and 1.");
		return false;
	}

	return true;
}
示例#23
0
void UnsaturatedFlow::Get1DData(const char* key, int* nRows, float** data)
{
	string s(key);
	if(StringMatch(s,"SOET"))				
	{
		*data = this->m_D_SOET;
	}
	else									throw ModelException("UnsaturatedFlow","getResult","Result " + s + " does not exist in UnsaturatedFlow method. Please contact the module developer.");

	*nRows = this->m_cellSize;
}
示例#24
0
double LogNormalShadowing::compute_SINR(Node<>::node_ptr sender,
                                        Node<>::node_ptr receiver) throw(ModelException)  {
	float distance = sender->distance(* receiver.get());

    if (distance < this->d0) // the model is not valid within this distance
        throw ModelException("distance between nodes is below distance 0 (d0), "
                             "Log-Normal Shadowing model does not work");

    /* Pt - PL_d0 - 10 * eta * log10(d/d0) - X_sigma - Pn */
	return sender->get_txPower() - this->path_loss_d0 - 10 * this->path_loss * log10(distance / this->d0) - X_sigma() - this->background_noise;
}
示例#25
0
bool SNO_DD::CheckInputData(void)
{
	if(this->m_date <=0)			throw ModelException("SNO_DD","CheckInputData","You have not set the time.");
	if(m_nCells <= 0)				throw ModelException("SNO_DD","CheckInputData","The dimension of the input data can not be less than zero.");
	//if(this->m_kblow == -99)		throw ModelException("SNO_DD","CheckInputData","The fraction coefficient of snow blowing into or out of the watershed can not be NULL.");
	if(this->m_Pnet == NULL)		throw ModelException("SNO_DD","CheckInputData","The net precipitation data can not be NULL.");
	if(this->m_tMin == NULL)		throw ModelException("SNO_DD","CheckInputData","The min temperature data can not be NULL.");
	if(this->m_tMax == NULL)		throw ModelException("SNO_DD","CheckInputData","The max temperature data can not be NULL.");
	//if(this->m_SA == NULL)			throw ModelException("SNO_DD","CheckInputData","The snow accumulation data can not be NULL.");
	//if(this->m_SR == NULL)			throw ModelException("SNO_DD","CheckInputData","The snow redistribution data can not be NULL.");
	//if(this->m_SE == NULL)			throw ModelException("SNO_DD","CheckInputData","The snow sublimation data can not be NULL.");
	//if(this->m_swe == -99)			throw ModelException("SNO_DD","CheckInputData","The swe can not be -99.");
	if(this->m_swe0 == -99)			throw ModelException("SNO_DD","CheckInputData","The swe0 can not be -99.");
	if(this->m_csnow == -99)		throw ModelException("SNO_DD","CheckInputData","The temperature impact factor can not be -99.");
	if(this->m_crain == -99)		throw ModelException("SNO_DD","CheckInputData","The rainfall impact factor can not be -99.");
	if(this->m_t0 == -99)			throw ModelException("SNO_DD","CheckInputData","The Snowmelt temperature can not be -99.");
	if(this->m_tsnow == -99)		throw ModelException("SNO_DD","CheckInputData","The snow fall temperature can not be -99.");

	return true;
}
示例#26
0
void clsPI_MSM::SetValue(const char* key, float data)
{
	string s(key);
	if(StringMatch(s,"Pi_b"))				this->m_Pi_b = data;
	else if(StringMatch(s,"Init_IS"))		this->m_Init_IS = data;
	else if (StringMatch(s, "ThreadNum"))
	{
		omp_set_num_threads((int)data);
	}
	else									throw ModelException("PI_MSM","SetValue","Parameter " + s + " does not exist in PI_MSM method. Please contact the module developer.");
}
示例#27
0
文件: IUH_OL.cpp 项目: crazyzlj/SEIMS
void IUH_OL::SetValue(const char* key, const float value) {
    string sk(key);
    if (StringMatch(sk, Tag_TimeStep)) m_TimeStep = CVT_INT(value);
    else if (StringMatch(sk, Tag_CellSize)) m_nCells = CVT_INT(value);
    else if (StringMatch(sk, Tag_CellWidth)) m_CellWth = value;
    else if (StringMatch(sk, VAR_SUBBSNID_NUM)) m_nSubbsns = CVT_INT(value);
    else if (StringMatch(sk, Tag_SubbasinId)) m_inputSubbsnID = CVT_INT(value);
    else {
        throw ModelException(MID_IUH_OL, "SetValue", "Parameter " + sk + " does not exist.");
    }
}
示例#28
0
文件: PER_PI.cpp 项目: fannq/SEIMS
void PER_PI::Set1DData(const char* key, int nRows, float* data)
{
	string s(key);

	CheckInputSize(key,nRows);

	if(StringMatch(s,VAR_SOTE))	m_soilT = data;		
	else if(StringMatch(s,VAR_INFIL))	m_infil = data;	
	else									
		throw ModelException(MID_PER_PI,"Set1DData",
		    "Parameter " + s + " does not exist in current module. Please contact the module developer.");
}
示例#29
0
int clsRasterData::getPosition(float x,float y)
{	
	float xllCenter = m_headers["XLLCENTER"];
	float yllCenter = m_headers["YLLCENTER"];
	float dx = m_headers["CELLSIZE"];
	float dy = m_headers["CELLSIZE"];
	float nRows = m_headers["NROWS"];
	float nCols = m_headers["NCOLS"];

	float xmin = xllCenter - dx/2;
	float xMax = xmin + dx * nCols;
	if(x>xMax || x < xllCenter) throw ModelException("Raster","At","The x coordinate is beyond the scale!");

	float ymin = yllCenter - dy/2;
	float yMax = ymin + dy * nRows;
	if(y>yMax || y < yllCenter ) throw ModelException("Raster","At","The y coordinate is beyond the scale!");

	int nRow = (int)((yMax - y)/dy); //calculate form ymax
	int nCol = (int)((x - xmin)/dx); //calculate from xmin
	return getPosition(nRow,nCol);
}
示例#30
0
void clsPI_STORM::Get1DData(const char *key, int *n, float **data)
{
    string s(key);
    if (StringMatch(s, VAR_INLO)) *data = this->m_interceptionLoss;
        //else if(StringMatch(s,"INET"))			*data = this->m_evaporation;
    else if (StringMatch(s, VAR_NEPR)) *data = this->m_netPrecipitation;
    else
        throw ModelException(MID_PI_STORM, "Get1DData",
                             "Result " + s + " does not exist in current module. Please contact the module developer.");

    *n = this->m_nCells;
}