lsst.astshim  master-ga9c57f210f+2
SkyFrame.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_SKYFRAME_H
23 #define ASTSHIM_SKYFRAME_H
24 
25 #include <memory>
26 #include <vector>
27 
28 #include "astshim/Frame.h"
29 
30 namespace ast {
31 
66 class SkyFrame : public Frame {
67  friend class Object;
68 
69 public:
124  explicit SkyFrame(std::string const &options = "")
125  : Frame(reinterpret_cast<AstFrame *>(astSkyFrame("%s", options.c_str()))) {}
126 
127  virtual ~SkyFrame() {}
128 
129  SkyFrame(SkyFrame const &) = delete;
130  SkyFrame(SkyFrame &&) = default;
131  SkyFrame &operator=(SkyFrame const &) = delete;
132  SkyFrame &operator=(SkyFrame &&) = default;
133 
135  std::shared_ptr<SkyFrame> copy() const { return std::static_pointer_cast<SkyFrame>(copyPolymorphic()); }
136 
138  bool getAlignOffset() const { return getB("AlignOffset"); }
139 
141  bool getAsTime(int axis) const { return getB(detail::formatAxisAttr("AsTime", axis)); }
142 
144  double getEquinox() const { return getD("Equinox"); }
145 
147  bool getIsLatAxis(int axis) const { return getB(detail::formatAxisAttr("IsLatAxis", axis)); }
148 
150  bool getIsLonAxis(int axis) const { return getB(detail::formatAxisAttr("IsLonAxis", axis)); }
151 
153  int getLatAxis() const { return getI("LatAxis"); }
154 
156  int getLonAxis() const { return getI("LonAxis"); }
157 
159  bool getNegLon() const { return getB("NegLon"); }
160 
162  std::string getProjection() const { return getC("Projection"); }
163 
166  std::vector<double> getSkyRef() const {
167  std::vector<double> ret;
168  for (int axis = 1; axis < 3; ++axis) {
169  ret.push_back(getD(detail::formatAxisAttr("SkyRef", axis)));
170  }
171  return ret;
172  }
173 
175  std::string getSkyRefIs() const { return getC("SkyRefIs"); }
176 
179  std::vector<double> getSkyRefP() const {
180  std::vector<double> ret;
181  for (int axis = 1; axis < 3; ++axis) {
182  ret.push_back(getD(detail::formatAxisAttr("SkyRefP", axis)));
183  }
184  return ret;
185  }
186 
188  double getSkyTol() const { return getD("SkyTol"); }
189 
191  void setAlignOffset(bool alignOffset) { setB("AlignOffset", alignOffset); }
192 
194  void setAsTime(int axis, bool asTime) { setB(detail::formatAxisAttr("AsTime", axis), asTime); }
195 
197  void setEquinox(double equinox) { setD("Equinox", equinox); }
198 
200  void setNegLon(bool negLon) { setB("NegLon", negLon); }
201 
203  void setProjection(std::string const &projection) { setC("Projection", projection); }
204 
206  void setSkyRef(std::vector<double> const &skyRef) {
207  detail::assertEqual(skyRef.size(), "skyRef length", 2u, "number of axes");
208  for (int i = 0; i < 2; ++i) {
209  setD(detail::formatAxisAttr("SkyRef", i + 1), skyRef[i]);
210  }
211  }
212 
214  void setSkyRefIs(std::string const &skyRefIs) { setC("SkyRefIs", skyRefIs); }
215 
217  void setSkyRefP(std::vector<double> const &skyRefP) {
218  detail::assertEqual(skyRefP.size(), "skyRefP length", 2u, "number of axes");
219  for (int i = 0; i < 2; ++i) {
220  setD(detail::formatAxisAttr("SkyRefP", i + 1), skyRefP[i]);
221  }
222  }
223 
225  void setSkyTol(double skyTol) { setD("SkyTol", skyTol); }
226 
235  std::shared_ptr<Mapping> skyOffsetMap() {
236  auto *rawMap = reinterpret_cast<AstObject *>(astSkyOffsetMap(getRawPtr()));
237  return Object::fromAstObject<Mapping>(rawMap, false);
238  }
239 
240 protected:
241  virtual std::shared_ptr<Object> copyPolymorphic() const override {
242  return copyImpl<SkyFrame, AstSkyFrame>();
243  }
244 
246  explicit SkyFrame(AstSkyFrame *rawptr) : Frame(reinterpret_cast<AstFrame *>(rawptr)) {
247  if (!astIsASkyFrame(getRawPtr())) {
248  std::ostringstream os;
249  os << "this is a " << getClassName() << ", which is not a SkyFrame";
250  throw std::invalid_argument(os.str());
251  }
252  }
253 };
254 
255 } // namespace ast
256 
257 #endif
virtual std::shared_ptr< Object > copyPolymorphic() const override
Definition: SkyFrame.h:241
std::shared_ptr< SkyFrame > copy() const
Return a deep copy of this object.
Definition: SkyFrame.h:135
bool getIsLatAxis(int axis) const
Get IsLatAxis(axis) for one axis: is the specified axis the latitude axis?
Definition: SkyFrame.h:147
AstObject const * getRawPtr() const
Definition: Object.h:286
bool getNegLon() const
Get NegLon: display longitude values in the range [-pi,pi]?
Definition: SkyFrame.h:159
void setB(std::string const &attrib, bool value)
Definition: Object.h:448
void setAlignOffset(bool alignOffset)
Set AlignOffset: align SkyFrames using the offset coordinate system?
Definition: SkyFrame.h:191
int getI(std::string const &attrib) const
Definition: Object.h:399
AST wrapper classes and functions.
Definition: attributes_channel.dox:1
std::string getClassName() const
Definition: Object.h:133
std::string getSkyRefIs() const
Get SkyRefIs: selects the nature of the offset coordinate system.
Definition: SkyFrame.h:175
void setSkyTol(double skyTol)
Set SkyTol: smallest significant shift in sky coordinates.
Definition: SkyFrame.h:225
double getSkyTol() const
Get SkyTol: smallest significant shift in sky coordinates.
Definition: SkyFrame.h:188
void setNegLon(bool negLon)
Set NegLon: display longitude values in the range [-pi,pi]?
Definition: SkyFrame.h:200
int getLatAxis() const
Get LatAxis: index of the latitude axis.
Definition: SkyFrame.h:153
double getEquinox() const
Get Equinox: epoch of the mean equinox.
Definition: SkyFrame.h:144
SkyFrame(std::string const &options="")
Definition: SkyFrame.h:124
std::vector< double > getSkyRefP() const
Definition: SkyFrame.h:179
Definition: SkyFrame.h:66
bool getB(std::string const &attrib) const
Definition: Object.h:347
Definition: Frame.h:157
bool getAsTime(int axis) const
Get AsTime(axis) for one axis: format celestial coordinates as times?
Definition: SkyFrame.h:141
void setC(std::string const &attrib, std::string const &value)
Definition: Object.h:460
bool getIsLonAxis(int axis) const
Get IsLonAxis(axis) for one axis: is the specified axis the longitude axis?
Definition: SkyFrame.h:150
void setAsTime(int axis, bool asTime)
Set AsTime(axis) for one axis: format celestial coordinates as times?
Definition: SkyFrame.h:194
void setEquinox(double equinox)
Set Equinox: epoch of the mean equinox.
Definition: SkyFrame.h:197
int getLonAxis() const
Get LonAxis: index of the longitude axis.
Definition: SkyFrame.h:156
void setProjection(std::string const &projection)
Set Projection: sky projection description.
Definition: SkyFrame.h:203
void setD(std::string const &attrib, double value)
Definition: Object.h:472
void setSkyRefP(std::vector< double > const &skyRefP)
Set SkyRefP: position defining orientation of the offset coordinate system.
Definition: SkyFrame.h:217
double getD(std::string const &attrib) const
Definition: Object.h:373
std::shared_ptr< Mapping > skyOffsetMap()
Definition: SkyFrame.h:235
SkyFrame(AstSkyFrame *rawptr)
Construct a SkyFrame from a raw AST pointer.
Definition: SkyFrame.h:246
std::string const getC(std::string const &attrib) const
Definition: Object.h:360
void setSkyRefIs(std::string const &skyRefIs)
Set SkyRefIs: selects the nature of the offset coordinate system.
Definition: SkyFrame.h:214
Definition: Object.h:49
void setSkyRef(std::vector< double > const &skyRef)
Set SkyRef: position defining location of the offset coordinate system.
Definition: SkyFrame.h:206
std::vector< double > getSkyRef() const
Definition: SkyFrame.h:166
std::string getProjection() const
Get Projection: sky projection description.
Definition: SkyFrame.h:162
bool getAlignOffset() const
Get AlignOffset: align SkyFrames using the offset coordinate system?
Definition: SkyFrame.h:138