Example #1
0
//------------------------------------------------------------------------------
void WeatherManager::init(){
	if (!weather_climate) {
		weather_climate = new WeatherClimate();
	}
	enabled = (weather_climate && weather_climate->getEnabled());

    SeasonType season_type = SeasonType(weather_climate->getSeason());
    HumidityType humidity_type = HumidityType(weather_climate->getHumidity());

    int cloudiness = 0;
    //int fogginess = 20;
    //int wind_direction = 2;
    //float wind_speed = 1.0;
    bool is_snow = false;
    long cycle_max = 40000; // TODO: should be influenced by WeatherClimate settings

    if (season_type == WEATHER_SEASON_WINTER) is_snow=true;
    // Note: Likeliness of rain and clouds is not ONLY influenced by the
        // WeatherClimate setting, but is partly also random
        // the random part of both cloudiness and cycle_max is done in
        // ListWeatherClouds
    cloudiness = 10;
    // TODO: wind variables changes
      // ...
    if (humidity_type == WEATHER_HUMIDITY_NORMAL){
        cloudiness+=16;
    }
    else if(humidity_type == WEATHER_HUMIDITY_WET){
        cloudiness+=32;
    } // else DRY, stays
    if (season_type == WEATHER_SEASON_SUMMER){ // dryer in the summer
        cloudiness-=10;
    }
    else if (season_type == WEATHER_SEASON_AUTUNM){
        cloudiness+=10;
        //fogginess = 50; // TODO, fog
    }
    // ListWeatherCloud mustn't use WeatherClimate!
    list_weather_cloud = new ListWeatherCloud();
	if (list_weather_cloud) {
		list_weather_cloud->setSnow(is_snow);
		list_weather_cloud->logicClouds(cloudiness, cycle_max);
	}
}
Example #2
0
void
PeaksOverThresholdAttributes::SetFromNode(DataNode *parentNode)
{
    if(parentNode == 0)
        return;

    DataNode *searchNode = parentNode->GetNode("PeaksOverThresholdAttributes");
    if(searchNode == 0)
        return;

    DataNode *node;
    if((node = searchNode->GetNode("dataYearBegin")) != 0)
        SetDataYearBegin(node->AsInt());
    if((node = searchNode->GetNode("dataAnalysisYearRangeEnabled")) != 0)
        SetDataAnalysisYearRangeEnabled(node->AsBool());
    if((node = searchNode->GetNode("dataAnalysisYearRange")) != 0)
        SetDataAnalysisYearRange(node->AsIntArray());
    if((node = searchNode->GetNode("aggregation")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 3)
                SetAggregation(AggregationType(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            AggregationType value;
            if(AggregationType_FromString(node->AsString(), value))
                SetAggregation(value);
        }
    }
    if((node = searchNode->GetNode("annualPercentile")) != 0)
        SetAnnualPercentile(node->AsDouble());
    if((node = searchNode->GetNode("seasonalPercentile")) != 0)
        SetSeasonalPercentile(node->AsDoubleArray());
    if((node = searchNode->GetNode("monthlyPercentile")) != 0)
        SetMonthlyPercentile(node->AsDoubleArray());
    if((node = searchNode->GetNode("displaySeason")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 4)
                SetDisplaySeason(SeasonType(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            SeasonType value;
            if(SeasonType_FromString(node->AsString(), value))
                SetDisplaySeason(value);
        }
    }
    if((node = searchNode->GetNode("displayMonth")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 12)
                SetDisplayMonth(MonthType(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            MonthType value;
            if(MonthType_FromString(node->AsString(), value))
                SetDisplayMonth(value);
        }
    }
    if((node = searchNode->GetNode("cutoff")) != 0)
        SetCutoff(node->AsFloat());
    if((node = searchNode->GetNode("computeParamValues")) != 0)
        SetComputeParamValues(node->AsBool());
    if((node = searchNode->GetNode("computeCovariates")) != 0)
        SetComputeCovariates(node->AsBool());
    if((node = searchNode->GetNode("covariateReturnYears")) != 0)
        SetCovariateReturnYears(node->AsIntVector());
    if((node = searchNode->GetNode("covariateModelLocation")) != 0)
        SetCovariateModelLocation(node->AsBool());
    if((node = searchNode->GetNode("covariateModelShape")) != 0)
        SetCovariateModelShape(node->AsBool());
    if((node = searchNode->GetNode("covariateModelScale")) != 0)
        SetCovariateModelScale(node->AsBool());
    if((node = searchNode->GetNode("computeRVDifferences")) != 0)
        SetComputeRVDifferences(node->AsBool());
    if((node = searchNode->GetNode("rvDifferences")) != 0)
        SetRvDifferences(node->AsIntArray());
    if((node = searchNode->GetNode("dataScaling")) != 0)
        SetDataScaling(node->AsDouble());
    if((node = searchNode->GetNode("dumpData")) != 0)
        SetDumpData(node->AsBool());
}
void
ExtremeValueAnalysisAttributes::SetFromNode(DataNode *parentNode)
{
    if(parentNode == 0)
        return;

    DataNode *searchNode = parentNode->GetNode("ExtremeValueAnalysisAttributes");
    if(searchNode == 0)
        return;

    DataNode *node;
    if((node = searchNode->GetNode("dataYearBegin")) != 0)
        SetDataYearBegin(node->AsInt());
    if((node = searchNode->GetNode("dataAnalysisYearRangeEnabled")) != 0)
        SetDataAnalysisYearRangeEnabled(node->AsBool());
    if((node = searchNode->GetNode("dataAnalysisYear1")) != 0)
        SetDataAnalysisYear1(node->AsInt());
    if((node = searchNode->GetNode("dataAnalysisYear2")) != 0)
        SetDataAnalysisYear2(node->AsInt());
    if((node = searchNode->GetNode("ensemble")) != 0)
        SetEnsemble(node->AsBool());
    if((node = searchNode->GetNode("numEnsembles")) != 0)
        SetNumEnsembles(node->AsInt());
    if((node = searchNode->GetNode("dataScaling")) != 0)
        SetDataScaling(node->AsDouble());
    if((node = searchNode->GetNode("extremeMethod")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 2)
                SetExtremeMethod(ExtremeType(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            ExtremeType value;
            if(ExtremeType_FromString(node->AsString(), value))
                SetExtremeMethod(value);
        }
    }
    if((node = searchNode->GetNode("optimizationMethod")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 2)
                SetOptimizationMethod(OptimizationType(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            OptimizationType value;
            if(OptimizationType_FromString(node->AsString(), value))
                SetOptimizationMethod(value);
        }
    }
    if((node = searchNode->GetNode("aggregation")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 3)
                SetAggregation(AggregationType(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            AggregationType value;
            if(AggregationType_FromString(node->AsString(), value))
                SetAggregation(value);
        }
    }
    if((node = searchNode->GetNode("covariateModelScale")) != 0)
        SetCovariateModelScale(node->AsBool());
    if((node = searchNode->GetNode("covariateModelLocation")) != 0)
        SetCovariateModelLocation(node->AsBool());
    if((node = searchNode->GetNode("covariateModelShape")) != 0)
        SetCovariateModelShape(node->AsBool());
    if((node = searchNode->GetNode("computeReturnValues")) != 0)
        SetComputeReturnValues(node->AsBool());
    if((node = searchNode->GetNode("returnValues")) != 0)
        SetReturnValues(node->AsIntVector());
    if((node = searchNode->GetNode("computeRVDifferences")) != 0)
        SetComputeRVDifferences(node->AsBool());
    if((node = searchNode->GetNode("rvDifference1")) != 0)
        SetRvDifference1(node->AsInt());
    if((node = searchNode->GetNode("rvDifference2")) != 0)
        SetRvDifference2(node->AsInt());
    if((node = searchNode->GetNode("displayMonth")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 12)
                SetDisplayMonth(MonthType(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            MonthType value;
            if(MonthType_FromString(node->AsString(), value))
                SetDisplayMonth(value);
        }
    }
    if((node = searchNode->GetNode("displaySeason")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 4)
                SetDisplaySeason(SeasonType(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            SeasonType value;
            if(SeasonType_FromString(node->AsString(), value))
                SetDisplaySeason(value);
        }
    }
    if((node = searchNode->GetNode("computeParamValues")) != 0)
        SetComputeParamValues(node->AsBool());
    if((node = searchNode->GetNode("dumpData")) != 0)
        SetDumpData(node->AsBool());
    if((node = searchNode->GetNode("dumpDebug")) != 0)
        SetDumpDebug(node->AsBool());
}
Example #4
0
PeaksOverThresholdAttributes::SeasonType
PeaksOverThresholdAttributes::GetDisplaySeason() const
{
    return SeasonType(displaySeason);
}
ExtremeValueAnalysisAttributes::SeasonType
ExtremeValueAnalysisAttributes::GetDisplaySeason() const
{
    return SeasonType(displaySeason);
}