bool GibbsTrackingFilter< ItkQBallImageType >::LoadParameters() { m_AbortTracking = true; try { if( m_LoadParameterFile.length()==0 ) { m_AbortTracking = false; return true; } MITK_INFO << "GibbsTrackingFilter: loading parameter file " << m_LoadParameterFile; TiXmlDocument doc( m_LoadParameterFile ); doc.LoadFile(); TiXmlHandle hDoc(&doc); TiXmlElement* pElem; TiXmlHandle hRoot(0); pElem = hDoc.FirstChildElement().Element(); hRoot = TiXmlHandle(pElem); pElem = hRoot.FirstChildElement("parameter_set").Element(); string iterations(pElem->Attribute("iterations")); m_Iterations = boost::lexical_cast<unsigned long>(iterations); string particleLength(pElem->Attribute("particle_length")); m_ParticleLength = boost::lexical_cast<float>(particleLength); string particleWidth(pElem->Attribute("particle_width")); m_ParticleWidth = boost::lexical_cast<float>(particleWidth); string partWeight(pElem->Attribute("particle_weight")); m_ParticleWeight = boost::lexical_cast<float>(partWeight); string startTemp(pElem->Attribute("temp_start")); m_StartTemperature = boost::lexical_cast<float>(startTemp); string endTemp(pElem->Attribute("temp_end")); m_EndTemperature = boost::lexical_cast<float>(endTemp); string inExBalance(pElem->Attribute("inexbalance")); m_InexBalance = boost::lexical_cast<float>(inExBalance); string fiberLength(pElem->Attribute("fiber_length")); m_MinFiberLength = boost::lexical_cast<float>(fiberLength); string curvThres(pElem->Attribute("curvature_threshold")); m_CurvatureThreshold = cos(boost::lexical_cast<float>(curvThres)*M_PI/180); m_AbortTracking = false; MITK_INFO << "GibbsTrackingFilter: parameter file loaded successfully"; return true; } catch(...) { MITK_INFO << "GibbsTrackingFilter: could not load parameter file"; return false; } }
void Wave::createAnimation() { float /*origin_x, origin_y,*/ distance, height, ripple_interval = 1.3; fillCubeArray(0x00); // QVector<QVector<QVector<quint8> > > tripleVector(iterations(),QVector<QVector<quint8> >(8, QVector<quint8>(8))); for (quint16 i=0; i<iterations(); i++) { if(m_abort) return; for (quint8 x=0; x<8; x++) { for (quint8 y=0; y<8; y++) { distance = distance2d(3.5,3.5,x,y)/9.899495*8; height = 4+sin(distance/ripple_interval+static_cast<float>(i)/50)*4; setBixel(x,y,static_cast<quint8>(height)); } } waitMs(speed()); // tripleVector[i] = cubeFrame; fillCubeArray(0x00); } // for (int i = 0; i < iterations(); i++) { // sendData(tripleVector[i]); //// if(i/10 == 0) //// waitMs(speed()); // } Q_EMIT done(); }
void DilateTest::testManual0() { m_operator->setParameter(Dilate::PARAMETER_DATA_FLOW, runtime::Enum(Dilate::MANUAL)); m_operator->initialize(); m_operator->activate(); runtime::DataContainer src(new cvsupport::Image("lenna.jpg")); runtime::DataContainer dst(new cvsupport::Image(1000000)); runtime::UInt32 ksizex(3); runtime::UInt32 ksizey(4); runtime::Enum shape(1); runtime::UInt32 iterations(2); m_operator->setInputData(Dilate::INPUT_SRC, src); m_operator->setInputData(Dilate::INPUT_DST, dst); m_operator->setParameter(Dilate::PARAMETER_KSIZEX, ksizex); m_operator->setParameter(Dilate::PARAMETER_KSIZEY, ksizey); m_operator->setParameter(Dilate::PARAMETER_SHAPE, shape); m_operator->setParameter(Dilate::PARAMETER_ITERATIONS, iterations); runtime::DataContainer dstResult = m_operator->getOutputData(Dilate::OUTPUT_DST); runtime::ReadAccess dstAccess(dstResult); cvsupport::Image::save("DilateTest_testManual0_dst.png", dstAccess.get<runtime::Image>()); }
void OpReplaceRepeated::Apply(Expression *expression, Calculator *calculator, int32 recursions) { if(expression->LeafCount() != 2) throw ArgumentException("ReplaceRepeated expects 2 arguments."); if(expression->LeafCount() != 2) throw ArgumentException("ReplaceRepeated expects 2 arguments."); string leafFunction = expression->Leaf(1)->FunctionName(); if(leafFunction != "Rule" && leafFunction != "RuleDelayed" && leafFunction != "List") throw ArgumentException("ReplaceRepeated expects its second argument to be a rule or a list of rules."); ExprVector rules; if(leafFunction == "List") { for(ExprVector::const_iterator item = expression->Leaf(1)->Leaves().begin(); item != expression->Leaf(1)->Leaves().end(); ++ item) if((*item)->FunctionName() != "Rule" && (*item)->FunctionName() != "RuleDelayed") throw ArgumentException("ReplaceRepeated expects its second argument to be a rule or a list of rules."); rules = expression->Leaf(1)->Leaves(); } else rules.push_back(expression->Leaf(1)); int32 iterations(0); Expression *result = expression->Leaf(0); while(true) { bool changed(false); if(!result->ReplaceAll(rules, calculator, &changed)) break; if(!changed) break; ++iterations; if(iterations >= Max_ReplaceRepeated_Iterations) throw LimitationException("Maximum number of iterations reached."); } expression->AssignLeaf(0); expression->Evaluate(calculator, recursions); }
/** * Print benchmark results. */ void logResults(std::vector<Result>& results, unsigned long time) { typedef OpenANN::FloatingPointFormatter fmt; OpenANN::Logger resultLogger(OpenANN::Logger::CONSOLE); resultLogger << "\t\tCorrect\t\tAccuracy\tTime/ms\t\tIterations\n"; Eigen::VectorXd correct(results.size()); Eigen::VectorXd accuracy(results.size()); Eigen::VectorXd iterations(results.size()); for(unsigned i = 0; i < results.size(); i++) { correct(i) = (double) results[i].correct; accuracy(i) = results[i].accuracy; iterations(i) = results[i].iterations; } double correctMean = correct.mean(); double accuracyMean = accuracy.mean(); double iterationsMean = iterations.mean(); double correctMin = correct.minCoeff(); double accuracyMin = accuracy.minCoeff(); double iterationsMin = iterations.minCoeff(); double correctMax = correct.maxCoeff(); double accuracyMax = accuracy.maxCoeff(); double iterationsMax = iterations.maxCoeff(); for(unsigned i = 0; i < results.size(); i++) { correct(i) -= correctMean; accuracy(i) -= accuracyMean; iterations(i) -= iterationsMean; } correct = correct.cwiseAbs(); accuracy = accuracy.cwiseAbs(); iterations = iterations.cwiseAbs(); double correctStdDev = std::sqrt(correct.mean()); double accuracyStdDev = std::sqrt(accuracy.mean()); double iterationsStdDev = std::sqrt(iterations.mean()); resultLogger << "Mean+-StdDev\t"; resultLogger << fmt(correctMean, 3) << "+-" << fmt(correctStdDev, 3) << "\t" << fmt(accuracyMean, 3) << "+-" << fmt(accuracyStdDev, 3) << "\t" << (int)((double)time / (double)results.size()) << "\t\t" << iterationsMean << "+-" << fmt(iterationsStdDev, 3) << "\n"; resultLogger << "[min,max]\t"; resultLogger << "[" << correctMin << "," << correctMax << "]\t" << "[" << fmt(accuracyMin, 3) << "," << fmt(accuracyMax, 3) << "]\t\t\t" << "[" << (int) iterationsMin << "," << (int) iterationsMax << "]\n\n"; }
int main() { /* * Вычисляем ширину эпсилон. */ int epswidth = ceil(-log10(REAL_EPSILON)); printf( "target_1 = 0, x = %.*f; dichotomy, x ∈ [%f, %f]\n", epswidth, dichotomy(target_1, TARGET_1_A, TARGET_1_B), TARGET_1_A, TARGET_1_B ); printf( "target_1 = 0, x = %.*f; iterations, x ∈ [%f, %f]\n", epswidth, iterations(target_1_xfx, TARGET_1_A, TARGET_1_B), TARGET_1_A, TARGET_1_B ); printf( "target_1 = 0, x = %.*f; newton, x ∈ [%f, %f]\n", epswidth, newton(target_1, target_1_derivative, TARGET_1_A, TARGET_1_B), TARGET_1_A, TARGET_1_B ); printf( "target_2 = 0, x = %.*f; dichotomy, x ∈ [%f, %f]\n", epswidth, dichotomy(target_2, TARGET_2_A, TARGET_2_B), TARGET_2_A, TARGET_2_B ); printf( "target_2 = 0, x = %.*f; iterations, x ∈ [%f, %f]\n", epswidth, iterations(target_2_xfx, TARGET_2_A, TARGET_2_B), TARGET_2_A, TARGET_2_B ); printf( "target_2 = 0, x = %.*f; newton, x ∈ [%f, %f]\n", epswidth, newton(target_2, target_2_derivative, TARGET_2_A, TARGET_2_B), TARGET_2_A, TARGET_2_B ); return (0); }
duration_type overhead_clock() { std::size_t iterations( 10); std::vector< boost::uint64_t > overhead( iterations, 0); for ( std::size_t i = 0; i < iterations; ++i) std::generate( overhead.begin(), overhead.end(), clock_overhead() ); BOOST_ASSERT( overhead.begin() != overhead.end() ); return duration_type( std::accumulate( overhead.begin(), overhead.end(), 0) / iterations); }
bool fractal_base::process_line(const line &l) { const vec_ull start = l.start_point; const vec_ull end = l.end_point; // handle lines containing only a single pixel const vec_ull diff = ((start - end) != vec_ull{0, 0}) ? (end - start).unitV() : vec_ull{0, 0}; const size_t length = (end - start).norm(); bool out = true; for (size_t i = 0; i <= length; i++) { vec_ull pos = start + diff * i; if (iterations(pos) == NOT_DEFINED) { // imaginary axis is different because it points opposite our +y axis complex complex_pos = index_to_complex(pos); iterations(pos) = iterate_cell(complex_pos); } if (iterations(pos) != iterations(start)) { out = false; } } return out; }
inline zeit_t overhead_zeit() { std::size_t iterations( 10); std::vector< zeit_t > overhead( iterations, 0); for ( std::size_t i( 0); i < iterations; ++i) std::generate( overhead.begin(), overhead.end(), measure_zeit() ); BOOST_ASSERT( overhead.begin() != overhead.end() ); return std::accumulate( overhead.begin(), overhead.end(), 0) / iterations; }
split_rectangle fractal_base::process_rectangle(rectangle r) { bool edges_equal = true; for (auto &side : r.get_sides()) { // pre-calculate to avoid lazy evaluation skipping bool res = process_line(side); edges_equal = edges_equal && res; } size_t shortest_edge = std::min(r.xmax - r.xmin, r.ymax - r.ymin); if (!edges_equal && shortest_edge > 1) { // must be careful how we round up and down because rectangles are inclusive on all bounds return {true, { rectangle(r.xmin, (r.xmin + r.xmax) / 2, r.ymin, (r.ymin + r.ymax) / 2), rectangle((r.xmin + r.xmax) / 2, r.xmax, r.ymin, (r.ymin + r.ymax) / 2), rectangle(r.xmin, (r.xmin + r.xmax) / 2, (r.ymin + r.ymax) / 2, r.ymax), rectangle((r.xmin + r.xmax) / 2, r.xmax, (r.ymin + r.ymax) / 2, r.ymax), }, }; } else if (edges_equal /*&& shortest_edge < longest_bound / 2*/) { double iter_fill = iterations(r.xmin, r.ymin); for (size_t i = r.xmin; i <= r.xmax; i++) { for (size_t j = r.ymin; j <= r.ymax; j++) { iterations(i, j) = iter_fill; } } if (do_grid) { for (size_t j = r.ymin; j < r.ymax; j++) { grid_mask(r.xmin, j) = true; } for (size_t i = r.xmin; i < r.xmax; i++) { grid_mask(i, r.ymin) = true; } } } return {false, {}}; }
int test_omp_for() { std::vector<int> iterations(omp_get_max_threads(), 0); int n = 100; #pragma omp parallel shared(iterations, n) { #pragma omp for for (int i = 0; i < n; i++) { iterations[omp_get_thread_num()]++; } } print_iterations(iterations); return 0; }
void seissol::checkpoint::mpio::Wavefield::write(const void* header, size_t headerSize) { SCOREP_USER_REGION("CheckPoint_write", SCOREP_USER_REGION_TYPE_FUNCTION); logInfo(rank()) << "Checkpoint backend: Writing."; // Write the header writeHeader(header, headerSize); // Save data SCOREP_USER_REGION_DEFINE(r_write_wavefield); SCOREP_USER_REGION_BEGIN(r_write_wavefield, "checkpoint_write_wavefield", SCOREP_USER_REGION_TYPE_COMMON); checkMPIErr(setDataView(file())); unsigned int totalIter = totalIterations(); unsigned int iter = iterations(); unsigned int count = dofsPerIteration(); if (m_useLargeBuffer) { totalIter = (totalIter + sizeof(real) - 1) / sizeof(real); iter = (iter + sizeof(real) - 1) / sizeof(real); count *= sizeof(real); } unsigned long offset = 0; for (unsigned int i = 0; i < totalIter; i++) { if (i == iter-1) // Last iteration count = numDofs() - (iter-1) * count; checkMPIErr(MPI_File_write_all(file(), const_cast<real*>(&dofs()[offset]), count, MPI_DOUBLE, MPI_STATUS_IGNORE)); if (i < iter-1) offset += count; // otherwise we just continue writing the last chunk over and over else if (i != totalIter-1) checkMPIErr(MPI_File_seek(file(), -count * sizeof(real), MPI_SEEK_CUR)); } SCOREP_USER_REGION_END(r_write_wavefield); // Finalize the checkpoint finalizeCheckpoint(); logInfo(rank()) << "Checkpoint backend: Writing. Done."; }
void seissol::checkpoint::h5::Wavefield::load(double &time, int ×tepWavefield, real* dofs) { logInfo(rank()) << "Loading wave field checkpoint"; seissol::checkpoint::CheckPoint::setLoaded(); hid_t h5file = open(linkFile()); checkH5Err(h5file); // Attributes hid_t h5attr = H5Aopen(h5file, "time", H5P_DEFAULT); checkH5Err(h5attr); checkH5Err(H5Aread(h5attr, H5T_NATIVE_DOUBLE, &time)); checkH5Err(H5Aclose(h5attr)); h5attr = H5Aopen(h5file, "timestep_wavefield", H5P_DEFAULT); checkH5Err(h5attr); checkH5Err(H5Aread(h5attr, H5T_NATIVE_INT, ×tepWavefield)); checkH5Err(H5Aclose(h5attr)); // Get dataset hid_t h5data = H5Dopen(h5file, "values", H5P_DEFAULT); checkH5Err(h5data); hid_t h5fSpace = H5Dget_space(h5data); checkH5Err(h5fSpace); // Read the data unsigned int offset = 0; hsize_t fStart = fileOffset(); hsize_t count = dofsPerIteration(); hid_t h5memSpace = H5Screate_simple(1, &count, 0L); checkH5Err(h5memSpace); checkH5Err(H5Sselect_all(h5memSpace)); for (unsigned int i = 0; i < totalIterations()-1; i++) { checkH5Err(H5Sselect_hyperslab(h5fSpace, H5S_SELECT_SET, &fStart, 0L, &count, 0L)); checkH5Err(H5Dread(h5data, H5T_NATIVE_DOUBLE, h5memSpace, h5fSpace, h5XferList(), &dofs[offset])); // We are finished in less iterations, read data twice // so everybody needs the same number of iterations if (i < iterations()-1) { fStart += count; offset += count; } } checkH5Err(H5Sclose(h5memSpace)); // Read reminding data in the last iteration count = numDofs() - (iterations() - 1) * count; h5memSpace = H5Screate_simple(1, &count, 0L); checkH5Err(h5memSpace); checkH5Err(H5Sselect_all(h5memSpace)); checkH5Err(H5Sselect_hyperslab(h5fSpace, H5S_SELECT_SET, &fStart, 0L, &count, 0L)); checkH5Err(H5Dread(h5data, H5T_NATIVE_DOUBLE, h5memSpace, h5fSpace, h5XferList(), &dofs[offset])); checkH5Err(H5Sclose(h5memSpace)); checkH5Err(H5Sclose(h5fSpace)); checkH5Err(H5Dclose(h5data)); checkH5Err(H5Fclose(h5file)); }
void seissol::checkpoint::h5::Wavefield::write(double time, int waveFieldTimeStep) { EPIK_TRACER("CheckPoint_write"); SCOREP_USER_REGION("CheckPoint_write", SCOREP_USER_REGION_TYPE_FUNCTION); logInfo(rank()) << "Writing check point."; EPIK_USER_REG(r_header, "checkpoint_write_header"); SCOREP_USER_REGION_DEFINE(r_header); EPIK_USER_START(r_header); SCOREP_USER_REGION_BEGIN(r_header, "checkpoint_write_header", SCOREP_USER_REGION_TYPE_COMMON); // Time checkH5Err(H5Awrite(m_h5time[odd()], H5T_NATIVE_DOUBLE, &time)); // Wavefield writer checkH5Err(H5Awrite(m_h5timestepWavefield[odd()], H5T_NATIVE_INT, &waveFieldTimeStep)); EPIK_USER_END(r_header); SCOREP_USER_REGION_END(r_header); // Save data EPIK_USER_REG(r_write_wavefield, "checkpoint_write_wavefield"); SCOREP_USER_REGION_DEFINE(r_write_wavefield); EPIK_USER_START(r_write_wavefield); SCOREP_USER_REGION_BEGIN(r_write_wavefield, "checkpoint_write_wavefield", SCOREP_USER_REGION_TYPE_COMMON); // Write the wave field unsigned int offset = 0; hsize_t fStart = fileOffset(); hsize_t count = dofsPerIteration(); hid_t h5memSpace = H5Screate_simple(1, &count, 0L); checkH5Err(h5memSpace); checkH5Err(H5Sselect_all(h5memSpace)); for (unsigned int i = 0; i < totalIterations()-1; i++) { checkH5Err(H5Sselect_hyperslab(m_h5fSpaceData, H5S_SELECT_SET, &fStart, 0L, &count, 0L)); checkH5Err(H5Dwrite(m_h5data[odd()], H5T_NATIVE_DOUBLE, h5memSpace, m_h5fSpaceData, h5XferList(), &const_cast<real*>(dofs())[offset])); // We are finished in less iterations, read data twice // so everybody needs the same number of iterations if (i < iterations()-1) { fStart += count; offset += count; } } checkH5Err(H5Sclose(h5memSpace)); // Save reminding data in the last iteration count = numDofs() - (iterations() - 1) * count; h5memSpace = H5Screate_simple(1, &count, 0L); checkH5Err(h5memSpace); checkH5Err(H5Sselect_all(h5memSpace)); checkH5Err(H5Sselect_hyperslab(m_h5fSpaceData, H5S_SELECT_SET, &fStart, 0L, &count, 0L)); checkH5Err(H5Dwrite(m_h5data[odd()], H5T_NATIVE_DOUBLE, h5memSpace, m_h5fSpaceData, h5XferList(), &dofs()[offset])); checkH5Err(H5Sclose(h5memSpace)); EPIK_USER_END(r_write_wavefield); SCOREP_USER_REGION_END(r_write_wavefield); // Finalize the checkpoint finalizeCheckpoint(); logInfo(rank()) << "Writing check point. Done."; }
int main (int argc, char **argv) { FILE *fp_out, *fp_f1plus, *fp_f1min; FILE *fp_gmin, *fp_gplus, *fp_f2, *fp_pmin; int i, j, l, ret, nshots, Nsyn, nt, nx, nts, nxs, ngath; int size, n1, n2, ntap, tap, di, ntraces, nb, ib; int nw, nw_low, nw_high, nfreq, *xnx, *xnxsyn, *synpos; int reci, mode, ixa, ixb, n2out, verbose, ntfft; int iter, niter, niterh, tracf, *muteW, pad, nt0, ampest, *hmuteW, *hxnxsyn; int hw, smooth, above, shift, *ixpossyn, npossyn, ix, first=1; float fmin, fmax, *tapersh, *tapersy, fxf, dxf, fxs2, *xsrc, *xrcv, *zsyn, *zsrc, *xrcvsyn; float *hzsyn, *hxsyn, *hxrcvsyn, *hG_d, xloc, zloc, *HomG; double t0, t1, t2, t3, tsyn, tread, tfft, tcopy, energyNi, *J; float d1, d2, f1, f2, fxs, ft, fx, *xsyn, dxsrc, Q, f0, *Costdet; float *green, *f2p, *pmin, *G_d, dt, dx, dxs, scl, mem, *Image, *Image2; float *f1plus, *f1min, *iRN, *Ni, *trace, *Gmin, *Gplus, *Gm0; float xmin, xmax, weight, tsq, *Gd, *amp, bstart, bend, db, *bdet, bp, b, bmin; complex *Refl, *Fop, *cshot; char *file_tinv, *file_shot, *file_green, *file_iter, *file_wav, *file_ray, *file_amp, *file_img, *file_cp, *file_rays, *file_amps; char *file_f1plus, *file_f1min, *file_gmin, *file_gplus, *file_f2, *file_pmin, *wavtype, *wavtype2, *file_homg, *file_tinvs; segy *hdrs_im, *hdrs_homg; WavePar WP,WPs; modPar mod; recPar rec; srcPar src; shotPar shot; rayPar ray; initargs(argc, argv); requestdoc(1); tsyn = tread = tfft = tcopy = 0.0; t0 = wallclock_time(); if (!getparstring("file_img", &file_img)) file_img = "img.su"; if (!getparstring("file_homg", &file_homg)) file_homg = NULL; if (!getparstring("file_shot", &file_shot)) file_shot = NULL; if (!getparstring("file_tinv", &file_tinv)) file_tinv = NULL; if (!getparstring("file_tinvs", &file_tinvs)) file_tinvs = NULL; if (!getparstring("file_f1plus", &file_f1plus)) file_f1plus = NULL; if (!getparstring("file_f1min", &file_f1min)) file_f1min = NULL; if (!getparstring("file_gplus", &file_gplus)) file_gplus = NULL; if (!getparstring("file_gmin", &file_gmin)) file_gmin = NULL; if (!getparstring("file_pplus", &file_f2)) file_f2 = NULL; if (!getparstring("file_f2", &file_f2)) file_f2 = NULL; if (!getparstring("file_pmin", &file_pmin)) file_pmin = NULL; if (!getparstring("file_iter", &file_iter)) file_iter = NULL; if (!getparstring("file_wav", &file_wav)) file_wav=NULL; if (!getparstring("file_ray", &file_ray)) file_ray=NULL; if (!getparstring("file_amp", &file_amp)) file_amp=NULL; if (!getparstring("file_rays", &file_rays)) file_rays=NULL; if (!getparstring("file_amps", &file_amps)) file_amps=NULL; if (!getparstring("file_cp", &file_cp)) file_cp = NULL; if (!getparint("verbose", &verbose)) verbose = 0; if (file_tinv == NULL && file_shot == NULL) verr("file_tinv and file_shot cannot be both input pipe"); if (!getparstring("file_green", &file_green)) { if (verbose) vwarn("parameter file_green not found, assume pipe"); file_green = NULL; } if (!getparfloat("fmin", &fmin)) fmin = 0.0; if (!getparfloat("fmax", &fmax)) fmax = 70.0; if (!getparint("ixa", &ixa)) ixa = 0; if (!getparint("ixb", &ixb)) ixb = ixa; // if (!getparint("reci", &reci)) reci = 0; reci=0; // source-receiver reciprocity is not yet fully build into the code if (!getparfloat("weight", &weight)) weight = 1.0; if (!getparfloat("tsq", &tsq)) tsq = 0.0; if (!getparfloat("Q", &Q)) Q = 0.0; if (!getparfloat("f0", &f0)) f0 = 0.0; if (!getparint("tap", &tap)) tap = 0; if (!getparint("ntap", &ntap)) ntap = 0; if (!getparint("pad", &pad)) pad = 0; if(!getparint("hw", &hw)) hw = 15; if(!getparint("smooth", &smooth)) smooth = 5; if(!getparint("above", &above)) above = 0; if(!getparint("shift", &shift)) shift=12; if(!getparint("ampest", &est)) ampest=0; if(!getparint("nb", &nb)) nb=0; if (!getparfloat("bstart", &bstart)) bstart = 1.0; if (!getparfloat("bend", &bend)) bend = 1.0; if (reci && ntap) vwarn("tapering influences the reciprocal result"); /* Reading in wavelet parameters */ if(!getparfloat("fpw", &WP.fp)) WP.fp = -1.0; if(!getparfloat("fminw", &WP.fmin)) WP.fmin = 10.0; if(!getparfloat("flefw", &WP.flef)) WP.flef = 20.0; if(!getparfloat("frigw", &WP.frig)) WP.frig = 50.0; if(!getparfloat("fmaxw", &WP.fmax)) WP.fmax = 60.0; else WP.fp = -1; if(!getparfloat("dbw", &WP.db)) WP.db = -20.0; if(!getparfloat("t0w", &WP.t0)) WP.t0 = 0.0; if(!getparint("shiftw", &WP.shift)) WP.shift = 0; if(!getparint("invw", &WP.inv)) WP.inv = 0; if(!getparfloat("epsw", &WP.eps)) WP.eps = 1.0; if(!getparfloat("scalew", &WP.scale)) WP.scale = 1.0; if(!getparint("scfftw", &WP.scfft)) WP.scfft = 1; if(!getparint("cmw", &WP.cm)) WP.cm = 10; if(!getparint("cnw", &WP.cn)) WP.cn = 1; if(!getparint("wav", &WP.wav)) WP.wav = 0; if(!getparstring("file_wav", &WP.file_wav)) WP.file_wav=NULL; if(!getparstring("w", &wavtype)) strcpy(WP.w, "g2"); else strcpy(WP.w, wavtype); if(!getparfloat("fpws", &WPs.fp)) WPs.fp = -1.0; if(!getparfloat("fminws", &WPs.fmin)) WPs.fmin = 10.0; if(!getparfloat("flefws", &WPs.flef)) WPs.flef = 20.0; if(!getparfloat("frigws", &WPs.frig)) WPs.frig = 50.0; if(!getparfloat("fmaxws", &WPs.fmax)) WPs.fmax = 60.0; else WPs.fp = -1; if(!getparfloat("dbw", &WPs.db)) WPs.db = -20.0; if(!getparfloat("t0ws", &WPs.t0)) WPs.t0 = 0.0; if(!getparint("shiftws", &WPs.shift)) WPs.shift = 0; if(!getparint("invws", &WPs.inv)) WPs.inv = 0; if(!getparfloat("epsws", &WPs.eps)) WPs.eps = 1.0; if(!getparfloat("scalews", &WPs.scale)) WPs.scale = 1.0; if(!getparint("scfftws", &WPs.scfft)) WPs.scfft = 1; if(!getparint("cmws", &WPs.cm)) WPs.cm = 10; if(!getparint("cnws", &WPs.cn)) WPs.cn = 1; if(!getparint("wavs", &WPs.wav)) WPs.wav = 0; if(!getparstring("file_wavs", &WPs.file_wav)) WPs.file_wav=NULL; if(!getparstring("ws", &wavtype2)) strcpy(WPs.w, "g2"); else strcpy(WPs.w, wavtype2); if(!getparint("niter", &niter)) niter = 10; if(!getparint("niterh", &niterh)) niterh = niter; /*================ Reading info about shot and initial operator sizes ================*/ ngath = 0; /* setting ngath=0 scans all traces; n2 contains maximum traces/gather */ if (file_ray!=NULL && file_tinv==NULL) { ret = getFileInfo(file_ray, &n2, &n1, &ngath, &d1, &d2, &f2, &f1, &xmin, &xmax, &scl, &ntraces); n1 = 1; ntraces = n2*ngath; scl = 0.0010; d1 = -1.0*xmin; xmin = -1.0*xmax; xmax = d1; WP.wav = 1; WP.xloc = -123456.0; WP.zloc = -123456.0; synpos = (int *)calloc(ngath,sizeof(int)); shot.nz = 1; shot.nx = ngath; shot.n = shot.nx*shot.nz; for (l=0; l<shot.nz; l++) { for (j=0; j<shot.nx; j++) { synpos[l*shot.nx+j] = j*shot.nz+l; } } } else if (file_ray==NULL && file_tinv==NULL) { getParameters(&mod, &rec, &src, &shot, &ray, verbose); n1 = 1; n2 = rec.n; ngath = shot.n; d1 = mod.dt; d2 = (rec.x[1]-rec.x[0])*mod.dx; f1 = 0.0; f2 = mod.x0+rec.x[0]*mod.dx; xmin = mod.x0+rec.x[0]*mod.dx; xmax = mod.x0+rec.x[rec.n-1]*mod.dx; scl = 0.0010; ntraces = n2*ngath; WP.wav = 1; WP.xloc = -123456.0; WP.zloc = -123456.0; synpos = (int *)calloc(ngath,sizeof(int)); for (l=0; l<shot.nz; l++) { for (j=0; j<shot.nx; j++) { synpos[l*shot.nx+j] = j*shot.nz+l; } } } else { ret = getFileInfo(file_tinv, &n1, &n2, &ngath, &d1, &d2, &f1, &f2, &xmin, &xmax, &scl, &ntraces); } Nsyn = ngath; nxs = n2; nts = n1; nt0 = n1; dxs = d2; fxs = f2; ngath = 0; /* setting ngath=0 scans all traces; nx contains maximum traces/gather */ ret = getFileInfo(file_shot, &nt, &nx, &ngath, &d1, &dx, &ft, &fx, &xmin, &xmax, &scl, &ntraces); nshots = ngath; assert (nxs >= nshots); if (!getparfloat("dt", &dt)) dt = d1; ntfft = optncr(MAX(nt+pad, nts+pad)); nfreq = ntfft/2+1; nw_low = (int)MIN((fmin*ntfft*dt), nfreq-1); nw_low = MAX(nw_low, 1); nw_high = MIN((int)(fmax*ntfft*dt), nfreq-1); nw = nw_high - nw_low + 1; scl = 1.0/((float)ntfft); if (nb > 1) { db = (bend-bstart)/((float)(nb-1)); } else if (nb == 1) { db = 0; bend = bstart; } /*================ Allocating all data arrays ================*/ green = (float *)calloc(Nsyn*nxs*ntfft,sizeof(float)); f2p = (float *)calloc(Nsyn*nxs*ntfft,sizeof(float)); pmin = (float *)calloc(Nsyn*nxs*ntfft,sizeof(float)); f1plus = (float *)calloc(Nsyn*nxs*ntfft,sizeof(float)); f1min = (float *)calloc(Nsyn*nxs*ntfft,sizeof(float)); G_d = (float *)calloc(Nsyn*nxs*ntfft,sizeof(float)); muteW = (int *)calloc(Nsyn*nxs,sizeof(int)); trace = (float *)malloc(ntfft*sizeof(float)); ixpossyn = (int *)malloc(nxs*sizeof(int)); xrcvsyn = (float *)calloc(Nsyn*nxs,sizeof(float)); xsyn = (float *)malloc(Nsyn*sizeof(float)); zsyn = (float *)malloc(Nsyn*sizeof(float)); xnxsyn = (int *)calloc(Nsyn,sizeof(int)); tapersy = (float *)malloc(nxs*sizeof(float)); Refl = (complex *)malloc(nw*nx*nshots*sizeof(complex)); tapersh = (float *)malloc(nx*sizeof(float)); xsrc = (float *)calloc(nshots,sizeof(float)); zsrc = (float *)calloc(nshots,sizeof(float)); xrcv = (float *)calloc(nshots*nx,sizeof(float)); xnx = (int *)calloc(nshots,sizeof(int)); /*================ Read and define mute window based on focusing operator(s) ================*/ /* G_d = p_0^+ = G_d (-t) ~ Tinv */ WPs.nt = ntfft; WPs.dt = dt; WP.nt = ntfft; WP.dt = dt; if (file_ray!=NULL || file_cp!=NULL) { makeWindow(WP, file_ray, file_amp, dt, xrcvsyn, xsyn, zsyn, xnxsyn, Nsyn, nxs, ntfft, mode, muteW, G_d, hw, verbose); } else { mode=-1; /* apply complex conjugate to read in data */ readTinvData(file_tinv, dt, xrcvsyn, xsyn, zsyn, xnxsyn, Nsyn, nxs, ntfft, mode, muteW, G_d, hw, verbose); } /* reading data added zero's to the number of time samples to be the same as ntfft */ nts = ntfft; /* define tapers to taper edges of acquisition */ if (tap == 1 || tap == 3) { for (j = 0; j < ntap; j++) tapersy[j] = (cos(PI*(j-ntap)/ntap)+1)/2.0; for (j = ntap; j < nxs-ntap; j++) tapersy[j] = 1.0; for (j = nxs-ntap; j < nxs; j++) tapersy[j] =(cos(PI*(j-(nxs-ntap))/ntap)+1)/2.0; } else { for (j = 0; j < nxs; j++) tapersy[j] = 1.0; } if (tap == 1 || tap == 3) { if (verbose) vmess("Taper for operator applied ntap=%d", ntap); for (l = 0; l < Nsyn; l++) { for (i = 0; i < nxs; i++) { for (j = 0; j < nts; j++) { G_d[l*nxs*nts+i*nts+j] *= tapersy[i]; } } } } /* check consistency of header values */ dxf = (xrcvsyn[nxs-1] - xrcvsyn[0])/(float)(nxs-1); if (NINT(dxs*1e3) != NINT(fabs(dxf)*1e3)) { vmess("dx in hdr.d1 (%.3f) and hdr.gx (%.3f) not equal",d2, dxf); if (dxf != 0) dxs = fabs(dxf); vmess("dx in operator => %f", dxs); } if (xrcvsyn[0] != 0 || xrcvsyn[1] != 0 ) fxs = xrcvsyn[0]; fxs2 = fxs + (float)(nxs-1)*dxs; /*================ Reading shot records ================*/ mode=1; readShotData(file_shot, xrcv, xsrc, zsrc, xnx, Refl, nw, nw_low, ngath, nx, nx, ntfft, mode, weight, tsq, Q, f0, verbose); tapersh = (float *)malloc(nx*sizeof(float)); if (tap == 2 || tap == 3) { for (j = 0; j < ntap; j++) tapersh[j] = (cos(PI*(j-ntap)/ntap)+1)/2.0; for (j = ntap; j < nx-ntap; j++) tapersh[j] = 1.0; for (j = nx-ntap; j < nx; j++) tapersh[j] =(cos(PI*(j-(nx-ntap))/ntap)+1)/2.0; } else { for (j = 0; j < nx; j++) tapersh[j] = 1.0; } if (tap == 2 || tap == 3) { if (verbose) vmess("Taper for shots applied ntap=%d", ntap); for (l = 0; l < nshots; l++) { for (j = 1; j < nw; j++) { for (i = 0; i < nx; i++) { Refl[l*nx*nw+j*nx+i].r *= tapersh[i]; Refl[l*nx*nw+j*nx+i].i *= tapersh[i]; } } } } free(tapersh); /* check consistency of header values */ fxf = xsrc[0]; if (nx > 1) dxf = (xrcv[0] - xrcv[nx-1])/(float)(nx-1); else dxf = d2; if (NINT(dx*1e3) != NINT(fabs(dxf)*1e3)) { vmess("dx in hdr.d1 (%.3f) and hdr.gx (%.3f) not equal",dx, dxf); if (dxf != 0) dx = fabs(dxf); else verr("gx hdrs not set"); vmess("dx used => %f", dx); } dxsrc = (float)xsrc[1] - xsrc[0]; if (dxsrc == 0) { vwarn("sx hdrs are not filled in!!"); dxsrc = dx; } /*================ Check the size of the files ================*/ if (NINT(dxsrc/dx)*dx != NINT(dxsrc)) { vwarn("source (%.2f) and receiver step (%.2f) don't match",dxsrc,dx); if (reci == 2) vwarn("step used from operator (%.2f) ",dxs); } di = NINT(dxf/dxs); if ((NINT(di*dxs) != NINT(dxf)) && verbose) vwarn("dx in receiver (%.2f) and operator (%.2f) don't match",dx,dxs); if (nt != nts) vmess("Time samples in shot (%d) and focusing operator (%d) are not equal",nt, nts); if (verbose) { vmess("Number of focusing operators = %d", Nsyn); vmess("Number of receivers in focusop = %d", nxs); vmess("number of shots = %d", nshots); vmess("number of receiver/shot = %d", nx); vmess("first model position = %.2f", fxs); vmess("last model position = %.2f", fxs2); vmess("first source position fxf = %.2f", fxf); vmess("source distance dxsrc = %.2f", dxsrc); vmess("last source position = %.2f", fxf+(nshots-1)*dxsrc); vmess("receiver distance dxf = %.2f", dxf); vmess("direction of increasing traces = %d", di); vmess("number of time samples (nt,nts) = %d (%d,%d)", ntfft, nt, nts); vmess("time sampling = %e ", dt); if (ampest > 0) vmess("Amplitude correction estimation is switched on"); if (nb > 0) vmess("Scaling estimation in %d step(s) from %.3f to %.3f (db=%.3f)",nb,bstart,bend,db); if (file_green != NULL) vmess("Green output file = %s ", file_green); if (file_gmin != NULL) vmess("Gmin output file = %s ", file_gmin); if (file_gplus != NULL) vmess("Gplus output file = %s ", file_gplus); if (file_pmin != NULL) vmess("Pmin output file = %s ", file_pmin); if (file_f2 != NULL) vmess("f2 (=pplus) output file = %s ", file_f2); if (file_f1min != NULL) vmess("f1min output file = %s ", file_f1min); if (file_f1plus != NULL)vmess("f1plus output file = %s ", file_f1plus); if (file_iter != NULL) vmess("Iterations output file = %s ", file_iter); } /*================ initializations ================*/ if (ixa || ixb) n2out = ixa + ixb + 1; else if (reci) n2out = nxs; else n2out = nshots; mem = Nsyn*n2out*ntfft*sizeof(float)/1048576.0; if (verbose) { vmess("number of output traces = %d", n2out); vmess("number of output samples = %d", ntfft); vmess("Size of output data/file = %.1f MB", mem); } //memcpy(Ni, G_d, Nsyn*nxs*ntfft*sizeof(float)); if (file_homg!=NULL) { hG_d = (float *)calloc(nxs*ntfft,sizeof(float)); hmuteW = (int *)calloc(nxs,sizeof(int)); hxrcvsyn = (float *)calloc(nxs,sizeof(float)); hxsyn = (float *)calloc(1,sizeof(float)); hzsyn = (float *)calloc(1,sizeof(float)); hxnxsyn = (int *)calloc(1,sizeof(int)); cshot = (complex *)calloc(nxs*nfreq,sizeof(complex)); if(!getparfloat("xloc", &WPs.xloc)) WPs.xloc = -123456.0; if(!getparfloat("zloc", &WPs.zloc)) WPs.zloc = -123456.0; if (WPs.xloc == -123456.0 && WPs.zloc == -123456.0) file_cp = NULL; if (WPs.xloc == -123456.0) WPs.xloc = 0.0; if (WPs.zloc == -123456.0) WPs.zloc = 0.0; xloc = WPs.xloc; zloc = WPs.zloc; ngath = 1; if (file_rays!=NULL || file_cp!=NULL) { WPs.wav=1; makeWindow(WPs, file_rays, file_amps, dt, hxrcvsyn, hxsyn, hzsyn, hxnxsyn, ngath, nxs, ntfft, mode, hmuteW, hG_d, hw, verbose); } else { mode=-1; /* apply complex conjugate to read in data */ readTinvData(file_tinvs, dt, hxrcvsyn, hxsyn, hzsyn, hxnxsyn, ngath, nxs, ntfft, mode, hmuteW, hG_d, hw, verbose); } WPs.xloc = -123456.0; WPs.zloc = -123456.0; if (tap == 1 || tap == 3) { if (verbose) vmess("Taper for operator applied ntap=%d", ntap); for (i = 0; i < nxs; i++) { for (j = 0; j < nts; j++) { hG_d[i*nts+j] *= tapersy[i]; } } } ngath = omp_get_max_threads(); synthesisPosistions(nx, nt, nxs, nts, dt, hxsyn, 1, xrcv, xsrc, fxs2, fxs, dxs, dxsrc, dx, ixa, ixb, reci, nshots, ixpossyn, &npossyn, verbose); iterations(Refl,nx,nt,nxs,nts,dt,hxsyn,1,xrcv,xsrc,fxs2,fxs,dxs,dxsrc,dx,ixa,ixb, ntfft,nw,nw_low,nw_high,mode,reci,nshots,ixpossyn,npossyn,pmin,f1min,f1plus, f2p,hG_d,hmuteW,smooth,shift,above,pad,nt0,&first,niterh,verbose); /* compute full Green's function G = int R * f2(t) + f2(-t) = Pplus + Pmin */ for (i = 0; i < npossyn; i++) { j = 0; /* set green to zero if mute-window exceeds nt/2 */ if (hmuteW[ixpossyn[i]] >= nts/2) { memset(&green[i*nts],0, sizeof(float)*nt); continue; } green[i*nts+j] = f2p[i*nts+j] + pmin[i*nts+j]; for (j = 1; j < nts; j++) { green[i*nts+j] = f2p[i*nts+nts-j] + pmin[i*nts+j]; } } applyMute(green, hmuteW, smooth, 4, 1, nxs, nts, ixpossyn, npossyn, shift, pad, nt0); omp_set_num_threads(ngath); /* Transform the green position to the frequency domain */ /*for (i = 0; i < npossyn; i++) { rc1fft(&green[i*nts],&cshot[i*nfreq],ntfft,-1); }*/ //free(hG_d);free(hmuteW);free(hxrcvsyn); free(hmuteW);free(hxrcvsyn); free(hxsyn);free(hzsyn);free(hxnxsyn);free(cshot); } /* dry-run of synthesis to get all x-positions calcalated by the integration */ synthesisPosistions(nx, nt, nxs, nts, dt, xsyn, Nsyn, xrcv, xsrc, fxs2, fxs, dxs, dxsrc, dx, ixa, ixb, reci, nshots, ixpossyn, &npossyn, verbose); if (verbose) { vmess("synthesisPosistions: nshots=%d npossyn=%d", nshots, npossyn); } t1 = wallclock_time(); tread = t1-t0; iterations(Refl,nx,nt,nxs,nts,dt,xsyn,Nsyn,xrcv,xsrc,fxs2,fxs,dxs,dxsrc,dx,ixa,ixb, ntfft,nw,nw_low,nw_high,mode,reci,nshots,ixpossyn,npossyn,pmin,f1min,f1plus, f2p,G_d,muteW,smooth,shift,above,pad,nt0,&first,niter,verbose); /*if (niter==0) { for (l = 0; l < Nsyn; l++) { for (i = 0; i < npossyn; i++) { j = 0; ix = ixpossyn[i]; f2p[l*nxs*nts+i*nts+j] = G_d[l*nxs*nts+ix*nts+j]; f1plus[l*nxs*nts+i*nts+j] = G_d[l*nxs*nts+ix*nts+j]; for (j = 1; j < nts; j++) { f2p[l*nxs*nts+i*nts+j] = G_d[l*nxs*nts+ix*nts+j]; f1plus[l*nxs*nts+i*nts+j] = G_d[l*nxs*nts+ix*nts+j]; } } } }*/ if (niterh==0) { for (l = 0; l < Nsyn; l++) { for (i = 0; i < npossyn; i++) { j = 0; ix = ixpossyn[i]; green[i*nts+j] = hG_d[ix*nts+j]; for (j = 1; j < nts; j++) { green[i*nts+j] = hG_d[ix*nts+nts-j]; } } } } if (file_img!=NULL) { /*================ set variables for output data ================*/ hdrs_im = (segy *) calloc(shot.nx,sizeof(segy)); if (hdrs_im == NULL) verr("allocation for hdrs_out"); Image = (float *)calloc(Nsyn,sizeof(float)); first=0; imaging(Image,WPs,Refl,nx,nt,nxs,nts,dt,xsyn,Nsyn,xrcv,xsrc,fxs2,fxs,dxs,dxsrc,dx,ixa,ixb, ntfft,nw,nw_low,nw_high,mode,reci,nshots,ixpossyn,npossyn,pmin,f1min,f1plus, f2p,G_d,muteW,smooth,shift,above,pad,nt0,synpos,verbose); /*============= write output files ================*/ fp_out = fopen(file_img, "w+"); for (i = 0; i < shot.nx; i++) { hdrs_im[i].fldr = 1; hdrs_im[i].tracl = 1; hdrs_im[i].tracf = i+1; hdrs_im[i].scalco = -1000; hdrs_im[i].scalel = -1000; hdrs_im[i].sdepth = 0; hdrs_im[i].trid = 1; hdrs_im[i].ns = shot.nz; hdrs_im[i].trwf = shot.nx; hdrs_im[i].ntr = hdrs_im[i].fldr*hdrs_im[i].trwf; hdrs_im[i].f1 = zsyn[0]; hdrs_im[i].f2 = xsyn[0]; hdrs_im[i].dt = dt*(1E6); hdrs_im[i].d1 = (float)zsyn[shot.nx]-zsyn[0]; hdrs_im[i].d2 = (float)xsyn[1]-xsyn[0]; hdrs_im[i].sx = (int)roundf(xsyn[0] + (i*hdrs_im[i].d2)); hdrs_im[i].gx = (int)roundf(xsyn[0] + (i*hdrs_im[i].d2)); hdrs_im[i].offset = (hdrs_im[i].gx - hdrs_im[i].sx)/1000.0; } ret = writeData(fp_out, &Image[0], hdrs_im, shot.nz, shot.nx); if (ret < 0 ) verr("error on writing output file."); fclose(fp_out); } if (file_homg!=NULL) { /*================ set variables for output data ================*/ hdrs_homg = (segy *) calloc(shot.nx,sizeof(segy)); if (hdrs_homg == NULL) verr("allocation for hdrs_out"); HomG = (float *)calloc(Nsyn*ntfft,sizeof(float)); homogeneousg(HomG,green,Refl,nx,nt,nxs,nts,dt,xsyn,Nsyn,xrcv,xsrc,fxs2,fxs,dxs,dxsrc,dx,ixa,ixb, ntfft,nw,nw_low,nw_high,mode,reci,nshots,ixpossyn,npossyn,pmin,f1min,f1plus, f2p,G_d,muteW,smooth,shift,above,pad,nt0,synpos,verbose); /*============= write output files ================*/ fp_out = fopen(file_homg, "w+"); for (j = 0; j < ntfft; j++) { for (i = 0; i < shot.nx; i++) { hdrs_homg[i].fldr = j+1; hdrs_homg[i].tracl = j*shot.nx+i+1; hdrs_homg[i].tracf = i+1; hdrs_homg[i].scalco = -1000; hdrs_homg[i].scalel = -1000; hdrs_homg[i].sdepth = (int)(zloc*1000.0); hdrs_homg[i].trid = 1; hdrs_homg[i].ns = shot.nz; hdrs_homg[i].trwf = shot.nx; hdrs_homg[i].ntr = hdrs_homg[i].fldr*hdrs_homg[i].trwf; hdrs_homg[i].f1 = zsyn[0]; hdrs_homg[i].f2 = xsyn[0]; hdrs_homg[i].dt = dt*(1E6); hdrs_homg[i].d1 = (float)zsyn[shot.nx]-zsyn[0]; hdrs_homg[i].d2 = (float)xsyn[1]-xsyn[0]; hdrs_homg[i].sx = (int)roundf(xsyn[0] + (i*hdrs_homg[i].d2)); hdrs_homg[i].gx = (int)roundf(xsyn[0] + (i*hdrs_homg[i].d2)); hdrs_homg[i].offset = (hdrs_homg[i].gx - hdrs_homg[i].sx)/1000.0; } ret = writeData(fp_out, &HomG[j*shot.n], hdrs_homg, shot.nz, shot.nx); if (ret < 0 ) verr("error on writing output file."); } fclose(fp_out); } if (verbose) { t1 = wallclock_time(); vmess("and CPU-time write data = %.3f", t1-t2); } free(tapersy); exit(0); }
QString VESPERSTimeScanConfiguration::headerText() const { QString header("Configuration of the Scan\n\n"); header.append(fluorescenceHeaderString(fluorescenceDetector())); header.append(incomingChoiceHeaderString(incomingChoice())); header.append(regionsOfInterestHeaderString(regionsOfInterest()) % "\n"); header.append(ccdDetectorHeaderString(ccdDetector())); header.append("\n"); header.append(QString("Acquired for %1 seconds every %2 seconds %3 times.\n").arg(time()).arg(timePerAcquisition()).arg(iterations())); return header; }