Gyoto
GyotoScreen.h
Go to the documentation of this file.
1 
7 /*
8  Copyright 2011-2017, 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
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 azimuthal_fov_;
183  // double tmin_;
184  size_t npix_;
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 
242  std::string observerkind_;
243 
244  public:
245  GYOTO_OBJECT;
247 
248  // Constructors - Destructor
249  // -------------------------
250  Screen() ;
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);
310  void spectrometer(SmartPointer<Spectrometer::Generic> spectro);
312  SmartPointer<Spectrometer::Generic> spectrometer() const ;
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 
409  SmartPointer<Metric::Generic> metric() const;
410  void metric(SmartPointer<Metric::Generic> gg);
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 
554  void getRayCoord(double x, double y, double dest[8]) const;
555 
557 
565  void getRayCoord(const size_t i, const size_t j, double dest[8]) const;
566 
567  void coordToSky(const double pos[4], double dest[3]) const;
569 
570  void coordToXYZ(const double pos[4], double dest[3]) const;
572 
573  void computeBaseVectors() ;
575 
577  // friend std::ostream& operator<<(std::ostream& , const Screen& ) ;
578  std::ostream& print(std::ostream&) const ;
579  std::ostream& printBaseVectors(std::ostream&) const ;
580 
581  // UDUNITS
582 # ifdef HAVE_UDUNITS
583 
592  void mapPixUnit();
593 
595 
598  void unmapPixUnit();
599 # endif
600 
601 
602 #ifdef GYOTO_USE_XERCES
603  public:
604  void fillProperty(Gyoto::FactoryMessenger *fmp, Property const &p) const;
605 
608 #endif
609 
611  enum CoordType_e {angle, pixel};
612 
614 
621  class Coord1dSet {
622  public:
625  public:
629  virtual ~Coord1dSet();
631  virtual void begin() =0;
633  virtual bool valid() =0;
635  virtual size_t size()=0;
637  virtual size_t operator*() const ;
639  virtual double angle() const ;
641  virtual Coord1dSet& operator++()=0;
643 
648  virtual size_t index() const=0;
649  };
650 
652 
657  class Coord2dSet {
658  public:
664  virtual ~Coord2dSet();
666  virtual Coord2dSet& operator++() =0;
668  virtual GYOTO_ARRAY<size_t, 2> operator* () const;
670  virtual GYOTO_ARRAY<double, 2> angles() const ;
672  virtual void begin() =0;
674  virtual bool valid() =0;
676  virtual size_t size()=0;
677  };
678 
680  class Grid: public Coord2dSet {
681  protected:
682  protected:
684  const char * const prefix_;
685  Coord1dSet &iset_;
686  Coord1dSet &jset_;
687  public:
688  Grid(Coord1dSet &iset, Coord1dSet &jset, const char * const p=NULL);
689  virtual Coord2dSet& operator++();
690  virtual GYOTO_ARRAY<size_t, 2> operator* () const;
691  virtual void begin();
692  virtual bool valid();
693  virtual size_t size();
694  };
695 
697 
700  class Bucket : public Coord2dSet {
701  protected:
702  Coord1dSet &alpha_;
703  Coord1dSet &delta_;
704  public:
705  Bucket(Coord1dSet &iset, Coord1dSet &jset);
706  virtual Coord2dSet& operator++();
707  virtual GYOTO_ARRAY<double, 2> angles() const;
708  virtual GYOTO_ARRAY<size_t, 2> operator*() const;
709  virtual void begin();
710  virtual bool valid();
711  virtual size_t size();
712  };
713 
715  class Empty: public Coord2dSet {
716  public:
717  Empty();
718  virtual Coord2dSet& operator++();
719  virtual void begin();
720  virtual bool valid();
721  virtual size_t size();
722  };
723 
725  class Range : public Coord1dSet {
726  protected:
727  const size_t mi_, ma_, d_, sz_;
728  size_t cur_;
729  public:
731  Range(size_t mi, size_t ma, size_t d);
732  void begin();
733  bool valid();
734  size_t size();
735  Coord1dSet& operator++();
736  size_t operator*() const ;
737  virtual size_t index() const ;
738  };
739 
741  class Indices : public Coord1dSet {
742  protected:
743  size_t const * const indices_;
744  size_t const sz_;
745  size_t i_;
746  public:
747  Indices (size_t const*const buf, size_t sz);
748  void begin();
749  bool valid();
750  size_t size();
751  Coord1dSet& operator++();
752  size_t operator*() const ;
753  virtual size_t index() const ;
754  };
755 
757  class Angles : public Coord1dSet {
758  protected:
759  double const * const buf_;
760  size_t const sz_;
761  size_t i_;
762  public:
763  Angles (double const*const buf, size_t sz);
764  void begin();
765  bool valid();
766  size_t size();
767  Coord1dSet& operator++();
768  double angle() const ;
769  virtual size_t index() const ;
770  };
771 
773  class RepeatAngle : public Coord1dSet {
774  protected:
775  double const val_;
776  size_t const sz_;
777  size_t i_;
778  public:
779  RepeatAngle (double val, size_t sz);
780  void begin();
781  bool valid();
782  size_t size();
783  Coord1dSet& operator++();
784  double angle() const ;
785  virtual size_t index() const ;
786  };
787 };
788 
789 #endif
1D specifier for an angle that is repeated.
Definition: GyotoScreen.h:773
SmartPointer< Spectrometer::Generic > spectro_
Gyoto::Spectrometer::Generic subclass instance used for quantities Spectrum and BinSpectrum.
Definition: GyotoScreen.h:229
#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:236
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:715
#define size_t
If not defined in <sys/types.h>.
Definition: GyotoConfig.h:390
double dangle1_
Increment to first position angle of Screen; can be typically alpha if in Equatorial Angles...
Definition: GyotoScreen.h:222
Factory / SmartPointee::Subcontractor_t interface.
Definition: GyotoFactoryMessenger.h:92
1D coordinated specifier for a range
Definition: GyotoScreen.h:725
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:242
CoordType_e
Enum to specify whether a coordinate set (Coord1dSet or Coord2dSet) holds pixel values or angles...
Definition: GyotoScreen.h:611
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:205
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:741
Class containing arbitrary 2D-points.
Definition: GyotoScreen.h:700
Pointers performing reference counting.
Definition: GyotoProperty.h:45
Can be pointed to by a SmartPointer.
Definition: GyotoSmartPointer.h:80
GYOTO utilities.
const char *const prefix_
If non-NULL, cout j each tims it is incremented.
Definition: GyotoScreen.h:684
SmartPointer< Metric::Generic > gg_
The Metric in this end of the Universe.
Definition: GyotoScreen.h:224
Class to specify a set of points on the Screen.
Definition: GyotoScreen.h:657
Object with properties.
Definition: GyotoObject.h:151
1D specifier for an arbitrary angle coordinate set.
Definition: GyotoScreen.h:757
const CoordType_e kind
Whether this set holds pixels or angle specifications.
Definition: GyotoScreen.h:660
double dangle2_
Increment to second position angle of Screen; can be typically delta if in Equatorial Angles...
Definition: GyotoScreen.h:223
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:680
const CoordType_e kind
Whether this specifier represents angles or pixels.
Definition: GyotoScreen.h:624
Set of 1-d coordinates: indices or angles.
Definition: GyotoScreen.h:621