lsst.astshim  master-gd1207e8857
 All Classes Namespaces Functions Variables Typedefs Enumerations Pages
SkyFrame.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_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 public:
123  explicit SkyFrame(std::string const & options="")
124  :
125  Frame(reinterpret_cast<AstFrame *>(astSkyFrame(options.c_str())))
126  {}
127 
128  virtual ~SkyFrame() {}
129 
130  SkyFrame(SkyFrame const &) = delete;
131  SkyFrame(SkyFrame &&) = default;
132  SkyFrame & operator=(SkyFrame const &) = delete;
133  SkyFrame & operator=(SkyFrame &&) = default;
134 
136  std::shared_ptr<SkyFrame> copy() const {
137  return std::static_pointer_cast<SkyFrame>(_copyPolymorphic());
138  }
139 
141  bool getAlignOffset() const { return getB("AlignOffset"); }
142 
144  bool getAsTime(int axis) const { return getB(detail::formatAxisAttr("AsTime", axis)); }
145 
147  double getEquinox() const { return getD("Equinox"); }
148 
150  bool getIsLatAxis(int axis) const { return getB(detail::formatAxisAttr("IsLatAxis", axis)); }
151 
153  bool getIsLonAxis(int axis) const { return getB(detail::formatAxisAttr("IsLonAxis", axis)); }
154 
156  int getLatAxis() const { return getI("LatAxis"); }
157 
159  int getLonAxis() const { return getI("LonAxis"); }
160 
162  bool getNegLon() const { return getB("NegLon"); }
163 
165  std::string getProjection() const { return getC("Projection"); }
166 
169  std::vector<double> getSkyRef() const {
170  std::vector<double> ret;
171  for (int axis = 1; axis < 3; ++axis) {
172  ret.push_back(getD(detail::formatAxisAttr("SkyRef", axis)));
173  }
174  return ret;
175  }
176 
178  std::string getSkyRefIs() const { return getC("SkyRefIs"); }
179 
182  std::vector<double> getSkyRefP() const {
183  std::vector<double> ret;
184  for (int axis = 1; axis < 3; ++axis) {
185  ret.push_back(getD(detail::formatAxisAttr("SkyRefP", axis)));
186  }
187  return ret;
188  }
189 
191  double getSkyTol() const { return getD("SkyTol"); }
192 
193 
195  void setAlignOffset(bool alignOffset) { setB("AlignOffset", alignOffset); }
196 
198  void setAsTime(int axis, bool asTime) { setB(detail::formatAxisAttr("AsTime", axis), asTime); }
199 
201  void setEquinox(double equinox) { setD("Equinox", equinox); }
202 
204  void setNegLon(bool negLon) { setB("NegLon", negLon); }
205 
207  void setProjection(std::string const & projection) { setC("Projection", projection); }
208 
210  void setSkyRef(std::vector<double> const & skyRef) {
211  detail::assertEqual(skyRef.size(), "skyRef length", 2, "number of axes");
212  for (int i = 0; i < 2; ++i) {
213  setD(detail::formatAxisAttr("SkyRef", i + 1), skyRef[i]);
214  }
215  }
216 
218  void setSkyRefIs(std::string const & skyRefIs) { setC("SkyRefIs", skyRefIs); }
219 
221  void setSkyRefP(std::vector<double> const & skyRefP) {
222  detail::assertEqual(skyRefP.size(), "skyRefP length", 2, "number of axes");
223  for (int i = 0; i < 2; ++i) {
224  setD(detail::formatAxisAttr("SkyRefP", i + 1), skyRefP[i]);
225  }
226  }
227 
229  void setSkyTol(double skyTol) { setD("SkyTol", skyTol); }
230 
239  std::shared_ptr<Mapping> skyOffsetMap() {
240  auto * rawMap = reinterpret_cast<AstObject *>(astSkyOffsetMap(getRawPtr()));
241  return Object::fromAstObject<Mapping>(rawMap, false);
242  }
243 
244 protected:
245  virtual std::shared_ptr<Object> _copyPolymorphic() const override {
246  return _copyImpl<SkyFrame, AstSkyFrame>();
247  }
248 
250  explicit SkyFrame(AstSkyFrame * rawptr) :
251  Frame(reinterpret_cast<AstFrame *>(rawptr))
252  {
253  if (!astIsASkyFrame(getRawPtr())) {
254  std::ostringstream os;
255  os << "this is a " << getClass() << ", which is not a SkyFrame";
256  throw std::invalid_argument(os.str());
257  }
258  }
259 };
260 
261 } // namespace ast
262 
263 #endif
std::string getSkyRefIs() const
Get SkyRefIs: selects the nature of the offset coordinate system.
Definition: SkyFrame.h:178
bool getAsTime(int axis) const
Get AsTime(axis) for one axis: format celestial coordinates as times?
Definition: SkyFrame.h:144
void setSkyTol(double skyTol)
Set SkyTol: smallest significant shift in sky coordinates.
Definition: SkyFrame.h:229
Definition: Frame.h:158
void setAlignOffset(bool alignOffset)
Set AlignOffset: align SkyFrames using the offset coordinate system?
Definition: SkyFrame.h:195
std::string getClass() const
Definition: Object.h:117
std::string const getC(std::string const &attrib) const
Definition: Object.h:347
void setSkyRef(std::vector< double > const &skyRef)
Set SkyRef: position defining location of the offset coordinate system.
Definition: SkyFrame.h:210
bool getAlignOffset() const
Get AlignOffset: align SkyFrames using the offset coordinate system?
Definition: SkyFrame.h:141
void setB(std::string const &attrib, bool value)
Definition: Object.h:435
Definition: Object.h:49
double getSkyTol() const
Get SkyTol: smallest significant shift in sky coordinates.
Definition: SkyFrame.h:191
void setSkyRefIs(std::string const &skyRefIs)
Set SkyRefIs: selects the nature of the offset coordinate system.
Definition: SkyFrame.h:218
Definition: SkyFrame.h:66
void setAsTime(int axis, bool asTime)
Set AsTime(axis) for one axis: format celestial coordinates as times?
Definition: SkyFrame.h:198
void setC(std::string const &attrib, std::string const &value)
Definition: Object.h:447
void setSkyRefP(std::vector< double > const &skyRefP)
Set SkyRefP: position defining orientation of the offset coordinate system.
Definition: SkyFrame.h:221
std::vector< double > getSkyRef() const
Definition: SkyFrame.h:169
void setProjection(std::string const &projection)
Set Projection: sky projection description.
Definition: SkyFrame.h:207
std::shared_ptr< Mapping > skyOffsetMap()
Definition: SkyFrame.h:239
SkyFrame(AstSkyFrame *rawptr)
Construct a SkyFrame from a raw AST pointer.
Definition: SkyFrame.h:250
bool getIsLonAxis(int axis) const
Get IsLonAxis(axis) for one axis: is the specified axis the longitude axis?
Definition: SkyFrame.h:153
std::vector< double > getSkyRefP() const
Definition: SkyFrame.h:182
double getD(std::string const &attrib) const
Definition: Object.h:360
virtual std::shared_ptr< Object > _copyPolymorphic() const override
Definition: SkyFrame.h:245
double getEquinox() const
Get Equinox: epoch of the mean equinox.
Definition: SkyFrame.h:147
std::string getProjection() const
Get Projection: sky projection description.
Definition: SkyFrame.h:165
void setD(std::string const &attrib, double value)
Definition: Object.h:459
void setNegLon(bool negLon)
Set NegLon: display longitude values in the range [-pi,pi]?
Definition: SkyFrame.h:204
void setEquinox(double equinox)
Set Equinox: epoch of the mean equinox.
Definition: SkyFrame.h:201
int getI(std::string const &attrib) const
Definition: Object.h:386
int getLatAxis() const
Get LatAxis: index of the latitude axis.
Definition: SkyFrame.h:156
bool getB(std::string const &attrib) const
Definition: Object.h:334
bool getNegLon() const
Get NegLon: display longitude values in the range [-pi,pi]?
Definition: SkyFrame.h:162
int getLonAxis() const
Get LonAxis: index of the longitude axis.
Definition: SkyFrame.h:159
SkyFrame(std::string const &options="")
Definition: SkyFrame.h:123
bool getIsLatAxis(int axis) const
Get IsLatAxis(axis) for one axis: is the specified axis the latitude axis?
Definition: SkyFrame.h:150
std::shared_ptr< SkyFrame > copy() const
Return a deep copy of this object.
Definition: SkyFrame.h:136
AstObject const * getRawPtr() const
Definition: Object.h:260