namespace WBSF
{

	const int CHourlyDatabase::VERSION = 1;
	const char* CHourlyDatabase::XML_FLAG = "HourlyDatabase";
	const char* CHourlyDatabase::DATABASE_EXT = ".HourlyDB";
	const char* CHourlyDatabase::OPT_EXT = ".Hzop";
	const char* CHourlyDatabase::DATA_EXT = ".csv";
	const char* CHourlyDatabase::META_EXT = ".HourlyHdr.csv";
	const CTM CHourlyDatabase::DATA_TM = CTM(CTM::HOURLY);

	ERMsg CHourlyDatabase::CreateDatabase(const std::string& filePath)
	{
		ERMsg msg;

		CHourlyDatabase DB;
		msg = DB.Open(filePath, modeWrite);
		if (msg)
		{
			DB.Close();
			ASSERT(FileExists(filePath));
		}

		return msg;
	}


	//stategy to get static method
	int CHourlyDatabase::GetVersion(const std::string& filePath){ return ((CDHDatabaseBase&)CHourlyDatabase()).GetVersion(filePath); }
	ERMsg CHourlyDatabase::DeleteDatabase(const std::string&  outputFilePath, CCallback& callback){ return ((CDHDatabaseBase&)CHourlyDatabase()).DeleteDatabase(outputFilePath, callback); }
	//ERMsg CHourlyDatabase::AppendDatabase(const std::string& inputFilePath1, const std::string& inputFilePath2, CCallback& callback){ return ((CDHDatabaseBase&)CHourlyDatabase()).AppendDatabase(inputFilePath1, inputFilePath2, callback); }
	ERMsg CHourlyDatabase::RenameDatabase(const std::string& inputFilePath, const std::string& outputFilePath, CCallback& callback){ return ((CDHDatabaseBase&)CHourlyDatabase()).RenameDatabase(inputFilePath, outputFilePath, callback); }

}
void laydata::tdtdesign::openGL_draw(const layprop::DrawProperties& drawprop) {
   if (_target.checkedit()) {
      ctmstack transtack;
      transtack.push(CTM());
      _target.view()->openGL_draw(transtack, drawprop, _target.iscell());
   }
}
void GDSin::gds2ted::aref(GDSin::GDSaref* wd, laydata::tdtcell* dst) {
   if (NULL != _dst_lib->checkcell(wd->GetStrname())) {
      laydata::refnamepair striter = _dst_lib->getcellnamepair(wd->GetStrname());
      // Absolute magnification, absolute angle should be reflected somehow!!!

      laydata::ArrayProperties arrprops(wd->Get_Xstep(),wd->Get_Ystep(),
                                 static_cast<word>(wd->Get_colnum()),
                                 static_cast<word>(wd->Get_rownum()));
      dst->addcellaref(_dst_lib,
         striter, 
         CTM( wd->GetMagn_point(), 
              wd->GetMagnification(), 
              wd->GetAngle(),
              (0 != wd->GetReflection()) ),
         arrprops,
         false
      );
   }
   else {
      std::string news = "Referenced structure \"";
      news += wd->GetStrname(); news += "\" not found. Reference ignored";
      tell_log(console::MT_ERROR,news);
   }
   // How about structures defined, but not parsed yet????
}
	void CGypsyMothStability::ExecuteWithoutGeneration()
	{
		//Set global class variables
		CGypsyMoth::SetApplyMortality(false);

		bool bViability = true;

		CGMEggParam eggParamTmp = m_eggParam;

		for (size_t y = 0; y < m_weather.GetNbYears() - 1 && bViability; y++)
		{
			//CTPeriod p(m_weather[y].GetFirstTRef(), m_weather[y + 1].GetLastTRef());
			CTPeriod p(m_weather[y].GetEntireTPeriod(CTM::DAILY).Begin(), m_weather[y + 1].GetEntireTPeriod(CTM::DAILY).End());

			//simulate developement
			CGypsyMoth gypsyMoth(m_hatchModelType, eggParamTmp);
			gypsyMoth.SimulateDeveloppement(m_weather, p);

			bViability = gypsyMoth.GetViabilityFlag();
			eggParamTmp.m_ovipDate = gypsyMoth.GetNewOvipDate();;
		}

		//Output data
		COutputVector stat(1, CTRef(0, 0, 0, 0, CTM(CTRef::ANNUAL, CTRef::OVERALL_YEARS)));
		stat[0][0] = bViability ? 1 : 0;
		SetOutput(stat);


	}
	CTM CAnalysisHowPage::GetTM()
	{
		short TType = m_TTTypeCtrl.GetCurItemData();
		short TMode = m_TTModeCtrl.GetCurItemData();

		return CTM(TType, TMode);// (TType != -1 && TMode != -1) ? CTRef::GetTM(TType, TMode) : CTRef::GetTM(CTRef::ANNUAL, CTRef::FOR_EACH_YEAR);
	}
