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
15namespace Pulsar {
16
17 class Archive;
18
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
66template<class Container>
67unsigned 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
The primary interface to pulsar observational data.
Definition Archive.h:46
std::string reason
Match failure reason.
Definition ChannelSubsetMatch.h:55
double bw_tol
Fractional BW matching tolerance.
Definition ChannelSubsetMatch.h:61
std::string get_reason() const
Get reason for match failure.
Definition ChannelSubsetMatch.h:46
int super_channel(const Archive *super, const Archive *sub, int subchan)
Definition ChannelSubsetMatch.C:150
bool match(const Archive *super, const Archive *sub)
Check that Archive sub's channels all exist in super.
Definition ChannelSubsetMatch.C:43
ChannelSubsetMatch()
Default constructor.
Definition ChannelSubsetMatch.C:19
int sub_channel(const Archive *super, const Archive *sub, int superchan)
Definition ChannelSubsetMatch.C:162
double freq_tol
Fractional freq matching tolerance.
Definition ChannelSubsetMatch.h:58
~ChannelSubsetMatch()
Default constructor.
Definition ChannelSubsetMatch.C:27
Data storage implementations.
Definition Container.h:19
Defines the PSRCHIVE library.
Definition CalSource.h:17

Generated using doxygen 1.14.0