Gyoto
GyotoScreen.h
Go to the documentation of this file.
1 
7 /*
8  Copyright 2011-2015 Thibaut Paumard, Frederic Vincent
9 
10  This file is part of Gyoto.
11 
12  Gyoto is free software: you can redistribute it and/or modify
13  it under the terms of the GNU General Public License as published by
14  the Free Software Foundation, either version 3 of the License, or
15  (at your option) any later version.
16 
17  Gyoto is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  GNU General Public License for more details.
21 
22  You should have received a copy of the GNU General Public License
23  along with Gyoto. If not, see <http://www.gnu.org/licenses/>.
24  */
25 
26 #ifndef __GyotoScreen_H_
27 #define __GyotoScreen_H_
28 
29 #include <iostream>
30 #include <fstream>
31 #include <string>
32 #if defined HAVE_BOOST_ARRAY_HPP
33 #include <boost/array.hpp>
34 #define GYOTO_ARRAY boost::array
35 #else
36 template <typename T, size_t sz> class GYOTO_ARRAY {
37  private:
38  T buf[sz];
39  public:
40  T& operator[](size_t c) { return buf[c] ; }
41 };
42 #endif
43 
44 namespace Gyoto {
45  class Screen;
46 }
47 
48 #include <GyotoDefs.h>
49 #include <GyotoUtils.h>
50 #include <GyotoSmartPointer.h>
51 #include <GyotoObject.h>
52 #include <GyotoMetric.h>
53 #include <GyotoSpectrometer.h>
54 
167 : public Gyoto::SmartPointee,
168  public Gyoto::Object
169 {
170  friend class Gyoto::SmartPointer<Gyoto::Screen>;
171 
172  private:
173  double tobs_;
174  double fov_;
175  // double tmin_;
176  size_t npix_;
177 
181  double * mask_;
182 
189  std::string mask_filename_;
190 
191  double distance_;
192  double dmax_;
193 
194  enum anglekind_e { equatorial_angles=0, rectilinear=1, spherical_angles=2};
195  typedef int anglekind_t;
196 
197  anglekind_t anglekind_;
198 
204  double euler_[3];
205  double ex_[3];
206  double ey_[3];
207  double ez_[3];
208 
209  double fourvel_[4];
210  double screen1_[4];
211  double screen2_[4];
212  double screen3_[4];
213 
214  double alpha0_;
215  double delta0_;
217 
222 
228  double freq_obs_;
229 
234  std::string observerkind_;
235 
236  public:
237  GYOTO_OBJECT;
238 
239  // Constructors - Destructor
240  // -------------------------
241  Screen() ;
242  Screen(const Screen& ) ;
243  Screen * clone() const;
244 
245  virtual ~Screen() ;
246 
247  // Mutators / assignment
248  // ---------------------
249 
251  void setProjection(const double paln,
252  const double inclination,
253  const double argument);
255  void setProjection(const double distance,
256  const double paln,
257  const double inclination,
258  const double argument);
259 
261 
264  void distance(double dist);
265 
267 
270  void dMax(double dist);
271 
273 
277  void distance(double dist, const std::string &unit);
278 
280 
284  void inclination(double);
285 
287 
291  void inclination(double, const std::string &unit);
292 
293  void PALN(double);
295  void PALN(double, const std::string &unit);
297  void argument(double);
299  void argument(double, const std::string &unit);
301  void spectrometer(SmartPointer<Spectrometer::Generic> spectro);
303  SmartPointer<Spectrometer::Generic> spectrometer() const ;
305 
310  void freqObs(double fo);
311 
312 
319  void freqObs(double fo, const std::string &unit);
320 
324  double freqObs() const ;
325 
331  double freqObs(const std::string &unit) const;
332 
334 
342  void setObserverPos(const double pos[4]);
343  void observerKind(const std::string &kind);
344  std::string observerKind() const;
345  void setFourVel(const double coord[4]);
347  void setScreen1(const double coord[4]);
349  void setScreen2(const double coord[4]);
351  void setScreen3(const double coord[4]);
353 
354  // Accessors
355  // ---------
356 
358 
361  int coordKind() const;
362 
364 
367  double distance() const;
368 
370 
373  double distance(const std::string&) const;
374 
376 
379  double dMax() const;
380 
382 
386  double inclination() const;
387 
389 
393  double inclination(const std::string&) const;
394 
395  double PALN() const;
396  double PALN(const std::string&) const;
397  double argument() const;
398  double argument(const std::string&) const;
399 
400  SmartPointer<Metric::Generic> metric() const;
401  void metric(SmartPointer<Metric::Generic> gg);
402 
404  double time() const;
405 
407  double time(const std::string &) const;
408 
410  void time(double, const std::string &);
411 
413  void time(double);
414 
416  double fieldOfView() const;
417 
419  double fieldOfView(std::string const &unit) const;
420 
422  void fieldOfView(double);
423 
425  void fieldOfView(double, const std::string &unit);
426 
428  void alpha0(double);
430  void alpha0(double, const std::string &unit);
432  double alpha0() const;
434  double alpha0(std::string const &unit)const;
436  void delta0(double);
438  void delta0(double, const std::string &unit);
440  double delta0() const;
442  double delta0(std::string const &unit)const;
443 
445  void anglekind(int);
446  void anglekind(std::string const&);
447  std::string anglekind() const;
448 
450  size_t resolution() const;
452  void resolution(size_t);
453 
455 
459  void mask(double const * const mm, size_t resolution=0);
460 
462  double const * mask() const ;
463  void maskFile(std::string const &fname);
464  std::string maskFile() const;
465 # ifdef GYOTO_USE_CFITSIO
466 
468  void fitsReadMask(std::string const &fname);
469 
471  void fitsWriteMask(std::string const &fname);
472 # endif
473 
475 
479  bool operator()(size_t, size_t);
480 
481 
483 
494  void getObserverPos(double dest[4]) const;
495 
497 
500  void getFourVel(double dest[4]) const;
501 
502  void fourVel(std::vector<double> const &);
503  std::vector<double> fourVel() const;
504  void screenVector1(std::vector<double> const &);
505  std::vector<double> screenVector1() const;
506  void screenVector2(std::vector<double> const &);
507  std::vector<double> screenVector2() const;
508  void screenVector3(std::vector<double> const &);
509  std::vector<double> screenVector3() const;
510 
512 
515  void getScreen1(double dest[4]) const;
516 
518 
521  void getScreen2(double dest[4]) const;
522 
524 
527  void getScreen3(double dest[4]) const;
528 
530 
539  void getRayCoord(double x, double y, double dest[8]) const;
540 
542 
550  void getRayCoord(const size_t i, const size_t j, double dest[8]) const;
551 
552  void coordToSky(const double pos[4], double dest[3]) const;
554 
555  void coordToXYZ(const double pos[4], double dest[3]) const;
557 
558  void computeBaseVectors() ;
560 
562  // friend std::ostream& operator<<(std::ostream& , const Screen& ) ;
563  std::ostream& print(std::ostream&) const ;
564  std::ostream& printBaseVectors(std::ostream&) const ;
565 
566  // UDUNITS
567 # ifdef HAVE_UDUNITS
568 
577  void mapPixUnit();
578 
580 
583  void unmapPixUnit();
584 # endif
585 
586 
587 #ifdef GYOTO_USE_XERCES
588  public:
589  void fillProperty(Gyoto::FactoryMessenger *fmp, Property const &p) const;
590 
593 #endif
594 
596  enum CoordType_e {angle, pixel};
597 
599 
606  class Coord1dSet {
607  public:
610  public:
614  virtual ~Coord1dSet();
616  virtual void begin() =0;
618  virtual bool valid() =0;
620  virtual size_t size()=0;
622  virtual size_t operator*() const ;
624  virtual double angle() const ;
626  virtual Coord1dSet& operator++()=0;
628 
633  virtual size_t index() const=0;
634  };
635 
637 
642  class Coord2dSet {
643  public:
649  virtual ~Coord2dSet();
651  virtual Coord2dSet& operator++() =0;
653  virtual GYOTO_ARRAY<size_t, 2> operator* () const;
655  virtual GYOTO_ARRAY<double, 2> angles() const ;
657  virtual void begin() =0;
659  virtual bool valid() =0;
661  virtual size_t size()=0;
662  };
663 
665  class Grid: public Coord2dSet {
666  protected:
667  protected:
669  const char * const prefix_;
670  Coord1dSet &iset_;
671  Coord1dSet &jset_;
672  public:
673  Grid(Coord1dSet &iset, Coord1dSet &jset, const char * const p=NULL);
674  virtual Coord2dSet& operator++();
675  virtual GYOTO_ARRAY<size_t, 2> operator* () const;
676  virtual void begin();
677  virtual bool valid();
678  virtual size_t size();
679  };
680 
682 
685  class Bucket : public Coord2dSet {
686  protected:
687  Coord1dSet &alpha_;
688  Coord1dSet &delta_;
689  public:
690  Bucket(Coord1dSet &iset, Coord1dSet &jset);
691  virtual Coord2dSet& operator++();
692  virtual GYOTO_ARRAY<double, 2> angles() const;
693  virtual GYOTO_ARRAY<size_t, 2> operator*() const;
694  virtual void begin();
695  virtual bool valid();
696  virtual size_t size();
697  };
698 
700  class Empty: public Coord2dSet {
701  public:
702  Empty();
703  virtual Coord2dSet& operator++();
704  virtual void begin();
705  virtual bool valid();
706  virtual size_t size();
707  };
708 
710  class Range : public Coord1dSet {
711  protected:
712  const size_t mi_, ma_, d_, sz_;
713  size_t cur_;
714  public:
716  Range(size_t mi, size_t ma, size_t d);
717  void begin();
718  bool valid();
719  size_t size();
720  Coord1dSet& operator++();
721  size_t operator*() const ;
722  virtual size_t index() const ;
723  };
724 
726  class Indices : public Coord1dSet {
727  protected:
728  size_t const * const indices_;
729  size_t const sz_;
730  size_t i_;
731  public:
732  Indices (size_t const*const buf, size_t sz);
733  void begin();
734  bool valid();
735  size_t size();
736  Coord1dSet& operator++();
737  size_t operator*() const ;
738  virtual size_t index() const ;
739  };
740 
742  class Angles : public Coord1dSet {
743  protected:
744  double const * const buf_;
745  size_t const sz_;
746  size_t i_;
747  public:
748  Angles (double const*const buf, size_t sz);
749  void begin();
750  bool valid();
751  size_t size();
752  Coord1dSet& operator++();
753  double angle() const ;
754  virtual size_t index() const ;
755  };
756 
758  class RepeatAngle : public Coord1dSet {
759  protected:
760  double const val_;
761  size_t const sz_;
762  size_t i_;
763  public:
764  RepeatAngle (double val, size_t sz);
765  void begin();
766  bool valid();
767  size_t size();
768  Coord1dSet& operator++();
769  double angle() const ;
770  virtual size_t index() const ;
771  };
772 };
773 
774 #endif
1D specifier for an angle that is repeated.
Definition: GyotoScreen.h:758
SmartPointer< Spectrometer::Generic > spectro_
Gyoto::Spectrometer::Generic subclass instance used for quantities Spectrum and BinSpectrum.
Definition: GyotoScreen.h:221
#define GYOTO_OBJECT
Declare class::properties and class::getProperties()
Definition: GyotoObject.h:83
double freq_obs_
Frequency at which the observer observes.
Definition: GyotoScreen.h:228
Reference-counting pointers.
SmartPointer< Astrobj::Generic > Subcontractor(FactoryMessenger *fmp)
A template for Subcontractor_t functions.
Definition: GyotoAstrobj.h:76
A dummy, empty 2D set.
Definition: GyotoScreen.h:700
#define size_t
If not defined in <sys/types.h>.
Definition: GyotoConfig.h:354
Factory / SmartPointee::Subcontractor_t interface.
Definition: GyotoFactoryMessenger.h:92
1D coordinated specifier for a range
Definition: GyotoScreen.h:710
Definition: GyotoScreen.h:36
The camera with which the Astrobj is observed.
Definition: GyotoScreen.h:166
std::string observerkind_
What kind of observer are we considering? (At infinity, ZAMO...)
Definition: GyotoScreen.h:234
CoordType_e
Enum to specify whether a coordinate set (Coord1dSet or Coord2dSet) holds pixel values or angles...
Definition: GyotoScreen.h:596
Gyoto ubiquitous macros and typedefs.
Base class for metric description.
Property that can be set and got using standard methods.
Definition: GyotoProperty.h:533
anglekind_t anglekind_
Screen angles kind (0: equatorial, 1: spherical)
Definition: GyotoScreen.h:197
Introspectable objects.
Spectroscopic capabilities of a Screen.
Namespace for the Gyoto library.
Definition: GyotoAstrobj.h:43
1D specifier for an arbitrary pixel coordinate set.
Definition: GyotoScreen.h:726
Class containing arbitrary 2D-points.
Definition: GyotoScreen.h:685
Pointers performing reference counting.
Definition: GyotoProperty.h:41
Can be pointed to by a SmartPointer.
Definition: GyotoSmartPointer.h:78
double delta0_
Screen orientation (0,0) is right towards the BH.
Definition: GyotoScreen.h:215
GYOTO utilities.
const char *const prefix_
If non-NULL, cout j each tims it is incremented.
Definition: GyotoScreen.h:669
SmartPointer< Metric::Generic > gg_
The Metric in this end of the Universe.
Definition: GyotoScreen.h:216
Class to specify a set of points on the Screen.
Definition: GyotoScreen.h:642
Object with properties.
Definition: GyotoObject.h:136
double alpha0_
Screen orientation (0,0) is right towards the BH.
Definition: GyotoScreen.h:214
1D specifier for an arbitrary angle coordinate set.
Definition: GyotoScreen.h:742
const CoordType_e kind
Whether this set holds pixels or angle specifications.
Definition: GyotoScreen.h:645
Class containing 2D-points organized in a grid.
Definition: GyotoScreen.h:665
const CoordType_e kind
Whether this specifier represents angles or pixels.
Definition: GyotoScreen.h:609
Set of 1-d coordinates: indices or angles.
Definition: GyotoScreen.h:606