//This method is call to compute solution
ERMsg CYHSSModel::OnExecuteDaily()
{
    ERMsg msg;

    //	if (!m_weather.IsHourly() )
    //m_weather.ComputeHourlyVariables();

    static const double THRESHOLD = 0;

    CDegreeDays DD(CDegreeDays::DAILY_AVERAGE, THRESHOLD);


    CYHSSStatVector stat(m_weather.GetEntireTPeriod(CTM(CTM::DAILY)));

    for (size_t y = 0; y < m_weather.size(); y++)
    {
        CTPeriod p = m_weather[y].GetEntireTPeriod();

        double tot_adult[366] = { 0 };
        double dd = 0;
        double cum_adult = 0;

        for (size_t jd = 0; jd < 90; jd++)
        {
            CTRef TRef = p.Begin() + jd;
            stat[TRef][O_L1] = 100;
            stat[TRef][O_AI] = 1;
        }

        for (size_t jd = 89; jd < m_weather[y].GetNbDays(); jd++)
        {
            CTRef TRef = p.Begin() + jd;
            const CWeatherDay& wDay = m_weather.GetDay(TRef);
            dd += DD.GetDD(wDay);

            double freq[9] = { 0 };
            double ai = ComputeStageFrequencies(dd, freq);

            //		adults alive
            tot_adult[jd] = freq[0];
            cum_adult += (tot_adult[jd] - tot_adult[jd - m_adultLongevity]) / m_adultLongevity;


            stat[TRef][O_DEGREE_DAY] = dd;

            stat[TRef][O_ADULT] = freq[0];
            stat[TRef][O_TRAP_CATCH] = cum_adult;

            for (size_t i = 0; i < 6; i++)
                stat[TRef][O_L1 + i] = freq[i + 3];

            stat[TRef][O_AI] = ai;
        }
    }

    SetOutput(stat);

    return msg;
}
void laydata::tdtdesign::tmp_draw(const layprop::DrawProperties& drawprop,
                                          TP base, TP newp) {
   ctmqueue tmp_stack;
   if (_tmpdata) {
      glColor4f(1.0, 1.0, 1.0, 0.7);
      tmp_stack.push_front(CTM(newp - base,1,0,false));
      _tmpdata->tmp_draw(drawprop, tmp_stack,NULL,true);
   }
   else if ((drawprop.currentop() != layprop::op_none) && _target.checkedit()) {
      base *= _target.rARTM();
      newp *= _target.rARTM();
      tmp_stack.push_front(CTM(_target.ARTM()));
      tmp_stack.push_front(CTM(newp - base,1,0,false)*_target.ARTM());
      _target.edit()->tmp_draw(drawprop, tmp_stack, true);
      tmp_stack.clear();
   }   
}
void GDSin::gds2ted::text(GDSin::GDStext* wd, laydata::tdtcell* dst) {
   laydata::tdtlayer* wl = static_cast<laydata::tdtlayer*>
                                       (dst->securelayer(wd->GetLayer()));
   // @FIXME absolute magnification, absolute angle should be reflected somehow!!!
   wl->addtext(wd->GetText(), 
               CTM(wd->GetMagn_point(), 
                   wd->GetMagnification() / (_dst_lib->UU() *  OPENGL_FONT_UNIT),
                   wd->GetAngle(),wd->GetReflection()));
}
Beispiel #9
0
CTM laydata::TEDfile::getCTM() 
{
   real _a  = getReal();
   real _b  = getReal();
   real _c  = getReal();
   real _d  = getReal();
   real _tx = getReal();
   real _ty = getReal();
   return CTM(_a, _b, _c, _d, _tx, _ty);
}
void GDSin::Gds2Ted::text(GDSin::GdsText* wd, laydata::tdtlayer* wl)
{
   // @FIXME absolute magnification, absolute angle should be reflected somehow!!!
   wl->addtext(wd->text(),
               CTM(wd->magnPoint(),
                   wd->magnification() / ((*_tdt_db)()->UU() *  OPENGL_FONT_UNIT),
                   wd->angle(),
                   (0 != wd->reflection()) )
              );
}
Beispiel #11
0
void laydata::tdtdesign::tmp_draw(const layprop::DrawProperties& drawprop,
                                          TP base, TP newp) {
   ctmqueue tmp_stack;
   glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
   if (_tmpdata)
   {
      glColor4f((GLfloat)1.0, (GLfloat)1.0, (GLfloat)1.0, (GLfloat)0.7);
      tmp_stack.push_front(CTM(newp - base,1,0,false));
      _tmpdata->tmp_draw(drawprop, tmp_stack,NULL,true);
   }
   else if ((drawprop.currentop() != console::op_none) && _target.checkedit())
   {
      if ((console::op_copy == drawprop.currentop()) || (console::op_move == drawprop.currentop()))
      {
         base *= _target.rARTM();
         newp *= _target.rARTM();
         tmp_stack.push_front(CTM(_target.ARTM()));
         tmp_stack.push_front(CTM(newp - base,1,0,false)*_target.ARTM());
      }
      else if ((console::op_flipX == drawprop.currentop()) || (console::op_flipY == drawprop.currentop()))
      {
         CTM newpos = _target.ARTM();
         tmp_stack.push_front(newpos);
         if (console::op_flipX == drawprop.currentop())
            newpos.FlipX(newp.y());
         else
            newpos.FlipY(newp.x());
         tmp_stack.push_front(newpos);
      }
      else if (console::op_rotate == drawprop.currentop())
      {
         CTM newpos = _target.ARTM();
         tmp_stack.push_front(_target.ARTM());
         newpos.Translate(-newp.x(),-newp.y());
         newpos *= _tmpctm;
         newpos.Translate(newp.x(),newp.y());
         tmp_stack.push_front(newpos);
      }
      _target.edit()->tmp_draw(drawprop, tmp_stack, true);
      tmp_stack.clear();
   }
   glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
}
	void CModelOutputVariableDef::Reset()
	{
		m_name.clear();
		m_title.clear();
		m_units.clear();
		m_description.clear();
		m_TM = CTM(CTM::ATEMPORAL, CTM::FOR_EACH_YEAR);
		m_precision = 4;
		m_equation.clear();
		m_climaticVariable = UNKNOWN_POS;

	}
