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) { throwError("toto"); 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_;
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);
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 
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 coord[]) const;
495 
497 
500  void getFourVel(double fourvel[]) 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 output[]) const;
516 
518 
521  void getScreen2(double output[]) const;
522 
524 
527  void getScreen3(double output[]) const;
528 
530 
539  void getRayCoord(double x, double y, double coord[]) const;
540 
542 
550  void getRayCoord(const size_t i, const size_t j, double coord[]) const;
551 
552  void coordToSky(const double pos[4], double skypos[3]) const;
554 
555  void coordToXYZ(const double pos[4], double xyz[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 
592  static SmartPointer<Screen> Subcontractor(FactoryMessenger* fmp);
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;
627  };
628 
630 
635  class Coord2dSet {
636  public:
642  virtual ~Coord2dSet();
644  virtual Coord2dSet& operator++() =0;
646  virtual GYOTO_ARRAY<size_t, 2> operator* () const;
648  virtual GYOTO_ARRAY<double, 2> angles() const ;
650  virtual void begin() =0;
652  virtual bool valid() =0;
654  virtual size_t size()=0;
655  };
656 
658  class Grid: public Coord2dSet {
659  protected:
660  protected:
662  const char * const prefix_;
663  Coord1dSet &iset_;
664  Coord1dSet &jset_;
665  public:
666  Grid(Coord1dSet &iset, Coord1dSet &jset, const char * const p=NULL);
667  virtual Coord2dSet& operator++();
668  virtual GYOTO_ARRAY<size_t, 2> operator* () const;
669  virtual void begin();
670  virtual bool valid();
671  virtual size_t size();
672  };
673 
675 
678  class Bucket : public Coord2dSet {
679  protected:
680  Coord1dSet &alpha_;
681  Coord1dSet &delta_;
682  public:
683  Bucket(Coord1dSet &iset, Coord1dSet &jset);
684  virtual Coord2dSet& operator++();
685  virtual GYOTO_ARRAY<double, 2> angles() const;
686  virtual GYOTO_ARRAY<size_t, 2> operator*() const;
687  virtual void begin();
688  virtual bool valid();
689  virtual size_t size();
690  };
691 
693  class Empty: public Coord2dSet {
694  public:
695  Empty();
696  virtual Coord2dSet& operator++();
697  virtual void begin();
698  virtual bool valid();
699  virtual size_t size();
700  };
701 
703  class Range : public Coord1dSet {
704  protected:
705  const size_t mi_, ma_, d_, sz_;
706  size_t cur_;
707  public:
709  Range(size_t mi, size_t ma, size_t d);
710  void begin();
711  bool valid();
712  size_t size();
714  size_t operator*() const ;
715  };
716 
718  class Indices : public Coord1dSet {
719  protected:
720  size_t const * const indices_;
721  size_t const sz_;
722  size_t i_;
723  public:
724  Indices (size_t const*const buf, size_t sz);
725  void begin();
726  bool valid();
727  size_t size();
729  size_t operator*() const ;
730  };
731 
733  class Angles : public Coord1dSet {
734  protected:
735  double const * const buf_;
736  size_t const sz_;
737  size_t i_;
738  public:
739  Angles (double const*const buf, size_t sz);
740  void begin();
741  bool valid();
742  size_t size();
744  double angle() const ;
745  };
746 
748  class RepeatAngle : public Coord1dSet {
749  protected:
750  double const val_;
751  size_t const sz_;
752  size_t i_;
753  public:
754  RepeatAngle (double val, size_t sz);
755  void begin();
756  bool valid();
757  size_t size();
759  double angle() const ;
760  };
761 };
762 
763 #endif
1D specifier for an angle that is repeated.
Definition: GyotoScreen.h:748
double tobs_
Observing date in s.
Definition: GyotoScreen.h:173
size_t size()
Number of values in this container.
double const * mask() const
Retrieve const pointer to mask_.
virtual ~Screen()
Destructor.
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
virtual GYOTO_ARRAY< double, 2 > angles() const
Get angle coordinates.
void unmapPixUnit()
Unmap "pix" and "pixel" from unit system.
Pointers performing reference counting.
Definition: GyotoProperty.h:41
void getFourVel(double fourvel[]) const
Get copy of Screen::fourvel_.
double ey_[3]
Sky coordinate of base Y vector.
Definition: GyotoScreen.h:206
virtual GYOTO_ARRAY< size_t, 2 > operator*() const
Get pixel coordinates.
void setObserverPos(const double pos[4])
Alternative way to set projection.
double alpha0() const
Get direction of the center of the field.
size_t size()
Number of values in this container.
virtual size_t size()=0
Number of values in this container.
size_t resolution() const
Get Screen::npix_.
void setScreen1(const double coord[4])
Sets the screen vector e1.
double screen3_[4]
Screen e3 vector (normal)
Definition: GyotoScreen.h:212
double distance_
Distance to the observer in m.
Definition: GyotoScreen.h:191
virtual void begin()
Reset pointer.
void setScreen3(const double coord[4])
Sets the screen vector e3 (normal)
double fourvel_[4]
Observer's 4-velocity.
Definition: GyotoScreen.h:209
std::ostream & print(std::ostream &) const
Display.
double freq_obs_
Frequency at which the observer observes.
Definition: GyotoScreen.h:228
std::ostream & printBaseVectors(std::ostream &) const
Debug helper.
int coordKind() const
Get coordinate kind.
Reference-counting pointers.
size_t size()
Number of values in this container.
double distance() const
Get distance from observer.
double angle() const
Get double value currently pointed to.
Screen * clone() const
Cloner.
void getRayCoord(double x, double y, double coord[]) const
Get 8-coordinate of Photon hitting screen from a given direction.
A dummy, empty 2D set.
Definition: GyotoScreen.h:693
bool valid()
True if pointing to something, false if end has been reached.
#define size_t
If not defined in .
Definition: GyotoConfig.h:357
virtual size_t size()=0
Number of positions contained.
virtual double angle() const
Get double value currently pointed to.
double screen2_[4]
Screen e2 vector.
Definition: GyotoScreen.h:211
virtual Coord1dSet & operator++()=0
Increment iterator (point to next value)
void anglekind(int)
Set Screen::anglekind_.
Coord2dSet(CoordType_e k)
Set kind at initialisation.
void coordToSky(const double pos[4], double skypos[3]) const
Convert 4-position to 3-sky position.
virtual size_t size()
Number of positions contained.
virtual Coord2dSet & operator++()
Increment pointer.
virtual GYOTO_ARRAY< size_t, 2 > operator*() const
Get pixel coordinates.
1D coordinated specifier for a range
Definition: GyotoScreen.h:703
virtual void begin()
Reset pointer.
double fov_
Field-of-view in rad.
Definition: GyotoScreen.h:174
double euler_[3]
Euler angles.
Definition: GyotoScreen.h:204
Definition: GyotoScreen.h:36
void getScreen1(double output[]) const
Get copy of Screen::screen1_.
The camera with which the Astrobj is observed.
Definition: GyotoScreen.h:166
Range(size_t mi, size_t ma, size_t d)
Specify min, max and step of this range.
virtual size_t operator*() const
Get size_t value crrently pointed to.
double dmax_
Maximum distance from which the photons are launched (geometrical units)
Definition: GyotoScreen.h:192
virtual Coord2dSet & operator++()
Increment pointer.
Coord1dSet & operator++()
Increment iterator (point to next value)
void setScreen2(const double coord[4])
Sets the screen vector e2.
virtual bool valid()=0
True if pointing to something, false if end has been reached.
virtual ~Coord2dSet()
Virtual destructor.
void mapPixUnit()
Map "pix" and "pixel" to angular pixel width in unit system.
std::string observerkind_
What kind of observer are we considering? (At infinity, ZAMO...)
Definition: GyotoScreen.h:234
std::string mask_filename_
Last read or written FITS file.
Definition: GyotoScreen.h:189
double freqObs() const
Get freq_obs_.
size_t npix_
Resolution in pixels.
Definition: GyotoScreen.h:176
void fitsWriteMask(std::string const &fname)
Save mask_ from FITS file.
Coord1dSet & operator++()
Increment iterator (point to next value)
CoordType_e
Enum to specify whether a coordinate set (Coord1dSet or Coord2dSet) holds pixel values or angles...
Definition: GyotoScreen.h:596
double argument() const
Get angle between line of nodes and X axis of object.
Gyoto ubiquitous macros and typedefs.
Base class for metric description.
Coord1dSet & operator++()
Increment iterator (point to next value)
double delta0() const
Get direction of the center of the field.
double ez_[3]
Sky coordinate of base Z vector.
Definition: GyotoScreen.h:207
double dMax() const
Get maximum ray-tracing distance.
void setProjection(const double paln, const double inclination, const double argument)
Set inclination etc.
double time() const
Get observing date in seconds.
Property that can be set and got using standard methods.
Definition: GyotoProperty.h:313
double PALN() const
Get position angle of the line of nodes.
virtual bool valid()
Whether the end has not been passed.
anglekind_t anglekind_
Screen angles kind (0: equatorial, 1: spherical)
Definition: GyotoScreen.h:197
virtual void begin()
Reset pointer.
virtual GYOTO_ARRAY< double, 2 > angles() const
Get angle coordinates.
void begin()
Reset specifier to point to the first value.
Introspectable objects.
void coordToXYZ(const double pos[4], double xyz[3]) const
Convert 4-position to 3-cartesian coordinates.
Spectroscopic capabilities of a Screen.
void computeBaseVectors()
Compute base vectors according to projection parameters.
Namespace for the Gyoto library.
Definition: GyotoAstrobj.h:43
virtual void begin()=0
Reset pointer.
double inclination() const
Get inclination relative to line-of-sight.
void throwError(std::string)
Throw a Gyoto::Error.
Screen()
Default constructor.
void fitsReadMask(std::string const &fname)
Read mask_ from FITS file.
SmartPointer< Metric::Generic > metric() const
Get Screen::gg_.
virtual GYOTO_ARRAY< size_t, 2 > operator*() const
Get pixel coordinates.
1D specifier for an arbitrary pixel coordinate set.
Definition: GyotoScreen.h:718
void getScreen2(double output[]) const
Get copy of Screen::screen2_.
Class containing arbitrary 2D-points.
Definition: GyotoScreen.h:678
Coord1dSet & operator++()
Increment iterator (point to next value)
Can be pointed to by a SmartPointer.
Definition: GyotoSmartPointer.h:78
virtual size_t size()
Number of positions contained.
double delta0_
Screen orientation (0,0) is right towards the BH.
Definition: GyotoScreen.h:215
GYOTO utilities.
virtual Coord2dSet & operator++()=0
Increment pointer.
bool operator()(size_t, size_t)
Whether this pixel should be ray-traced.
double ex_[3]
Sky coordinate of base X vector.
Definition: GyotoScreen.h:205
virtual ~Coord1dSet()
Virtual destructor.
void begin()
Reset specifier to point to the first value.
SmartPointer< Spectrometer::Generic > spectrometer() const
Get Screen::spectro_.
double screen1_[4]
Screen e1 vector.
Definition: GyotoScreen.h:210
void getScreen3(double output[]) const
Get copy of Screen::screen3_.
const char *const prefix_
If non-NULL, cout j each tims it is incremented.
Definition: GyotoScreen.h:662
size_t size()
Number of values in this container.
virtual Coord2dSet & operator++()
Increment pointer.
void fillProperty(Gyoto::FactoryMessenger *fmp, Property const &p) const
Output a single Property to XML.
virtual void begin()=0
Reset specifier to point to the first value.
double angle() const
Get double value currently pointed to.
void begin()
Reset specifier to point to the first value.
SmartPointer< Metric::Generic > gg_
The Metric in this end of the Universe.
Definition: GyotoScreen.h:216
virtual bool valid()=0
Whether the end has not been passed.
bool valid()
True if pointing to something, false if end has been reached.
virtual size_t size()
Number of positions contained.
Class to specify a set of points on the Screen.
Definition: GyotoScreen.h:635
Coord1dSet(CoordType_e k)
Set kind during initialization.
size_t operator*() const
Get size_t value crrently pointed to.
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:733
const CoordType_e kind
Whether this set holds pixels or angle specifications.
Definition: GyotoScreen.h:638
bool valid()
True if pointing to something, false if end has been reached.
void begin()
Reset specifier to point to the first value.
void setFourVel(const double coord[4])
Sets the observer's 4-velocity.
virtual bool valid()
Whether the end has not been passed.
double fieldOfView() const
Get Screen::fov_ in radians.
static SmartPointer< Screen > Subcontractor(FactoryMessenger *fmp)
Instanciate a Screen from XML entity.
size_t operator*() const
Get size_t value crrently pointed to.
Class containing 2D-points organized in a grid.
Definition: GyotoScreen.h:658
virtual bool valid()
Whether the end has not been passed.
double * mask_
Mask with 0 where the ray-tracing should not be performed.
Definition: GyotoScreen.h:181
void getObserverPos(double coord[]) const
4-Position of the observer relative to the metric
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
bool valid()
True if pointing to something, false if end has been reached.