void PhaseEstimator::DoPhaseEstimation(RawWells *wells, Mask *mask, const ion::FlowOrder& flow_order, const vector<KeySequence>& keys, int region_size_x, int region_size_y, bool use_single_core) { flow_order_.SetFlowOrder(flow_order.str(), min(flow_order.num_flows(), 120)); keys_ = keys; chip_size_x_ = mask->W(); chip_size_y_ = mask->H(); region_size_x_ = region_size_x; region_size_y_ = region_size_y; printf("Phase estimation mode = %s\n", phasing_estimator_.c_str()); if (phasing_estimator_ == "override") { // Nothing to do! } else if (phasing_estimator_ == "spatial-refiner") { int num_workers = max(numCores(), 2); if (use_single_core) num_workers = 1; wells->Close(); wells->OpenForIncrementalRead(); SpatialRefiner(wells, mask, num_workers); } else if (phasing_estimator_ == "spatial-refiner-2") { int num_workers = max(numCores(), 2); if (use_single_core) num_workers = 1; wells->Close(); wells->OpenForIncrementalRead(); train_subset_count_ = 2; train_subset_cf_.resize(train_subset_count_); train_subset_ie_.resize(train_subset_count_); train_subset_dr_.resize(train_subset_count_); train_subset_regions_x_.resize(train_subset_count_); train_subset_regions_y_.resize(train_subset_count_); for (train_subset_ = 0; train_subset_ < train_subset_count_; ++train_subset_) { SpatialRefiner(wells, mask, num_workers); train_subset_cf_[train_subset_] = result_cf_; train_subset_ie_[train_subset_] = result_ie_; train_subset_dr_[train_subset_] = result_dr_; train_subset_regions_x_[train_subset_] = result_regions_x_; train_subset_regions_y_[train_subset_] = result_regions_y_; } } else ION_ABORT("Requested phase estimator is not recognized"); // Compute mean cf, ie, dr average_cf_ = 0; average_ie_ = 0; average_dr_ = 0; int count = 0; for (int r = 0; r < result_regions_x_*result_regions_y_; r++) { if (result_cf_[r] || result_ie_[r] || result_dr_[r]) { average_cf_ += result_cf_[r]; average_ie_ += result_ie_[r]; average_dr_ += result_dr_[r]; count++; } } if (count > 0) { average_cf_ /= count; average_ie_ /= count; average_dr_ /= count; } }
void PhaseEstimator::DoPhaseEstimation(RawWells *wells, Mask *mask, const ion::FlowOrder& flow_order, const vector<KeySequence>& keys, bool use_single_core) { // We only load / process what is necessary flow_order_.SetFlowOrder(flow_order.str(), min(flow_order.num_flows(), phasing_end_flow_+20)); keys_ = keys; // Do we have enough flows to do phase estimation? // Check and, if necessary, adjust flow interval for estimation, if (not have_phase_estimates_) { if (flow_order_.num_flows() < 50) { phasing_estimator_ = "override"; cout << "PhaseEstimator WARNING: Not enough flows to estimate phase; using default values." << endl; } else { // Make sure we have at least 30 flows to estimate over if (phasing_end_flow_ - phasing_start_flow_ < 30) { phasing_end_flow_ = min(phasing_start_flow_+30, flow_order_.num_flows()); phasing_start_flow_ = phasing_end_flow_ - 30; // We are guaranteed to have at least 50 flows cout << "PhaseEstimator WARNING: Shifting phase estimation window to flows " << phasing_start_flow_ << "-" << phasing_end_flow_ << endl; cerr << "PhaseEstimator WARNING: Shifting phase estimation window to flows " << phasing_start_flow_ << "-" << phasing_end_flow_ << endl; } // Check boundaries of estimation window and adjust if necessary, // try to keep estimation window size if possible, but don't start before flow 20 if (phasing_end_flow_ > flow_order_.num_flows()) { phasing_start_flow_ = max(20, (phasing_start_flow_ - phasing_end_flow_ + flow_order_.num_flows()) ); phasing_end_flow_ = flow_order_.num_flows(); cout << "PhaseEstimator WARNING: Shifting phase estimation window to flows " << phasing_start_flow_ << "-" << phasing_end_flow_ << endl; cerr << "PhaseEstimator WARNING: Shifting phase estimation window to flows " << phasing_start_flow_ << "-" << phasing_end_flow_ << endl; } } } // ------------------------------------ if (phasing_estimator_ == "override") { if (not have_phase_estimates_) SetPhaseParameters(init_cf_, init_ie_, init_dr_); } else if (phasing_estimator_ == "spatial-refiner") { int num_workers = max(numCores(), 2); if (use_single_core) num_workers = 1; wells->Close(); wells->OpenForIncrementalRead(); SpatialRefiner(wells, mask, num_workers); } else if (phasing_estimator_ == "spatial-refiner-2") { int num_workers = max(numCores(), 2); if (use_single_core) num_workers = 1; wells->Close(); wells->OpenForIncrementalRead(); train_subset_count_ = 2; train_subset_cf_.resize(train_subset_count_); train_subset_ie_.resize(train_subset_count_); train_subset_dr_.resize(train_subset_count_); train_subset_regions_x_.resize(train_subset_count_); train_subset_regions_y_.resize(train_subset_count_); for (train_subset_ = 0; train_subset_ < train_subset_count_; ++train_subset_) { SpatialRefiner(wells, mask, num_workers); train_subset_cf_[train_subset_] = result_cf_; train_subset_ie_[train_subset_] = result_ie_; train_subset_dr_[train_subset_] = result_dr_; train_subset_regions_x_[train_subset_] = result_regions_x_; train_subset_regions_y_[train_subset_] = result_regions_y_; } } else ION_ABORT("Requested phase estimator is not recognized"); // Compute mean cf, ie, dr average_cf_ = 0; average_ie_ = 0; average_dr_ = 0; int count = 0; for (int r = 0; r < result_regions_x_*result_regions_y_; r++) { if (result_cf_.at(r) || result_ie_.at(r) || result_dr_.at(r)) { average_cf_ += result_cf_[r]; average_ie_ += result_ie_[r]; average_dr_ += result_dr_[r]; count++; } } if (count > 0) { average_cf_ /= count; average_ie_ /= count; average_dr_ /= count; } have_phase_estimates_ = true; }