Tempo::toa Pulsar::ArrivalTime::get_toa (Estimate<double>& shift, const Pulsar::Integration* subint, unsigned ichan) { Tempo::toa toa (format); // phase shift in turns toa.set_phase_shift (shift.get_value()); // topocentric folding period double period = subint->get_folding_period(); // epoch of the integration (rise time of bin 0 in each profile) MJD epoch = subint->get_epoch (); // arrival time toa.set_arrival (epoch + shift.get_value() * period); // arrival time error in microseconds toa.set_error (shift.get_error() * period * 1e6); if (subint->get_dedispersed()) toa.set_frequency (subint->get_centre_frequency()); else toa.set_frequency (subint->get_centre_frequency(ichan)); toa.set_channel (ichan); // would like to see this go somewhere else if (format == Tempo::toa::Parkes || format == Tempo::toa::Psrclock) toa.set_auxilliary_text( tostring(ichan) ); return toa; }
Estimate<double> Pulsar::FourierDomainFit::get_shift () const { Profile prfcopy = *observation; Reference::To<Profile> obs_p = &prfcopy; if (error_method=="mcmc") fit.set_error_method(ProfileShiftFit::MCMC_Variance); else if (error_method=="trad") fit.set_error_method(ProfileShiftFit::Traditional_Chi2); else if (error_method=="num") fit.set_error_method(ProfileShiftFit::Numerical); else throw Error (InvalidParam, "Pulsar::FourierDomainFit::get_shift", "Uncertainty method '" + error_method + "' not known"); fit.set_Profile(obs_p); fit.compute(); reduced_chisq = fit.get_reduced_chisq(); snr = fit.get_snr(); // Change shift range from 0->1 to -0.5->0.5 Estimate<double> result = fit.get_shift(); if (result.get_value() > 0.5) { result -= 1.0; } return result; }
void Pulsar::LastHarmonic::build () { if (!profile) throw Error (InvalidState, "Pulsar::LastHarmonic::build", "Profile not set"); if (!baseline_estimator) throw Error (InvalidState, "Pulsar::LastHarmonic::build", "Baseline estimator not set"); Reference::To<PhaseWeight> baseline = baseline_estimator->baseline (profile); Estimate<double> mean = baseline->get_mean (); Estimate<double> var = baseline->get_variance (); Estimate<double> rms = sqrt(var); #ifdef _DEBUG cerr << "Pulsar::LastHarmonic::build mean=" << mean << " rms=" << rms << endl; #endif significant.find (profile, rms.get_value()); // skip the DC term bin_rise = 1; bin_fall = significant.get(); }
//! Set the Stokes parameters of the model void MEAL::ModeCoherency::set_stokes (const Stokes<Estimate<double> >& stokes) { if (stokes[0].get_value() <= 0.0) throw Error (InvalidParam, "MEAL::ModeCoherency::set_stokes", "total intensity I=%lf <= 0", stokes[0].get_value()); Estimate<double> p = stokes.abs_vect() / stokes[0]; if (p.get_value() >= 1) throw Error (InvalidParam, "MEAL::ModeCoherency::set_stokes", "degree of polarization p=%lf >= 1", p.get_value()); if (p.get_value() == 0.0) throw Error (InvalidParam, "MEAL::ModeCoherency::set_stokes", "degree of polarization p==0"); log_intensity->set_value ( log( 0.5 * stokes[0] * sqrt(1-p*p) ) ); log_beta->set_value ( log(atanh(p)) ); axis->set_vector (stokes.get_vector()); }
void Pulsar::ComponentModel::align (const Profile *profile) { Profile modelprof(*profile); evaluate (modelprof.get_amps(), modelprof.get_nbin()); Estimate<double> shift = profile->shift (modelprof); if (verbose) cerr << "Pulsar::ComponentModel::align shift=" << shift << endl; if (phase) { float normalization = profile->sum() / modelprof.sum(); if (verbose) cerr << "Pulsar::ComponentModel::align normalization=" << normalization << endl; for (unsigned icomp=0; icomp < components.size(); icomp++) { Estimate<double> height = components[icomp]->get_height(); components[icomp]->set_height ( height * normalization ); } phase->set_value (phase->get_value() + shift.get_value() * 2*M_PI); return; } // Dick requires this cout << setprecision(6) << fixed << "Shift= " << shift.val << endl; for (unsigned icomp=0; icomp < components.size(); icomp++) { Estimate<double> centre = components[icomp]->get_centre() + shift * 2*M_PI; if (centre.val >= M_PI) centre -= 2*M_PI; if (centre.val < -M_PI) centre += 2*M_PI; components[icomp]->set_centre(centre); } }
/* returns the phase shift and scale that aligns the profile with the model */ void Pulsar::ComponentModel::get_best_alignment (const Profile* profile, double& the_phase, double& the_scale) { Profile modelprof (profile->get_nbin()); if (verbose) cerr << "Pulsar::ComponentModel::get_best_alignment calling evaluate" << endl; evaluate (modelprof.get_amps(), modelprof.get_nbin()); Estimate<double> shift = profile->shift (modelprof); if (verbose) cerr << "Pulsar::ComponentModel::get_best_alignment shift=" << shift << endl; the_phase = shift.get_value(); the_scale = profile->sum() / modelprof.sum(); if (verbose) cerr << "Pulsar::ComponentModel::get_best_alignment scale=" << the_scale << endl; }
void psrflux::process (Pulsar::Archive* archive) { // Convert to total intensity archive->convert_state(Signal::Intensity); // Set self-standard if needed if (stdfile=="") set_standard(archive); // Test for single-profile data bool single_profile = archive->get_nsubint()==1 && archive->get_nchan()==1; // Access to the flux computation StandardFlux *flux = dynamic_cast<StandardFlux*>(ds.get_flux_method().get()); // If shifts not fit, need to dedisperse and possibly align total // with standard. if (noalign) { archive->dedisperse(); flux->set_fit_shift(false); } else if (align==false && single_profile==false) { archive->dedisperse(); Reference::To<Archive> arch_tot = archive->total(); Estimate<double> shift = arch_tot->get_Profile(0,0,0)->shift(stdarch->get_Profile(0,0,0)); stdarch->get_Profile(0,0,0)->rotate_phase(-1.0*shift.get_value()); flux->set_fit_shift(false); } else { flux->set_fit_shift(true); } // Compute DS ds.set_Archive(archive); ds.compute(); // Unload archive with .sm extension std::string outf = archive->get_filename() + "." + ext; cerr << "psrflux: unloading " << outf << endl; ds.unload(outf, command); }