openstudio::TimeSeries ScheduleVariableInterval_Impl::timeSeries() const
  {
    unsigned numExtensibleGroups = this->numExtensibleGroups();
    if (numExtensibleGroups == 0){
      return TimeSeries(Date(MonthOfYear::Jan, 1), 0, Vector(), "");
    }

    DateTimeVector dateTimes;
    Vector values(numExtensibleGroups);
    unsigned i = 0;
    for (const ModelExtensibleGroup& group : castVector<ModelExtensibleGroup>(extensibleGroups()))
    {
      OptionalInt month = group.getInt(0);
      OptionalInt day = group.getInt(1);
      OptionalInt hour = group.getInt(2);
      OptionalInt minute = group.getInt(3);
      OptionalDouble x = group.getDouble(4);
      OS_ASSERT(month);
      OS_ASSERT(day);
      OS_ASSERT(hour);
      OS_ASSERT(minute);
      OS_ASSERT(x);
      dateTimes.push_back(DateTime(Date(MonthOfYear(*month), *day), Time(0, *hour, *minute)));
      values[i] = *x;
      ++i;
    }

    TimeSeries result(dateTimes, values, "");
    result.setOutOfRangeValue(this->outOfRangeValue());

    return result;
  }
void SchedulesTabController::setDstEndDayOfWeekAndMonth(int newWeek, int newDay, int newMonth)
{
  model::RunPeriodControlDaylightSavingTime dst =
    m_model.getUniqueModelObject<model::RunPeriodControlDaylightSavingTime>();

  dst.setEndDate(NthDayOfWeekInMonth(newWeek), DayOfWeek(newDay), MonthOfYear(newMonth));
}
Beispiel #3
0
  std::vector<openstudio::Date> ScheduleRule_Impl::specificDates() const
  {
    YearDescription yd = this->model().getUniqueModelObject<model::YearDescription>();

    std::vector<openstudio::Date> result;
    BOOST_FOREACH(const ModelExtensibleGroup& group,castVector<ModelExtensibleGroup>(extensibleGroups()))
    {
      OptionalInt month = group.getInt(0);
      BOOST_ASSERT(month);
      OptionalInt day = group.getInt(1);
      BOOST_ASSERT(day);

      result.push_back(yd.makeDate(MonthOfYear(*month), *day));
    }
Beispiel #4
0
  boost::optional<openstudio::Date> ScheduleRule_Impl::endDate() const
  {
    boost::optional<openstudio::Date> result;
    boost::optional<std::string> dateSpecificationType = this->getString(OS_Schedule_RuleFields::DateSpecificationType, true);
    BOOST_ASSERT(dateSpecificationType);
    if (istringEqual("DateRange", *dateSpecificationType)){
      boost::optional<int> endMonth = this->getInt(OS_Schedule_RuleFields::EndMonth, true);
      BOOST_ASSERT(endMonth);
      boost::optional<int> endDay = this->getInt(OS_Schedule_RuleFields::EndDay, true);
      BOOST_ASSERT(endDay);
      YearDescription yd = this->model().getUniqueModelObject<model::YearDescription>();
      result = yd.makeDate(MonthOfYear(*endMonth), *endDay);
    }

    return result;
  }
Beispiel #5
0
 BOOST_FOREACH(int endUse,endUses) {
   EndUseCategoryType category(endUse);
   row1.push_back(TableElement(category.valueDescription(),loadString));
   numMonths = 0;
   BOOST_FOREACH(int month,months) {
     OptionalDouble value = sqlFile.energyConsumptionByMonth(fuelType,category,MonthOfYear(month));
     if (!value) {
       row1.push_back(TableElement(0.0));
     }
     else {
       row1.push_back(TableElement(*value));
       allNull = false;
     }
     ++numMonths;
     if (numMonths == 12) {
       break;
     }
   }
Beispiel #6
0
Table monthlyEndUsesTable(const SqlFile& sqlFile,const EndUseFuelType& fuelType,const Unit& unit)
{
  Table result;
  result.setTitle(fuelType.valueDescription() + " Consumption");
  TableElementVector row1,row2;
  TableLoadOptions loadString(false,false,false);
  std::set<int> months = MonthOfYear::getValues();

  // set header rows
  row1.push_back(TableElement("",loadString));
  row2.push_back(TableElement("",loadString));
  int numMonths = 0;
  BOOST_FOREACH(int month,months) {
    row1.push_back(TableElement(MonthOfYear(month).valueName(),loadString));
    row2.push_back(TableElement("(J)",loadString));
    ++numMonths;
    if (numMonths == 12) {
      break;
    }
  }
Beispiel #7
0
void
MakeMotTitle ( char *title, char *dattim, char *product, char *level,
	       char *vlevel, char *label, char *location )
{
	char	buf[GEMPAKSTRING];
	char	time[20], day[4], imon[3], year[5], slash[2];
	char	*dayw, *month;
	int	len=FILENAMESTRING, iret;
	BooleanType	pdattim = False;

	strcpy ( title, " " );
	bpad ( title, len, &iret );
	strcpy ( title, " " );

/*
 *	Parse the input dattim string formatted as: YYYYMMDD/HHMM????? where
 *	the question marks (?) could represent model forecast time.
 */
	if ( dattim != NULL ) {
/*
 *	Write date/time to title as a dattim string.
 */
	    if ( pdattim ) {
		if ( strcmp ( dattim, "MISSING" ) != 0 )
	    	    strcat ( title, dattim );
	    }
/*
 *	Write date/time to title in components.
 */
	    else if ( strlen (dattim)>10 ) {
	    	sscanf ( dattim, "%4s%2s%2s%1s%s",
	                         year, imon, day, slash, time );
	    	dayw = DayOfWeek ( dattim );
	    	month = MonthOfYear ( str2int(imon) );;

		strcat ( title, dayw );
		strcat ( title, " " );
		strcat ( title, month );
		strcat ( title, " " );
		strcat ( title, day );
		strcat ( title, " " );
		strcat ( title, year );
		strcat ( title, " " );
		strcat ( title, time );

		Free ( dayw );
		Free ( month );
	    }
/*
 *	Date time is missing so don't write it to the title.
 */
	    else if ( strcmp ( dattim, "MISSING" ) == 0 )
		(void) 0;

/*
 *	Error check.
 */
	    else
	    	printf ("MakeMotTitle - input time is invalid\n");
	}

/*
 *	Write product ( or model ) to title.
 */
	if ( product != NULL ) {
	    strcat ( title, " " );
	    strcat ( title, product );
	}

/*
 *	Special case for level = 0, vcord = none
 */
	if ( level && vlevel &&
	     strncmp (level, "0", 1 ) == 0 &&
	   ( strncmp (vlevel, "NONE", 4 ) == 0 || strncmp (vlevel, "none", 4 ) == 0 )) {
	     strcat ( title, " (SFC)" );
	}
	else {
/*
 *	    Write vertical level to title.
 */
	    if ( level != NULL ) {
		strcat ( title, " (" );
		strcat ( title, level );
	    }

/*
 *	    Write vertical coordinate units to title.
 */
	    if ( vlevel != NULL ) {
		if ( level == NULL )
		    strcat ( title, " (" );
		else
		    strcat ( title, " " );
		strcat ( title, vlevel );
		strcat ( title, ")" );
	    }
	    else
		if ( level != NULL ) strcat ( title, ")" );
	}

/*
 *	Write label ( or model field ) to title.
 */
	if ( label != NULL ) {
	    strcat ( title, " " );
	    strcat ( title, label );
	}

/*
 *	Write station location to title.
 */
	if ( location != NULL ) {
	    sprintf ( buf, "%s%s%s", " (", location, ")" );
	    strcat ( title, buf );
	}
}