~pconv-team/polconvertsd/trunk-1

« back to all changes in this revision

Viewing changes to DataIO.cpp

  • Committer: Ivan Marti-Vidal
  • Date: 2017-05-27 18:24:27 UTC
  • Revision ID: i.martividal@gmail.com-20170527182427-rzp08c378mpwblln
VersionĀ 1.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* DATAIO - FITS-IDI interface to PolConvert
 
2
 
 
3
             Copyright (C) 2013  Ivan Marti-Vidal
 
4
             Nordic Node of EU ALMA Regional Center (Onsala, Sweden)
 
5
             Max-Planck-Institut fuer Radioastronomie (Bonn, Germany)
 
6
  
 
7
This program is free software: you can redistribute it and/or modify
 
8
it under the terms of the GNU General Public License as published by
 
9
the Free Software Foundation, either version 3 of the License, or
 
10
(at your option) any later version.
 
11
  
 
12
This program is distributed in the hope that it will be useful,
 
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
GNU General Public License for more details.
 
16
  
 
17
You should have received a copy of the GNU General Public License   
 
18
along with this program.  If not, see <http://www.gnu.org/licenses/>
 
19
  
 
20
*/
 
21
 
 
22
 
 
23
 
 
24
#include <sys/types.h>
 
25
#include <iostream> 
 
26
#include <fstream>
 
27
#include <stdlib.h>  
 
28
#include <string.h>
 
29
#include <math.h>
 
30
#include <dirent.h>
 
31
#include "DataIO.h"
 
32
#include "fitsio.h"
 
33
 
 
34
 
 
35
//#define   NIOBUF = 1;
 
36
 
 
37
 
 
38
 
 
39
 
 
40
DataIO::~DataIO() {
 
41
 
 
42
};
 
43
 
 
44
DataIO::DataIO() { printf("\nCreating VLBI data structure");};
 
45
 
 
46
 
 
47
// SELF-EXPLANATORY FUNCTIONS:
 
48
int DataIO::getNfreqs() {return Nfreqs;};  // NUMBER OF IFs
 
49
int DataIO::getNant() {return Nants;};  // TOTAL NUMBER OF ANTENNAS
 
50
int DataIO::getNchan(int freqid) {return Freqs[freqid].Nchan;};  // # OF CHANNEL IN freqid IF
 
51
long DataIO::getMixedNvis() {return NLinVis;};  // NUMBER OF MIXED-POLARIZATION VISIBILITIES FOUND
 
52
 
 
53
 
 
54
 
 
55
// GET FREQUENCIES OF CURRENT IF:
 
56
void DataIO::getFrequencies(double* output){
 
57
memcpy(output,Freqvals[currFreq],Freqs[currFreq].Nchan*sizeof(double));
 
58
};
 
59
 
 
60
 
 
61
// CHECK WHETHER SOMETHING FAILED:
 
62
bool DataIO::succeed(){return success;};
 
63
 
 
64
 
 
65
// GET FIRST DAY OF OBSERVATION (MODIFIED JULIAN DATE)
 
66
double DataIO::getDay0(){return day0;};
 
67
 
 
68
 
 
69
 
 
70
 
 
71
 
 
72
 
 
73
 
 
74
void DataIO::getParAng(int sidx, int Ant1, int Ant2, double*UVW, double &P1, double &P2){
 
75
 
 
76
double V2, Bx, By, Bz;
 
77
double CH, SH, CT1, CT2, HAng, H1, H2;
 
78
int ibas;
 
79
 
 
80
 
 
81
if(sidx<Geometry->NtotSou && Ant1<Geometry->NtotAnt && Ant2<Geometry->NtotAnt){
 
82
 
 
83
  V2 = Geometry->SinDec[sidx]*UVW[1] - Geometry->CosDec[sidx]*UVW[2];
 
84
  ibas = Geometry->BasNum[Ant1][Ant2];
 
85
 
 
86
 
 
87
  if (ibas<0){
 
88
  ibas = -ibas;
 
89
   Bx = -Geometry->BaseLine[0][ibas];
 
90
   By = -Geometry->BaseLine[1][ibas];
 
91
   Bz = -Geometry->BaseLine[2][ibas];
 
92
  } else {
 
93
   Bx = Geometry->BaseLine[0][ibas];
 
94
   By = Geometry->BaseLine[1][ibas];
 
95
   Bz = Geometry->BaseLine[2][ibas];
 
96
  };
 
97
 
 
98
  CH = (UVW[0]*By - V2*Bx); // /(By**2. + Bx**2.);
 
99
  SH = (UVW[0]*Bx + V2*By); // /(By**2. + Bx**2.);
 
100
  CT1 = Geometry->CosDec[sidx]*tan(Geometry->Lat[Ant1]);
 
101
  CT2 = Geometry->CosDec[sidx]*tan(Geometry->Lat[Ant2]);
 
102
 
 
103
  HAng = atan2(SH,CH);
 
104
  H1 = HAng + Geometry->AntLon[Ant1];
 
105
  H2 = HAng + Geometry->AntLon[Ant2];
 
106
 
 
107
  P1 = atan2(sin(H1), CT1 - Geometry->SinDec[sidx]*cos(H1));
 
108
  P2 = atan2(sin(H2), CT2 - Geometry->SinDec[sidx]*cos(H2));
 
109
 
 
110
 
 
111
} else {
 
112
 
 
113
  P1 = 0.0;
 
114
  P2 = 0.0;
 
115
 
 
116
};
 
117
 
 
118
};
 
119
 
 
120