Line data Source code
1 : //# FluxCalcQS.cc: Implementation of FluxCalcQS.h
2 : //# Copyright (C) 2010
3 : //# Associated Universities, Inc. Washington DC, USA.
4 : //#
5 : //# This library is free software; you can redistribute it and/or modify it
6 : //# under the terms of the GNU Library General Public License as published by
7 : //# the Free Software Foundation; either version 2 of the License, or (at your
8 : //# option) any later version.
9 : //#
10 : //# This library is distributed in the hope that it will be useful, but WITHOUT
11 : //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 : //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 : //# License for more details.
14 : //#
15 : //# You should have received a copy of the GNU Library General Public License
16 : //# along with this library; if not, write to the Free Software Foundation,
17 : //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 : //#
19 : //# Correspondence concerning AIPS++ should be addressed as follows:
20 : //# Internet email: casa-feedback@nrao.edu.
21 : //# Postal address: AIPS++ Project Office
22 : //# National Radio Astronomy Observatory
23 : //# 520 Edgemont Road
24 : //# Charlottesville, VA 22903-2475 USA
25 : //#
26 : #include <components/ComponentModels/FluxCalcQS.h>
27 : #include <casacore/casa/Arrays/Vector.h>
28 : #include <casacore/casa/BasicSL/String.h>
29 : #include <casacore/measures/Measures/MDirection.h>
30 : #include <casacore/measures/Measures/MFrequency.h>
31 :
32 : // Handy for passing anonymous arrays to functions.
33 : #include <casacore/scimath/Mathematics/RigidVector.h>
34 :
35 : #include <map>
36 :
37 :
38 : using namespace casacore;
39 : namespace casa { //# NAMESPACE CASA - BEGIN
40 :
41 0 : FluxCalcQS::FluxCalcQS() :
42 0 : srcEnum_p(FluxCalcQS::UNKNOWN_SOURCE)
43 : {
44 0 : names_p[FCQS::THREEC286] = RVS4("3C286", "1328+307", "1331+305", "J1331+3030").vector();
45 0 : directions_p[FCQS::THREEC286] = MDirection(MVDirection(3.539257626070549, 0.5324850225220917),
46 0 : MDirection::J2000);
47 0 : names_p[FCQS::THREEC48] = RVS4("3C48", "0134+329",
48 : "0137+331", // Together these match 33d09m35s
49 0 : "J0137+3309").vector(); // for dd.d or ddmm with a margin.
50 0 : directions_p[FCQS::THREEC48] = MDirection(MVDirection(0.4262457643630985, 0.5787463318245085),
51 0 : MDirection::J2000);
52 0 : names_p[FCQS::THREEC147] = RVS4("3C147", "0538+498", "0542+498",
53 0 : "J0542+4951").vector(); // Jhhmm+ddmm, CAS-2020
54 0 : directions_p[FCQS::THREEC147] = MDirection(MVDirection(1.4948817765383597, 0.8700805690768509),
55 0 : MDirection::J2000);
56 0 : names_p[FCQS::THREEC138] = RVS4("3C138", "0518+165", "0521+166",
57 0 : "J0521+1638").vector(); // Jhhmm+ddmm, CAS-2020
58 0 : directions_p[FCQS::THREEC138] = MDirection(MVDirection(1.401346673041897, 0.2904130912582342),
59 0 : MDirection::J2000);
60 0 : names_p[FCQS::NINETEEN34M638] = RigidVector<String, 2>("1934-638","J1939-6342").vector();
61 0 : directions_p[FCQS::NINETEEN34M638] = MDirection(MVDirection(5.146176021557448, -1.1119977478136984),
62 0 : MDirection::J2000);
63 0 : names_p[FCQS::THREEC295] = RVS4("3C295", "1409+524", "1411+522",
64 0 : "J1411+5212").vector(); // Jhhmm+ddmm, CAS-2020
65 0 : directions_p[FCQS::THREEC295] = MDirection(MVDirection(3.7146787856873478, 0.9111103509091509),
66 0 : MDirection::J2000);
67 0 : names_p[FCQS::THREEC196] = RVS4("3C196", "0809+483", "0813+482",
68 0 : "J0813+4813").vector(); // Jhhmm+ddmm, CAS-2020
69 0 : directions_p[FCQS::THREEC196] = MDirection(MVDirection(2.1537362969610023, 0.8415541320803659),
70 0 : MDirection::J2000);
71 : // added for Perley-Butler 2013 4h 37m 4.375301s 29d 40' 13.819008" CAS-4489 (other alias:B0433+2934)
72 0 : names_p[FCQS::THREEC123] = RVS4("3C123", "0433+295", "0437+296",
73 0 : "J0437+2940").vector();
74 0 : directions_p[FCQS::THREEC123] = MDirection(MVDirection(1.2089586878736391, 0.51784800786636209),
75 0 : MDirection::J2000);
76 0 : directions_p[FCQS::UNKNOWN_SOURCE] = MDirection(); // Default.
77 0 : }
78 :
79 : // Defined even though it's pure virtual; see http://www.gotw.ca/gotw/031.htm
80 0 : FluxCalcQS::~FluxCalcQS() { }
81 :
82 0 : Bool FluxCalcQS::operator()(Vector<Flux<Double> >& values,
83 : Vector<Flux<Double> >& errors,
84 : const Vector<MFrequency>& mfreqs)
85 : {
86 0 : uInt nfreqs = mfreqs.nelements();
87 :
88 0 : values.resize(nfreqs);
89 0 : errors.resize(nfreqs);
90 :
91 0 : Bool success = true;
92 0 : for(uInt f = 0; f < nfreqs; ++f)
93 0 : success &= (*this)(values[f], errors[f], mfreqs[f]);
94 0 : return success;
95 : }
96 :
97 0 : FluxCalcQS::Source FluxCalcQS::srcNameToEnum(const String& srcName) const
98 : {
99 0 : FCQS::Source srcEnum = FCQS::UNKNOWN_SOURCE;
100 :
101 0 : for(std::map<FCQS::Source, Vector<String> >::const_iterator it = names_p.begin();
102 0 : it != names_p.end(); ++it){
103 0 : for(Int i = it->second.nelements(); i--;){
104 0 : if(srcName.contains(it->second[i])){
105 0 : srcEnum = it->first;
106 0 : break;
107 : }
108 : }
109 0 : if(srcEnum != FCQS::UNKNOWN_SOURCE)
110 0 : break;
111 : }
112 0 : return srcEnum;
113 : }
114 :
115 0 : Bool FluxCalcQS::setSource(const String& sourceName)
116 : {
117 0 : srcEnum_p = srcNameToEnum(sourceName);
118 0 : return srcEnum_p != FCQS::UNKNOWN_SOURCE;
119 : }
120 :
121 0 : FluxCalcQS::Source FluxCalcQS::getSrcEnum()
122 : {
123 0 : return srcEnum_p;
124 : }
125 :
126 : } //# NAMESPACE CASA - END
|