lsst.astshim  master-g139ee105a0+1
SpecFrame.h
1 /*
2  * LSST Data Management System
3  * Copyright 2017 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 
110 public:
116  explicit SpecFrame(std::string const &options = "")
117  : Frame(reinterpret_cast<AstFrame *>(astSpecFrame("%s", options.c_str()))) {}
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 
204  void setAlignSpecOffset(bool align) { setB("AlignSpecOffset", align); }
205 
210  void setAlignStdOfRest(std::string const &stdOfRest) { setC("AlignStdOfRest", stdOfRest); }
211 
213  void setRefDec(std::string const &refDec) { setC("RefDec", refDec); }
214 
216  void setRefRA(std::string const &refRA) { setC("RefRA", refRA); }
217 
230  void setRefPos(SkyFrame const &frm, double lon, double lat) {
231  astSetRefPos(getRawPtr(), frm.getRawPtr(), lon, lat);
232  assertOK();
233  }
234 
242  void setRefPos(double ra, double dec) {
243  // using NULL instead of nullptr avoids a compiler warning about comparing NULL to nullptr_t
244  astSetRefPos(getRawPtr(), NULL, ra, dec);
245  assertOK();
246  }
247 
249  void setRestFreq(double freq) { setD("RestFreq", freq); }
250 
252  void setRestFreq(std::string const &freq) { setC("RestFreq", freq); }
253 
255  void setSourceSys(std::string const &system) { setC("SourceSys", system); }
256 
261  void setSourceVel(double vel) { setD("SourceVel", vel); }
262 
264  void setSourceVRF(std::string const &vrf) { setC("SourceVRF", vrf); }
265 
267  void setSpecOrigin(double origin) { setD("SpecOrigin", origin); }
268 
270  void setStdOfRest(std::string const &stdOfRest) { setC("StdOfRest", stdOfRest); }
271 
272 protected:
273  virtual std::shared_ptr<Object> copyPolymorphic() const override {
274  return copyImpl<SpecFrame, AstSpecFrame>();
275  }
276 
278  explicit SpecFrame(AstSpecFrame *rawptr) : Frame(reinterpret_cast<AstFrame *>(rawptr)) {
279  if (!astIsASpecFrame(getRawPtr())) {
280  std::ostringstream os;
281  os << "this is a " << getClassName() << ", which is not a SpecFrame";
282  throw std::invalid_argument(os.str());
283  }
284  }
285 };
286 
287 } // namespace ast
288 
289 #endif
void setSourceVel(double vel)
Definition: SpecFrame.h:261
std::vector< double > getRefPos() const
Definition: SpecFrame.h:170
AstObject const * getRawPtr() const
Definition: Object.h:286
double getSourceVel() const
Definition: SpecFrame.h:189
void setSpecOrigin(double origin)
Set SpecOrigin: the zero point for SpecFrame axis values.
Definition: SpecFrame.h:267
void setB(std::string const &attrib, bool value)
Definition: Object.h:448
std::string getSourceSys() const
Get SourceSys: source velocity spectral system.
Definition: SpecFrame.h:183
std::string getRefDec() const
Get RefDec: declination of the source (FK5 J2000, "dd:mm:ss.s").
Definition: SpecFrame.h:144
AST wrapper classes and functions.
Definition: attributes_channel.dox:1
void setSourceSys(std::string const &system)
Set SourceSys: source velocity spectral system.
Definition: SpecFrame.h:255
std::string getClassName() const
Definition: Object.h:133
void setRefDec(std::string const &refDec)
Set RefDec: declination of the source (FK5 J2000, "dd:mm:ss.s").
Definition: SpecFrame.h:213
Definition: SpecFrame.h:107
void assertOK(AstObject *rawPtr1=nullptr, AstObject *rawPtr2=nullptr)
Definition: base.cc:49
void setRestFreq(std::string const &freq)
Set RestFreq: rest frequency in user-specified units.
Definition: SpecFrame.h:252
SpecFrame(std::string const &options="")
Definition: SpecFrame.h:116
SpecFrame(AstSpecFrame *rawptr)
Construct a SpecFrame from a raw AST pointer.
Definition: SpecFrame.h:278
void setSourceVRF(std::string const &vrf)
Set SourceVRF: source velocity rest frame.
Definition: SpecFrame.h:264
std::string getStdOfRest() const
Get StdOfRest: standard of rest.
Definition: SpecFrame.h:198
void setAlignSpecOffset(bool align)
Definition: SpecFrame.h:204
std::vector< double > getRefPos(SkyFrame const &frm) const
Definition: SpecFrame.h:158
Definition: SkyFrame.h:66
void setRefPos(SkyFrame const &frm, double lon, double lat)
Definition: SpecFrame.h:230
bool getB(std::string const &attrib) const
Definition: Object.h:347
double getSpecOrigin() const
Get SpecOrigin: the zero point for SpecFrame axis values.
Definition: SpecFrame.h:195
Definition: Frame.h:157
void setC(std::string const &attrib, std::string const &value)
Definition: Object.h:460
void setRefPos(double ra, double dec)
Definition: SpecFrame.h:242
std::shared_ptr< SpecFrame > copy() const
Return a deep copy of this object.
Definition: SpecFrame.h:127
double getRestFreq() const
Get RestFreq: rest frequency (GHz).
Definition: SpecFrame.h:180
std::string getRefRA() const
Get RefRA: right ascension of the source (FK5 J2000, "hh:mm:ss.s").
Definition: SpecFrame.h:147
bool getAlignSpecOffset() const
Definition: SpecFrame.h:135
void setAlignStdOfRest(std::string const &stdOfRest)
Definition: SpecFrame.h:210
void setRefRA(std::string const &refRA)
Set RefRA: right ascension of the source (FK5 J2000, "hh:mm:ss.s").
Definition: SpecFrame.h:216
void setD(std::string const &attrib, double value)
Definition: Object.h:472
std::string getAlignStdOfRest() const
Definition: SpecFrame.h:141
virtual std::shared_ptr< Object > copyPolymorphic() const override
Definition: SpecFrame.h:273
double getD(std::string const &attrib) const
Definition: Object.h:373
std::string const getC(std::string const &attrib) const
Definition: Object.h:360
Definition: Object.h:49
void setStdOfRest(std::string const &stdOfRest)
Set StdOfRest: standard of rest.
Definition: SpecFrame.h:270
std::string getSourceVRF() const
Get SourceVRF: source velocity rest frame.
Definition: SpecFrame.h:192
void setRestFreq(double freq)
Set RestFreq: rest frequency in GHz.
Definition: SpecFrame.h:249