TEST_F(TestCalibratorPhase, useWetbulb) { FileFake file(1,1,1,1); FieldPtr phase = file.getField(Variable::Phase, 0); ParameterFile parFile = getParameterFile(273.7,274.7); CalibratorPhase cal = getCalibrator(&parFile); setValues(file, 5, 275, 0.5, 101325); cal.setUseWetbulb(false); cal.calibrate(file); EXPECT_FLOAT_EQ(Variable::PhaseRain, (*phase)(0,0,0)); cal.setUseWetbulb(true); cal.calibrate(file); EXPECT_FLOAT_EQ(Variable::PhaseSnow, (*phase)(0,0,0)); setValues(file, 5, 274, 0.5, 101325); cal.setUseWetbulb(false); cal.calibrate(file); EXPECT_FLOAT_EQ(Variable::PhaseSleet, (*phase)(0,0,0)); cal.setUseWetbulb(true); cal.calibrate(file); EXPECT_FLOAT_EQ(Variable::PhaseSnow, (*phase)(0,0,0)); }
Calibrator* Calibrator::getScheme(std::string iName, const Options& iOptions) { if(iName == "zaga") { std::string variable; if(!iOptions.getValue("variable", variable)) { Util::error("Calibrator 'zaga' needs variable"); } CalibratorZaga* c = new CalibratorZaga(Variable::getType(variable), iOptions); return c; } else if(iName == "cloud") { std::string variable; if(!iOptions.getValue("variable", variable)) { Util::error("Calibrator 'cloud' needs variable"); } CalibratorCloud* c = new CalibratorCloud(Variable::getType(variable), iOptions); return c; } else if(iName == "accumulate") { std::string variable; if(!iOptions.getValue("variable", variable)) { Util::error("Calibrator 'accumulate' needs variable"); } CalibratorAccumulate* c = new CalibratorAccumulate(Variable::getType(variable), iOptions); return c; } else if(iName == "gaussian") { std::string variable; if(!iOptions.getValue("variable", variable)) { Util::error("Calibrator 'gaussian' needs variable"); } CalibratorGaussian* c = new CalibratorGaussian(Variable::getType(variable), iOptions); return c; } else if(iName == "neighbourhood") { std::string variable; if(!iOptions.getValue("variable", variable)) { Util::error("Calibrator 'neighbourhood' needs variable"); } CalibratorNeighbourhood* c = new CalibratorNeighbourhood(Variable::getType(variable), iOptions); return c; } else if(iName == "phase") { CalibratorPhase* c = new CalibratorPhase(iOptions); float minPrecip; if(iOptions.getValue("minPrecip", minPrecip)) { c->setMinPrecip(minPrecip); } bool useWetbulb; if(iOptions.getValue("useWetbulb", useWetbulb)) { c->setUseWetbulb(useWetbulb); } return c; } else if(iName == "windDirection") { std::string variable; if(!iOptions.getValue("variable", variable)) { Util::error("Calibrator 'windDirection' needs variable"); } CalibratorWindDirection* c = new CalibratorWindDirection(Variable::getType(variable), iOptions); return c; } else if(iName == "kriging") { std::string variable; if(!iOptions.getValue("variable", variable)) { Util::error("Calibrator 'kriging' needs variable"); } CalibratorKriging* c = new CalibratorKriging(Variable::getType(variable), iOptions); return c; } else if(iName == "diagnose") { std::string variable; if(!iOptions.getValue("variable", variable)) { Util::error("Calibrator 'diagnose' needs variable"); } CalibratorDiagnose* c = new CalibratorDiagnose(Variable::getType(variable), iOptions); return c; } else if(iName == "window") { std::string variable; if(!iOptions.getValue("variable", variable)) { Util::error("Calibrator 'window' needs variable"); } CalibratorWindow* c = new CalibratorWindow(Variable::getType(variable), iOptions); return c; } else if(iName == "qc") { std::string variable; if(!iOptions.getValue("variable", variable)) { Util::error("Calibrator 'qc' needs variable"); } CalibratorQc* c = new CalibratorQc(Variable::getType(variable), iOptions); return c; } else if(iName == "qnh") { CalibratorQnh* c = new CalibratorQnh(iOptions); return c; } else if(iName == "qq") { std::string variable; if(!iOptions.getValue("variable", variable)) { Util::error("Calibrator 'regression' needs variable"); } CalibratorQq* c = new CalibratorQq(Variable::getType(variable), iOptions); return c; } else if(iName == "regression") { std::string variable; if(!iOptions.getValue("variable", variable)) { Util::error("Calibrator 'regression' needs variable"); } CalibratorRegression* c = new CalibratorRegression(Variable::getType(variable), iOptions); return c; } else if(iName == "bct") { std::string variable; if(!iOptions.getValue("variable", variable)) { Util::error("Calibrator 'bct' needs variable"); } CalibratorBct* c = new CalibratorBct(Variable::getType(variable), iOptions); return c; } else if(iName == "sort") { std::string variable; if(!iOptions.getValue("variable", variable)) { Util::error("Calibrator 'sort' needs variable"); } CalibratorSort* c = new CalibratorSort(Variable::getType(variable), iOptions); return c; } else if(iName == "altitude") { CalibratorAltitude* c = new CalibratorAltitude(iOptions); return c; } else { Util::error("Could not instantiate calibrator with name '" + iName + "'"); return NULL; } }