//---------------------------------------------------------
void CWaterRetentionCapacity::Get_WaterRetention(CSG_Matrix &Data, double fC, CSG_Shape *pPoint)
{
	int		i;

	double	fWRC = 0, fPerm = 0, fHe = 0, fK = 0, fCCC = 0, fCIL = 0, fTotalDepth = 0;

	CSG_Vector	CCC (Data.Get_NRows());
	CSG_Vector	CIL (Data.Get_NRows());
	CSG_Vector	K   (Data.Get_NRows());
	CSG_Vector	Perm(Data.Get_NRows());
	CSG_Vector	He  (Data.Get_NRows());
	CSG_Vector	CRA (Data.Get_NRows());

	for(i=0; i<Data.Get_NRows(); i++)
	{
		CCC [i]	= Get_CCC(Data[i]);
		CIL [i]	= Get_CIL(Data[i]);
		He  [i]	= Get_He (Data[i]);

		Perm[i]	= Get_Permeability(CCC[i], CIL[i]);

		if( i > 0 )
		{
			K[i] = Get_K(Perm[i - 1], Perm[i], fC);
		}

		CRA[i]	= (double)((12.5 * He[i] + 12.5 * (50. - He[i]) * K[i] / 2.) * Data[i][1] / 100.);

		fTotalDepth	+= Data[i][0];
	}

	for(i=0; i<Data.Get_NRows(); i++)
	{
		fWRC	+= Data[i][0] / fTotalDepth * CRA [i];
		fCCC	+= Data[i][0] / fTotalDepth * CCC [i];
		fCIL	+= Data[i][0] / fTotalDepth * CIL [i];
		fPerm	+= Data[i][0] / fTotalDepth * Perm[i];
		fHe		+= Data[i][0] / fTotalDepth * He  [i];
		fK		+= Data[i][0] / fTotalDepth * K   [i];
	}

	pPoint->Set_Value(0, fCCC );
	pPoint->Set_Value(1, fCIL );
	pPoint->Set_Value(2, fPerm);
	pPoint->Set_Value(3, fHe  );
	pPoint->Set_Value(4, fWRC );
}
예제 #2
0
//---------------------------------------------------------
bool CWindeffect_Correction::Fit_Scaling_Factor(int x, int y, double &B, double B_min, double B_max, double B_Step)
{
	CSG_Simple_Statistics	Statistics[3];

	CSG_Matrix	Data;

	if( !Get_Data(x, y, Data, Statistics[OBS]) )
	{
		return( false );
	}

	//-----------------------------------------------------
	double	dMin	= -1.0;

	for(double iB=B_min; iB<=B_max; iB+=B_Step)
	{
		int	i;

		Statistics[COR].Create(true);	// reset

		for(i=0; i<Data.Get_NRows(); i++)
		{
			Statistics[COR]	+= Get_Wind_Corr(iB, Data[i][BND], Data[i][WND]);
		}

		Statistics[VAL].Create(false);	// reset

		for(i=0; i<Data.Get_NRows(); i++)
		{
			Statistics[VAL]	+= Statistics[OBS].Get_Mean() * Statistics[COR].Get_Value(i) / Statistics[COR].Get_Mean();
		}

		double	d	= fabs(Statistics[VAL].Get_StdDev() - Statistics[OBS].Get_StdDev());

		if( dMin < 0.0 || dMin > d )
		{
			B		= iB;
			dMin	= d;
		}
	}

	return( dMin >= 0.0 );
}
예제 #3
0
//---------------------------------------------------------
Ptr<TrainData> COpenCV_ML_ANN::Get_Training(const CSG_Matrix &Data)
{
	Mat	Samples (Data.Get_NRows(), Data.Get_NCols() - 1 , CV_32F);
	Mat	Response(Data.Get_NRows(), Get_Class_Count()    , CV_32F);

	for(int i=0; i<Data.Get_NRows(); i++)
	{
		int	j, k	= (int)Data[i][Data.Get_NCols() - 1];

		for(j=0; j<Response.cols; j++)
		{
			Response.at<float>(i, j)	= j == k ? 1.f : 0.f;
		}

		for(j=0; j<Samples.cols; j++)
		{
			Samples.at<float>(i, j)	= (float)Data[i][j];
		}
	}

	return( TrainData::create(Samples, ROW_SAMPLE, Response) );
}
예제 #4
0
//---------------------------------------------------------
bool CSG_mRMR::Set_Data(CSG_Matrix &Data, int ClassField, double Threshold)
{
    if( !Get_Memory(Data.Get_NCols(), Data.Get_NRows()) )
    {
        return( false );
    }

    //-----------------------------------------------------
    if( ClassField < 0 || ClassField >= m_nVars )
    {
        ClassField	= 0;
    }

    for(int iSample=0; iSample<m_nSamples; iSample++)
    {
        double	*pData	= m_Samples[iSample] = m_Samples[0] + iSample * m_nVars;

        *pData++	= Data[iSample][ClassField];

        for(int iVar=0; iVar<m_nVars; iVar++)
        {
            if( iVar != ClassField )
            {
                *pData++	= Data[iSample][iVar];
            }
        }
    }

    m_VarNames	+= "CLASS";

    for(int iVar=0; iVar<m_nVars; iVar++)
    {
        if( iVar != ClassField )
        {
            m_VarNames	+= CSG_String::Format(SG_T("FEATURE_%02d"), iVar);
        }
    }

    //-----------------------------------------------------
    if( Threshold >= 0.0 )	// discretization
    {
        Discretize(Threshold);
    }

    return( true );
}