MIDI Pipeline Reference Manual  2.8.3
midiLib.h
1 /**********************************************************
2 ***********************************************************
3 * European Southern Observatory
4 * VLTI MIDI Data Reduction Software
5 *
6 * Module name: midiLib.h
7 * Description:
8 *
9 *
10 * History:
11 * 03-Mar-03 (csabet) Created
12 ***********************************************************
13 **********************************************************/
14 #ifndef _MIDI_LIB_H
15 #define _MIDI_LIB_H
16 
17 /**********************************************************
18 * Include files
19 **********************************************************/
20 #include "iauExchange.h"
21 
22 /**********************************************************
23 * Constant definitions
24 **********************************************************/
25 
26 /**********************************************************
27 * Enumeration definitions
28 **********************************************************/
29 /* Mask Mode */
30 enum MaskMode
31 {
32  COMPUTED,
33  SELECTED,
34  SPECIFIED
35 };
36 
37 /* Obs Technique */
38 enum ObsTechnique
39 {
40  INTERF,
41  PHOTOMA,
42  PHOTOMB,
43  UNKNOWN
44 };
45 
46 /* Processing Modes */
47 enum ProcessingMode
48 {
49  UNDISPERSED,
50  DISPERSED,
51  DISPERSED_SLIT,
52  DISPERSED_3PH
53 };
54 
55 /**********************************************************
56 * Type definitions
57 **********************************************************/
58 typedef struct
59 {
60  enum MaskMode maskMode;
61  enum ProcessingMode processing;
62  int drsFrg; // 0, 1, 2: Decativate, Activate
63  int drsKap; // 0, 1, 2: Decativate, Read, Update
64  int drsAcq; // 0, 1, 2: Decativate, Activate
65  int tecRon; // 0, 1, 2: Decativate, Activate
66  int tecLin; // 0, 1, 2: Decativate, Activate
67  int tecPix; // 0, 1, 2: Decativate, Activate
68  int tecTrn; // 0, 1, 2: Decativate, Activate
69  int tecWav; // 0, 1, 2: Decativate, Create, Correlate
70 } UserOptions;
71 
72 typedef struct
73 {
74  OiArray *array;
75  OiTarget *targets;
76  OiWavelength *wavelength;
77  OiVis *vis;
78  OiVis2 *vis2;
79 } IauExchange;
80 
81 typedef struct
82 {
83  char *inFitsList;
84  char *inFitsClassified;
85  char *inFitsBatch;
86  char *inFileDir;
87  char *inFitsName;
88  char *maskFileDir;
89  char *maskFileName;
90  char *outFitsName;
91  char *outWaterfallName;
92  char *outWaterpowerName;
93  char *outAveImageName;
94  char *outChSpectrumName;
95  char *calibDbName;
96  char *waveCalibName;
97  char *grismFoilName;
98  char *prismFoilName;
99  char *calibDbDir;
100  char *trfNameWrite;
101  char *trfNameRead;
102  char *trfHistoryName;
103  char *trrNameWrite;
104  char *trrNameRead;
105  char *trrHistoryName;
106  char *wclNameWrite;
107  char *wclNameRead;
108  char *transferRatiosName;
109  char *wclHistoryName;
110  char *archFileName;
111  char *pipeFileName;
112 } MidiFiles;
113 
114 // Fits file format
115 typedef struct
116 {
117  int chopped;
118  int hasData;
119  int isDisp;
120  int numOfFrames; // Total number of frames in a batch. used in UNDISPERSED
121  int framesPerScan;
122  int numOfScans; // numOfScans = numOfFrames / framesPerScan;
123  int numOfPinholes; // 1 standard; 3 if triple pinhole; 2 if slit with sky definition
124  int numOfDetectorRegions; // In raw data from detector. Number of Detector regions
125  int numOfRegionsToProcess;// Number that get processed
126  int iXWidth; // X dimension
127  int iYWidth; // Y dimension
128  int subWindowSize; // iXWidth * iYWidth;
129  int numOfTemplates;
130  int numOfFilesInTemplate;
131  int fileNumInTemplate;
132  int numOfExposures;
133  int fileNumInExposure;
134  int exposureNumInTemplate;
135  int fftsize;
136  int allSpectrumLength;
137  float optFreqCal;
138  int numOfScansRejected;
139  int numOfScansProcessed;
140  int numOfChannelsProcessed;
141  int numOfChannelsRejected;
142  int numOfSkyScans;
143  char *beamCombiner;
144  char *tplName;
145  char *obsTech;
146  char *obsCatg;
147  char *obsType;
148  char *shutterId;
149  char *grismId;
150  char *targetName;
151  char *tplStart;
152  char *cameraId;
153  char *slitName;
154  char *filterName;
155 } ImageFormat;
156 
157 // Transfer Ratios
158 typedef struct
159 {
160  int exists;
161  float *ka1;
162  float *siga1;
163  float *ka2;
164  float *siga2;
165  float *kb1;
166  float *sigb1;
167  float *kb2;
168  float *sigb2;
169 } TransferRatios;
170 
171 // Kappa Coefficients
172 typedef struct
173 {
174  float *k11;
175  float *sig11;
176  float *k21;
177  float *sig21;
178  float *k31;
179  float *sig31;
180  float *k22;
181  float *sig22;
182  float *k32;
183  float *sig32;
184  float *k42;
185  float *sig42;
186 } KappaCoefficients;
187 
188 // Only for DISPERSED
189 typedef struct
190 {
191  int photomAExists;
192  int photomBExists;
193  int photomIExists;
194  int trfExists;
195  int calibVisExists;
196  float *rawVis2;
197  float *rawVis2Err;
198  float *normVis2;
199  float *normVis2Err;
200  float *calibVis2;
201  float *calibVis2Err;
202  float **photomA;
203  float **photomB;
204  float **photomI;
205  float **photomAErr;
206  float **photomBErr;
207  float **photomIErr;
208  float *photomNet2; // Net photometry estimate
209  float *photomNet2Err; // Net photometry error
210  float *trf;
211  float *trfErr;
212  float photomATarg1;
213  float photomATarg2;
214  float photomATarg3;
215  float photomBTarg1;
216  float photomBTarg2;
217  float photomBTarg3;
218  float photomATotal1;
219  float photomATotal2;
220  float photomATotal3;
221  float photomBTotal1;
222  float photomBTotal2;
223  float photomBTotal3;
224  float uncalVisBinned1;
225  float uncalVisBinned2;
226  float uncalVisBinned3;
227  float uncalVisBinned4;
228  float uncalVisBinned5;
229  float trfBinned1;
230  float trfBinned2;
231  float trfBinned3;
232  float trfBinned4;
233  float trfBinned5;
234 } DispersedResult;
235 
236 typedef struct
237 {
238  int exists;
239  float ***iDispFringe; // Triple pointer: regionsToProcess, Wave (X), time (frame)
240  double *iFringe;
241  double *iFringe1;
242  double *iFringe2;
243  float *allSpectrum;
244  float **image; // Region, image
245  float *dcLevels;
246  char *tarType;
247  int numOfTargetChops;
248  float *time; // Array of framelength, time of each in JD relative to timezero
249  float *localOPD; // Array of framelength, net Piezo OPD
250  float *bigDL; // Array of framelength, net Piezo OPD
251  int **rejectList; // 2D array of numOfChannels and numOfFrames
252  int *badScanList; // Array of numOfScans
253 } CompressedData;
254 
255 typedef struct
256 {
257  float optFreqLo;
258  float optFreqHi;
259  char *filterName;
260 } FilterData;
261 
262 // Only for UNDISPERSED
263 typedef struct
264 {
265  float vis;
266  float visErr;
267  float vis1;
268  float vis1Err;
269  float vis2;
270  float vis2Err;
271  float visSqrd;
272  float visSqrdErr;
273  float visSqrd1;
274  float visSqrd1Err;
275  float visSqrd2;
276  float visSqrd2Err;
277 } RawVisibility;
278 
279 // Only for UNDISPERSED
280 typedef struct
281 {
282  int exists;
283  float *vis;
284  float *visErr;
285  float *visSqrd;
286  float *visSqrdErr;
287 } CalibratedVisibility;
288 
289 // Only for UNDISPERSED
290 typedef struct
291 {
292  int exists;
293  float *trf;
294  float *trfErr;
295 } TransferFunction;
296 
297 // Only for UNDISPERSED
298 typedef struct
299 {
300  float *photomA;
301  float *photomAErr;
302  float *photomB;
303  float *photomBErr;
304  float ratioPhotomA0toA1;
305  float ratioPhotomB0toB1;
306  float *chop2ChopAErr;
307  float *chop2ChopBErr;
308 } PhotometryResult;
309 
310 typedef struct
311 {
312  double uCoord;
313  double vCoord;
314  double wCoord;
315 } UVW;
316 
317 typedef struct
318 {
319  char *calibName;
320  float calibRA;
321  float calibDEC;
322  float calibDistance;
323  float calibVis;
324  float calibVisErr;
325  float calibVisSqrd;
326  float calibVisSqrdErr;
327  float calibPblAverage;
328  float calibParangAverage;
329  float calibDiameter;
330  float calibDiameterErr;
331  double calibFlux;
332  int calibFlag;
333 } CalibratorParam;
334 
335 typedef struct
336 {
337  double xCoord;
338  double yCoord;
339  double dxCoord;
340  double dyCoord;
341  double size;
342 } MidiCoords;
343 
344 typedef struct
345 {
346  int exists;
347  float **aveImage;
348  float **aveImageSky;
349  double *coordX;
350  double *coordY;
351  double *sizeX;
352  double *sizeY;
353  float *targetFlux;
354  int *targetPixelCount;
355  char *tarType;
356 } ImageQuality;
357 
358 
359 typedef struct
360 {
361  int exists;
362  float *pattern;
363  float *aveImage;
364  double median;
365 } DetRonNoise;
366 
367 typedef struct
368 {
369  int exists;
370  int size;
371  float *mean;
372  char *grismId;
373  int *saturated;
374  float **aveImage;
375  float *integTime;
376  float *deviation;
377  float meanCoeffA0;
378  float meanCoeffA1;
379  float meanCoeffA2;
380  float meanCoeffA3;
381  float meanSigma;
382  int winx;
383  int windx;
384  int winy;
385  int windy;
386 } DetLinearity;
387 
388 typedef struct
389 {
390  float *xCoord;
391  float *yCoord;
392  float *wavelength;
393  char *fileName;
394  float **image;
395 } NarrowBandInfo;
396 
397 typedef struct
398 {
399  float *actualWavelength;
400  float *actualTransmission;
401  char *fileName;
402  float **image;
403 } FoilInfo;
404 
405 typedef struct
406 {
407  char *fileName;
408  float **image;
409 } OpenInfo;
410 
411 typedef struct
412 {
413  char *fileName;
414  float **image;
415 } DarkInfo;
416 
417 typedef struct
418 {
419  int exists;
420  int numOfFiles;
421  char **filterName;
422  char **shutterId;
423  char *tarType;
424  float **calibratedWave;
425  float *variance;
426  NarrowBandInfo *ArIII;
427  NarrowBandInfo *NeII;
428  NarrowBandInfo *SIV;
429  FoilInfo *foil;
430  OpenInfo *open;
431  DarkInfo *dark;
432 } WaveCalibration;
433 
434 typedef struct
435 {
436  int numOfBeams;
437  char *shutterId;
438  char *beamCombiner;
439  MidiCoords *centroid;
440 } RefPixExposure;
441 
442 typedef struct
443 {
444  int exists;
445  int numOfExposures;
446  RefPixExposure *exposure;
447 } ReferencePixel;
448 
449 typedef struct
450 {
451  int exists;
452  char **beamCombiner;
453  char **shutterId;
454  char **cameraId;
455  char **grismId;
456  char **filterName;
457  int numOfFiles;
458  MidiCoords *target;
459  float *integTime;
460  float *integFlux;
461  float *meanFlux;
462  float *transmission;
463 } DispersiveTrans;
464 
465 typedef struct
466 {
467  long CorrInterf;
468  long CorrPhotomA;
469  long CorrPhotomB;
470 } CorrectedFrames;
471 
472 /**********************************************************
473 * Global Variables
474 **********************************************************/
475 
476 /**********************************************************
477 * Function Prototypes
478 **********************************************************/
479 float sqrtp (float x);
480 float sqr(float x);
481 void Trace (int n);
482 
483 /*********************************************************/
484 #endif
485 /*********************************************************/
486 /*********************************************************/