Gyoto
GyotoScreen.h
Go to the documentation of this file.
1
7/*
8 Copyright 2011-2019 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
43template <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
51namespace 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_;
183 // double tmin_;
185
189 double * mask_;
190
197 std::string mask_filename_;
198
199 double distance_;
200 double dmax_;
201
202 enum anglekind_e { equatorial_angles=0, rectilinear=1, spherical_angles=2};
203 typedef int anglekind_t;
204
205 anglekind_t anglekind_;
206
212 double euler_[3];
213 double ex_[3];
214 double ey_[3];
215 double ez_[3];
216
217 double fourvel_[4];
218 double screen1_[4];
219 double screen2_[4];
220 double screen3_[4];
221
222 double dangle1_;
223 double dangle2_;
225
230
236 double freq_obs_;
237
243
244 public:
246 GYOTO_OBJECT_THREAD_SAFETY;
247
248 // Constructors - Destructor
249 // -------------------------
251 Screen(const Screen& ) ;
252 Screen * clone() const;
253
254 virtual ~Screen() ;
255
256 // Mutators / assignment
257 // ---------------------
258
260 void setProjection(const double paln,
261 const double inclination,
262 const double argument);
264 void setProjection(const double distance,
265 const double paln,
266 const double inclination,
267 const double argument);
268
270
273 void distance(double dist);
274
276
279 void dMax(double dist);
280
282
286 void distance(double dist, const std::string &unit);
287
289
293 void inclination(double);
294
296
300 void inclination(double, const std::string &unit);
301
302 void PALN(double);
304 void PALN(double, const std::string &unit);
306 void argument(double);
308 void argument(double, const std::string &unit);
314
319 void freqObs(double fo);
320
321
328 void freqObs(double fo, const std::string &unit);
329
333 double freqObs() const ;
334
340 double freqObs(const std::string &unit) const;
341
343
351 void setObserverPos(const double pos[4]);
352 void observerKind(const std::string &kind);
353 std::string observerKind() const;
354 void setFourVel(const double coord[4]);
356 void setScreen1(const double coord[4]);
358 void setScreen2(const double coord[4]);
360 void setScreen3(const double coord[4]);
362
363 // Accessors
364 // ---------
365
367
370 int coordKind() const;
371
373
376 double distance() const;
377
379
382 double distance(const std::string&) const;
383
385
388 double dMax() const;
389
391
395 double inclination() const;
396
398
402 double inclination(const std::string&) const;
403
404 double PALN() const;
405 double PALN(const std::string&) const;
406 double argument() const;
407 double argument(const std::string&) const;
408
411
413 double time() const;
414
416 double time(const std::string &) const;
417
419 void time(double, const std::string &);
420
422 void time(double);
423
425 double fieldOfView() const;
426
428 double fieldOfView(std::string const &unit) const;
429
431 void fieldOfView(double);
432
434 void fieldOfView(double, const std::string &unit);
435
437 double azimuthalFieldOfView() const;
438
440 void azimuthalFieldOfView(double ff);
441
443 void dangle1(double);
445 void dangle1(double, const std::string &unit);
447 double dangle1() const;
449 double dangle1(std::string const &unit)const;
451 void dangle2(double);
453 void dangle2(double, const std::string &unit);
455 double dangle2() const;
457 double dangle2(std::string const &unit)const;
458
460 void anglekind(int);
461 void anglekind(std::string const&);
462 std::string anglekind() const;
463
465 size_t resolution() const;
467 void resolution(size_t);
468
470
474 void mask(double const * const mm, size_t resolution=0);
475
477 double const * mask() const ;
478 void maskFile(std::string const &fname);
479 std::string maskFile() const;
480# ifdef GYOTO_USE_CFITSIO
481
483 void fitsReadMask(std::string const &fname);
484
486 void fitsWriteMask(std::string const &fname);
487# endif
488
490
494 bool operator()(size_t, size_t);
495
496
498
509 void getObserverPos(double dest[4]) const;
510
512
515 void getFourVel(double dest[4]) const;
516
517 void fourVel(std::vector<double> const &);
518 std::vector<double> fourVel() const;
519 void screenVector1(std::vector<double> const &);
520 std::vector<double> screenVector1() const;
521 void screenVector2(std::vector<double> const &);
522 std::vector<double> screenVector2() const;
523 void screenVector3(std::vector<double> const &);
524 std::vector<double> screenVector3() const;
525
527
530 void getScreen1(double dest[4]) const;
531
533
536 void getScreen2(double dest[4]) const;
537
539
542 void getScreen3(double dest[4]) const;
543
545
557 void getRayTriad(double x, double y,
558 double dest[8],
559 bool compute_polar_basis=false,
560 double Ephi[4]=NULL, double Etheta[4]=NULL) const;
561
563
574 void getRayTriad(const size_t i, const size_t j,
575 double dest[8],
576 bool compute_polar_basis=false,
577 double Ephi[4]=NULL, double Etheta[4]=NULL) const;
578
585 void coordToSky(const double pos[4], double dest[3], bool geometrical=false) const;
586
593 void skyToCoord(const double sky[3], double dest[4], bool geometrical=false) const;
594
595 void coordToXYZ(const double pos[4], double dest[3]) const;
597
600
602 // friend std::ostream& operator<<(std::ostream& , const Screen& ) ;
603 std::ostream& print(std::ostream&) const ;
604 std::ostream& printBaseVectors(std::ostream&) const ;
605
606 // UDUNITS
607# ifdef HAVE_UDUNITS
609
617 void mapPixUnit();
618
620
623 void unmapPixUnit();
624# endif
625
626
627#ifdef GYOTO_USE_XERCES
628 public:
630
633#endif
634
636 enum CoordType_e {angle, pixel};
637
639
647 public:
650 public:
654 virtual ~Coord1dSet();
656 virtual void begin() =0;
658 virtual bool valid() =0;
660 virtual size_t size()=0;
662 virtual size_t operator*() const ;
664 virtual double angle() const ;
666 virtual Coord1dSet& operator++()=0;
668
673 virtual size_t index() const=0;
674 };
675
677
683 public:
689 virtual ~Coord2dSet();
691 virtual Coord2dSet& operator++() =0;
697 virtual void begin() =0;
699 virtual bool valid() =0;
701 virtual size_t size()=0;
702 };
703
705 class Grid: public Coord2dSet {
706 protected:
707 protected:
709 char * prefix_;
710 Coord1dSet &iset_;
711 Coord1dSet &jset_;
712 public:
713 Grid(Coord1dSet &iset, Coord1dSet &jset, const char * const p=NULL);
714 virtual ~Grid();
717 virtual void begin();
718 virtual bool valid();
719 virtual size_t size();
720 };
721
723
726 class Bucket : public Coord2dSet {
727 protected:
728 Coord1dSet &alpha_;
729 Coord1dSet &delta_;
730 public:
731 Bucket(Coord1dSet &iset, Coord1dSet &jset);
735 virtual void begin();
736 virtual bool valid();
737 virtual size_t size();
738 };
739
741 class Empty: public Coord2dSet {
742 public:
743 Empty();
745 virtual void begin();
746 virtual bool valid();
747 virtual size_t size();
748 };
749
751 class Range : public Coord1dSet {
752 protected:
753 const size_t mi_, ma_, d_, sz_;
754 size_t cur_;
755 public:
757 Range(size_t mi, size_t ma, size_t d);
758 void begin();
759 bool valid();
760 size_t size();
762 size_t operator*() const ;
763 virtual size_t index() const ;
764 };
765
767 class Indices : public Coord1dSet {
768 protected:
769 size_t * indices_;
770 size_t const sz_;
771 size_t i_;
772 public:
773 Indices (size_t const*const buf, size_t sz);
774 ~Indices();
775 void begin();
776 bool valid();
777 size_t size();
779 size_t operator*() const ;
780 virtual size_t index() const ;
781 };
782
784 class Angles : public Coord1dSet {
785 protected:
786 double * buf_;
787 size_t const sz_;
788 size_t i_;
789 public:
790 Angles (double const*const buf, size_t sz);
791 ~Angles();
792 void begin();
793 bool valid();
794 size_t size();
796 double angle() const ;
797 virtual size_t index() const ;
798 };
799
801 class RepeatAngle : public Coord1dSet {
802 protected:
803 double const val_;
804 size_t const sz_;
805 size_t i_;
806 public:
807 RepeatAngle (double val, size_t sz);
808 void begin();
809 bool valid();
810 size_t size();
812 double angle() const ;
813 virtual size_t index() const ;
814 };
815};
816
817#endif
#define size_t
If not defined in <sys/types.h>.
Definition GyotoConfig.h:390
Gyoto ubiquitous macros and typedefs.
#define obskind_t
Type for observer kind.
Definition GyotoDefs.h:554
Base class for metric description.
Introspectable objects.
#define GYOTO_OBJECT
Declare class::properties and class::getProperties()
Definition GyotoObject.h:84
Reference-counting pointers.
Spectroscopic capabilities of a Screen.
GYOTO utilities.
Definition GyotoScreen.h:43
Factory / SmartPointee::Subcontractor_t interface.
Definition GyotoFactoryMessenger.h:92
Object with properties.
Definition GyotoObject.h:152
virtual std::string kind() const
Get kind_.
Property that can be set and got using standard methods.
Definition GyotoProperty.h:608
1D specifier for an arbitrary angle coordinate set.
Definition GyotoScreen.h:784
void begin()
Reset specifier to point to the first value.
virtual size_t index() const
Get index of value currently pointed to.
double angle() const
Get double value currently pointed to.
Coord1dSet & operator++()
Increment iterator (point to next value)
size_t size()
Number of values in this container.
bool valid()
True if pointing to something, false if end has been reached.
Class containing arbitrary 2D-points.
Definition GyotoScreen.h:726
virtual GYOTO_ARRAY< size_t, 2 > operator*() const
Get pixel coordinates.
virtual Coord2dSet & operator++()
Increment pointer.
virtual size_t size()
Number of positions contained.
virtual GYOTO_ARRAY< double, 2 > angles() const
Get angle coordinates.
virtual void begin()
Reset pointer.
virtual bool valid()
Whether the end has not been passed.
Set of 1-d coordinates: indices or angles.
Definition GyotoScreen.h:646
const CoordType_e kind
Whether this specifier represents angles or pixels.
Definition GyotoScreen.h:649
virtual void begin()=0
Reset specifier to point to the first value.
virtual size_t index() const =0
Get index of value currently pointed to.
virtual Coord1dSet & operator++()=0
Increment iterator (point to next value)
virtual size_t size()=0
Number of values in this container.
virtual bool valid()=0
True if pointing to something, false if end has been reached.
virtual double angle() const
Get double value currently pointed to.
Coord1dSet(CoordType_e k)
Set kind during initialization.
virtual ~Coord1dSet()
Virtual destructor.
virtual size_t operator*() const
Get size_t value currently pointed to.
Class to specify a set of points on the Screen.
Definition GyotoScreen.h:682
virtual void begin()=0
Reset pointer.
virtual Coord2dSet & operator++()=0
Increment pointer.
virtual size_t size()=0
Number of positions contained.
const CoordType_e kind
Whether this set holds pixels or angle specifications.
Definition GyotoScreen.h:685
virtual bool valid()=0
Whether the end has not been passed.
virtual GYOTO_ARRAY< double, 2 > angles() const
Get angle coordinates.
virtual ~Coord2dSet()
Virtual destructor.
virtual GYOTO_ARRAY< size_t, 2 > operator*() const
Get pixel coordinates.
Coord2dSet(CoordType_e k)
Set kind at initialisation.
A dummy, empty 2D set.
Definition GyotoScreen.h:741
virtual void begin()
Reset pointer.
virtual size_t size()
Number of positions contained.
virtual Coord2dSet & operator++()
Increment pointer.
virtual bool valid()
Whether the end has not been passed.
Class containing 2D-points organized in a grid.
Definition GyotoScreen.h:705
virtual size_t size()
Number of positions contained.
virtual bool valid()
Whether the end has not been passed.
char * prefix_
If non-NULL, cout j each tims it is incremented.
Definition GyotoScreen.h:709
virtual void begin()
Reset pointer.
virtual Coord2dSet & operator++()
Increment pointer.
virtual GYOTO_ARRAY< size_t, 2 > operator*() const
Get pixel coordinates.
1D specifier for an arbitrary pixel coordinate set.
Definition GyotoScreen.h:767
bool valid()
True if pointing to something, false if end has been reached.
size_t size()
Number of values in this container.
void begin()
Reset specifier to point to the first value.
virtual size_t index() const
Get index of value currently pointed to.
Coord1dSet & operator++()
Increment iterator (point to next value)
size_t operator*() const
Get size_t value currently pointed to.
1D coordinated specifier for a range
Definition GyotoScreen.h:751
Range(size_t mi, size_t ma, size_t d)
Specify min, max and step of this range.
bool valid()
True if pointing to something, false if end has been reached.
virtual size_t index() const
Get index of value currently pointed to.
void begin()
Reset specifier to point to the first value.
size_t size()
Number of values in this container.
size_t operator*() const
Get size_t value currently pointed to.
Coord1dSet & operator++()
Increment iterator (point to next value)
1D specifier for an angle that is repeated.
Definition GyotoScreen.h:801
double angle() const
Get double value currently pointed to.
virtual size_t index() const
Get index of value currently pointed to.
void begin()
Reset specifier to point to the first value.
size_t size()
Number of values in this container.
Coord1dSet & operator++()
Increment iterator (point to next value)
bool valid()
True if pointing to something, false if end has been reached.
The camera with which the Astrobj is observed.
Definition GyotoScreen.h:176
SmartPointer< Metric::Generic > gg_
The Metric in this end of the Universe.
Definition GyotoScreen.h:224
double freq_obs_
Frequency at which the observer observes.
Definition GyotoScreen.h:236
double PALN(const std::string &) const
Get position angle of the line of nodes.
double fov_
Field-of-view in rad.
Definition GyotoScreen.h:181
double screen3_[4]
Screen e3 vector (normal)
Definition GyotoScreen.h:220
double ex_[3]
Sky coordinate of base X vector.
Definition GyotoScreen.h:213
double ez_[3]
Sky coordinate of base Z vector.
Definition GyotoScreen.h:215
double azimuthalFieldOfView() const
Get Screen::azimuthal_fov_.
size_t npix_
Resolution in pixels.
Definition GyotoScreen.h:184
void getScreen2(double dest[4]) const
Get copy of Screen::screen2_.
Screen(const Screen &)
Copy constructor.
double dangle1(std::string const &unit) const
Get increment to first position angle in specified unit.
void freqObs(double fo, const std::string &unit)
Set freq_obs_.
double ey_[3]
Sky coordinate of base Y vector.
Definition GyotoScreen.h:214
virtual ~Screen()
Destructor.
double distance_
Distance to the observer in m.
Definition GyotoScreen.h:199
double argument() const
Get angle between line of nodes and X axis of object.
void PALN(double)
Set position angle of the line of nodes.
double const * mask() const
Retrieve const pointer to mask_.
double azimuthal_fov_
Azimuthal field-of-view for Spherical Angles images. Maximal extent of image in the azimuthal b-angle...
Definition GyotoScreen.h:182
CoordType_e
Enum to specify whether a coordinate set (Coord1dSet or Coord2dSet) holds pixel values or angles.
Definition GyotoScreen.h:636
Screen()
Default constructor.
double freqObs(const std::string &unit) const
Get freq_obs_.
void PALN(double, const std::string &unit)
Set position angle of the line of nodes.
void fieldOfView(double)
Set Screen::fov_ in radians.
void setScreen2(const double coord[4])
Sets the screen vector e2.
SmartPointer< Metric::Generic > metric() const
Get Screen::gg_.
std::string mask_filename_
Last read or written FITS file.
Definition GyotoScreen.h:197
double time(const std::string &) const
Get observing date in seconds.
double freqObs() const
Get freq_obs_.
double distance() const
Get distance from observer.
void fillProperty(Gyoto::FactoryMessenger *fmp, Property const &p) const
Output a single Property to XML.
void argument(double)
Set angle beetwen line of nodes and X axis of object.
void argument(double, const std::string &unit)
Set angle beetwen line of nodes and X axis of object.
void time(double, const std::string &)
Set observing date in specified unit.
double distance(const std::string &) const
Get distance from observer.
void getRayTriad(const size_t i, const size_t j, double dest[8], bool compute_polar_basis=false, double Ephi[4]=NULL, double Etheta[4]=NULL) const
Get 8-coordinate of Photon hitting screen pixel and polarization basis if needed.
double inclination() const
Get inclination relative to line-of-sight.
double time() const
Get observing date in seconds.
void getScreen1(double dest[4]) const
Get copy of Screen::screen1_.
anglekind_t anglekind_
Screen angles kind (0: equatorial, 1: spherical)
Definition GyotoScreen.h:205
void freqObs(double fo)
Set freq_obs_.
void dangle2(double)
Set increment to second position angle.
obskind_t observerkind_
What kind of observer are we considering? (At infinity, ZAMO...)
Definition GyotoScreen.h:242
void dangle1(double, const std::string &unit)
Set increment to first position angle in specified unit.
void setFourVel(const double coord[4])
Sets the observer's 4-velocity.
double argument(const std::string &) const
Get angle between line of nodes and X axis of object.
static SmartPointer< Screen > Subcontractor(FactoryMessenger *fmp)
Instanciate a Screen from XML entity.
void inclination(double)
Set inclination relative to line-of-sight.
void coordToSky(const double pos[4], double dest[3], bool geometrical=false) const
Convert metric 4-position to sky 3-position.
double euler_[3]
Euler angles.
Definition GyotoScreen.h:212
void time(double)
Set observing date in seconds.
int coordKind() const
Get coordinate kind.
void dMax(double dist)
Set ray-tracing maximum distance.
double PALN() const
Get position angle of the line of nodes.
void dangle2(double, const std::string &unit)
Set increment to second position angle in specified unit.
double screen1_[4]
Screen e1 vector.
Definition GyotoScreen.h:218
std::ostream & printBaseVectors(std::ostream &) const
Debug helper.
void getRayTriad(double x, double y, double dest[8], bool compute_polar_basis=false, double Ephi[4]=NULL, double Etheta[4]=NULL) const
Get 8-coordinate of Photon hitting screen from a given direction and polarization basis if needed.
double tobs_
Observing date in s.
Definition GyotoScreen.h:180
void getFourVel(double dest[4]) const
Get copy of Screen::fourvel_.
void getObserverPos(double dest[4]) const
4-Position of the observer relative to the metric
void distance(double dist, const std::string &unit)
Set distance from observer.
void getScreen3(double dest[4]) const
Get copy of Screen::screen3_.
double fieldOfView() const
Get Screen::fov_ in radians.
void inclination(double, const std::string &unit)
Set inclination relative to line-of-sight.
double fieldOfView(std::string const &unit) const
Get Screen::fov_ in specified unit.
double dangle2_
Increment to second position angle of Screen; can be typically delta if in Equatorial Angles,...
Definition GyotoScreen.h:223
double dangle1() const
Get increment to first position angle.
void skyToCoord(const double sky[3], double dest[4], bool geometrical=false) const
Convert sky 3-position to metric 4-position.
void setProjection(const double paln, const double inclination, const double argument)
Set inclination etc.
void azimuthalFieldOfView(double ff)
Set Screen::azimuthal_fov_.
double dangle2(std::string const &unit) const
Get increment to second position angle in specified unit.
double fourvel_[4]
Observer's 4-velocity.
Definition GyotoScreen.h:217
bool operator()(size_t, size_t)
Whether this pixel should be ray-traced.
void setScreen3(const double coord[4])
Sets the screen vector e3 (normal)
double dMax() const
Get maximum ray-tracing distance.
void anglekind(int)
Set Screen::anglekind_.
double dangle1_
Increment to first position angle of Screen; can be typically alpha if in Equatorial Angles,...
Definition GyotoScreen.h:222
void dangle1(double)
Set increment to first position angle.
double * mask_
Mask with 0 where the ray-tracing should not be performed.
Definition GyotoScreen.h:189
void spectrometer(SmartPointer< Spectrometer::Generic > spectro)
Set Screen::spectro_.
void setObserverPos(const double pos[4])
Alternative way to set projection.
SmartPointer< Spectrometer::Generic > spectro_
Gyoto::Spectrometer::Generic subclass instance used for quantities Spectrum and BinSpectrum.
Definition GyotoScreen.h:229
void coordToXYZ(const double pos[4], double dest[3]) const
Convert 4-position to 3-cartesian coordinates.
Screen * clone() const
Cloner.
void setScreen1(const double coord[4])
Sets the screen vector e1.
void setProjection(const double distance, const double paln, const double inclination, const double argument)
Set distance, inclination etc.
double dangle2() const
Get increment to second position angle.
SmartPointer< Spectrometer::Generic > spectrometer() const
Get Screen::spectro_.
double dmax_
Maximum distance from which the photons are launched (geometrical units)
Definition GyotoScreen.h:200
double screen2_[4]
Screen e2 vector.
Definition GyotoScreen.h:219
void fieldOfView(double, const std::string &unit)
Set Screen::fov_ in specified unit.
void mask(double const *const mm, size_t resolution=0)
Set mask_ from array.
void distance(double dist)
Set distance from observer.
void metric(SmartPointer< Metric::Generic > gg)
Set Screen::gg_.
void resolution(size_t)
Set Screen::npix_.
void computeBaseVectors()
Compute base vectors according to projection parameters.
std::ostream & print(std::ostream &) const
Display.
double inclination(const std::string &) const
Get inclination relative to line-of-sight.
size_t resolution() const
Get Screen::npix_.
Can be pointed to by a SmartPointer.
Definition GyotoSmartPointer.h:81
Pointers performing reference counting.
Definition GyotoSmartPointer.h:135
Namespace for the Gyoto library.
Definition GyotoAstrobj.h:44