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 # if defined HAVE_MPI
36 # include <boost/version.hpp>
37 # if BOOST_VERSION >= 106400
38 # include <boost/serialization/boost_array.hpp>
39 # include <boost/serialization/array_wrapper.hpp>
40 # endif
41 # endif
42 #else
43 template <typename T, size_t sz> class GYOTO_ARRAY {
44  private:
45  T buf[sz];
46  public:
47  T& operator[](size_t c) { return buf[c] ; }
48 };
49 #endif
50 
51 namespace Gyoto {
52  class Screen;
53 }
54 
55 #include <GyotoDefs.h>
56 #include <GyotoUtils.h>
57 #include <GyotoSmartPointer.h>
58 #include <GyotoObject.h>
59 #include <GyotoMetric.h>
60 #include <GyotoSpectrometer.h>
61 
174 : public Gyoto::SmartPointee,
175  public Gyoto::Object
176 {
177  friend class Gyoto::SmartPointer<Gyoto::Screen>;
178 
179  private:
180  double tobs_;
181  double fov_;
182  // double tmin_;
183  size_t npix_;
184 
188  double * mask_;
189 
196  std::string mask_filename_;
197 
198  double distance_;
199  double dmax_;
200 
201  enum anglekind_e { equatorial_angles=0, rectilinear=1, spherical_angles=2};
202  typedef int anglekind_t;
203 
204  anglekind_t anglekind_;
205 
211  double euler_[3];
212  double ex_[3];
213  double ey_[3];
214  double ez_[3];
215 
216  double fourvel_[4];
217  double screen1_[4];
218  double screen2_[4];
219  double screen3_[4];
220 
221  double alpha0_;
222  double delta0_;
224 
229 
235  double freq_obs_;
236 
241  std::string observerkind_;
242 
243  public:
244  GYOTO_OBJECT;
246 
247  // Constructors - Destructor
248  // -------------------------
249  Screen() ;
250  Screen(const Screen& ) ;
251  Screen * clone() const;
252 
253  virtual ~Screen() ;
254 
255  // Mutators / assignment
256  // ---------------------
257 
259  void setProjection(const double paln,
260  const double inclination,
261  const double argument);
263  void setProjection(const double distance,
264  const double paln,
265  const double inclination,
266  const double argument);
267 
269 
272  void distance(double dist);
273 
275 
278  void dMax(double dist);
279 
281 
285  void distance(double dist, const std::string &unit);
286 
288 
292  void inclination(double);
293 
295 
299  void inclination(double, const std::string &unit);
300 
301  void PALN(double);
303  void PALN(double, const std::string &unit);
305  void argument(double);
307  void argument(double, const std::string &unit);
309  void spectrometer(SmartPointer<Spectrometer::Generic> spectro);
311  SmartPointer<Spectrometer::Generic> spectrometer() const ;
313 
318  void freqObs(double fo);
319 
320 
327  void freqObs(double fo, const std::string &unit);
328 
332  double freqObs() const ;
333 
339  double freqObs(const std::string &unit) const;
340 
342 
350  void setObserverPos(const double pos[4]);
351  void observerKind(const std::string &kind);
352  std::string observerKind() const;
353  void setFourVel(const double coord[4]);
355  void setScreen1(const double coord[4]);
357  void setScreen2(const double coord[4]);
359  void setScreen3(const double coord[4]);
361 
362  // Accessors
363  // ---------
364 
366 
369  int coordKind() const;
370 
372 
375  double distance() const;
376 
378 
381  double distance(const std::string&) const;
382 
384 
387  double dMax() const;
388 
390 
394  double inclination() const;
395 
397 
401  double inclination(const std::string&) const;
402 
403  double PALN() const;
404  double PALN(const std::string&) const;
405  double argument() const;
406  double argument(const std::string&) const;
407 
408  SmartPointer<Metric::Generic> metric() const;
409  void metric(SmartPointer<Metric::Generic> gg);
410 
412  double time() const;
413 
415  double time(const std::string &) const;
416 
418  void time(double, const std::string &);
419 
421  void time(double);
422 
424  double fieldOfView() const;
425 
427  double fieldOfView(std::string const &unit) const;
428 
430  void fieldOfView(double);
431 
433  void fieldOfView(double, const std::string &unit);
434 
436  void alpha0(double);
438  void alpha0(double, const std::string &unit);
440  double alpha0() const;
442  double alpha0(std::string const &unit)const;
444  void delta0(double);
446  void delta0(double, const std::string &unit);
448  double delta0() const;
450  double delta0(std::string const &unit)const;
451 
453  void anglekind(int);
454  void anglekind(std::string const&);
455  std::string anglekind() const;
456 
458  size_t resolution() const;
460  void resolution(size_t);
461 
463 
467  void mask(double const * const mm, size_t resolution=0);
468 
470  double const * mask() const ;
471  void maskFile(std::string const &fname);
472  std::string maskFile() const;
473 # ifdef GYOTO_USE_CFITSIO
474 
476  void fitsReadMask(std::string const &fname);
477 
479  void fitsWriteMask(std::string const &fname);
480 # endif
481 
483 
487  bool operator()(size_t, size_t);
488 
489 
491 
502  void getObserverPos(double dest[4]) const;
503 
505 
508  void getFourVel(double dest[4]) const;
509 
510  void fourVel(std::vector<double> const &);
511  std::vector<double> fourVel() const;
512  void screenVector1(std::vector<double> const &);
513  std::vector<double> screenVector1() const;
514  void screenVector2(std::vector<double> const &);
515  std::vector<double> screenVector2() const;
516  void screenVector3(std::vector<double> const &);
517  std::vector<double> screenVector3() const;
518 
520 
523  void getScreen1(double dest[4]) const;
524 
526 
529  void getScreen2(double dest[4]) const;
530 
532 
535  void getScreen3(double dest[4]) const;
536 
538 
547  void getRayCoord(double x, double y, double dest[8]) const;
548 
550 
558  void getRayCoord(const size_t i, const size_t j, double dest[8]) const;
559 
560  void coordToSky(const double pos[4], double dest[3]) const;
562 
563  void coordToXYZ(const double pos[4], double dest[3]) const;
565 
566  void computeBaseVectors() ;
568 
570  // friend std::ostream& operator<<(std::ostream& , const Screen& ) ;
571  std::ostream& print(std::ostream&) const ;
572  std::ostream& printBaseVectors(std::ostream&) const ;
573 
574  // UDUNITS
575 # ifdef HAVE_UDUNITS
576 
585  void mapPixUnit();
586 
588 
591  void unmapPixUnit();
592 # endif
593 
594 
595 #ifdef GYOTO_USE_XERCES
596  public:
597  void fillProperty(Gyoto::FactoryMessenger *fmp, Property const &p) const;
598 
601 #endif
602 
604  enum CoordType_e {angle, pixel};
605 
607 
614  class Coord1dSet {
615  public:
618  public:
622  virtual ~Coord1dSet();
624  virtual void begin() =0;
626  virtual bool valid() =0;
628  virtual size_t size()=0;
630  virtual size_t operator*() const ;
632  virtual double angle() const ;
634  virtual Coord1dSet& operator++()=0;
636 
641  virtual size_t index() const=0;
642  };
643 
645 
650  class Coord2dSet {
651  public:
657  virtual ~Coord2dSet();
659  virtual Coord2dSet& operator++() =0;
661  virtual GYOTO_ARRAY<size_t, 2> operator* () const;
663  virtual GYOTO_ARRAY<double, 2> angles() const ;
665  virtual void begin() =0;
667  virtual bool valid() =0;
669  virtual size_t size()=0;
670  };
671 
673  class Grid: public Coord2dSet {
674  protected:
675  protected:
677  const char * const prefix_;
678  Coord1dSet &iset_;
679  Coord1dSet &jset_;
680  public:
681  Grid(Coord1dSet &iset, Coord1dSet &jset, const char * const p=NULL);
682  virtual Coord2dSet& operator++();
683  virtual GYOTO_ARRAY<size_t, 2> operator* () const;
684  virtual void begin();
685  virtual bool valid();
686  virtual size_t size();
687  };
688 
690 
693  class Bucket : public Coord2dSet {
694  protected:
695  Coord1dSet &alpha_;
696  Coord1dSet &delta_;
697  public:
698  Bucket(Coord1dSet &iset, Coord1dSet &jset);
699  virtual Coord2dSet& operator++();
700  virtual GYOTO_ARRAY<double, 2> angles() const;
701  virtual GYOTO_ARRAY<size_t, 2> operator*() const;
702  virtual void begin();
703  virtual bool valid();
704  virtual size_t size();
705  };
706 
708  class Empty: public Coord2dSet {
709  public:
710  Empty();
711  virtual Coord2dSet& operator++();
712  virtual void begin();
713  virtual bool valid();
714  virtual size_t size();
715  };
716 
718  class Range : public Coord1dSet {
719  protected:
720  const size_t mi_, ma_, d_, sz_;
721  size_t cur_;
722  public:
724  Range(size_t mi, size_t ma, size_t d);
725  void begin();
726  bool valid();
727  size_t size();
728  Coord1dSet& operator++();
729  size_t operator*() const ;
730  virtual size_t index() const ;
731  };
732 
734  class Indices : public Coord1dSet {
735  protected:
736  size_t const * const indices_;
737  size_t const sz_;
738  size_t i_;
739  public:
740  Indices (size_t const*const buf, size_t sz);
741  void begin();
742  bool valid();
743  size_t size();
744  Coord1dSet& operator++();
745  size_t operator*() const ;
746  virtual size_t index() const ;
747  };
748 
750  class Angles : public Coord1dSet {
751  protected:
752  double const * const buf_;
753  size_t const sz_;
754  size_t i_;
755  public:
756  Angles (double const*const buf, size_t sz);
757  void begin();
758  bool valid();
759  size_t size();
760  Coord1dSet& operator++();
761  double angle() const ;
762  virtual size_t index() const ;
763  };
764 
766  class RepeatAngle : public Coord1dSet {
767  protected:
768  double const val_;
769  size_t const sz_;
770  size_t i_;
771  public:
772  RepeatAngle (double val, size_t sz);
773  void begin();
774  bool valid();
775  size_t size();
776  Coord1dSet& operator++();
777  double angle() const ;
778  virtual size_t index() const ;
779  };
780 };
781 
782 #endif
1D specifier for an angle that is repeated.
Definition: GyotoScreen.h:766
SmartPointer< Spectrometer::Generic > spectro_
Gyoto::Spectrometer::Generic subclass instance used for quantities Spectrum and BinSpectrum.
Definition: GyotoScreen.h:228
#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:235
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:708
#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:718
Definition: GyotoScreen.h:43
The camera with which the Astrobj is observed.
Definition: GyotoScreen.h:173
std::string observerkind_
What kind of observer are we considering? (At infinity, ZAMO...)
Definition: GyotoScreen.h:241
CoordType_e
Enum to specify whether a coordinate set (Coord1dSet or Coord2dSet) holds pixel values or angles...
Definition: GyotoScreen.h:604
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:204
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:734
Class containing arbitrary 2D-points.
Definition: GyotoScreen.h:693
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:222
GYOTO utilities.
const char *const prefix_
If non-NULL, cout j each tims it is incremented.
Definition: GyotoScreen.h:677
SmartPointer< Metric::Generic > gg_
The Metric in this end of the Universe.
Definition: GyotoScreen.h:223
Class to specify a set of points on the Screen.
Definition: GyotoScreen.h:650
Object with properties.
Definition: GyotoObject.h:151
double alpha0_
Screen orientation (0,0) is right towards the BH.
Definition: GyotoScreen.h:221
1D specifier for an arbitrary angle coordinate set.
Definition: GyotoScreen.h:750
const CoordType_e kind
Whether this set holds pixels or angle specifications.
Definition: GyotoScreen.h:653
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:673
const CoordType_e kind
Whether this specifier represents angles or pixels.
Definition: GyotoScreen.h:617
Set of 1-d coordinates: indices or angles.
Definition: GyotoScreen.h:614