source: trunk/src/Cubes/WriteBaselineArray.cc @ 1120

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

Ticket #170, #105 - The bulk of the work allowing this to happen. Have implemented different classes for each of the output types, including the baselines (which required new parameters etc.) Not yet implemented in mainDuchamp, so needs testing.

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