ProfileAmps.h
1 //-*-C++-*-
2 /***************************************************************************
3  *
4  * Copyright (C) 2002 by Willem van Straten
5  * Licensed under the Academic Free License version 2.1
6  *
7  ***************************************************************************/
8 
9 // psrchive/Base/Classes/Pulsar/ProfileAmps.h
10 
11 #ifndef __Pulsar_ProfileAmps_h
12 #define __Pulsar_ProfileAmps_h
13 
14 #include "Pulsar/Container.h"
15 
16 namespace Pulsar {
17 
19 
23  class ProfileAmps : public Container {
24 
25  public:
26 
28  static bool no_amps;
29 
31  ProfileAmps (unsigned nbin = 0);
32 
34  virtual ~ProfileAmps ();
35 
37  ProfileAmps (const ProfileAmps&);
38 
40  unsigned get_nbin () const { return nbin; }
41 
43  virtual void resize (unsigned nbin);
44 
46  const float* get_amps () const;
47 
49  float* get_amps ();
50 
52  template <typename T> void set_amps (const T* data);
53 
55  template <typename T> void set_amps (const std::vector<T>& data);
56 
58  template <typename T> void get_amps (std::vector<T>& data) const;
59 
61 
62  void remove (const std::vector<unsigned>& indeces);
63 
65  class Expert;
66 
67  private:
68 
69  friend class Expert;
70 
72  unsigned nbin;
73 
75  float *amps;
76 
78  unsigned amps_size;
79 
80  };
81 
82 }
83 
88 template <typename T>
89 void Pulsar::ProfileAmps::set_amps (const T* data)
90 {
91  for (unsigned ibin=0; ibin<nbin; ibin++)
92  amps[ibin] = static_cast<float>( data[ibin] );
93 }
94 
98 template <typename T>
99 void Pulsar::ProfileAmps::set_amps (const std::vector<T>& data)
100 {
101  resize (data.size());
102  for (unsigned ibin=0; ibin<nbin; ibin++)
103  amps[ibin] = static_cast<float>( data[ibin] );
104 }
105 
109 template <typename T>
110 void Pulsar::ProfileAmps::get_amps (std::vector<T>& data) const
111 {
112  data.resize (nbin);
113  for (unsigned ibin=0; ibin<nbin; ibin++)
114  data[ibin] = static_cast<T>( amps[ibin] );
115 }
116 
117 #endif // !defined __Pulsar_ProfileAmps_h
void average(const Profile *that)
set this to the weighted average of this and that
Definition: Profile_average.C:52
void correlate_normalized(const Profile *profile)
cross-correlates and normalizes this with the given profile in time domain
Definition: Profile_convolve.C:24
virtual ~ProfileAmps()
Destructor destroys the data array.
Definition: ProfileAmps.C:89
static bool no_amps
When true, no memory is allocated for amps.
Definition: ProfileAmps.h:38
double mean(float phase, float duty_cycle=default_duty_cycle) const
Convenience interface to stats, returns only the mean.
Definition: Profile_stats.C:121
const float * get_amps() const
Return a pointer to the amplitudes array.
Definition: ProfileAmps.C:141
void frc1d(size_t nfft, float *into, const float *from)
float get_weight() const
get the weight of the profile
Definition: Profile.h:207
Estimate< double > shift(const Profile &std) const
Returns the shift (in turns) between profile and standard.
Definition: Profile_shift.C:20
void bcr1d(size_t nfft, float *into, const float *from)
Provides access to private and protected members of ProfileAmps.
Definition: ProfileAmpsExpert.h:32
void set_amps(const T *data)
set the amplitudes array equal to the contents of the data array
Definition: ProfileAmps.h:89
Stores a weight for each Profile phase bin.
Definition: PhaseWeight.h:29
float find_min_phase(float duty_cycle=default_duty_cycle) const
Returns the phase of the centre of the region with minimum mean.
Definition: Profile_find_minmax_phase.C:21
float snr() const
Returns the signal to noise ratio of the profile.
Definition: Profile_snr.C:15
void convolve(const Profile *profile)
convolves this with the given profile in time domain
Definition: Profile_convolve.C:14
Any quantity recorded as a function of pulse phase.
Definition: Profile.h:45
static Option< Edges > peak_edges_strategy
The default implementation of the edge detection algorithm.
Definition: Profile.h:172
unsigned get_nbin() const
Return the number of bins.
Definition: ProfileAmps.h:50
void remove(const std::vector< unsigned > &indeces)
remove the elements specified in the array of indeces
Definition: ProfileAmps.C:161
const ScalarMath sqrt(const ScalarMath &x)
void derivative()
compute the derivative of profile with respect to index
Definition: Profile_derivative.C:20
Estimates phase shift in Fourier domain.
Definition: PhaseGradShift.h:27
void rotate_phase(double phase)
rotates the profile by phase (in turns)
Definition: Profile_rotate.C:35
void shift(unsigned npts, float *arr, double shift)
virtual Profile * clone() const
returns a pointer to a new copy of self
Definition: Profile.C:124
void fft_convolve(const Profile *profile)
convolves this with the given profile (using fft method)
Definition: Profile_convolve.C:65
float find_max_phase(float duty_cycle=default_duty_cycle) const
Returns the phase of the centre of the region with maximum mean.
Definition: Profile_find_minmax_phase.C:43
static Option< bool > rotate_in_phase_domain
When true, Profile::rotate shifts bins in the phase domain.
Definition: Profile.h:56
void derivative(unsigned npts, float *data)
void find_transitions(int &highlow, int &lowhigh, int &width) const
Find the bin numbers at which the mean power transits.
Definition: Profile_find_transitions.C:45
Configuration option.
Definition: Config.h:73
void correlate(const Profile *profile)
cross-correlates this with the given profile in time domain
Definition: Profile_convolve.C:19
void dedisperse(double dm, double ref_freq, double pfold)
Rotates the profile to remove dispersion delay.
Definition: Profile_dedisperse.C:24
ProfileAmps(unsigned nbin=0)
Constructor initializes the data array.
Definition: ProfileAmps.C:56
Finds the phase window in which the smoothed Profile is an extremum.
Definition: BaselineWindow.h:28
virtual void resize(unsigned nbin)
Resize the data area.
Definition: ProfileAmps.C:104
Estimates phase shift in time domain using parabolic interpolation.
Definition: ParIntShift.h:24
Provides protected access to the Profile amplitudes array.
Definition: ProfileAmps.h:28
void stats(double *mean, double *variance=0, double *varmean=0, int bin_start=0, int bin_end=0) const
Calculates the mean, variance, and variance of the mean.
Definition: Profile_stats.C:27
PhaseWeight * baseline() const
Return a new PhaseWeight instance with the baseline phase bins masked.
Definition: Profile_baseline.C:15
Defines the PSRCHIVE library.
Definition: CalSource.h:17
virtual void set_weight(float)
set the weight of the profile
Definition: Profile.C:185
static Option< float > transition_duty_cycle
fractional phase window used to find rise and fall of running mean
Definition: Profile.h:59
void find_peak_edges(int &rise, int &fall) const
Find the bin numbers at which the cumulative power crosses thresholds.
Definition: Profile_find_peak_edges.C:34

Generated using doxygen 1.8.17