Gyoto
GyotoScreen.h
Go to the documentation of this file.
1 
7 /*
8  Copyright 2011-2016 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;
239 
240  // Constructors - Destructor
241  // -------------------------
242  Screen() ;
243  Screen(const Screen& ) ;
244  Screen * clone() const;
245 
246  virtual ~Screen() ;
247 
248  // Mutators / assignment
249  // ---------------------
250 
252  void setProjection(const double paln,
253  const double inclination,
254  const double argument);
256  void setProjection(const double distance,
257  const double paln,
258  const double inclination,
259  const double argument);
260 
262 
265  void distance(double dist);
266 
268 
271  void dMax(double dist);
272 
274 
278  void distance(double dist, const std::string &unit);
279 
281 
285  void inclination(double);
286 
288 
292  void inclination(double, const std::string &unit);
293 
294  void PALN(double);
296  void PALN(double, const std::string &unit);
298  void argument(double);
300  void argument(double, const std::string &unit);
302  void spectrometer(SmartPointer<Spectrometer::Generic> spectro);
304  SmartPointer<Spectrometer::Generic> spectrometer() const ;
306 
311  void freqObs(double fo);
312 
313 
320  void freqObs(double fo, const std::string &unit);
321 
325  double freqObs() const ;
326 
332  double freqObs(const std::string &unit) const;
333 
335 
343  void setObserverPos(const double pos[4]);
344  void observerKind(const std::string &kind);
345  std::string observerKind() const;
346  void setFourVel(const double coord[4]);
348  void setScreen1(const double coord[4]);
350  void setScreen2(const double coord[4]);
352  void setScreen3(const double coord[4]);
354 
355  // Accessors
356  // ---------
357 
359 
362  int coordKind() const;
363 
365 
368  double distance() const;
369 
371 
374  double distance(const std::string&) const;
375 
377 
380  double dMax() const;
381 
383 
387  double inclination() const;
388 
390 
394  double inclination(const std::string&) const;
395 
396  double PALN() const;
397  double PALN(const std::string&) const;
398  double argument() const;
399  double argument(const std::string&) const;
400 
401  SmartPointer<Metric::Generic> metric() const;
402  void metric(SmartPointer<Metric::Generic> gg);
403 
405  double time() const;
406 
408  double time(const std::string &) const;
409 
411  void time(double, const std::string &);
412 
414  void time(double);
415 
417  double fieldOfView() const;
418 
420  double fieldOfView(std::string const &unit) const;
421 
423  void fieldOfView(double);
424 
426  void fieldOfView(double, const std::string &unit);
427 
429  void alpha0(double);
431  void alpha0(double, const std::string &unit);
433  double alpha0() const;
435  double alpha0(std::string const &unit)const;
437  void delta0(double);
439  void delta0(double, const std::string &unit);
441  double delta0() const;
443  double delta0(std::string const &unit)const;
444 
446  void anglekind(int);
447  void anglekind(std::string const&);
448  std::string anglekind() const;
449 
451  size_t resolution() const;
453  void resolution(size_t);
454 
456 
460  void mask(double const * const mm, size_t resolution=0);
461 
463  double const * mask() const ;
464  void maskFile(std::string const &fname);
465  std::string maskFile() const;
466 # ifdef GYOTO_USE_CFITSIO
467 
469  void fitsReadMask(std::string const &fname);
470 
472  void fitsWriteMask(std::string const &fname);
473 # endif
474 
476 
480  bool operator()(size_t, size_t);
481 
482 
484 
495  void getObserverPos(double dest[4]) const;
496 
498 
501  void getFourVel(double dest[4]) const;
502 
503  void fourVel(std::vector<double> const &);
504  std::vector<double> fourVel() const;
505  void screenVector1(std::vector<double> const &);
506  std::vector<double> screenVector1() const;
507  void screenVector2(std::vector<double> const &);
508  std::vector<double> screenVector2() const;
509  void screenVector3(std::vector<double> const &);
510  std::vector<double> screenVector3() const;
511 
513 
516  void getScreen1(double dest[4]) const;
517 
519 
522  void getScreen2(double dest[4]) const;
523 
525 
528  void getScreen3(double dest[4]) const;
529 
531 
540  void getRayCoord(double x, double y, double dest[8]) const;
541 
543 
551  void getRayCoord(const size_t i, const size_t j, double dest[8]) const;
552 
553  void coordToSky(const double pos[4], double dest[3]) const;
555 
556  void coordToXYZ(const double pos[4], double dest[3]) const;
558 
559  void computeBaseVectors() ;
561 
563  // friend std::ostream& operator<<(std::ostream& , const Screen& ) ;
564  std::ostream& print(std::ostream&) const ;
565  std::ostream& printBaseVectors(std::ostream&) const ;
566 
567  // UDUNITS
568 # ifdef HAVE_UDUNITS
569 
578  void mapPixUnit();
579 
581 
584  void unmapPixUnit();
585 # endif
586 
587 
588 #ifdef GYOTO_USE_XERCES
589  public:
590  void fillProperty(Gyoto::FactoryMessenger *fmp, Property const &p) const;
591 
594 #endif
595 
597  enum CoordType_e {angle, pixel};
598 
600 
607  class Coord1dSet {
608  public:
611  public:
615  virtual ~Coord1dSet();
617  virtual void begin() =0;
619  virtual bool valid() =0;
621  virtual size_t size()=0;
623  virtual size_t operator*() const ;
625  virtual double angle() const ;
627  virtual Coord1dSet& operator++()=0;
629 
634  virtual size_t index() const=0;
635  };
636 
638 
643  class Coord2dSet {
644  public:
650  virtual ~Coord2dSet();
652  virtual Coord2dSet& operator++() =0;
654  virtual GYOTO_ARRAY<size_t, 2> operator* () const;
656  virtual GYOTO_ARRAY<double, 2> angles() const ;
658  virtual void begin() =0;
660  virtual bool valid() =0;
662  virtual size_t size()=0;
663  };
664 
666  class Grid: public Coord2dSet {
667  protected:
668  protected:
670  const char * const prefix_;
671  Coord1dSet &iset_;
672  Coord1dSet &jset_;
673  public:
674  Grid(Coord1dSet &iset, Coord1dSet &jset, const char * const p=NULL);
675  virtual Coord2dSet& operator++();
676  virtual GYOTO_ARRAY<size_t, 2> operator* () const;
677  virtual void begin();
678  virtual bool valid();
679  virtual size_t size();
680  };
681 
683 
686  class Bucket : public Coord2dSet {
687  protected:
688  Coord1dSet &alpha_;
689  Coord1dSet &delta_;
690  public:
691  Bucket(Coord1dSet &iset, Coord1dSet &jset);
692  virtual Coord2dSet& operator++();
693  virtual GYOTO_ARRAY<double, 2> angles() const;
694  virtual GYOTO_ARRAY<size_t, 2> operator*() const;
695  virtual void begin();
696  virtual bool valid();
697  virtual size_t size();
698  };
699 
701  class Empty: public Coord2dSet {
702  public:
703  Empty();
704  virtual Coord2dSet& operator++();
705  virtual void begin();
706  virtual bool valid();
707  virtual size_t size();
708  };
709 
711  class Range : public Coord1dSet {
712  protected:
713  const size_t mi_, ma_, d_, sz_;
714  size_t cur_;
715  public:
717  Range(size_t mi, size_t ma, size_t d);
718  void begin();
719  bool valid();
720  size_t size();
721  Coord1dSet& operator++();
722  size_t operator*() const ;
723  virtual size_t index() const ;
724  };
725 
727  class Indices : public Coord1dSet {
728  protected:
729  size_t const * const indices_;
730  size_t const sz_;
731  size_t i_;
732  public:
733  Indices (size_t const*const buf, size_t sz);
734  void begin();
735  bool valid();
736  size_t size();
737  Coord1dSet& operator++();
738  size_t operator*() const ;
739  virtual size_t index() const ;
740  };
741 
743  class Angles : public Coord1dSet {
744  protected:
745  double const * const buf_;
746  size_t const sz_;
747  size_t i_;
748  public:
749  Angles (double const*const buf, size_t sz);
750  void begin();
751  bool valid();
752  size_t size();
753  Coord1dSet& operator++();
754  double angle() const ;
755  virtual size_t index() const ;
756  };
757 
759  class RepeatAngle : public Coord1dSet {
760  protected:
761  double const val_;
762  size_t const sz_;
763  size_t i_;
764  public:
765  RepeatAngle (double val, size_t sz);
766  void begin();
767  bool valid();
768  size_t size();
769  Coord1dSet& operator++();
770  double angle() const ;
771  virtual size_t index() const ;
772  };
773 };
774 
775 #endif
1D specifier for an angle that is repeated.
Definition: GyotoScreen.h:759
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:84
double freq_obs_
Frequency at which the observer observes.
Definition: GyotoScreen.h:228
Reference-counting pointers.
#define GYOTO_OBJECT_THREAD_SAFETY
Declare virtual bool isThreadSafe() const.
Definition: GyotoObject.h:99
A dummy, empty 2D set.
Definition: GyotoScreen.h:701
#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:711
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:597
Gyoto ubiquitous macros and typedefs.
Base class for metric description.
Property that can be set and got using standard methods.
Definition: GyotoProperty.h:607
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:727
Class containing arbitrary 2D-points.
Definition: GyotoScreen.h:686
Pointers performing reference counting.
Definition: GyotoProperty.h:45
Can be pointed to by a SmartPointer.
Definition: GyotoSmartPointer.h:80
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:670
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:643
Object with properties.
Definition: GyotoObject.h:151
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:743
const CoordType_e kind
Whether this set holds pixels or angle specifications.
Definition: GyotoScreen.h:646
SmartPointer< Astrobj::Generic > Subcontractor(FactoryMessenger *fmp, std::vector< std::string > const &plugin)
A template for Subcontractor_t functions.
Definition: GyotoAstrobj.h:76
Class containing 2D-points organized in a grid.
Definition: GyotoScreen.h:666
const CoordType_e kind
Whether this specifier represents angles or pixels.
Definition: GyotoScreen.h:610
Set of 1-d coordinates: indices or angles.
Definition: GyotoScreen.h:607