/** * Build any runtime relationships we may have and ensure * the labels for other objects are valid. */ void ProcessRemovalsByLength::DoBuild() { partition_ = CombinedCategoriesPtr(new niwa::partition::accessors::CombinedCategories(model_, category_labels_)); cached_partition_ = CachedCombinedCategoriesPtr(new niwa::partition::accessors::cached::CombinedCategories(model_, category_labels_)); // if (ageing_error_label_ != "") // LOG_CODE_ERROR() << "ageing error has not been implemented for the proportions at age observation"; length_results_.resize(number_bins_ * category_labels_.size(), 0.0); auto time_step = model_->managers().time_step()->GetTimeStep(time_step_label_); if (!time_step) { LOG_FATAL_P(PARAM_TIME_STEP)<< time_step_label_ << " could not be found. Have you defined it?"; } else { auto process = time_step->SubscribeToProcess(this, years_, process_label_); mortality_instantaneous_ = dynamic_cast<MortalityInstantaneous*>(process); } if (!mortality_instantaneous_) LOG_ERROR_P(PARAM_PROCESS) << "This observation can only be used for Process of type = " << PARAM_MORTALITY_INSTANTANEOUS; // Need to split the categories if any are combined for checking vector<string> temp_split_category_labels, split_category_labels; for (const string& category_label : category_labels_) { boost::split(temp_split_category_labels, category_label, boost::is_any_of("+")); for (const string& split_category_label : temp_split_category_labels) { split_category_labels.push_back(split_category_label); } } // Need to make this a vector so its compatible with the function couldn't be bothered templating sorry vector<string> methods; methods.push_back(method_); // Do some checks so that the observation and process are compatible if (!mortality_instantaneous_->check_methods_for_removal_obs(methods)) LOG_ERROR_P(PARAM_METHOD_OF_REMOVAL) << "could not find all these methods in the instantaneous_mortality process labeled " << process_label_ << " please check that the methods are compatible with this process"; if (!mortality_instantaneous_->check_categories_in_methods_for_removal_obs(methods, split_category_labels)) LOG_ERROR_P(PARAM_CATEGORIES) << "could not find all these categories in the instantaneous_mortality process labeled " << process_label_ << " please check that the categories are compatible with this process"; if (!mortality_instantaneous_->check_years_in_methods_for_removal_obs(years_, methods)) LOG_ERROR_P(PARAM_YEARS) << "could not find catches in all years in the instantaneous_mortality process labeled " << process_label_ << " please check that the years are compatible with this process"; }
/** * Build any runtime relationships we may have and ensure * the labels for other objects are valid. */ void ProportionsMigrating::DoBuild() { partition_ = CombinedCategoriesPtr(new niwa::partition::accessors::CombinedCategories(model_, category_labels_)); cached_partition_ = CachedCombinedCategoriesPtr(new niwa::partition::accessors::cached::CombinedCategories(model_, category_labels_)); // Create a pointer to misclassification matrix if( ageing_error_label_ != "") { ageing_error_ = model_->managers().ageing_error()->GetAgeingError(ageing_error_label_); if (!ageing_error_) LOG_ERROR_P(PARAM_AGEING_ERROR) << "(" << ageing_error_label_ << ") could not be found. Have you defined it?"; } age_results_.resize(age_spread_ * category_labels_.size(), 0.0); TimeStep* time_step = model_->managers().time_step()->GetTimeStep(time_step_label_); if (!time_step) { LOG_FATAL_P(PARAM_TIME_STEP) << time_step_label_ << " could not be found. Have you defined it?"; } else time_step->SubscribeToProcess(this, years_, process_label_); }
/** * Build runtime relationships between this object and other objects. * Build any data objects that need to be built. */ void Cinitial::DoBuild() { LOG_TRACE(); time_steps_ = model_->managers().time_step()->ordered_time_steps(); // Create Category and cached category pointers partition_ = CombinedCategoriesPtr(new niwa::partition::accessors::CombinedCategories(model_, category_labels_)); cached_partition_ = CachedCombinedCategoriesPtr(new niwa::partition::accessors::cached::CombinedCategories(model_, category_labels_)); // Create derived quantity pointers unsigned i = 0; for (auto derived_quantities : derived_quanitity_) { if (derived_quantities != "") { derived_ptr_.push_back(model_->managers().derived_quantity()->GetDerivedQuantity(derived_quantities)); if (!derived_ptr_[i]) { LOG_ERROR() << "Cannot find " << derived_quantities; } } ++i; } }