Beispiel #13
0
void laydata::tdtdesign::tmp_draw(const layprop::DrawProperties& drawprop,
                                          TP base, TP oldp, TP newp, bool first) {
   ctmqueue tmp_stack;
   if (_tmpdata) {
      glColor4f(0.5, 0.5, 0.5, 0.5);
      if (!first) {
         // after window repaint, old position is not redrawn
         tmp_stack.push_front(CTM(oldp - base,1,0,false));
         _tmpdata->tmp_draw(drawprop, tmp_stack, NULL, true);
      }   
      tmp_stack.push_front(CTM(newp - base,1,0,false));
      _tmpdata->tmp_draw(drawprop, tmp_stack,NULL,true);
   }
   else if ((drawprop.currentop() != layprop::op_none) && _target.checkedit()) {
      base *= _target.rARTM();
      newp *= _target.rARTM();
      if (!first) {
         // after window repaint, old position is not redrawn
         oldp *= _target.rARTM();
         tmp_stack.push_front(CTM(_target.ARTM()));
         tmp_stack.push_front(CTM(oldp - base,1,0,false)*_target.ARTM());
         _target.edit()->tmp_draw(drawprop, tmp_stack, true);
         tmp_stack.clear();
      }   
      tmp_stack.push_front(CTM(_target.ARTM()));
      tmp_stack.push_front(CTM(newp - base,1,0,false)*_target.ARTM());
      _target.edit()->tmp_draw(drawprop, tmp_stack, true);
      tmp_stack.clear();
   }   
}
	void CGypsyMothStability::ExecuteWithGeneration()
	{
		//Set global class variables
		CGypsyMoth::SetApplyMortality(false);


		std::vector<bool> bViability(m_weather.GetNbYears() - 1, false);

		for (size_t y = 0; y < m_weather.GetNbYears() - 1; y++)
		{
			//init parameter and ovipisition for the current year
			CGMEggParam eggParamTmp = m_eggParam;
			eggParamTmp.m_ovipDate.m_year = m_weather[y].GetTRef().GetYear();

			bViability[y] = true;
			bool bStabilized = false;

			for (int g = 0; g < m_nbGenerations&& bViability[y] && !bStabilized; g++)
			{
				CTPeriod p(m_weather[y].GetEntireTPeriod(CTM::DAILY).Begin(), m_weather[y + 1].GetEntireTPeriod(CTM::DAILY).End());
				//simulate developement
				CGypsyMoth gypsyMoth(m_hatchModelType, eggParamTmp);
				gypsyMoth.SimulateDeveloppement(m_weather, p);


				if (gypsyMoth.GetViabilityFlag())
				{
					//Get stability and new oviposition date
					CTRef newOvipDate = gypsyMoth.GetNewOvipDate();
					bStabilized = newOvipDate.GetJDay() == eggParamTmp.m_ovipDate.GetJDay();
					eggParamTmp.m_ovipDate.SetJDay(newOvipDate.GetJDay());
				}
				else
				{
					//the model for this year is not viable
					bViability[y] = false;
				}
			}
		}

		//compute viability
		int nbValid = 0;
		for (size_t i = 0; i < bViability.size(); i++)
			if (bViability[i])
				nbValid++;

		COutputVector stat(1, CTRef(0, 0, 0, 0, CTM(CTRef::ANNUAL, CTRef::OVERALL_YEARS) ));
		stat[0][0] = (double)nbValid / bViability.size();
		SetOutput(stat);


	}
