-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDataIOSWIN.h
128 lines (91 loc) · 3.91 KB
/
DataIOSWIN.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/* 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 "DataIO.h"
typedef struct {
int fileNumber;
int Source;
double Time;
char Pol[2];
bool notUsed;
int Antennas[2];
int Baseline;
int freqIndex;
long byteIni;
long byteEnd;} Record;
/* Class to read FITS-IDI files, setup the data streams,
and iterate over all the baselines with mixed polarization. */
class DataIOSWIN: public DataIO {
public:
~DataIOSWIN();
DataIOSWIN(int nSWIN, std::string* outputfiles, int Nant, int *Ants, double *doRange, int nIF, int *nChan, int nIF2Conv, int *IF2Conv, int IFoffset, int Afilt, int *nChanACorr, double **Freqs, bool Overwrite, bool doTest, bool doSolve, int saveSource, double jd0, ArrayGeometry *Geom, bool doPar, FILE *logF);
bool setCurrentIF(int i);
// Average in time the antenna autocorrelations:
void averageAutocorrs();
// Returns the file number of the current visibility:
int getFileNumber();
/* 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();
// 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 openOutFiles(std::string* difxfiles);
void readHeader(bool doTest, int saveSource);
////////
// Only used for SWIN files. Not used here
static const long RECBUFFER = 1024*1024;
static const int NFRDATA = 8;
static const int NCFDATA = 2;
static const long endhead = sizeof(int) + 4*sizeof(double); // Useless info at the headers end.
////////
// char polOrder[4];
int AutoCorrMedianFilter;
int IFOffset;
int nDoIF;
int *DoIF;
FILE *logFile;
char message[512];
int nfiles;
std::ifstream *olddifx;
std::fstream *newdifx;
bool isOverWrite, doWriteCirc, canPlot, isAutoCorr, isTwoLinear, doParang;
bool debugNewIF, convisok;
long currEntries[MAXIF][4], nrec;
long *filesizes;
std::complex<float> *currentVis[4] ;
std::complex<float> *bufferVis[4] ;
std::complex<float> *auxVis[4] ;
Record *Records ;
};