source: tags/release-1.1.12/src/FitsIO/Beam.cc

Last change on this file was 788, checked in by MatthewWhiting, 13 years ago

First part of dealing with #110. Have defined a Beam & DuchampBeam? class and use these to hold the beam information. FitsHeader? holds the one that we work with, and copies it to Param for use with outputs. Parameters will be taken into account if no header information is present. Still need to add code to deal with the case of neither being present (the beam being EMPTY) and how that affects the integrated flux calculations.

File size: 1.2 KB
Line 
1#include <iostream>
2#include <math.h>
3#include <FitsIO/Beam.hh>
4#include <duchamp.hh>
5
6namespace duchamp
7{
8
9  Beam::Beam():
10    itsMaj(0), itsMin(0), itsPA(0), itsArea(0)
11  {
12  }
13
14  Beam::Beam(float maj, float min, float pa):
15    itsMaj(maj),itsMin(min),itsPA(pa)
16  {
17    this->calculateArea();
18  }
19
20  Beam::Beam(const Beam &b)
21  {
22    operator=(b);
23  }
24
25  Beam& Beam::operator=(const Beam &b)
26  {
27    if(this == &b ) return *this;
28    this->itsMaj = b.itsMaj;
29    this->itsMin = b.itsMin;
30    this->itsPA = b.itsPA;
31    this->itsArea = b.itsArea;
32    return *this;
33  }
34
35  void Beam::calculateArea()
36  {
37    this->itsArea =  M_PI * (this->itsMaj/2.) * (this->itsMin/2.) / M_LN2;
38  }
39
40  void Beam::areaToFWHM()
41  {
42    float fwhm = 2.*sqrt( this->itsArea * M_LN2 / M_PI );
43    this->itsMaj = fwhm;
44    this->itsMin = fwhm;
45    this->itsPA = 0.;
46  }
47
48  void Beam::define(float maj, float min, float pa)
49  {
50    this->itsMaj = maj;
51    this->itsMin = min;
52    this->itsPA  = pa;
53    this->calculateArea();
54  }
55
56  void Beam::setFWHM(float fwhm)
57  {
58    this->itsMaj = fwhm;
59    this->itsMin = fwhm;
60    this->itsPA = 0.;
61    this->calculateArea();
62  }
63
64  void Beam::setArea(float area)
65  {
66    this->itsArea = area;
67    this->areaToFWHM();
68  }
69
70
71}
Note: See TracBrowser for help on using the repository browser.