WikiStart: calibdocs.txt

File calibdocs.txt, 56.0 KB (added by pcr, 13 years ago)

documentation for data calibration procedures

Line 
1
2----- Documentation for Calib\calibrate_bisp_source.pro -----
3 NAME:
4      CALIBRATE_BISP_SOURCE
5
6 AUTHOR
7      pierre.cruzalebes@oca.eu
8
9 PURPOSE:
10      calibrate bispectral science data
11      true science = raw science / response
12      use 4th order approx of ensemble average and variance of ratio
13      according to Winzer, P., Review of Scientific Instruments, vol. 71 (issue 3),
14      pages 1447-1454 (2000)
15
16 CATEGORY:
17      data calibration
18
19 INPUTS:
20      need text input file (in OBS_PATH/INP/ directory) with :
21        - science and response observation file names (in same row)
22        - number of science data file(s)
23        - science bispectral data file name(s) (one name per row)
24        - bispectral response data file name(s) (one name per row, same
25        number as source)
26        - if needed (default = AMBER format) : data format ('clos' or 'bisp'
27        or 'trip')
28
29 REQUIREMENTS:
30      data read in science and response observation parameter files (in
31      subdirectory of OBS_PATH/) must be in ASCII format and contain
32      (one row per OB):
33        - (DIT[s] , NDIT), (RA[deg] , DEC[deg]), (START_UTC[h] , END_UTC[h]),
34        (START_FWHM["] , END_FWHM["]), (START_TAU0[s] , END_TAU0[s]), (MJD@0h , 0)
35
36      closure phase data:
37      data read in science data file(s) (in subdirectory of OBS_PATH/)
38      must be in ASCII format and contain :
39        - science closure phase and err. [deg]
40      data read in response data file(s) (in the same subdirectory of
41      OBS_PATH/) must be in ASCII format and contain :
42        - response closure phase and err. [deg]
43
44      bispectrum data:
45      data read in science data file(s) (in subdirectory of OBS_PATH/)
46      must be in ASCII format and contain :
47        - wavelength [nm], nber of fr., Re(bisp) and err., Im(bisp)
48        and err. [photoel^3]
49      data read in bispectrum response data file(s) (in the same
50      subdirectory of OBS_PATH/) must be in ASCII format and contain :
51        - wavelength [nm], nber of frames, Re(bisp resp) and err.,
52        Im(bisp resp) and err. [photoel^3/(W/m^2/mu)^3]
53
54      triple product data:
55      data read in science data file(s) (in subdirectory of OBS_PATH/)
56      must be in ASCII format and contain :
57        - wavelength [nm], nber of fr., Re(triple prod) and err., Im(triple prod)
58        and err.
59      data read in triple product response data file(s) (in the same
60      subdirectory of OBS_PATH/) must be in ASCII format and contain :
61        - wavelength [nm], nber of frames, Re(triple prod resp) and err.,
62        Im(triple prod resp) and err.
63
64      AMBER data (default):
65      data read in science data file(s) (in subdirectory of OBS_PATH/)
66      must be in ASCII format and contain :
67        - wavelength [nm], nber of fr., Re(bisp) and err., Im(bisp)
68        and err. [photoel^3], Re(triple prod) and err., Im(triple prod)
69        and err.
70      data read in response data file(s) (in the same
71      subdirectory of OBS_PATH/) must be in ASCII format and contain :
72        - wavelength [nm], nber of frames, Re(bisp resp) and err.,
73        Im(bisp resp) and err. [photoel^3/(W/m^2/mu)^3],
74       Re(triple prod resp) and err., Im(triple prod resp) and err.
75
76 OUTPUTS:
77      closure phase data:
78      data written in true closure file(s) (in the same
79      subdirectory of OBS_PATH/) are (in this order) :
80        - true closure phase and err. [deg]
81
82      bispectrum data:
83      data written in true bisp data file(s) (in the same
84      subdirectory of OBS_PATH/) are (in this order, one raw per spectral
85      channel) :
86        - response wavelength [nm], weight, real part of true bispectrum and error,
87        imaginary part of true bispectrum and error [(W/m^2/mu)^3]
88
89      triple product data:
90      data written in true triple product data file(s) (in the same
91      subdirectory of OBS_PATH/) are (in this order, one raw per spectral
92      channel) :
93        - response wavelength [nm], weight, real part of true triple product and error,
94        imaginary part of true triple product and error
95
96      AMBER data (default):
97      data written in true data file(s) (in the same subdirectory of OBS_PATH/)
98      are (in this order, one raw per spectral channel) :
99        - response wavelength [nm], weight, real part of true bispectrum and err.,
100        imaginary part of true bispectrum and err. [(W/m^2/mu)^3],
101       real part of true triple product and err.,
102        imaginary part of true triple product and err.
103
104 LOCAL PROCEDURE CALLED:
105        RESET_PLOT
106
107 LOCAL FUNCTION USED:
108        ANGULAR_DIST
109        COSD
110        EXTRACT_PROHEADER
111        GET_OUTLIER_FENCES
112        LORENTZIAN
113        SIND
114        SYM
115
116 LOCAL SYSTEM VARIABLE USED:
117        EPSILON
118        MAX_HEADER
119        MAX_REL_ERR
120        NB_DATA_BOOT
121        NB_OB_MAX
122        OBS_PATH
123        PLOT_DEV
124        REF_ANG_DIST
125        REF_FWHM
126        REF_TAU0
127        REF_TIME_DELAY
128        SPIDAST_PATH
129
130 REVISION HISTORY;
131       Written by pcr 2008/06/06
132       last modification by pcr 2011/01/08
133
134----- Documentation for Calib\calibrate_source.pro -----
135 NAME:
136      CALIBRATE_SOURCE
137
138 AUTHOR:
139      pierre.cruzalebes@oca.eu
140
141 PURPOSE:
142      calibrate science data
143      true science = raw science / response
144      use 4th order approx of ensemble average and variance of ratio
145      according to Winzer, P., Review of Scientific Instruments, vol. 71 (issue 3),
146      pages 1447-1454 (2000)
147
148 CATEGORY:
149      data calibration
150     
151 INPUTS:
152      need text input file (in OBS_PATH/INP/ directory) with :
153        - science and response observation file names (in same row)
154        - science data file name(s) (one name per row)
155        - response data file name(s) (one name per row, same number as
156        source(s))
157        - if needed (default = AMBER format) : data format ('vis' or 'spec'
158        or 'coh')
159
160 REQUIREMENTS:
161      data read in science and response observation parameter files (in
162      subdirectory of OBS_PATH/) must be in ASCII format and contain
163      (one row per OB):
164        - (DIT[s] , NDIT), (RA[deg] , DEC[deg]), (START_UTC[h] , END_UTC[h]),
165        (START_FWHM["] , END_FWHM["]), (START_TAU0[s] , END_TAU0[s]), (MJD@0h , 0)
166
167      vis data:
168      data read in science data file(s) (in subdirectory of OBS_PATH/)
169      must be in ASCII format and contain :
170        - visibility and error
171      data read in response data file(s) (in subdirectory of OBS_PATH/)
172      must be in ASCII format and contain :
173        - vis. resp. and error
174
175      spec data:
176      data read in science data file(s) (in subdirectory of OBS_PATH/)
177      must be in ASCII format and contain :
178        - flux and error [photoel]
179      data read in response data file(s) (in subdirectory of OBS_PATH/)
180      must be in ASCII format and contain :
181        - flux resp. and error [photoel/(W/m^2/mum)]
182
183      coh. spec data:
184      data read in science data file(s) (in subdirectory of OBS_PATH/)
185      must be in ASCII format and contain :
186        - coherent flux and error (in photoelectrons)
187      data read in response data file(s) (in subdirectory of OBS_PATH/)
188      must be in ASCII format and contain :
189        - coh. flux resp. and error [photoel/(W/m^2/mum)]
190
191      AMBER data (default):
192      data read in science data file(s) (in subdirectory of OBS_PATH/)
193      must be in ASCII format and contain :
194        - nber of sel. fr., vis. and error, flux and error, coh. flux
195        and error (in photoelectrons)
196      data read in response data file(s) (in subdirectory of OBS_PATH/)
197      must be in ASCII format and contain :
198        - nb of frames, vis. resp. and error, flux resp. and err.,
199        coh. flux resp. and err. [photoel/(W/m^2/mum)]
200
201 OUTPUTS:
202      vis data:
203      data written in true data file(s) (in the same
204      subdirectory of OBS_PATH/) are (in this order) :
205        - true vis. and error
206
207      spec data:
208      data written in true data file(s) (in the same
209      subdirectory of OBS_PATH/) are (in this order) :
210        - true flux and err. [W/m^2/mum]
211
212      coh. spec data:
213      data written in true data file(s) (in the same
214      subdirectory of OBS_PATH/) are (in this order) :
215        - true coh. flux and err. [W/m^2/mum]
216
217      AMBER data (default):
218      data written in true data file(s) (in the same
219      subdirectory of OBS_PATH/) are (in this order, one raw per spectral channel) :
220       - weight, true vis. and error, true flux and error,
221         true coh. flux and error [W/m^2/mum]
222
223 LOCAL PROCEDURE CALLED:
224        RESET_PLOT
225
226 LOCAL FUNCTION USED:
227        ANGULAR_DIST
228        EXTRACT_PROHEADER
229        GET_OUTLIER_FENCES
230        LORENTZIAN
231       SYM
232
233 LOCAL SYSTEM VARIABLE USED:
234        EPSILON
235        MAX_REL_ERR
236        NB_OB_MAX
237        OBS_PATH
238        PLOT_DEV
239        REF_ANG_DIST
240        REF_FWHM
241        REF_TAU0
242        REF_TIME_DELAY
243        SPIDAST_PATH
244
245 REVISION HISTORY:
246       Written by pcr 2008/06/06
247       last modification by pcr 2011/01/08
248
249----- Documentation for Calib\calib_coh.pro -----
250 NAME:
251      CALIB_COH
252
253 AUTHOR:
254      pierre.cruzalebes@oca.eu
255
256 PURPOSE:
257      calibrate coherent flux in spectral band using mean product
258      visibilibity times flux
259 
260 CATEGORY:
261      data calibration
262
263 INPUTS:
264      needs text input file (in OBS_PATH/INP/ directory) with :
265        - input data file name
266        - name of wavelength list associated to input data file
267        - polynomial degree of input visibility, degree of input flux,
268        degree of input coherent flux (if one is null : no calibration)
269        number of bad input data at band boundary (same number for
270        visibility, flux and coherent flux)
271
272 REQUIREMENTS:
273      data read in input data file (in OBS_PATH/DATA/ directory)
274      must be in ASCII format and contain (1 row per spectrum channel) :
275        - visibility and error, flux and error (in W.m^-2.mu^-1),
276        coherent flux and error (in W.m^-2.mu^-1)
277
278      data read in wavelength list (in OBS_PATH/DATA/ directory)
279      must be wavelengths (in mu) in ASCII format (in the same order
280      than the input data)
281
282 OUTPUTS:
283      data written in output data file (in OBS_PATH/DATA/ directory)
284      are in ASCII format and contain (1 row per spectrum channel) :
285        - visibility and error, flux and error (in W.m^-2.mu^-1),
286        coherent flux and error (in W.m^-2.mu^-1)
287
288 LOCAL PROCEDURE CALLED:
289        RESET_PLOT
290
291 LOCAL FUNCTION USED:
292        EXTRACT_PROHEADER
293        TRAP
294
295 LOCAL SYSTEM VARIABLE USED:
296        OBS_PATH
297        SPIDAST_PATH
298
299 REVISION HISTORY:
300       Written by pcr 2007/10/08
301       modified by pcr 2008/02/13
302
303----- Documentation for Calib\calib_flux.pro -----
304 NAME:
305      CALIB_FLUX
306
307 AUTHOR:
308      pierre.cruzalebes@oca.eu
309
310 PURPOSE:
311      calibrate flux of second data file using flux ratio between 2 bands given
312      by external photometry
313
314 CATEGORY:
315      data calibration
316
317 INPUTS:
318      needs text input file (in OBS_PATH/INP/ directory) with :
319        - name of first data file used as flux reference (input data)
320        - name of the second data file to be corrected (input data)
321        - the name of wavelength list associated to first data file
322        (input data)
323        - name of wavelength list associated to second data file (input
324        data)
325        - name of broadband photometric flux measurement file (input)
326        - effective wavelengths of bands
327        - names of input broadband filter+detector transmission files for bands
328        - name of input atmospheric transmission file
329        - polynomial degree of first data file, degree of second data file
330        (if one null : no calib),
331        - number of bad data at band boundary for first file, number of
332        bad data for second
333
334 REQUIREMENTS:
335      data read in input data files (in OBS_PATH/DATA/ directory)
336      must be in ASCII format and contain (1 row per spectrum channel) :
337        - visibility and error, flux and error (in W.m^-2.mu^-1), coherent
338        flux and error (in W.m^-2.mu^-1)
339
340      data read in wavelength lists (in OBS_PATH/DATA/ directory)
341      must be wavelengths (in mu) in ASCII format (in same order than input data)
342
343      data read in broadband photometric flux measurement file (in OBS_PATH/DATA/
344      directory) must be in ASCII format and contain (in this order) :
345        - wavelength (in mu), bandwidth (in mu), flux and absolute error
346        on flux (both in W.m^-2.mu^-1)
347
348      effective wavelengths must be in microns (in same row, reference first)
349
350 OUTPUTS:
351      data written in output joined data file (in OBS_PATH/DATA/ directory)
352      are in ASCII format and contain (1 row per spectrum channel) :
353      visibility and error, flux and error (in W.m^-2.mu^-1), coherent flux
354      and error (in W.m^-2.mu^-1)
355
356 LOCAL PROCEDURE CALLED:
357        RESET_PLOT
358
359 LOCAL FUNCTIOn USED:
360        EXTRACT_PROHEADER
361        TRAP
362
363 LOCAL SYSTEM VARIABLE USED:
364        OBS_PATH
365        SPIDAST_PATH
366
367 REVISION HISTORY:
368       Written by pcr 2007/10/07
369       modified by pcr 2008/04/12
370
371----- Documentation for Calib\create_calibration_batch.pro -----
372 NAME:
373      CREATE_CALIBRATION_BATCH
374
375 AUTHOR:
376      pierre.cruzalebes@oca.eu
377
378 PURPOSE:
379      create program batch for calibration processing and make input files
380      used by programs :
381      - spectral calibration
382      - synthetic data generation
383      - response interpolation
384      - cross calibration and averaging
385
386 CATEGORY:
387      data calibration
388
389 INPUTS:
390      needs text input file (in OBS_PATH/INP/ directory) with:
391        - subpath of OBS_PATH to observation data
392        - spectral bandwith name(s) (J or/and H or/and K) simultaneously
393        measured (in same row)
394        - name(s) of each part (corresponding to each P2VM settings,
395        in same row)
396        - min and max wavelengths of global spectral range covered
397        with all bandwidths in all parts [mum] (in same row)
398        - number of observing blocks in each part (in same row)
399       for each part :
400        - name of target, start-end obs time (hh:mm(:ss)-hh:mm(:ss))
401        for each OB (1 target per row)
402       then :
403        - number of calibrator targets
404       for each calibrator :
405        - name of calibrator, name of synthetic spectrum, name of diameter file,
406        name(s) of science target(s) associated (1 calibrator per row)
407
408 OUTPUTS:
409      data calibration processing batch text file (in SPIDAST_PATH/ directory)
410      and associated text input files (in OBS_PATH/INP/ directory)
411
412 LOCAL PROCEDURE CALLED:
413        EXTRACT_PROHEADER
414
415 LOCAL FUNCTION USED:
416        NONE
417
418 LOCAL SYSTEM VARIABLE USED:
419        MAX_HEADER
420        NB_BAND_MAX
421        NB_OB_MAX
422        NB_PART_MAX
423        NB_TARG_MAX
424        OBS_PATH
425        SPIDAST_PATH
426
427 REVISION HISTORY:
428       Written by pcr 2010/03/27
429       last modification by pcr 2010/12/21
430
431----- Documentation for Calib\create_data.pro -----
432 NAME:
433      CREATE_DATA
434
435 AUTHOR:
436      pierre.cruzalebes@oca.eu
437
438 PURPOSE:
439      create synthetic model data file(s) (1 vis/spec/coh.spec/vis+flux+coh file
440      per baseline pair and 1 bisp/trip file with per baseline triplet)
441
442 CATEGORY:
443      data manipulation
444
445 INPUTS:
446      needs text input file (in OBS_PATH/INP/ directory) with:
447        - baseline file name
448        - wavelength list name
449        - model parameter file name and covariance file name (in same row)
450        - flux scale [photoel/(W/m^2/mum)] (=0 => flux [W/m^2/mum],
451        else => flux [photoel])
452        - error factor (null for noiseless data creation)
453       - observation parameter file name (if error factor gt 0)
454
455 REQUIREMENTS:
456      data read in input baseline file(s) (in subdirectory of OBS_PATH/)
457      must be in ASCII format and contain (2*NBASE=NTEL*(NTEL-1) columns, one
458      row per obs file) :
459        - (length[m] , angle[deg]) of each projected baseline at obs file start/end
460
461      data read in wavelength list (in subdirectory of OBS_PATH/)
462      must be in ASCII format and contain (one row per spectral channel,
463      decreasing order of wavelength):
464        - wavelength and bandwidth [m]
465
466      data read in model parameter file (in OBS_PATH/OUT/ directory)
467      must be in ASCII format and contain (in this order):
468        - model flag, flux flag, synthetic exitance+radiance file names, data
469        format flag, starting parameters, free flag(s), goodness of fit
470        parameter, fitted parameters, inferior errors, superior errors, nber
471        of degrees of freedom
472
473      data read in covariance file (of name input_file_stem.cova in OBS_PATH/OUT/
474      directory) must be in ASCII format and contain the covariance matrix (of
475      size NB_MAX_PARAM*NB_MAX_PARAM)
476
477      data read in synthetic exitance file (in SYNTHE_PATH/ directory)
478      must be in ASCII format and contain:
479        - wavelength [AA = 10^-4 mu] and exitance [erg/cm^2/s/AA = 10*W/m^2/mu]
480
481      if synthetic radiance file also found in directory (of name
482      exitance_file_stem.limb) use also radiance data (in SYNTHE_PATH/ directory)
483      composed of !NB_LUMIN+1 colums of data:
484      first line:
485        - Rosseland to limb_darkened conversion factor and relative impact
486        parameters (!NB_LUMIN values between 0. and 1.)
487      then:
488        - wavelength [mum], !NB_LUMIN values of absolute intensities
489        [W/m^2/mum]
490
491      data read in input observation parameter file(s) (in subdirectory of
492      OBS_PATH/) must be in ASCII format and contain (one row per obs file):
493        - DIT[s]/NDIT, RA[deg]/DEC[deg], UTC-OBS[h] at start/end, FWHM["]
494        at start/end, TAU0[s] at start/end
495
496 OUTPUTS:
497      data written in output synthetic data file(s) (in the same subdirectory
498      of OBS_PATH/DATA/) are (one row per spectral channel):
499      vis data (one file per baseline):
500        - vis and error
501      spec data (one file per baseline):
502        - flux and error ([W/m^2/mum] or [photoel])
503      coh spec data (one file per baseline):
504        - coh flux and error ([W/m^2/mum] or [photoel])
505      AMBER data (one file per baseline):
506        - weight, vis, vis error, flux, flux error, coh. flux,
507        coh. flux error ([W/m^2/mum] or [photoel])
508      clos phase data (one file per baseline triplet):
509        - closure phase and error [deg]
510      bisp data (one file per baseline triplet):
511        - wavelength [nm], weight, bispectrum real part and error,
512        bispectrum imaginary part and error ([(W/m^6/mum)^3] or [photoel^3])
513      triple product data (one file per baseline triplet):
514        - wavelength [nm], weight, triple prod real part and error,
515        triple prod imaginary part and error
516      AMBER data (one file per baseline triplet):
517        - wavelength [nm], weight, bispectrum real part and error,
518        bispectrum imaginary part and error ([(W/m^6/mum)^3] or [photoel^3]),
519        triple prod real part and error, triple prod imaginary part and error
520
521 LOCAL PROCEDURE CALLED:
522        COV2COR
523        ENGELKE
524        EXTRACT_PROHEADER
525        GET_SYN_REF
526        MODEL_DATA_FUNCT_PROJ
527        MODEL_SPECTRUM
528        PLANCK
529        RESET_PLOT
530
531 LOCAL FUNCTION USED:
532        COSD
533        FUNCTPROJ
534        MAKE_TAB3
535        SIND
536        SYM
537        TRAP
538
539 LOCAL SYSTEM VARIABLE USED:
540        EPSILON
541        FORMAT_OUT
542        MAS2RADIAN
543        MAX_REL_ERR
544        NB_BASE_STEP
545        NB_MAX_PARAM
546        NB_OB_MAX
547        NB_PAIR_MAX
548        NB_RES_STEP
549        OBS_PATH
550        PLOT_DEV
551        SPIDAST_PATH
552        SYNTHE_PATH
553
554 REVISION HISTORY:
555       Written by pcr 2007/01/02
556       last modification by pcr 2011/01/13
557
558----- Documentation for Calib\create_data_spec.pro -----
559 NAME:
560      CREATE_DATA_SPEC
561
562 AUTHOR:
563      pierre.cruzalebes@oca.eu
564
565 PURPOSE:
566      create synthetic model spectrum file
567
568 CATEGORY:
569      data calibration
570
571 INPUTS:
572      needs text input file (in OBS_PATH/INP/ directory) with:
573        - wavelength list name
574        - model parameter file name and covariance file name (in same row)
575        - flux scale [photoel/(W/m^2/mum)] (=0 => flux [W/m^2/mum],
576        else => flux [photoel])
577        - error factor (null for noiseless data creation)
578
579 REQUIREMENTS:
580      data read in wavelength list (in subdirectory of OBS_PATH/)
581      must be in ASCII format and contain (one row per spectral channel,
582      decreasing order of wavelength):
583        - wavelength and bandwidth [m]
584
585      data read in model parameter file (in OBS_PATH/OUT/ directory)
586      must be in ASCII format and contain (in this order):
587        - model flag, flux flag, synthetic exitance+radiance file names, data
588        format flag, starting parameters, free flag(s), goodness of fit
589        parameter, fitted parameters, inferior errors, superior errors, nber
590        of degrees of freedom
591
592      data read in covariance file (of name input_file_stem.cova in OBS_PATH/OUT/
593      directory) must be in ASCII format and contain the covariance matrix (of size
594      NB_MAX_PARAM*NB_MAX_PARAM)
595
596      data read in synthetic exitance file (in SYNTHE_PATH/ directory)
597      must be in ASCII format and contain:
598        - wavelength [AA = 10^-4 mu] and exitance [erg/cm^2/s/AA = 10*W/m^2/mu]
599
600      if synthetic radiance file also found in directory (of name
601      exitance_file_stem.limb) use also radiance data (in SYNTHE_PATH/ directory)
602      composed of !NB_LUMIN+1 colums of data:
603      first line:
604        - Rosseland to limb_darkened conversion factor and relative impact
605        parameters (!NB_LUMIN values between 0. and 1.)
606      then:
607        - wavelength [mum], !NB_LUMIN values of absolute intensities [W/m^2/mum]
608
609 OUTPUTS:
610      data written in output synthetic data file (in the same subdirectory
611      of OBS_PATH/) are (one row per spectral channel):
612        - wavelength [nm], flux, flux error ([W/m^2/mum] or [photoel])
613
614 LOCAL PROCEDURE CALLED:
615        COV2COR
616        ENGELKE
617        EXTRACT_PROHEADER
618        GET_SYN_REF
619        MODEL_DATA_FUNCT_PROJ
620        MODEL_SPECTRUM
621        PLANCK
622        RESET_PLOT
623
624 LOCAL FUNCTIOn USED:
625        FUNCTPROJ
626        TRAP
627
628 LOCAL SYSTEM VARIABLE USED:
629        EPSILON
630        FORMAT_OUT
631        MAX_REL_ERR
632        NB_BASE_STEP
633        NB_MAX_PARAM
634        NB_RES_STEP
635        OBS_PATH
636        PLOT_DEV
637        SPIDAST_PATH
638        SYNTHE_PATH
639
640 REVISION HISTORY:
641       Written by pcr 2009/03/04
642       last modification by pcr 2010/12/21
643
644----- Documentation for Calib\create_input_files.pro -----
645 created by pcr 2010/03/27
646 modified by pcr 2010/03/31
647
648 create input files used by programs called for calibration processing :
649 - spectral calibration
650 - synthetic data generation
651 - response interpolation
652 - cross calibration and averaging
653
654 needs text input file (in OBS_PATH/INP/ directory) with:
655        - subpath of OBS_PATH to observation data
656        - spectral bandwith name(s) (J or/and H or/and K) of each part (in same row)
657        - name(s) of each part (corresponding to each P2VM settings,
658        in same row)
659        - number of observing blocks in each part (in same row)
660 for each part :
661        - name of target, Teff+logg (ex 4660g2.9), start-end obs time
662        (hh:mm(:ss)-hh:mm(:ss)) for each OB (1 target per row)
663 then :
664        - number of calibrator targets
665 for each calibrator :
666        - name of calibrator and name(s) of science target(s) associated
667        (1 calibrator per row)
668
669 local procedure called:
670        EXTRACT_PROHEADER
671 local function used:
672        none
673 local system variable used:
674        MAX_HEADER
675        NB_BAND_MAX
676        NB_OB_MAX
677        NB_PART_MAX
678        NB_TARG_MAX
679        OBS_PATH
680        SPIDAST_PATH
681
682----- Documentation for Calib\cross_calibrate_bisp_source.pro -----
683 NAME:
684      CROSS_CALIBRATE_BISP_SOURCE
685
686 AUTHOR:
687      pierre.cruzalebes@oca.eu
688
689 PURPOSE:
690      cross-calibrate bispectral source data
691      true source(k) = raw source(i) / response(j)
692      use 4th order approx of ensemble average and variance of ratio
693      according to Winzer, P., Review of Scientific Instruments, vol. 71 (issue 3),
694      pages 1447-1454 (2000)
695
696 CATEGORY:
697      data calibration
698
699 INPUTS:
700      need text input file (in OBS_PATH/INP/ directory) with:
701        - science and response observation file names (in same row)
702        - number of observing block(s)
703      for each observing block set:
704        - number of source and response files (in same row)
705        - bispectral source data file name(s) (one name per row)
706        - bispectral response data file name(s) (one name per row)
707      then:
708        - if needed (default = AMBER format) : data format ('clos' or 'bisp'
709        or 'trip')
710
711 REQUIREMENTS:
712      data read in science and response observation parameter files (in
713      subdirectory of OBS_PATH/) must be in ASCII format and contain
714      (one row per OB):
715        - (DIT[s] , NDIT), (RA[deg] , DEC[deg]), (START_UTC[h] , END_UTC[h]),
716        (START_FWHM["] , END_FWHM["]), (START_TAU0[s] , END_TAU0[s]), (MJD@0h , 0)
717
718      closure phase data:
719      data read in science data file(s) (in subdirectory of OBS_PATH/)
720      must be in ASCII format and contain :
721        - science closure phase and err. [deg]
722      data read in response data file(s) (in the same subdirectory of OBS_PATH/)
723      must be in ASCII format and contain :
724        - response closure phase and err. [deg]
725
726      bispectrum data :
727      data read in science data file(s) (in subdirectory of OBS_PATH/)
728      must be in ASCII format and contain :
729        - wavelength [nm], nber of frames, Re(bisp) and err.,
730        Im(bisp) and err. [photoel^3]
731      data read in bispectrum response data file(s) (in the same subdirectory
732      of OBS_PATH/) must be in ASCII format and contain :
733        - wavelength [nm], nber of frames, Re(bisp resp) and err.,
734        Im(bisp resp) and err. [photoel^3/(W/m^2/mu)^3]
735
736      triple product data :
737      data read in science data file(s) (in subdirectory of OBS_PATH/)
738      must be in ASCII format and contain :
739        - wavelength [nm], nber of frames, Re(triple prod) and err.,
740        Im(triple prod) and err.
741      data read in triple product response data file(s) (in the same subdirectory
742      of OBS_PATH/) must be in ASCII format and contain :
743        - wavelength [nm], nber of frames, Re(triple prod resp) and err.,
744        Im(triple prod resp) and err.
745
746      AMBER data (default) :
747      data read in science data file(s) (in subdirectory of OBS_PATH/)
748      must be in ASCII format and contain :
749        - wavelength [nm], nber of frames, Re(bisp) and err.,
750        Im(bisp) and err. [photoel^3], Re(triple prod) and err.,
751        Im(triple prod) and err.
752      data read in response data file(s) (in the same subdirectory
753      of OBS_PATH/) must be in ASCII format and contain :
754        - wavelength [nm], nber of frames, Re(bisp resp) and err.,
755        Im(bisp resp) and err. [photoel^3/(W/m^2/mu)^3], Re(triple prod resp) and err.,
756        Im(triple prod resp) and err.
757
758 OUTPUTS:
759      closure phase data:
760      data written in true closure phase file(s) (in the same subdir
761      of OBS_PATH/) are (in this order) :
762        - true closure phase and err. [deg]
763
764      bispectrum data :
765      data written in true bisp data file(s) (in the same subdir
766      of OBS_PATH/)  are (in this order, one raw per spectral channel) :
767        - response wavelength [nm], weight, real part of true bispectrum and error,
768        imaginary part of true bispectrum and error [(W/m^2/mu)^3]
769
770      triple product data :
771      data written in true triple prod data file(s) (in the same subdir
772      of OBS_PATH/)  are (in this order, one raw per spectral channel) :
773        - response wavelength [nm], weight, real part of true triple product and error,
774        imaginary part of true triple product and error
775
776      AMBER data (default) :
777      data written in true data file(s) (in the same subdir
778      of OBS_PATH/)  are (in this order, one raw per spectral channel) :
779        - response wavelength [nm], weight, real part of true bispectrum and error,
780        imaginary part of true bispectrum and error [(W/m^2/mu)^3],
781       real part of true triple product and error,
782        imaginary part of true triple product and error
783
784 LOCAL PROCEDURE CALLED:
785        RESET_PLOT
786
787 LOCAL FUNCTION USED:
788        ANGULAR_DIST
789        COSD
790        EXTRACT_PROHEADER
791        GET_OUTLIER_FENCES
792        LORENTZIAN
793        SIND
794        SYM
795
796 LOCAL SYSTEM VARIABLE USED:
797        EPSILON
798        MAX_HEADER
799        MAX_REL_ERR
800        NB_OB_MAX
801        OBS_PATH
802        PLOT_DEV
803        REF_ANG_DIST
804        REF_FWHM
805        REF_TAU0
806        REF_TIME_DELAY
807        SPIDAST_PATH
808
809 REVISION HISTORY:
810       Written by pcr 2008/05/14
811       last modification by pcr 2011/01/08
812
813----- Documentation for Calib\cross_calibrate_source.pro -----
814 NAME:
815      CROSS_CALIBRATE_SOURCE
816
817 AUTHOR:
818      pierre.cruzalebes@oca.eu
819
820 PURPOSE:
821      cross-calibrate science data
822      true science(k) = raw science(i) / response(j)
823      use 4th order approx of ensemble average and variance of ratio
824      according to Winzer, P., Review of Scientific Instruments, vol. 71 (issue 3),
825      pages 1447-1454 (2000)
826
827 CATEGORY:
828      data calibration
829
830 INPUTS:
831      need text input file (in OBS_PATH/INP/ directory) with:
832        - science and response observation file names (in same row,
833       potentially many responses per science)
834        - number of observing block(s)
835      for each observing block:
836        - number of science and response files (in same row)
837        - source data file name(s) (one name per row)
838        - response data file name(s) (one name per row)
839      then:
840        - if needed (default = AMBER format) : data format ('vis' or 'spec'
841        or 'coh')
842
843 REQUIREMENTS:
844      data read in science and response observation parameter files (in
845      subdirectory of OBS_PATH/) must be in ASCII format and contain
846      (one row per OB):
847        - (DIT[s] , NDIT), (RA[deg] , DEC[deg]), (START_UTC[h] , END_UTC[h]),
848        (START_FWHM["] , END_FWHM["]), (START_TAU0[s] , END_TAU0[s]), (MJD@0h , 0)
849
850      vis data:
851      data read in science data file(s) (in subdirectory of OBS_PATH/)
852      must be in ASCII format and contain :
853        - visibility and error
854      data read in response data file(s) (in the same subdir of OBS_PATH/)
855      must be in ASCII format and contain :
856        - vis. resp. and error
857
858      spec data:
859      data read in science data file(s) (in subdirectory of OBS_PATH/)
860      must be in ASCII format and contain :
861        - flux and error [photoel]
862      data read in response data file(s) (in the same subdir of OBS_PATH/)
863      must be in ASCII format and contain :
864        - flux resp. and error [photoel/(W/m^2/mum)]
865
866      coh. spec data:
867      data read in science data file(s) (in subdirectory of OBS_PATH/)
868      must be in ASCII format and contain :
869        - coherent flux and error (in photoelectrons)
870      data read in response data file(s) (in the same subdir of OBS_PATH/)
871      must be in ASCII format and contain :
872        - coh. flux resp. and error [photoel/(W/m^2/mum)]
873
874      AMBER data (default):
875      data read in science data file(s) (in subdirectory of OBS_PATH/)
876      must be in ASCII format and contain :
877        - nber of selected frames, vis. and error, flux and error,
878        coh. flux and error (in photoelectrons)
879      data read in response data file(s) (in the same subdirectory of OBS_PATH/)
880      must be in ASCII format and contain :
881        - nber of calib frames, vis. resp. and error, flux resp. and err.,
882        coh. flux resp. and err. [photoel/(W/m^2/mum)]
883
884 OUTPUTS:
885      vis data:
886      data written in true data file(s) (in the same subdirectory
887      of OBS_PATH/) are (in this order, one raw per spectral channel) :
888        - true vis. and error
889
890      spec data:
891      data written in true data file(s) (in the same subdirectory)
892      of OBS_PATH/) are (in this order, one raw per spectral channel) :
893        - true flux and err. [W/m^2/mum]
894
895      coh. spec data:
896      data written in true data file(s) (in the same subdirectory
897      of OBS_PATH/) are (in this order, one raw per spectral channel) :
898        - true coh. flux and err. [W/m^2/mum]
899
900      AMBER data (default):
901      data written in true data file(s) (in the same subdirectory
902      of OBS_PATH/) are (in this order, one raw per spectral channel) :
903        - weight, true vis. and error, true flux and error,
904        true coh. flux and error [W/m^2/mum]
905
906 LOCAL PROCEDURE CALLED:
907        RESET_PLOT
908
909 LOCAL FUNCTION USED:
910        ANGULAR_DIST
911        EXTRACT_PROHEADER
912        GET_OUTLIER_FENCES
913        LORENTZIAN
914        SYM
915
916 LOCAL SYSTEM VARIABLE USED:
917        EPSILON
918        MAX_REL_ERR
919        NB_OB_MAX
920        OBS_PATH
921        PLOT_DEV
922        REF_ANG_DIST
923        REF_FWHM
924        REF_TAU0
925        REF_TIME_DELAY
926        SPIDAST_PATH
927
928 REVISION HISTORY:
929       Written by pcr 2007/08/27
930       last modification by pcr 2011/01/08
931
932----- Documentation for Calib\get_bisp_response.pro -----
933 NAME:
934      GET_BISP_RESPONSE
935
936 AUTHOR:
937      pierre.cruzalebes@oca.eu
938
939 PURPOSE:
940      calculate closure phase/bispectrum/triple product intrumental spectral response
941      resp = raw calib / synthetic calib
942      use 4th order approx of ensemble average and variance of ratio
943      according to Winzer, P., Review of Scientific Instruments, vol. 71 (issue 3),
944      pages 1447-1454 (2000)
945      if synthetic calib eq 'none' then resp = raw calib
946
947 CATEGORY:
948      data calibration
949
950 INPUTS:
951       needs text input file (in OBS_PATH/INP/ directory) with :
952        - data file number
953        - calibrator data file name(s)
954        - synthetic data file name(s) (same number as calibrator(s))
955        - if needed (default = AMBER format) : data format ('clos' or 'bisp'
956        or 'trip')
957
958 REQUIREMENTS:
959      closure phase data:
960      data read in calibrator closure phase data file(s) (in subdirectory of
961      OBS_PATH/) must be in ASCII format and contain :
962        - closure phase and err. [deg]
963      data read in synthetic data file(s) (in subdirectory of OBS_PATH/)
964      must be in ASCII format and contain :
965        - closure phase and err. [deg]
966
967      bispectrum data:
968      data read in calibrator bispectral data file(s) (in subdirectory of
969      OBS_PATH/) must be in ASCII format and contain :
970        - wavelength [nm], nber of sel frames, Re(bisp) and err.,
971        Im(bisp) and err. [photoel^3]
972      data read in synthetic data file(s) (in subdirectory of OBS_PATH/)
973      must be in ASCII format and contain :
974        - wavelength [nm], weight, Re(bisp) and err., Im(bisp) and err.
975        [(W/m^2/mum)^3]
976
977      triple product data:
978      data read in calibrator bispectral data file(s) (in subdirectory of
979      OBS_PATH/) must be in ASCII format and contain :
980        - wavelength [nm], nber of sel frames, Re(trip) and err.,
981        Im(trip) and err.
982      data read in synthetic data file(s) (in subdirectory of OBS_PATH/)
983      must be in ASCII format and contain :
984        - wavelength [nm], weight, Re(trip) and err., Im(trip) and err.
985
986      AMBER data (default):
987      data read in calibrator data file(s) (in subdirectory of OBS_PATH/)
988      must be in ASCII format and contain :
989        - wavelength [nm], nber of sel frames, Re(bisp) and err.,
990        Im(bisp) and err. [photoel^3], Re(trip) and err.,
991        Im(trip) and err.
992
993 OUTPUTS:
994      closure phase data:
995      data written in output closure phase response file(s) (in the same
996      subdirectory of OBS_PATH/) are (in this order) :
997        - closure phase response and err. [deg]
998
999      bispectrum data:
1000      data written in output bispectral response file(s) (in the same
1001      subdirectory of OBS_PATH/) are (in this order) :
1002        - synthetic wavelength [nm], nber of calib fr, Re(bisp resp) and err.,
1003        Im(bisp resp) and err. [photoel^3/(W/m^2/mum)^3]
1004
1005      triple product data:
1006      data written in output triple product response file(s) (in the same
1007      subdirectory of OBS_PATH/) are (in this order) :
1008        - synthetic wavelength [nm], nber of calib fr, Re(trip resp) and err.,
1009        Im(trip resp) and err.
1010
1011      AMBER data (default):
1012      data written in output bispectral response file(s) (in the same
1013      subdirectory of OBS_PATH/) are (in this order) :
1014        - synthetic wavelength [nm], nber of calib fr, Re(bisp resp) and err.,
1015        Im(bisp resp) and err. [photoel^3/(W/m^2/mum)^3], Re(trip resp) and err.,
1016        Im(trip resp) and err.
1017
1018 LOCAL PROCEDURE CALLED:
1019        RESET_PLOT
1020
1021 LOCAL FUNCTION USED:
1022        COSD
1023        EXTRACT_PROHEADER
1024        GET_OUTLIER_FENCES
1025        SIND
1026        SYM
1027
1028 LOCAL SYSTEM VARIABLE USED:
1029        EPSILON
1030        MAX_REL_ERR
1031        OBS_PATH
1032        PLOT_DEV
1033        SPIDAST_PATH
1034
1035 REVISION HISTORY:
1036       Written by pcr 2008/05/14
1037       last modification by pcr 2011/01/08
1038
1039----- Documentation for Calib\get_observations.pro -----
1040 NAME:
1041      GET_OBSERVATIONS
1042 
1043 AUTHOR:
1044      pierre.cruzalebes@oca.eu
1045
1046 PURPOSE:
1047      extract start and end observation parameters and baseline(s)
1048      from header(s) of observing file(s)
1049
1050 CATEGORY:
1051      data calibration
1052
1053 INPUTS:
1054      needs text input file (in OBS_PATH/INP/ directory) with :
1055        - header file number
1056        - input observing file header name(s)  (one row per obs file)
1057       - input baseline station file
1058
1059 REQUIREMENTS:
1060      observing file header(s) (in OBS_PATH/DATA/ directory) must be in
1061      standard FITS format and contain the following ASCII lines with:
1062
1063       RA      =            aaa.aaaaaa      / RA pointing (deg)
1064       DEC     =            +-dd.ddddd      / DEC pointing (deg)
1065
1066       MJD-OBS =     ddddd.dddddddddd / Obs start
1067
1068       HIERARCH ESO DET DIT         = i.iiiiiii / Integration Time
1069       HIERARCH ESO DET NDIT        = n / # of Sub-Integrations
1070
1071       HIERARCH ESO ISS AMBI FWHM END=        e.ee / Observatory seeing
1072       HIERARCH ESO ISS AMBI FWHM START=      s.ss / Observatory seeing
1073
1074       HIERARCH ESO ISS AMBI TAU0 END=    e.eeeeee / Coherence time
1075       HIERARCH ESO ISS AMBI TAU0 START=  s.ssssss / Coherence time
1076
1077       HIERARCH ESO ISS CONF NTEL   =            n / Number of telescopes used
1078
1079      + NTEL ASCII lines with:
1080       HIERARCH ESO ISS CONF STATIONi= 'Xj      '  / Station of telescope i
1081
1082      + 2*NTEL*(NTEL-1) ASCII lines with:
1083       HIERARCH ESO ISS PBLij END   =       xx.xxx / Proj baseline Ti Tj at end
1084       HIERARCH ESO ISS PBLij START =       yy.yyy / Proj baseline Ti Tj at start
1085       HIERARCH ESO ISS PBLAij END   =       aa.aaa / Proj baseline orientation ang
1086       HIERARCH ESO ISS PBLAij START =       bb.bbb / Proj baseline orientation ang
1087
1088      where i,j = telescope indexes
1089       xx.xxx = proj (ij) baselength [m] at end,
1090       yy.yyy = proj (ij) baselength [m] at start,
1091       aa.aaa = proj (ij) baseline orientation ang [deg] at end (from N to E)
1092       bb.bbb = proj (ij) baseline orientation ang [deg] at start (N to E)
1093
1094      input baseline station file must contain NBASE=NTEL*(NTEL-1)/2 rows with each
1095      station combination, respecting baseline order of measured data files
1096
1097 OUTPUTS:
1098      output baseline file contain (in OBS_PATH/DATA/ directory, .base extension,
1099      2*NBASE columns of complex data, one row per file) :
1100        - (START_PBL[m] , START_PBLA[deg]) and (END_PBL[m] , END_PBLA[deg])
1101        of the projected baseline(s) associated to each data file
1102
1103      data written in input observation parameter file (in OBS_PATH/DATA/
1104      directory, .obs extension, one row per observation) are of complex type :
1105        - (DIT[s] , NDIT), (RA[deg] , DEC[deg]), (START_UTC[h] , END_UTC[h]),
1106        (START_FWHM["] , END_FWHM), (START_TAU0[s] , START_TAU0[s]), (MJD@Oh , 0)
1107
1108 LOCAL PROCEDURE CALLED:
1109        RESET_PLOT
1110
1111 LOCAL FUNCTION USED:
1112        COSD
1113        EXTRACT_PROHEADER
1114        SIND
1115
1116 LOCAL SYSTEM VARIABLE USED:
1117        MAX_HEADER
1118       NB_PAIR_MAX
1119        OBS_PATH
1120        PLOT_DEV
1121        SPIDAST_PATH
1122
1123 REVISION HISTORY:
1124      Written by pcr 2009/01/25
1125      last modification by pcr 2010/12/23
1126
1127----- Documentation for Calib\get_response.pro -----
1128 NAME:
1129      GET_RESPONSE
1130 
1131 AUTHOR:
1132      pierre.cruzalebes@oca.eu
1133
1134 PURPOSE:
1135      calculate vis/flux/coh flux instrumental spectral response
1136      resp = raw calib / synthetic calib
1137      use 4th order approx of ensemble average and variance of ratio
1138      according to Winzer, P., Review of Scientific Instruments, vol. 71 (issue 3),
1139      pages 1447-1454 (2000)
1140      if synthetic calib eq 'none' then resp = raw calib
1141
1142 CATEGORY:
1143      data calibration
1144
1145 INPUTS:
1146      needs text input file (in OBS_PATH/INP/ directory) with :
1147        - number of calibrator data file(s)
1148        - calibrator data file name(s)
1149        - synthetic data file name(s) (same number as calibrator(s))
1150        - if needed (default = AMBER format) : data format ('vis' or 'spec'
1151        or 'coh')
1152
1153 REQUIREMENTS:
1154      vis data:
1155      data read in calibrator data file(s) (in subdirectory of OBS_PATH/)
1156      must be in ASCII format and contain :
1157        - visibility and error
1158      data read in synthetic data file(s) (in subdirectory of OBS_PATH/)
1159      must be in ASCII format and contain :
1160        - visibility and error
1161
1162      spec data:
1163      data read in calibrator data file(s) (in subdirectory of OBS_PATH/)
1164      must be in ASCII format and contain :
1165        - flux and error [photoel]
1166      data read in synthetic data file(s) (in subdirectory of OBS_PATH/)
1167      must be in ASCII format and contain :
1168        - flux and error [W/m^2/mum]
1169
1170      coh. spec data:
1171      data read in calibrator data file(s) (in subdirectory of OBS_PATH/)
1172      must be in ASCII format and contain :
1173        - coh. flux and error [photoel]
1174      data read in synthetic data file(s) (in subdirectory of OBS_PATH/)
1175      must be in ASCII format and contain :
1176        - coh. flux and error [W/m^2/mum]
1177
1178      AMBER data (default):
1179      data read in calibrator data file(s) (in subdirectory of OBS_PATH/)
1180      must be in ASCII format and contain :
1181        - number of selected frames, visibility and error, flux
1182        and error, coherent flux and error [photoel]
1183      data read in synthetic data file(s) (in subdirectory of OBS_PATH/)
1184      must be in ASCII format and contain :
1185        - weight, visibility and error, flux and error,
1186        coherent flux and error [W/m^2/mum]
1187
1188 OUTPUTS:
1189      vis data:
1190      data written in output response file(s) (in subdirectory of OBS_PATH/)
1191      are (in this order) :
1192        - vis. resp. and error
1193
1194      spec data:
1195      data written in output response file(s) (in the same subdirectory
1196      of OBS_PATH/) are (in this order) :
1197        - flux resp. and err. [photoel/(W/m^2/mum)]
1198
1199      coh. spec data:
1200      data written in output response file(s) (in the same subdirectory
1201      of OBS_PATH/) are (in this order) :
1202        - coh. flux resp. and err. [photoel/(W/m^2/mum)]
1203
1204      AMBER data (default):
1205      data written in output response file(s) (in the same subdirectory
1206      of OBS_PATH/) are (in this order) :
1207        - number of calib frames, vis. resp. and error,
1208        flux resp. and err., coh. flux resp. and err. [photoel/(W/m^2/mum)]
1209
1210 LOCAL PROCEDURE CALLED:
1211        RESET_PLOT
1212
1213 LOCAL FUNCTION USED:
1214        EXTRACT_PROHEADER
1215        GET_OUTLIER_FENCES
1216        SYM
1217
1218 LOCAL VARIABLE SYSTEM USED:
1219        EPSILON
1220        MAX_REL_ERR
1221        OBS_PATH
1222        PLOT_DEV
1223        SPIDAST_PATH
1224
1225 REVISION HISTORY:
1226       Written by pcr 2007/08/27
1227       last modification by pcr 2011/01/08
1228
1229----- Documentation for Calib\interpol_bisp_response.pro -----
1230 NAME:
1231      INTERPOL_BISP_RESPONSE
1232
1233 AUTHOR:
1234      pierre.cruzalebes@oca.eu
1235
1236 PURPOSE:
1237      evaluate instrumental bispectral complex responses
1238      for each spectral channel and each baseline
1239      on time of science observations by temporal linear interpolation
1240      or polynomial fit
1241
1242 CATEGORY:
1243      data calibration
1244
1245 INPUTS:
1246      need text input file (in OBS_PATH/INP/ directory) with :
1247        - calibrator and science observation file names (in same row)
1248        - bispectral response file name(s)
1249        - degree of polynomial fit to be fitted to data (=0 for linear
1250        interpolation) and desired confidence level (only used for fit)
1251        - if needed (default = AMBER format) : data format ('clos' or 'bisp'
1252        or 'trip')
1253
1254 REQUIREMENTS:
1255      data read in science and calib observation parameter files (in
1256      subdirectory of OBS_PATH/) must be in ASCII format and contain
1257      (one row per OB):
1258        - (DIT[s] , NDIT), (RA[deg] , DEC[deg]), (START_UTC[h] , END_UTC[h]),
1259        (START_FWHM["] , END_FWHM["]), (START_TAU0[s] , END_TAU0[s]), (MJD@0h , 0)
1260
1261      closure phase data:
1262      data read in closure phase response data file(s) (in subdirectory of
1263      OBS_PATH/) must be in ASCII format and contain (in this order, one raw per
1264      spectral channel):
1265        - closure phase resp. and err. [deg]
1266
1267      bispectrum data :
1268      data read in bispectral response data files (in subdirectory of OBS_PATH/)
1269      must be in ASCII format and contain (in this order, one raw per spectral
1270      channel):
1271        - wavelength [nm], nber of frames, Re(bisp resp) and err.,
1272        Im(bisp resp) and err. [photoel^3/(W/m^2/mum)^3]
1273
1274      triple product data :
1275      data read in triple product response data files (in subdirectory of OBS_PATH/)
1276      must be in ASCII format and contain (in this order, one raw per spectral
1277      channel):
1278        - wavelength [nm], nber of frames, Re(triple prod resp) and err.,
1279        Im(triple prod resp) and err.
1280
1281      AMBER data (default) :
1282      data read in response data files (in subdirectory of OBS_PATH/)
1283      must be in ASCII format and contain (in this order, one raw per spectral
1284      channel):
1285        - wavelength [nm], nber of frames, Re(bisp resp) and err.,
1286        Im(bisp resp) and err. [photoel^3/(W/m^2/mum)^3],
1287       Re(triple prod resp) and err., Im(triple prod resp) and err.
1288
1289 OUTPUTS:
1290      closure phase data:
1291      data written in output interpolated closure phase response file(s)
1292      (in the same subdir of OBS_PATH/) must be in ASCII format and contain
1293      (in this order, one raw per spectral channel):
1294        - closure phase and err. [deg]
1295
1296      bispectrum data :
1297      data written in interpolated bispectral response files (in the same subdir of
1298      OBS_PATH/) must be in ASCII format and contain (in this order, one raw per
1299      spectral channel):
1300        - wavelength [nm], nber of frames, Re(bisp resp) and err.,
1301        Im(bisp resp) and err. [photoel^3/(W/m^2/mum)^3]
1302
1303      triple product data :
1304      data written in interpolated triple product response files (in the same subdir of
1305      OBS_PATH/) must be in ASCII format and contain (in this order, one raw per
1306      spectral channel):
1307        - wavelength [nm], nber of frames, Re(triple prod resp) and err.,
1308        Im(triple prod resp) and err.
1309
1310      AMBER data (default) :
1311      data written in interpolated response files (in the same subdir of
1312      OBS_PATH/) must be in ASCII format and contain (in this order, one raw per
1313      spectral channel):
1314        - wavelength [nm], nber of frames, Re(bisp resp) and err.,
1315        Im(bisp resp) and err. [photoel^3/(W/m^2/mum)^3],
1316       Re(triple prod resp) and err., Im(triple prod resp) and err.
1317
1318 LOCAL PROCEDURE CALLED:
1319        COV2COR
1320        RESET_PLOT
1321
1322 LOCAL FUNCTION USED:
1323        COSD
1324        EXTRACT_PROHEADER
1325        POLY_BOOT
1326        POLYBOOTW
1327        SIND
1328        SYM
1329
1330 LOCAL SYSTEM VARIABLE USED:
1331        EPSILON
1332        NB_BOOT_LOOPS
1333        NB_DATA_BOOT
1334        NB_OB_MAX
1335        OBS_PATH
1336        SPIDAST_PATH
1337
1338 REVISION HISTORY:
1339       Written by pcr 2008/06/05
1340       last modification by pcr 2010/12/26
1341
1342----- Documentation for Calib\interpol_observations.pro -----
1343 NAME:
1344      INTERPOL_OBSERVATIONS
1345
1346 AUTHOR:
1347      pierre.cruzalebes@oca.eu
1348
1349 PURPOSE:
1350      create response observing parameters during science observations :
1351      calib DIT+NDIT+RA+DEC + calib or sci start/end UTC+FWHM+TAU0+MJD@0h
1352
1353 CATEGORY:
1354      data calibration
1355
1356 INPUTS:
1357      needs text input file (in OBS_PATH/INP/ directory) with :
1358        - calibrator and science observation file names (in same row)
1359        - number of science observing blocks (if null => 1 block with
1360        all science obs files, first calib OB used for
1361        DIT+NDIT+RA+DEC(+UTC+FWHM+TAU0+MJD@0h) replacement)
1362      if nber of sci OB(s) gt 0 :
1363       - number of science observing file(s) in each OB (in same row)
1364       - index of calibrator file used for DIT+NDIT+RA+DEC(+UTC+FWHM+TAU0+MJD@0h)
1365       replacement for each science OB (starting at 0, in same row)
1366
1367 REQUIREMENTS:
1368      data read in input science and calib observation parameter files (in
1369      subdirectory of OBS_PATH/) must be in ASCII format and contain
1370      (one row per OB):
1371        - (DIT[s] , NDIT), (RA[deg] , DEC[deg]), (START_UTC[h] , END_UTC[h]),
1372        (START_FWHM["] , END_FWHM["]), (START_TAU0[s] , END_TAU0[s]), (MJD@0h , 0)
1373
1374 OUTPUTS:
1375      data written in interpolated output calib observation parameter file (in
1376      the same subdir of OBS_PATH/) are of same type as input (one row per OB):
1377        - (DIT[s] , NDIT), (RA[deg] , DEC[deg]) of calib, (START_UTC[h] ,
1378        END_UTC[h]) of calib or sci, (START_FWHM["] , END_FWHM["]) of sci,
1379        (START_TAU0[s] , END_TAU0[s]), (MJD@0h , 0) of sci
1380
1381 LOCAL PROCEDURE CALLED:
1382        NONE
1383
1384 LOCAL FUNCTION CALLED:
1385        EXTRACT_PROHEADER
1386        NONE
1387
1388 LOCAL SYSTEM VARIABLE USED:
1389        NB_OB_MAX
1390        OBS_PATH
1391        PLOT_DEV
1392        SPIDAST_PATH
1393
1394 REVISION HISTORY:
1395       Written by pcr 2009/02/11
1396       last modification by pcr 2010/05/31
1397
1398----- Documentation for Calib\interpol_response.pro -----
1399 NAME:
1400      INTERPOL_RESPONSE
1401
1402 AUTHOR:
1403      pierre.cruzalebes@oca.eu
1404
1405 PURPOSE:
1406      evaluate instrumental responses in vis, flux and/or coh flux
1407      for each spectral channel and each baseline
1408      on science observations by temporal linear interpolation or polynomial fit
1409
1410 CATEGORY:
1411      data calibration
1412
1413 INPUTS:
1414      need text input file (in OBS_PATH/INP/ directory) with :
1415        - calibrator and science observation file names (in same row)
1416        - response file name(s)
1417        - degree of polynomial fit to be fitted to data (=0 for linear
1418        interpolation) and desired confidence level (only used for fit)
1419        - if needed (default = AMBER format) : data format ('vis' or 'spec'
1420        or 'coh')
1421
1422 REQUIREMENTS:
1423      data read in science and calib observation parameter files (in
1424      subdirectory of OBS_PATH/) must be in ASCII format and contain
1425      (one row per OB):
1426        - (DIT[s] , NDIT), (RA[deg] , DEC[deg]), (START_UTC[h] , END_UTC[h]),
1427        (START_FWHM["] , END_FWHM["]), (START_TAU0[s] , END_TAU0[s]), (MJD@0h , 0)
1428
1429      vis data:
1430      data read in response data file(s) (in subdirectory of OBS_PATH/)
1431      must be in ASCII format and contain (in this order, one raw per spectral
1432      channel):
1433        - vis. resp. and error
1434
1435      spec data:
1436      data read in response data file(s) (in subdirectory of OBS_PATH/)
1437      must be in ASCII format and contain (in this order, one raw per
1438      spectral channel):
1439        - flux resp. and error [photoel/(W/m^2/mum)]
1440
1441      coh. spec data:
1442      data read in response data file(s) (in subdirectory of OBS_PATH/)
1443      must be in ASCII format and contain (in this order, one raw per spectral
1444      channel):
1445        - coh. flux resp. and error [photoel/(W/m^2/mum)]
1446
1447      data read in response data file(s) (in subdirectory of OBS_PATH/)
1448      must be in ASCII format and contain (in this order, one raw per spectral
1449      channel):
1450        - nber of frames, vis. resp. and error, flux resp. and err.,
1451        coh. flux resp. and err. [photoel/(W/m^2/mum)]
1452
1453 OUTPUTS:
1454      vis data:
1455      data written in interpolated response data file(s) (in the same subdir of
1456      OBS_PATH/) must be in ASCII format and contain (in this order, one raw
1457      per spectral channel):
1458        - vis. resp. and error
1459
1460      spec data:
1461      data written in interpolated response data file(s) (in the same subdir of
1462      OBS_PATH/) must be in ASCII format and contain (in this order, one raw
1463      per spectral channel):
1464        - flux resp. and error [photoel/(W/m^2/mum)]
1465
1466      coh. spec data:
1467      data written in interpolated response data file(s) (in the same subdir of
1468      OBS_PATH/) must be in ASCII format and contain (in this order, one raw
1469      per spectral channel):
1470        - coh. flux resp. and error [photoel/(W/m^2/mum)]
1471
1472      AMBER data (default):
1473      data written in interpolated response data file(s) (in the same subdir of
1474      OBS_PATH/) must be in ASCII format and contain (in this order, one raw
1475      per spectral channel):
1476        - nber of frames, vis. resp. and error, flux resp. and err.,
1477        coh. flux resp. and err. [photoel/(W/m^2/mum)]
1478
1479 LOCAL PROCEDURE CALLED:
1480        COV2COR
1481        RESET_PLOT
1482
1483 LOCAL FUNCTION USED:
1484        EXTRACT_PROHEADER
1485        POLY_BOOT
1486        SYM
1487
1488 LOCAL SYSTEM VARIABLE USED:
1489        POLYBOOTW
1490        NB_BOOT_LOOPS
1491        NB_DATA_BOOT
1492        NB_OB_MAX
1493        OBS_PATH
1494        PLOT_DEV
1495        SPIDAST_PATH
1496
1497 REVISION HISTORY
1498       Written by pcr 2008/06/03
1499       last modification by pcr 2010/12/23
1500
1501----- Documentation for Calib\print_night_stat.pro -----
1502 NAME:
1503      PRINT_NIGHT_STAT
1504
1505 AUTHOR:
1506      pierre.cruzalebes@oca.eu
1507
1508 PURPOSE:
1509      print whole-night uv-coverage of science-target and turbulence-statistics
1510      (seeing FWHM and tau0) extracted from baseline+observation+wavelength
1511      file(s) and gather all observation files of the night in one single file
1512
1513 CATEGORY:
1514      data calibration
1515
1516 INPUTS:
1517      needs text input file (in OBS_PATH/INP/ directory) with :
1518        - number of parts (defined with P2VM settings)
1519        - nber of input science-target baseline file(s) per part (in same row)
1520        - input science-target baseline file name(s) of each part
1521        (one row per part)
1522        - number of wavelength file(s) per part
1523        - wavelength list name(s) of each bands (all bands in same row,
1524        one row per part)
1525      for each part :
1526        - number of science and calibrator target(s) (in same row)
1527        - science observation parameter file name(s) (same row for all
1528        science in part)
1529        - calibrator observation parameter file name(s) (same row for all
1530        calib in part)
1531
1532 REQUIREMENTS:
1533      data read in input baseline file(s) (in subdirectory of OBS_PATH/)
1534      must be in ASCII format and contain (2*NBASE=NTEL*(NTEL-1) columns, one
1535      row per obs file) :
1536        - (START_PBL[m] , START_PBLA[deg]) and (END_PBL[m] , END_PBLA[deg])
1537        of the projected baseline(s) associated to each data file
1538
1539      data read in wavelength list(s) (in subdirectory of OBS_PATH/) must be in
1540      ASCII format and contain (one row per spectral channel):
1541        - wavelength and bandwidth [m]
1542
1543      data read in input observation parameter file(s) (in OBS_PATH/DATA/
1544      directory, .obs extension, one row per observation) are of complex type :
1545        - (DIT[s] , NDIT), (RA[deg] , DEC[deg]), (START_UTC[h] , END_UTC[h]),
1546        (START_FWHM["] , END_FWHM), (START_TAU0[s] , START_TAU0[s]), (MJD@Oh , 0)
1547
1548 OUTPUTS:
1549      data written in output observation parameter file (in OBS_PATH/OUT/
1550      directory, .obs extension, one row per observation) are of complex type :
1551        - (DIT[s] , NDIT), (RA[deg] , DEC[deg]), (START_UTC[h] , END_UTC[h]),
1552        (START_FWHM["] , END_FWHM), (START_TAU0[s] , START_TAU0[s]), (MJD@Oh , 0)
1553
1554 LOCAL PROCEDURE CALLED:
1555        RESET_PLOT
1556
1557 LOCAL FUNCTION USED:
1558        COSD
1559        EXTRACT_PROHEADER
1560        SIND
1561        SYM
1562
1563 LOCAL SYSTEM VARIABLE USED:
1564        NB_OB_MAX
1565        NB_PAIR_MAX
1566        NB_TARG_MAX
1567        OBS_PATH
1568        SPIDAST_PATH
1569
1570 REVISION HISTORY:
1571       Written by pcr 2008/06/13
1572       last modification by pcr 2010/12/23
1573
1574----- Documentation for Calib\shift_wave_list.pro -----
1575 NAME:
1576    SHIFT_WAVE_LIST
1577
1578 PURPOSE:
1579    shift wavelength lists using cross-correlation
1580
1581 CATEGORY:
1582    data calibration
1583
1584 INPUTS:
1585     needs text input file (in OBS_PATH/INP/ directory) with :
1586        - number of input data raw spectrum file(s)
1587        - input raw spectrum file name(s) (in same row)
1588        - reference line spectrum file name
1589        - reference line spectrum type ('star' or 'lab')
1590        - basic data file name & observing header file name(s) (in same row)
1591        - nber of spectral windows used for calculating wavelength shift(s)
1592        - atmospheric transmission file name
1593        - filter transmission file name
1594        - spectral resolution for calculating the spectrum continuum
1595        used for scaling
1596        - nber of pixels used for barycentric position of
1597        phase-correlation peak (odd integer)
1598        - output wavelength file name(s) (in same row)
1599        - reference spectral line table (in ALL_DATA/directory)
1600
1601 REQUIREMENTS:
1602   data read in raw spectrum file(s) (in subdirectory of OBS_PATH/)
1603   must be in ASCII format and contain the same number of spectral
1604   channels with (one row per spectral channel) :
1605        - wavelength and bandwidth [m], flux and error [photoel] for each
1606        observing file
1607
1608   if reference line spectrum type = 'star' (reference lines given by
1609   reference exitance) :
1610       data read in reference line spectrum (in SYNTHE_PATH/directory)
1611       must be in ASCII format and contain :
1612        - wavelength [AA = 10^-4 mum] and exitance [erg/cm^2/s/AA =
1613        10 W/m^2/mum]
1614   if reference line spectrum type = 'lab' (reference lines given by
1615   laboratory spectrum) :
1616      data read in reference line spectrum (in subdirectory of OBS_PATH/)
1617      must be in ASCII format and contain :
1618        - wavelength [m] and flux [photoel]
1619
1620   basic data file (in subdirectory of OBS_PATH/) must be in
1621   standard FITS format and contain the following ASCII lines with:
1622     RAEP0           = 'hh:mm:ss.sss'   / Right Ascension (J2000) (h:min:sec)
1623     DECEP0          = '+-dd:mm:ss.ss'  / Declination (J2000) (deg:arcmin:arcsec)
1624     PMRA        =       +-ppp.pp   / Annual Proper Motion in RA (milliarcsec/yr)
1625     PMDEC       =       +-ppp.pp   / Annual Proper Motion in DEC (milliarcsec/yr)
1626     SYSVEL      =       +-vvv.v    / Radial Velocity (km/s)
1627
1628   observing header file(s) (in OBS_PATH/DATA/ directory) must be in
1629   standard FITS format and contain the following ASCII lines with:
1630     EXPTIME =            t.ttttttt / Integration time
1631     MJD-OBS =     ddddd.dddddddddd / Obs start
1632     HIERARCH ESO DET NDIT        = nnn / # of Sub-Integrations
1633
1634   data read in atmospheric file (in ALL_DATA_PATH/directory)
1635   must be in ASCII format and contain :
1636   - wavelength [mum] and transmission
1637
1638    data read in filter file (in ALL_DATA_PATH/directory)
1639    must be in ASCII format and contain :
1640        - wavelength [mum] and transmission
1641
1642   data read in line table (in ALL_DATA_PATH/directory)
1643   must be in ASCII format and contain :
1644   - wavelength [mum] and element identification
1645
1646 OUTPUTS:
1647   data written in output wavelength file(s) (in the same subdirectory
1648   of OBS_PATH/) are (in this order, one row per spectral channel) :
1649        - shifted wavelengths and bandwidths [m]
1650
1651 LOCAL PROCEDURE CALLED:
1652        DEG2DMS
1653        DEG2HMS
1654        HELIOCOR
1655        HELIO_JD
1656        RESET_PLOT
1657       YDN2MD
1658
1659 LOCAL FUNCTION USED:
1660       DATE_CONV
1661        EXTRACT_PROHEADER
1662        GET_OUTLIER_FENCES
1663        JULDATE
1664        SYM
1665        TRAP
1666
1667 LOCAL SYSTEM VARIABLE USED:
1668        ALL_DATA_PATH
1669       GEOLAT
1670       GEOLON
1671        NB_LAMBDA_MAX
1672        NB_OB_MAX
1673        OBS_PATH
1674        PLOT_DEV
1675        SPIDAST_PATH
1676        SYNTHE_PATH
1677
1678 REVISION HISTORY:
1679    Written  by pcr 2010/03/06
1680    last modification by pcr 2011/01/12
1681