forked from marti-vidal-i/PolConvert
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDataIOFITS.h
executable file
·101 lines (69 loc) · 3.21 KB
/
DataIOFITS.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/* DATAIO - FITS-IDI interface to PolConvert
Copyright (C) 2013-2022 Ivan Marti-Vidal
Nordic Node of EU ALMA Regional Center (Onsala, Sweden)
Max-Planck-Institut fuer Radioastronomie (Bonn, Germany)
University of Valencia (Spain)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*/
#include <sys/types.h>
#include <iostream>
#include <fstream>
#include <math.h>
#include <complex>
#include "fitsio.h"
#include "DataIO.h"
/* Class to read FITS-IDI files, setup the data streams,
and iterate over all the baselines with mixed polarization. */
class DataIOFITS: public DataIO {
public:
~DataIOFITS();
DataIOFITS(std::string outputfile, int Nant, int *Ants, double *doRange, bool Overwrite, bool doConj, bool doSolve, int saveSource, ArrayGeometry *Geom, bool doPar, FILE *logF);
bool setCurrentIF(int i);
/* Very important function. Finds the next combination of the 4 correlation
products. Returns the visibilities as an array of pointers;
It also returns the time of the visibility and the ids of the antennas in the baseline.
If more than one lin-pol antenna are present, this function will still work, and will
return the pure-linear visibilities twice, one iteration for each antenna (the same is
true for the auto-correlations of each lin-pol antenna).
Returns false if no more mixed-pol visibilities are found for the corresponding IF. */
bool getNextMixedVis(double &JDTime, int &antenna, int &otherAnt, bool &conj, int &calField);
/* Complementary to the function above. Once the visibilities have been
corrected, this function puts them back into the right place. */
bool setCurrentMixedVis();
// Dummy function:
int getFileNumber();
// Modify the visibilities read by "getNextMixedVis" by the calibration matrix supplied
// Saves the result in the "bufferVis" pointer
void applyMatrix(std::complex<float> *M[2][2], bool swap, bool print, int thisAnt, FILE *plotFile);
// Flag bad (unconvertible) data:
void zeroWeight();
// Close all files.
void finish();
private:
void readInput(std::string inputfile, int saveSource);
void openOutFile(std::string outputfile, bool Overwrite);
void saveCirculars(std::string inputfile);
fitsfile *fptr, *ofile;
FILE *logFile ;
long *Vis2Save;
long NVis2Save;
int uu, vv, ww, ss;
double *Times;
bool doConjugate, doWriteCirc, canPlot, doParang;
char polOrder[4], message[512];
long jump, Nentry, djump, dsize, TotSize;
int currIF, currBand;
std::complex<float> *currentVis ;
std::complex<float> *bufferVis ;
float *currentData ;
float *bufferData ;
};