void GDSin::Gds2Ted::ref(GDSin::GdsRef* wd, laydata::tdtcell* dst)
{
   // Absolute magnification, absolute angle should be reflected somehow!!!
   laydata::refnamepair striter = linkcellref(wd->strName());
   dst->addcellref(
                    (*_tdt_db)(),
                      striter,
                      CTM(wd->magnPoint(),
                         wd->magnification(),
                         wd->angle(),
                         (0 != wd->reflection()) ),
                      false
   );
}
void CIFin::Cif2Ted::lbll( CIFin::CifLabelLoc* wd, laydata::tdtlayer* wl, std::string )
{
   // CIF doesn't have a concept of texts (as GDS)
   // text size and placement are just the default
   if (0.0 == _techno) return;
   TP pnt(*(wd->location()));
   pnt *= _crosscoeff;
   wl->addtext(wd->text(),
               CTM(pnt,
                   (_techno / OPENGL_FONT_UNIT),
                   0.0,
                   false )
              );
}
Beispiel #17
0
int tellstdfunc::getPOINT::execute() {
   // Here - try a hollow lock/unlock the database just to check that it exists
   // The use of this function should be deprecated
   DATC->lockDB();
   DATC->unlockDB();
   // flag the prompt that we expect a single point & handle a pointer to
   // the operand stack
   Console->waitGUInput(&OPstack, console::op_point, CTM());
   // force the thread in wait condition until the ted_prompt has our data
   Console->threadWaits4->Wait();
   // ... and continue when the thread is woken up
   if (Console->mouseIN_OK())  return EXEC_NEXT;
   else return EXEC_RETURN;
}
Beispiel #18
0
bool laydata::tdtdesign::group_selected(std::string name, laydata::tdtlibdir* libdir) {
   // first check that the cell with this name does not exist already
   if (_cells.end() != _cells.find(name)) {
      tell_log(console::MT_ERROR, "Cell with this name already exists. Group impossible");
      return false;
   }
   //unlink the fully selected shapes from the quadTree of the current cell
   atticList* TBgroup = _target.edit()->groupPrep(libdir);
   if (TBgroup->empty()) {
      tell_log(console::MT_WARNING, "Nothing to group");
      delete TBgroup; return false;
   }
   //Create a new cell
   tdtcell* newcell = addcell(name);
   assert(newcell);
   //Get the selected shapes from the current cell and add them to the new cell
   for(atticList::const_iterator CL = TBgroup->begin();
                                                   CL != TBgroup->end(); CL++) {
      shapeList* lslct = CL->second;
      quadTree* wl = newcell->securelayer(CL->first);
      // There is no point here to ensure that the layer definition exists.
      // We are just transfering shapes from one structure to another.
      // ATDB->securelaydef( CL->first );
      securelaydef( CL->first );
      for(shapeList::const_iterator CI = lslct->begin();
                                                     CI != lslct->end(); CI++) {
         wl->put(*CI);
         if (0 == CL->first) newcell->addchild(this,
                                    static_cast<tdtcellref*>(*CI)->structure());
      }
      lslct->clear();
      delete (lslct);
   }
   TBgroup->clear();delete TBgroup;
   newcell->resort();
   //reference the new cell into the current one.
   tdtdata* ref = _target.edit()->addcellref(this,
                                    getcellnamepair(name),CTM(TP(0,0),1,0,false));
   //select the new cell
   ref->set_status(sh_selected);
   _target.edit()->select_this(ref,0);
   //Just for the records. No shapes are moved to the Attic during this operation
   //Undo is possible simply by ungrouping the new cell
   return true;
}
	void CAnalysisHowPage::FillMode(short t)
	{
		WBSF::StringVector MODE_NAME = Tokenize(GetString(IDS_CMN_TIME_FORMAT_DATAHEAD1), ";|");

		int curSel = m_TTModeCtrl.GetCurItemData();
		m_TTModeCtrl.ResetContent();

		for (int m = 0; m < CTM::NB_MODE; m++)
		{
			if (m_sourceTM.IsModeAvailable(CTM(t, m)))
			{
				int pos = m_TTModeCtrl.AddString(MODE_NAME[m].c_str());
				m_TTModeCtrl.SetItemData(pos, m);
			}
		}

		m_TTModeCtrl.SelectFromItemData(curSel);
	}
