11 #ifndef __Pulsar_ColdPlasma_h
12 #define __Pulsar_ColdPlasma_h
14 #include "Pulsar/Transformation.h"
15 #include "Pulsar/Integration.h"
16 #include "Pulsar/Archive.h"
17 #include "Pulsar/Profile.h"
37 template< class Corrector, class History>
38 class ColdPlasma : public Transformation<Integration> {
42 typedef typename Corrector::Return Type;
63 virtual void combine (Type& result, const Type& add) = 0;
132 friend class Integration;
135 void range (Integration*, unsigned ichan, unsigned jchan);
150 double backup_measure;
156 template< class C, class H>
160 set_measure( get_correction_measure(data) );
162 if (Integration::verbose)
163 std::cerr << "Pulsar::" + name + "::setup lambda="
164 << get_reference_wavelength() << " measure=" << get_measure()
168 template< class C, class H>
176 throw error += "Pulsar::" + name + "::transform";
179 template< class C, class H>
186 template< class C, class H>
193 template< class C, class H>
196 delta = get_identity ();
202 template< class C, class H>
205 corrector.set_reference_frequency (MHz);
208 template< class C, class H>
211 return corrector.get_reference_frequency ();
214 template< class C, class H>
217 corrector.set_reference_wavelength (metres);
220 template< class C, class H>
223 return corrector.get_reference_wavelength ();
226 template< class C, class H>
229 corrector.set_measure (measure);
232 template< class C, class H>
235 return corrector.get_measure ();
238 template< class Corrector, class History>
242 backup_measure = get_measure();
244 double effective_measure = backup_measure;
246 if (Integration::verbose)
247 std::cerr << "Pulsar::" + name + "::update"
248 " backup measure=" << backup_measure << std::endl;
250 delta = get_identity();
252 double absolute_measure = get_absolute_measure (data);
253 if (absolute_measure)
255 if (Integration::verbose)
256 std::cerr << "Pulsar::" + name + "::update absolute"
257 " measure=" << absolute_measure << std::endl;
261 absolute.set_measure( absolute_measure );
262 absolute.set_reference_wavelength( 0 );
264 combine (delta, absolute.evaluate());
267 effective_measure += absolute_measure;
270 const History* corrected = 0;
272 if ( get_corrected(data) )
273 corrected = data->template get<History>();
277 double corrected_measure = corrected->get_measure();
278 double lambda = corrected->get_reference_wavelength();
280 if (Integration::verbose)
281 std::cerr << "Pulsar::" + name + "::update corrected"
282 " measure=" << corrected_measure << " lambda=" << lambda
286 corrector.set_wavelength( lambda );
287 combine (delta, corrector.evaluate());
289 effective_measure -= corrected_measure;
292 if (Integration::verbose)
293 std::cerr << "Pulsar::" + name + "::update effective_measure="
294 << effective_measure << std::endl;
297 set_measure( effective_measure );
301 throw error += "Pulsar::"+name+ "::update";
304 template< class C, class History>
309 if (Integration::verbose)
310 std::cerr << "Pulsar::"+name+ "::execute1"
311 " effective "+val+ "=" << get_measure() <<
312 " reference wavelength=" << get_reference_wavelength() << std::endl;
317 set_measure( backup_measure );
319 History* corrected = new History;
320 corrected->set_measure( backup_measure );
321 corrected->set_reference_wavelength( get_reference_wavelength() );
327 throw error += "Pulsar::"+name+ "::execute1";
330 template< class C, class History>
333 if ( !get_corrected(data) )
336 History* corrected = data->template get<History>();
339 throw Error (InvalidState, "Pulsar::" + name + "::revert1",
340 "no correction history");
342 set_measure( -corrected->get_measure() );
343 set_reference_wavelength( corrected->get_reference_wavelength() );
344 set_delta( get_identity() );
346 if (Integration::verbose)
347 std::cerr << "Pulsar::"+name+ "::revert1"
348 " effective "+val+ "=" << get_measure() <<
349 " reference wavelength=" << get_reference_wavelength() << std::endl;
358 throw error += "Pulsar::"+name+ "::revert1";
362 template< class C, class History>
366 const History* corrected = reference->template get<History>();
368 throw Error (InvalidState, "Pulsar::" + name + "::match",
369 "reference has no correction history");
371 set_measure( corrected->get_measure() );
372 set_reference_wavelength( corrected->get_reference_wavelength() );
374 execute1( to_correct );
388 template< class C, class H>
390 unsigned ichan, unsigned kchan) try
393 if (Integration::verbose)
394 std::cerr << "Pulsar::"+name+ "::range "+val+ "=" << get_measure()
395 << " lambda_0=" << get_reference_wavelength() << " m"
396 << " delta=" << delta << std::endl;
398 if (get_measure() == 0 && delta == get_identity())
402 throw Error (InvalidRange, "Pulsar::"+name+ "::range",
403 "start chan=%d >= nchan=%d", ichan, data-> get_nchan());
406 throw Error (InvalidRange, "Pulsar::"+name+ "::range",
407 "end chan=%d > nchan=%d", kchan, data-> get_nchan());
409 for ( unsigned jchan=ichan; jchan < kchan; jchan++)
416 catch ( Error& error) {
417 throw error += "Pulsar::"+name+ "::range";
426 template< class C, class H>
428 unsigned ichan, unsigned kchan,
429 double reference_frequency)
432 double effective_measure = get_effective_measure (subint);
434 if (Integration::verbose)
435 std::cerr << "Pulsar::" + name + "::correct"
436 " reference freq=" << reference_frequency <<
437 " effective measure=" << effective_measure << std::endl;
439 set_measure( effective_measure );
440 set_reference_frequency( reference_frequency );
441 set_delta( get_identity() );
443 range (subint, ichan, kchan);
447 throw error += "Pulsar::"+name+ "::correct";
ColdPlasma() Default constructor. Definition: ColdPlasma.h:55
virtual double get_effective_measure(const Integration *)=0 Derived classes must return the effective measure to be corrected.
Corrector corrector The dielectric effect corrector. Definition: ColdPlasma.h:148
virtual void set(const Integration *data) Calls setup then update. Definition: ColdPlasma.h:99
double get_centre_frequency() const get the centre frequency (in MHz) Definition: Profile.h:202
Type delta The correction due to a change in reference wavelength. Definition: ColdPlasma.h:151
void correct(Integration *, unsigned ichan, unsigned jchan, double freq) Correct the selected range according to effective_measure. Definition: ColdPlasma.h:427
double get_centre_frequency(unsigned ichan) const Get the Profile centre frequency attribute of the given channel. Definition: Integration.C:359
void revert1(Integration *) Undo the correction. Definition: ColdPlasma.h:331
virtual unsigned get_nsubint() const =0 Get the number of sub-integrations stored in the file.
Any quantity recorded as a function of pulse phase. Definition: Profile.h:45
The primary interface to pulsar observational data. Definition: Archive.h:45
void set_reference_frequency(double MHz) Set the reference frequency in MHz. Definition: ColdPlasma.h:203
virtual void execute(Archive *) Execute the correction for an entire Archive. Definition: ColdPlasma.h:180
void just_do_it(Archive *) Just do the correction (off the books) Definition: ColdPlasma.h:194
std::string name The name to be used in verbose messages. Definition: ColdPlasma.h:154
double get_reference_frequency() const Get the reference frequency in MHz. Definition: ColdPlasma.h:209
virtual void add_extension(Extension *extension) Add an Extension to the Integration instance. Definition: Integration.C:90
virtual void combine(Type &result, const Type &add)=0 Derived classes must define the operator.
void set_reference_wavelength(double metres) Set the reference wavelength in metres. Definition: ColdPlasma.h:215
void range(Integration *, unsigned ichan, unsigned jchan) Execute the correction on the selected range. Definition: ColdPlasma.h:389
virtual unsigned get_nchan() const =0 Get the number of frequency channels used.
virtual bool get_corrected(const Integration *)=0 Return true if the data have been corrected.
Record of phase-coherent dispersion removal algorithm. Definition: CoherentDedispersion.h:27
virtual double get_absolute_measure(const Integration *)=0 Return the measure to be corrected with respect to infinite frequency.
Integration * get_Integration(unsigned subint) Return pointer to the specified Integration. Definition: IntegrationManager.C:41
void update(const Integration *) update internal variables before execution Definition: ColdPlasma.h:239
std::string val The name of the correction measure. Definition: ColdPlasma.h:157
void set_delta(const Type &d) Set the correction due to a change in reference wavelength. Definition: ColdPlasma.h:136
Array of Profiles integrated over the same time interval. Definition: Integration.h:37
void execute1(Integration *) Execute the correction. Definition: ColdPlasma.h:305
virtual Type get_identity()=0 Derived classes must define the identity.
double get_measure() const Get the correction measure. Definition: ColdPlasma.h:233
void setup(const Integration *) Set up internal variables before execution. Definition: ColdPlasma.h:157
void set_measure(double measure) Set the correction measure. Definition: ColdPlasma.h:227
virtual void apply(Integration *, unsigned channel)=0 Derived classes must define how to apply the correction.
Type get_delta() const Get the correction due to a change in reference wavelength. Definition: ColdPlasma.h:138
virtual unsigned get_nchan() const =0 Get the number of chans.
virtual void revert(Archive *) Revert the correction for an entire Archive. Definition: ColdPlasma.h:187
void match(const Integration *reference, Integration *to_be_corrected) Correct the second argument as the first argument was corrected. Definition: ColdPlasma.h:363
Defines the PSRCHIVE library. Definition: CalSource.h:17
void transform(Integration *) The default correction. Definition: ColdPlasma.h:169
double get_reference_wavelength() const Get the reference wavelength. Definition: ColdPlasma.h:221
virtual void set_Profile(const Profile *data) Set the frequency for which the correction will be computed. Definition: ColdPlasma.h:103
virtual double get_correction_measure(const Integration *)=0 Return the measure to be corrected with respect to centre frequency.
Generated using doxygen 1.8.17
|