bool RasterInfo::save( QString imgFileName ) { bool returnValue = false; if( !imgFileName.isNull() ) { fileName = imgFileName; parseFileName(); } try { RasterXML r; r.setAuthorName( aName.toAscii() ); r.setAuthorCompany( aCompany.toAscii() ); r.setAuthorEmail( aEmail.toAscii() ); r.setUlCorner( ulx, uly ); r.setRows( row ); r.setCols( col ); r.setSigned( signd ); r.setBits( bits ); r.setDataType( datatype.toAscii() ); r.setPixelSize( pixsize ); r.setFillValue( fillval ); r.setNoDataValue( noval ); r.setHasFillValue( hasFillVal ); r.setHasNoDataValue( hasNoDataVal ); r.setProjNumber( projcode ); r.setProjName( projNames[projcode].toAscii() ); r.setZone( zonecode ); r.setDatumNumber( datumcode ); r.setDatumName( spheroidNames[datumcode].toAscii() ); r.setUnitsNumber( unitcode ); r.setUnitsName( unitNames[unitcode].toAscii() ); char variation = 'a'; if( projcode == 8 && gctpParams[8] == 1 ) variation = 'b'; if( ( projcode == 20 || projcode == 22 ) && gctpParams[12] == 1 ) variation = 'b'; QStringList paramNames( gctpNames(projcode, variation) ); for( int i = 0; i < 15; ++i ) r.setParam( i, gctpParams[i], nameMeanings(paramNames[i]).toAscii() ); returnValue = r.save( QString( fileName + ".xml" ).toAscii() ); } catch( XMLException exception ) { QMessageBox::critical( NULL, "Error", exception.getMessage() ); returnValue = false; } return returnValue; }
void uqAppl(const QUESO::BaseEnvironment& env) { if (env.fullRank() == 0) { std::cout << "Beginning run of 'uqTgaExample' example\n" << std::endl; } //int iRC; struct timeval timevalRef; struct timeval timevalNow; //****************************************************** // Task 1 of 5: instantiation of basic classes //****************************************************** // Instantiate the parameter space std::vector<std::string> paramNames(2,""); paramNames[0] = "A_param"; paramNames[1] = "E_param"; QUESO::VectorSpace<QUESO::GslVector,QUESO::GslMatrix> paramSpace(env,"param_",paramNames.size(),¶mNames); // Instantiate the parameter domain QUESO::GslVector paramMinValues(paramSpace.zeroVector()); paramMinValues[0] = 2.40e+11; paramMinValues[1] = 1.80e+05; QUESO::GslVector paramMaxValues(paramSpace.zeroVector()); paramMaxValues[0] = 2.80e+11; paramMaxValues[1] = 2.20e+05; QUESO::BoxSubset<QUESO::GslVector,QUESO::GslMatrix> paramDomain("param_", paramSpace, paramMinValues, paramMaxValues); // Instantiate the qoi space std::vector<std::string> qoiNames(1,""); qoiNames[0] = "TimeFor25PercentOfMass"; QUESO::VectorSpace<QUESO::GslVector,QUESO::GslMatrix> qoiSpace(env,"qoi_",qoiNames.size(),&qoiNames); // Instantiate the validation cycle QUESO::ValidationCycle<QUESO::GslVector,QUESO::GslMatrix,QUESO::GslVector,QUESO::GslMatrix> cycle(env, "", // No extra prefix paramSpace, qoiSpace); //******************************************************** // Task 2 of 5: calibration stage //******************************************************** /*iRC = */gettimeofday(&timevalRef, NULL); if (env.fullRank() == 0) { std::cout << "Beginning 'calibration stage' at " << ctime(&timevalRef.tv_sec) << std::endl; } // Inverse problem: instantiate the prior rv QUESO::UniformVectorRV<QUESO::GslVector,QUESO::GslMatrix> calPriorRv("cal_prior_", // Extra prefix before the default "rv_" prefix paramDomain); // Inverse problem: instantiate the likelihood Likelihood<> calLikelihood("cal_like_", paramDomain, "inputData/scenario_5_K_min.dat", "inputData/scenario_25_K_min.dat", "inputData/scenario_50_K_min.dat"); // Inverse problem: instantiate it (posterior rv is instantiated internally) cycle.instantiateCalIP(NULL, calPriorRv, calLikelihood); // Inverse problem: solve it, that is, set 'pdf' and 'realizer' of the posterior rv QUESO::GslVector paramInitialValues(paramSpace.zeroVector()); if (env.numSubEnvironments() == 1) { // For regression test purposes paramInitialValues[0] = 2.41e+11; paramInitialValues[1] = 2.19e+05; } else { calPriorRv.realizer().realization(paramInitialValues); } QUESO::GslMatrix* calProposalCovMatrix = cycle.calIP().postRv().imageSet().vectorSpace().newProposalMatrix(NULL,¶mInitialValues); cycle.calIP().solveWithBayesMetropolisHastings(NULL, paramInitialValues, calProposalCovMatrix); delete calProposalCovMatrix; // Forward problem: instantiate it (parameter rv = posterior rv of inverse problem; qoi rv is instantiated internally) double beta_prediction = 250.; double criticalMass_prediction = 0.; double criticalTime_prediction = 3.9; qoiRoutine_Data calQoiRoutine_Data; calQoiRoutine_Data.m_beta = beta_prediction; calQoiRoutine_Data.m_criticalMass = criticalMass_prediction; calQoiRoutine_Data.m_criticalTime = criticalTime_prediction; cycle.instantiateCalFP(NULL, qoiRoutine, (void *) &calQoiRoutine_Data); // Forward problem: solve it, that is, set 'realizer' and 'cdf' of the qoi rv cycle.calFP().solveWithMonteCarlo(NULL); // no extra user entities needed for Monte Carlo algorithm /*iRC = */gettimeofday(&timevalNow, NULL); if (env.fullRank() == 0) { std::cout << "Ending 'calibration stage' at " << ctime(&timevalNow.tv_sec) << "Total 'calibration stage' run time = " << timevalNow.tv_sec - timevalRef.tv_sec << " seconds\n" << std::endl; } //******************************************************** // Task 3 of 5: validation stage //******************************************************** /*iRC = */gettimeofday(&timevalRef, NULL); if (env.fullRank() == 0) { std::cout << "Beginning 'validation stage' at " << ctime(&timevalRef.tv_sec) << std::endl; } // Inverse problem: no need to instantiate the prior rv (= posterior rv of calibration inverse problem) // Inverse problem: instantiate the likelihood function object Likelihood<> valLikelihood("val_like_", paramDomain, "inputData/scenario_100_K_min.dat", NULL, NULL); // Inverse problem: instantiate it (posterior rv is instantiated internally) cycle.instantiateValIP(NULL,valLikelihood); // Inverse problem: solve it, that is, set 'pdf' and 'realizer' of the posterior rv const QUESO::SequentialVectorRealizer<QUESO::GslVector,QUESO::GslMatrix>* tmpRealizer = dynamic_cast< const QUESO::SequentialVectorRealizer<QUESO::GslVector,QUESO::GslMatrix>* >(&(cycle.calIP().postRv().realizer())); QUESO::GslMatrix* valProposalCovMatrix = cycle.calIP().postRv().imageSet().vectorSpace().newProposalMatrix(&tmpRealizer->unifiedSampleVarVector(), // Use 'realizer()' because post. rv was computed with MH &tmpRealizer->unifiedSampleExpVector()); // Use these values as the initial values cycle.valIP().solveWithBayesMetropolisHastings(NULL, tmpRealizer->unifiedSampleExpVector(), valProposalCovMatrix); delete valProposalCovMatrix; // Forward problem: instantiate it (parameter rv = posterior rv of inverse problem; qoi rv is instantiated internally) qoiRoutine_Data valQoiRoutine_Data; valQoiRoutine_Data.m_beta = beta_prediction; valQoiRoutine_Data.m_criticalMass = criticalMass_prediction; valQoiRoutine_Data.m_criticalTime = criticalTime_prediction; cycle.instantiateValFP(NULL, qoiRoutine, (void *) &valQoiRoutine_Data); // Forward problem: solve it, that is, set 'realizer' and 'cdf' of the qoi rv cycle.valFP().solveWithMonteCarlo(NULL); // no extra user entities needed for Monte Carlo algorithm /*iRC = */gettimeofday(&timevalNow, NULL); if (env.fullRank() == 0) { std::cout << "Ending 'validation stage' at " << ctime(&timevalNow.tv_sec) << "Total 'validation stage' run time = " << timevalNow.tv_sec - timevalRef.tv_sec << " seconds\n" << std::endl; } //******************************************************** // Task 4 of 5: comparison stage //******************************************************** /*iRC = */gettimeofday(&timevalRef, NULL); if (env.fullRank() == 0) { std::cout << "Beginning 'comparison stage' at " << ctime(&timevalRef.tv_sec) << std::endl; } uqAppl_LocalComparisonStage(cycle); if (env.numSubEnvironments() > 1) { uqAppl_UnifiedComparisonStage(cycle); } /*iRC = */gettimeofday(&timevalNow, NULL); if (env.fullRank() == 0) { std::cout << "Ending 'comparison stage' at " << ctime(&timevalNow.tv_sec) << "Total 'comparison stage' run time = " << timevalNow.tv_sec - timevalRef.tv_sec << " seconds\n" << std::endl; } //****************************************************** // Task 5 of 5: release memory before leaving routine. //****************************************************** if (env.fullRank() == 0) { std::cout << "Finishing run of 'uqTgaExample' example" << std::endl; } return; }