Beispiel #20
0
bool laydata::tdtdesign::editpush(const TP& pnt) {
   if (_target.checkedit()) {//
      ctmstack transtack;
      transtack.push(CTM());
      laydata::cellrefstack* crstack = DEBUG_NEW laydata::cellrefstack();
      tdtcell* oldtvcell = _target.view();
      // Find the new active reference
      laydata::tdtcellref *new_activeref =
                      oldtvcell->getcellover(pnt,transtack,crstack,_target.viewprop());
      if (new_activeref) {
         // Set the new active reference and the chain to it
         _target.push(new_activeref,oldtvcell,crstack,transtack.top());
         return true;
      }
      else
         delete crstack;
   }
   return false;
}
void GDSin::Gds2Ted::aref(GDSin::GdsARef* wd, laydata::tdtcell* dst)
{
   // Absolute magnification, absolute angle should be reflected somehow!!!
   laydata::refnamepair striter = linkcellref(wd->strName());

   laydata::ArrayProperties arrprops(wd->getXStep(),wd->getYStep(),
                                     static_cast<word>(wd->columns()),
                                     static_cast<word>(wd->rows()));
   dst->addcellaref(
                     (*_tdt_db)(),
                       striter,
                       CTM( wd->magnPoint(),
                            wd->magnification(),
                            wd->angle(),
                            (0 != wd->reflection()) ),
                       arrprops,
                       false
   );
}
Beispiel #22
0
int tellstdfunc::stdCELLAREF_D::execute() {
   real        stepY = getOpValue();
   real        stepX = getOpValue();
   word        row   = getWordValue();
   word        col   = getWordValue();
   std::string name  = getStringValue();
   
   // check that target cell exists - otherwise tmp_draw can't obviously work.
   // there is another more extensive check when the cell is added, there the circular
   // references are checked as well 
   laydata::tdtdesign* ATDB = DATC->lockDB(false);
   laydata::tdtcell *excell = static_cast<laydata::tdtcell*>(ATDB->checkcell(name));
   DATC->unlockDB();
   if (NULL == excell)
   {
      std::string news = "Can't find cell \"";
      news += name; news += "\" ";
      tell_log(console::MT_ERROR,news);
      return EXEC_ABORT;
   }
   
   real DBscale = DATC->DBscale();
   int4b istepX = (int4b)rint(stepX * DBscale);
   int4b istepY = (int4b)rint(stepY * DBscale);
   
   // stop the thread and wait for input from the GUI
   if (!tellstdfunc::waitGUInput(console::op_abind, &OPstack, name, CTM(), istepX, istepY,col,row))
      return EXEC_ABORT;
   // get the data from the stack
   telldata::ttbnd *bnd = static_cast<telldata::ttbnd*>(OPstack.top());OPstack.pop();

   OPstack.push(DEBUG_NEW telldata::ttstring(name));
   OPstack.push(DEBUG_NEW telldata::ttpnt(bnd->p()));
   OPstack.push(DEBUG_NEW telldata::ttreal(bnd->rot()));
   OPstack.push(DEBUG_NEW telldata::ttbool(bnd->flx()));
   OPstack.push(DEBUG_NEW telldata::ttreal(bnd->sc()));
   OPstack.push(DEBUG_NEW telldata::ttint(col));
   OPstack.push(DEBUG_NEW telldata::ttint(row));
   OPstack.push(DEBUG_NEW telldata::ttreal(stepX));
   OPstack.push(DEBUG_NEW telldata::ttreal(stepY));
   delete bnd;
   return stdCELLAREF::execute();
}
	ERMsg CClimaticModel::OnExecuteAnnual()
	{
		ERMsg msg;

		CTPeriod p = m_weather.GetEntireTPeriod(CTM(CTM::ANNUAL));
		m_output.Init(p, NB_ANNUAL_STATS, -9999);

		for (size_t y = 0; y < m_weather.GetNbYears(); y++)
		{
			double annualMinimum = m_weather[y][H_TMIN2][LOWEST];
			double annualMinMean = m_weather[y][H_TMIN2][MEAN];
			double annualMean = m_weather[y][H_TAIR2][MEAN];
			double annualMaxMean = m_weather[y][H_TMAX2][MEAN];
			double annualMaximum = m_weather[y][H_TMAX2][HIGHEST];
			double annualPpt = m_weather[y][H_PRCP][SUM];
			double annualSun = m_weather[y][H_SRMJ][SUM];//H_SRAD)[SUM];
			double annualSnow = m_weather[y][H_SNOW][SUM];
			double Tdew = m_weather[y][H_TDEW][MEAN];
			double relHum = m_weather[y][H_RELH][MEAN];
			double wnds = m_weather[y][H_WNDS][MEAN];

			double frostDay = GetNbFrostDay(m_weather[y]);
			size_t NBDayWithPrcp = GetNbDayWithPrcp(m_weather[y]);
			size_t NBDayWithoutPrcp = m_weather[y].size() - NBDayWithPrcp;

			m_output[y][ANNUAL_LOWEST_TMIN] = annualMinimum;
			m_output[y][ANNUAL_MEAN_TMIN] = annualMinMean;
			m_output[y][ANNUAL_MEAN_TMEAN] = annualMean;
			m_output[y][ANNUAL_MEAN_TMAX] = annualMaxMean;
			m_output[y][ANNUAL_HIGHEST_TMAX] = annualMaximum;
			m_output[y][ANNUAL_PPT] = annualPpt;
			m_output[y][ANNUAL_MEAN_TDEW] = Tdew;
			m_output[y][ANNUAL_MEAN_REL_HUM] = relHum;
			m_output[y][ANNUAL_MEAN_WNDS] = wnds;
			m_output[y][ANNUAL_FROST_DAY] = frostDay;
			m_output[y][ANNUAL_SUN] = annualSun;
		}

	

		return msg;
	}
	ERMsg CClimaticModel::OnExecuteMonthly()
	{
		ERMsg msg;

		CTPeriod p = m_weather.GetEntireTPeriod(CTM(CTM::MONTHLY));
		m_output.Init(p, NB_MONTHLY_STATS, -9999);

		for (size_t y = 0; y<m_weather.GetNbYears(); y++)
		{
			for (size_t m = 0; m<12; m++)
			{

				double monthlyMinimum = m_weather[y][m][H_TMIN2][LOWEST];
				double monthlyMinMean = m_weather[y][m][H_TMIN2][MEAN];
				double monthlyMean = m_weather[y][m][H_TAIR2][MEAN];
				double monthlyMaxMean = m_weather[y][m][H_TMAX2][MEAN];
				double monthlyMaximum = m_weather[y][m][H_TMAX2][HIGHEST];
				double monthlyPpt = m_weather[y][m][H_PRCP][SUM];
				double monthlySun = m_weather[y][m][H_SRMJ][SUM];
				double Tdew = m_weather[y][m].GetStat(H_TDEW)[MEAN];
				double relHum = m_weather[y][m].GetStat(H_RELH)[MEAN];
				double wnds = m_weather[y][m].GetStat(H_WNDS)[MEAN];
				double frostDay = GetNbFrostDay(m_weather[y][m]);


				m_output[y * 12 + m][MONTHLY_LOWEST_TMIN] = monthlyMinimum;
				m_output[y * 12 + m][MONTHLY_MEAN_TMIN] = monthlyMinMean;
				m_output[y * 12 + m][MONTHLY_MEAN_TMEAN] = monthlyMean;
				m_output[y * 12 + m][MONTHLY_MEAN_TMAX] = monthlyMaxMean;
				m_output[y * 12 + m][MONTHLY_HIGHEST_TMAX] = monthlyMaximum;
				m_output[y * 12 + m][MONTHLY_PPT] = monthlyPpt;
				m_output[y * 12 + m][MONTHLY_MEAN_TDEW] = Tdew;
				m_output[y * 12 + m][MONTHLY_MEAN_REL_HUM] = relHum;
				m_output[y * 12 + m][MONTHLY_MEAN_WNDS] = wnds;
				m_output[y * 12 + m][MONTHLY_FROST_DAY] = frostDay;
				m_output[y * 12 + m][MONTHLY_SUN] = monthlySun;
			}
		}


		return msg;
	}
