ChannelSubsetMatch.h
1 //-*-C++-*-
2 /***************************************************************************
3  *
4  * Copyright (C) 2008 by Paul Demorest
5  * Licensed under the Academic Free License version 2.1
6  *
7  ***************************************************************************/
8 
9 #ifndef __Pulsar_ChannelSubsetMatch_h
10 #define __Pulsar_ChannelSubsetMatch_h
11 
12 #include "Pulsar/Config.h"
13 #include "Pulsar/Database.h"
14 
15 namespace Pulsar {
16 
17  class Archive;
18 
20  class ChannelSubsetMatch {
21 
22  public:
23 
26 
29 
31  bool match (const Archive* super, const Archive* sub);
32 
34  bool match (const Database::StaticEntry* super,
35  const Database::StaticEntry* sub);
36 
39  int super_channel (const Archive* super, const Archive* sub, int subchan);
40 
43  int sub_channel (const Archive* super, const Archive* sub, int superchan);
44 
46  std::string get_reason() const { return reason; }
47 
48  template<class Container>
49  unsigned match_channel (const Container* container, double frequency,
50  double tolerance=0.0);
51 
52  protected:
53 
55  std::string reason;
56 
58  double freq_tol;
59 
61  double bw_tol;
62  };
63 
64 }
65 
66 template<class Container>
67 unsigned Pulsar::ChannelSubsetMatch::match_channel (const Container* container,
68  double frequency,
69  double tolerance)
70 {
71  if (tolerance==0.0)
72  {
73  // Use default value for class
74  tolerance = freq_tol * frequency;
75  }
76  for (unsigned j=0; j<container->get_nchan(); j++)
77  {
78  double cfreq = container->get_centre_frequency(j);
79  if (fabs(frequency-cfreq) < tolerance)
80  return j;
81  }
82 
83  throw Error (InvalidParam, "Pulsar::ChannelSubsetMatch::match_channel",
84  "no match for frequency=%lf", frequency);
85 }
86 
87 #endif
~ChannelSubsetMatch()
Default constructor.
Definition: ChannelSubsetMatch.C:27
int sub_channel(const Archive *super, const Archive *sub, int superchan)
Return channel in sub matching the given channel in super -1 == no match.
Definition: ChannelSubsetMatch.C:162
double bw_tol
Fractional BW matching tolerance.
Definition: ChannelSubsetMatch.h:66
virtual double get_centre_frequency(unsigned ichan) const
Get the centre frequency of the specified channel.
Definition: CalibratorExtension.C:101
Data storage implementations.
Definition: Container.h:24
ChannelSubsetMatch()
Default constructor.
Definition: ChannelSubsetMatch.C:19
double get_centre_frequency(unsigned ichan) const
Get the Profile centre frequency attribute of the given channel.
Definition: Integration.C:359
The primary interface to pulsar observational data.
Definition: Archive.h:45
std::string reason
Match failure reason.
Definition: ChannelSubsetMatch.h:60
Type * get() const
virtual unsigned get_nchan() const =0
Get the number of frequency channels used.
Integration * get_Integration(unsigned subint)
Return pointer to the specified Integration.
Definition: IntegrationManager.C:41
virtual double get_bandwidth() const =0
Get the overall bandwidth of the observation.
std::string get_reason() const
Get reason for match failure.
Definition: ChannelSubsetMatch.h:51
Stores Calibrator parameters in an Archive.
Definition: CalibratorExtension.h:27
Defines the PSRCHIVE library.
Definition: CalSource.h:17
double freq_tol
Fractional freq matching tolerance.
Definition: ChannelSubsetMatch.h:63
bool match(const Archive *super, const Archive *sub)
Check that Archive sub's channels all exist in super.
Definition: ChannelSubsetMatch.C:43
int super_channel(const Archive *super, const Archive *sub, int subchan)
Return channel in super matching the given channel in sub -1 == no match.
Definition: ChannelSubsetMatch.C:150

Generated using doxygen 1.8.17