source: trunk/src/FitsIO/WriteBaselineArray.cc @ 1339

Last change on this file since 1339 was 1123, checked in by MatthewWhiting, 12 years ago

Moving the code that reads from and writes to FITS files containing reconstructed, momentmap, mask etc arrays to the FitsIO directory, away from Cubes. Updating all include statements as well.

File size: 3.1 KB
Line 
1#include <duchamp/FitsIO/WriteBaselineArray.hh>
2#include <duchamp/FitsIO/WriteArray.hh>
3#include <duchamp/duchamp.hh>
4#include <duchamp/Cubes/cubes.hh>
5#include <fitsio.h>
6
7namespace duchamp {
8
9  WriteBaselineArray::WriteBaselineArray():
10    WriteArray()
11  {
12    this->itsBitpix=FLOAT_IMG;
13  }
14 
15  WriteBaselineArray::WriteBaselineArray(Cube *cube):
16    WriteArray(cube,FLOAT_IMG)
17  {
18  }
19
20  WriteBaselineArray::WriteBaselineArray(const WriteBaselineArray &other)
21  {
22    this->operator=(other);
23  }
24
25  WriteBaselineArray::WriteBaselineArray(const WriteArray &base)
26  {
27    this->operator=(base);
28  }
29
30  WriteBaselineArray& WriteBaselineArray::operator= (const WriteBaselineArray& other)
31  {
32    if(this==&other) return *this;
33    ((WriteArray &) *this) = other;
34    return *this;
35  }
36
37  WriteBaselineArray& WriteBaselineArray::operator= (const WriteArray& base)
38  {
39    if(this==&base) return *this;
40    ((WriteArray &) *this) = base;
41    return *this;
42  }
43
44  OUTCOME WriteBaselineArray::writeHeader()
45  {
46    /// @details
47    ///   A simple function that writes all the necessary keywords and comments
48    ///    to the FITS header pointed to by this->itsFptr.
49    ///   The keyword names and comments are taken from duchamp.hh
50
51    OUTCOME result=SUCCESS;
52    int status = 0;
53    if(fits_write_history(this->itsFptr, (char *)header_baselineHistory.c_str(), &status)){
54      duchampFITSerror(status,"writeBaselineArray","Error : header I/O");
55      result=FAILURE;
56    }
57    status = 0;
58    if(fits_write_history(this->itsFptr, (char *)header_baselineHistory_input.c_str(),&status)){
59      duchampFITSerror(status,"writeBaselineArray","Error : header I/O");
60      result=FAILURE;
61    }
62    status = 0;
63    if(fits_write_history(this->itsFptr, (char *)this->itsCube->pars().getImageFile().c_str(), &status)){
64      duchampFITSerror(status,"writeBaselineArray","Error : header I/O");
65      result=FAILURE;
66    }
67
68    if(this->itsCube->pars().getFlagSubsection()){
69      status = 0;
70      if(fits_write_comment(this->itsFptr,(char *)header_baselineSubsection_comment.c_str(),&status)){
71        duchampFITSerror(status,"writeBaselineArray","Error : header I/O");
72        result=FAILURE;
73      }
74      status = 0;
75      if(fits_write_key(this->itsFptr, TSTRING, (char *)keyword_subsection.c_str(),
76                        (char *)this->itsCube->pars().getSubsection().c_str(),
77                        (char *)comment_subsection.c_str(), &status)){
78        duchampFITSerror(status,"writeBaselineArray","Error : header I/O");
79        result=FAILURE;
80      }
81    }
82 
83    return result;
84
85  }
86
87  OUTCOME WriteBaselineArray::writeData()
88  {
89    OUTCOME result = SUCCESS;
90
91    long group=0;
92    int status=0;
93    if(this->itsCube->pars().getFlagBlankPix())
94      fits_write_imgnull_flt(this->itsFptr, group, 1, this->itsCube->getSize(), this->itsCube->getBaseline(), this->itsCube->pars().getBlankPixVal(), &status);
95    else
96      fits_write_img_flt(this->itsFptr, group, 1, this->itsCube->getSize(), this->itsCube->getBaseline(), &status);
97    if(status){
98      duchampFITSerror(status,"writeBaselineArray","Error writing baseline array:");
99      result = FAILURE;
100    }
101
102    return result;
103
104  }
105
106}
107
Note: See TracBrowser for help on using the repository browser.