void GDSin::gds2ted::ref(GDSin::GDSref* wd, laydata::tdtcell* dst) {
   if (NULL != _dst_lib->checkcell(wd->GetStrname())) {
      laydata::refnamepair striter = _dst_lib->getcellnamepair(wd->GetStrname());
      // Absolute magnification, absolute angle should be reflected somehow!!!
      dst->addcellref(_dst_lib,
                   striter, 
                   CTM(wd->GetMagn_point(), 
                   wd->GetMagnification(),
                   wd->GetAngle(),
                   wd->GetReflection()),
                   false
      );
   }
   else {
      std::string news = "Referenced structure \"";
      news += wd->GetStrname(); news += "\" not found. Reference ignored";
      tell_log(console::MT_ERROR,news);
   }
   // How about structures defined, but not parsed yet????
}
	ERMsg CClimaticModel::OnExecuteDaily()
	{
		ERMsg msg;

		CTPeriod p = m_weather.GetEntireTPeriod(CTM(CTM::DAILY));
		m_output.Init(p, NB_DAILY_STATS, -9999);

		for (size_t y = 0; y<m_weather.size(); y++)
		{
			for (size_t m = 0; m<m_weather[y].size(); m++)
			{
				for (size_t d = 0; d<m_weather[y][m].size(); d++)
				{
					const CWeatherDay& wDay = m_weather[y][m][d];

					double Tmin = wDay[H_TMIN2][MEAN];
					double Tmean = wDay[H_TAIR2][MEAN];
					double Tmax = wDay[H_TMAX2][MEAN];
					double ppt = wDay[H_PRCP][SUM] >= 0.1 ? wDay[H_PRCP][SUM] : 0;

					double Tdew = wDay[H_TDEW][MEAN];
					double relHum = wDay[H_RELH][MEAN];
					double wnds = wDay[H_WNDS][MEAN];
					double srad = wDay[H_SRAD2][MEAN];

					CTRef ref = m_weather[y][m][d].GetTRef();

					m_output[ref][DAILY_TMIN] = Tmin;
					m_output[ref][DAILY_TMEAN] = Tmean;
					m_output[ref][DAILY_TMAX] = Tmax;
					m_output[ref][DAILY_PPT] = ppt;
					m_output[ref][DAILY_MEAN_TDEW] = Tdew;
					m_output[ref][DAILY_MEAN_REL_HUM] = relHum;
					m_output[ref][DAILY_MEAN_WNDS] = wnds;
					m_output[ref][DAILY_SUN] = srad;
				}
			}
		}

		return msg;
	}
Beispiel #27
0
int tellstdfunc::getPOINTLIST::execute() {
   // Here - try a hollow lock/unlock the database just to check that it exists
   // The use of this function should be deprecated
   DATC->lockDB();
   DATC->unlockDB();
   // flag the prompt that we expect a list of points & handle a pointer to
   // the operand stack
   Console->waitGUInput(&OPstack, console::op_dpoly, CTM());
   // 
   wxCommandEvent eventMOUSEIN(wxEVT_MOUSE_INPUT);
   eventMOUSEIN.SetInt(-1);
   eventMOUSEIN.SetExtraLong(1);
   wxPostEvent(TopedCanvasW, eventMOUSEIN);
   // force the thread in wait condition until the ted_prompt has our data
   Console->threadWaits4->Wait();
   // ... and continue when the thread is woken up
   eventMOUSEIN.SetExtraLong(0);
   wxPostEvent(TopedCanvasW, eventMOUSEIN);
   if (Console->mouseIN_OK())  return EXEC_NEXT;
   else return EXEC_RETURN;
}
Beispiel #28
0
void trend::TrendBase::setRmm(const CTM& mm)
{
    _rmm = DEBUG_NEW CTM(mm.Reversed());
}