lsst.astshim  master-gd1207e8857
 All Classes Namespaces Functions Variables Typedefs Enumerations Pages
SpecFrame.h
1 /*
2  * LSST Data Management System
3  * Copyright 2016 AURA/LSST.
4  *
5  * This product includes software developed by the
6  * LSST Project (http://www.lsst.org/).
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the LSST License Statement and
19  * the GNU General Public License along with this program. If not,
20  * see <https://www.lsstcorp.org/LegalNotices/>.
21  */
22 #ifndef ASTSHIM_SPECFRAME_H
23 #define ASTSHIM_SPECFRAME_H
24 
25 #include <memory>
26 #include <vector>
27 
28 #include "astshim/base.h"
29 #include "astshim/detail/utils.h"
30 #include "astshim/Frame.h"
31 
32 namespace ast {
33 
107 class SpecFrame : public Frame {
108 friend class Object;
109 public:
115  explicit SpecFrame(std::string const & options="") :
116  Frame(reinterpret_cast<AstFrame *>(astSpecFrame(options.c_str())))
117  {}
118 
119  virtual ~SpecFrame() {}
120 
121  SpecFrame(SpecFrame const &) = delete;
122  SpecFrame(SpecFrame &&) = default;
123  SpecFrame & operator=(SpecFrame const &) = delete;
124  SpecFrame & operator=(SpecFrame &&) = default;
125 
127  std::shared_ptr<SpecFrame> copy() const {
128  return std::static_pointer_cast<SpecFrame>(_copyPolymorphic());
129  }
130 
135  bool getAlignSpecOffset() const { return getB("AlignSpecOffset"); }
136 
141  std::string getAlignStdOfRest() const { return getC("AlignStdOfRest"); }
142 
144  std::string getRefDec() const { return getC("RefDec"); }
145 
147  std::string getRefRA() const { return getC("RefRA"); }
148 
158  std::vector<double> getRefPos(SkyFrame const & frm) const {
159  std::vector<double> ret(2);
160  astGetRefPos(getRawPtr(), frm.getRawPtr(), &ret[0], &ret[1]);
161  assertOK();
162  detail::astBadToNan(ret);
163  return ret;
164  }
165 
170  std::vector<double> getRefPos() const {
171  std::vector<double> ret(2);
172  // using NULL instead of nullptr avoids a compiler warning about comparing NULL to nullptr_t
173  astGetRefPos(getRawPtr(), NULL, &ret[0], &ret[1]);
174  assertOK();
175  detail::astBadToNan(ret);
176  return ret;
177  }
178 
180  double getRestFreq() const { return getD("RestFreq"); }
181 
183  std::string getSourceSys() const { return getC("SourceSys"); }
184 
189  double getSourceVel() const { return getD("SourceVel"); }
190 
192  std::string getSourceVRF() const { return getC("SourceVRF"); }
193 
195  double getSpecOrigin() const { return getD("SpecOrigin"); }
196 
198  std::string getStdOfRest() const { return getC("StdOfRest"); }
199 
200 
205  void setAlignSpecOffset(bool align) { setB("AlignSpecOffset", align); }
206 
211  void setAlignStdOfRest(std::string const & stdOfRest) { setC("AlignStdOfRest", stdOfRest); }
212 
214  void setRefDec(std::string const & refDec) { setC("RefDec", refDec); }
215 
217  void setRefRA(std::string const & refRA) { setC("RefRA", refRA); }
218 
231  void setRefPos(SkyFrame const & frm, double lon, double lat) {
232  astSetRefPos(getRawPtr(), frm.getRawPtr(), lon, lat);
233  assertOK();
234  }
235 
243  void setRefPos(double ra, double dec) {
244  // using NULL instead of nullptr avoids a compiler warning about comparing NULL to nullptr_t
245  astSetRefPos(getRawPtr(), NULL, ra, dec);
246  assertOK();
247  }
248 
250  void setRestFreq(double freq) { setD("RestFreq", freq); }
251 
253  void setRestFreq(std::string const & freq) { setC("RestFreq", freq); }
254 
256  void setSourceSys(std::string const & system) { setC("SourceSys", system); }
257 
262  void setSourceVel(double vel) { setD("SourceVel", vel); }
263 
265  void setSourceVRF(std::string const & vrf) { setC("SourceVRF", vrf); }
266 
268  void setSpecOrigin(double origin) { setD("SpecOrigin", origin); }
269 
271  void setStdOfRest(std::string const & stdOfRest) { setC("StdOfRest", stdOfRest); }
272 
273 protected:
274  virtual std::shared_ptr<Object> _copyPolymorphic() const override {
275  return _copyImpl<SpecFrame, AstSpecFrame>();
276  }
277 
279  explicit SpecFrame(AstSpecFrame * rawptr) :
280  Frame(reinterpret_cast<AstFrame *>(rawptr))
281  {
282  if (!astIsASpecFrame(getRawPtr())) {
283  std::ostringstream os;
284  os << "this is a " << getClass() << ", which is not a SpecFrame";
285  throw std::invalid_argument(os.str());
286  }
287  }
288 };
289 
290 } // namespace ast
291 
292 #endif
virtual std::shared_ptr< Object > _copyPolymorphic() const override
Definition: SpecFrame.h:274
void setRestFreq(double freq)
Set RestFreq: rest frequency in GHz.
Definition: SpecFrame.h:250
void setRefDec(std::string const &refDec)
Set RefDec: declination of the source (FK5 J2000, &quot;dd:mm:ss.s&quot;).
Definition: SpecFrame.h:214
std::string getAlignStdOfRest() const
Definition: SpecFrame.h:141
Definition: Frame.h:158
void setSourceVel(double vel)
Definition: SpecFrame.h:262
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Definition: base.cc:53
std::string getClass() const
Definition: Object.h:117
void setRefPos(double ra, double dec)
Definition: SpecFrame.h:243
std::string const getC(std::string const &attrib) const
Definition: Object.h:347
std::string getStdOfRest() const
Get StdOfRest: standard of rest.
Definition: SpecFrame.h:198
void setStdOfRest(std::string const &stdOfRest)
Set StdOfRest: standard of rest.
Definition: SpecFrame.h:271
void setB(std::string const &attrib, bool value)
Definition: Object.h:435
void setSourceVRF(std::string const &vrf)
Set SourceVRF: source velocity rest frame.
Definition: SpecFrame.h:265
Definition: Object.h:49
std::string getRefRA() const
Get RefRA: right ascension of the source (FK5 J2000, &quot;hh:mm:ss.s&quot;).
Definition: SpecFrame.h:147
SpecFrame(AstSpecFrame *rawptr)
Construct a SpecFrame from a raw AST pointer.
Definition: SpecFrame.h:279
Definition: SkyFrame.h:66
double getSpecOrigin() const
Get SpecOrigin: the zero point for SpecFrame axis values.
Definition: SpecFrame.h:195
std::vector< double > getRefPos() const
Definition: SpecFrame.h:170
double getRestFreq() const
Get RestFreq: rest frequency (GHz).
Definition: SpecFrame.h:180
void setC(std::string const &attrib, std::string const &value)
Definition: Object.h:447
void setAlignStdOfRest(std::string const &stdOfRest)
Definition: SpecFrame.h:211
void setAlignSpecOffset(bool align)
Definition: SpecFrame.h:205
Definition: SpecFrame.h:107
SpecFrame(std::string const &options="")
Definition: SpecFrame.h:115
bool getAlignSpecOffset() const
Definition: SpecFrame.h:135
void setSpecOrigin(double origin)
Set SpecOrigin: the zero point for SpecFrame axis values.
Definition: SpecFrame.h:268
double getD(std::string const &attrib) const
Definition: Object.h:360
std::string getSourceVRF() const
Get SourceVRF: source velocity rest frame.
Definition: SpecFrame.h:192
void setRefPos(SkyFrame const &frm, double lon, double lat)
Definition: SpecFrame.h:231
void setD(std::string const &attrib, double value)
Definition: Object.h:459
std::string getRefDec() const
Get RefDec: declination of the source (FK5 J2000, &quot;dd:mm:ss.s&quot;).
Definition: SpecFrame.h:144
std::shared_ptr< SpecFrame > copy() const
Return a deep copy of this object.
Definition: SpecFrame.h:127
void setRestFreq(std::string const &freq)
Set RestFreq: rest frequency in user-specified units.
Definition: SpecFrame.h:253
bool getB(std::string const &attrib) const
Definition: Object.h:334
std::string getSourceSys() const
Get SourceSys: source velocity spectral system.
Definition: SpecFrame.h:183
void setRefRA(std::string const &refRA)
Set RefRA: right ascension of the source (FK5 J2000, &quot;hh:mm:ss.s&quot;).
Definition: SpecFrame.h:217
std::vector< double > getRefPos(SkyFrame const &frm) const
Definition: SpecFrame.h:158
double getSourceVel() const
Definition: SpecFrame.h:189
AstObject const * getRawPtr() const
Definition: Object.h:260
void setSourceSys(std::string const &system)
Set SourceSys: source velocity spectral system.
Definition: SpecFrame.h:256