26 #include "midiGlobal.h"
28 #include "memoryHandling.h"
29 #include "errorHandling.h"
30 #include "calibration.h"
31 #include "fitsAnalysisFrgSP.h"
32 #include "imageProcessing.h"
33 #include "createProdFrg.h"
34 #include "transferFunction.h"
35 #include "visibility.h"
36 #include "diagnostics.h"
37 #include "estimationFrg.h"
38 #include "photometry.h"
39 #include "preProcFrgSP.h"
40 #include "procFrgSP.h"
41 #include "procFrgHS.h"
42 #include "statistics.h"
80 cpl_parameterlist *parlist,
81 cpl_frameset *frameset)
86 const char routine[] =
"procFrgSP";
87 ImageFormat *formatInterf=NULL;
88 ImageFormat *formatPhotomA=NULL;
89 ImageFormat *formatPhotomB=NULL;
90 CompressedData *compressedInterf=NULL, *compressedPhotomA=NULL, *compressedPhotomB=NULL;
91 FilterData *filterInfo=NULL;
92 DispersedResult *dispResult=NULL;
93 CorrectedFrames *corrFrames=NULL;
96 if (diagnostic > 4)cpl_msg_info(cpl_func,
"Invoking routine '%s' \n", routine);
97 if (diagnostic > 4) fprintf(midiReportPtr,
"Invoking routine '%s' \n", routine);
101 if (options->processing == UNDISPERSED)
104 midiReportWarning (midiReportPtr, routine, __FILE__, __LINE__,
105 "'UNDISPERSED' is an invalid processing request for SCI_PHOT data");
110 formatInterf = callocImageFormat ();
111 formatPhotomA = callocImageFormat ();
112 formatPhotomB = callocImageFormat ();
113 corrFrames = cpl_calloc (1,
sizeof (CorrectedFrames));
115 corrFrames->CorrInterf=0;
116 corrFrames->CorrPhotomA=0;
117 corrFrames->CorrPhotomB=0;
121 analyseFitsFrgSP (fileNames, formatInterf, formatPhotomA, formatPhotomB, error);
124 midiReportWarning (midiReportPtr, routine, __FILE__, __LINE__,
"Cannot analyse FITS files");
125 freeImageFormat (formatInterf);
126 freeImageFormat (formatPhotomA);
127 freeImageFormat (formatPhotomB);
134 compressedInterf = callocMidiCompressed (formatInterf);
135 compressedPhotomA = callocMidiCompressed (formatPhotomA);
136 compressedPhotomB = callocMidiCompressed (formatPhotomB);
137 badChannelList = (
int *) calloc (formatInterf->iXWidth, sizeof (
int));
138 filterInfo = callocFilterInfo();
142 preProcFrgSP (options, filterInfo, fileNames, compressedInterf,
143 compressedPhotomA, compressedPhotomB, formatInterf, formatPhotomA, formatPhotomB, error);
146 midiReportWarning (midiReportPtr, routine, __FILE__, __LINE__,
"Cannot compress FITS files");
147 freeCompressedData (formatInterf, compressedInterf);
148 freeCompressedData (formatPhotomA, compressedPhotomA);
149 freeCompressedData (formatPhotomB, compressedPhotomB);
150 free (badChannelList);
151 freeImageFormat (formatInterf);
152 freeImageFormat (formatPhotomA);
153 freeImageFormat (formatPhotomB);
154 freeFilterInfo (filterInfo);
159 checkDelayLineJumps (
"INTERF", formatInterf, compressedInterf);
160 checkDelayLineJumps (
"PHOTOMA", formatPhotomA, compressedPhotomA);
161 checkDelayLineJumps (
"PHOTOMB", formatPhotomB, compressedPhotomB);
164 checkDelayLineConsistencies (
"INTERF",
"PHOTOMA", compressedInterf, compressedPhotomA, formatInterf, formatPhotomA, error);
165 checkDelayLineConsistencies (
"INTERF",
"PHOTOMB", compressedInterf, compressedPhotomB, formatInterf, formatPhotomB, error);
168 midiReportWarning (midiReportPtr, routine, __FILE__, __LINE__,
"SCI_PHOT processing abandonned");
169 freeCompressedData (formatInterf, compressedInterf);
170 freeCompressedData (formatPhotomA, compressedPhotomA);
171 freeCompressedData (formatPhotomB, compressedPhotomB);
172 free (badChannelList);
173 freeImageFormat (formatInterf);
174 freeImageFormat (formatPhotomA);
175 freeImageFormat (formatPhotomB);
176 freeFilterInfo (filterInfo);
182 reportInterfChopping (
"INTERF", formatInterf, compressedInterf);
183 reportPhotomChopping (
"PHOTOMA", formatPhotomA, compressedPhotomA);
184 reportPhotomChopping (
"PHOTOMB", formatPhotomB, compressedPhotomB);
185 displayInterfChoppingDisp (
"INTERF", formatInterf, compressedInterf);
186 displayPhotomChoppingDisp (
"PHOTOMA", formatPhotomA, compressedPhotomA);
187 displayPhotomChoppingDisp (
"PHOTOMB", formatPhotomB, compressedPhotomB);
190 dispResult = callocDispResult (formatInterf->iXWidth);
191 cleanupFrgSP (options->processing, formatInterf, formatPhotomA, formatPhotomB, compressedInterf,
192 compressedPhotomA, compressedPhotomB, error, corrFrames);
195 midiReportWarning (midiReportPtr, routine, __FILE__, __LINE__,
"SCI_PHOT processing abandonned");
196 freeCompressedData (formatInterf, compressedInterf);
197 freeCompressedData (formatPhotomA, compressedPhotomA);
198 freeCompressedData (formatPhotomB, compressedPhotomB);
199 free (badChannelList);
200 freeImageFormat (formatInterf);
201 freeImageFormat (formatPhotomA);
202 freeImageFormat (formatPhotomB);
203 freeFilterInfo (filterInfo);
204 freeDispResult (dispResult);
209 prepareWaterfallDisplay (fileNames, formatInterf, compressedInterf);
212 applyOpticalCompensation (fileNames, formatInterf, compressedInterf,
213 compressedPhotomA, compressedPhotomB, error, parlist, frameset);
217 if (strcmp (formatInterf->obsCatg,
"CALIB") == 0)
218 calibrateWaveUsingPolynom (fileNames, formatInterf);
224 postProcFringe (fileNames, filterInfo, compressedInterf, compressedPhotomA,
225 compressedPhotomB, formatInterf, formatPhotomA,
226 formatPhotomB, dispResult, error,
227 parlist, frameset, corrFrames);
230 midiReportWarning (midiReportPtr, routine, __FILE__, __LINE__,
"SCI_PHOT processing abandonned");
231 freeCompressedData (formatInterf, compressedInterf);
232 freeCompressedData (formatPhotomA, compressedPhotomA);
233 freeCompressedData (formatPhotomB, compressedPhotomB);
234 free (badChannelList);
235 freeImageFormat (formatInterf);
236 freeImageFormat (formatPhotomA);
237 freeImageFormat (formatPhotomB);
238 freeFilterInfo (filterInfo);
239 freeDispResult (dispResult);
244 freeCompressedData (formatInterf, compressedInterf);
245 freeCompressedData (formatPhotomA, compressedPhotomA);
246 freeCompressedData (formatPhotomB, compressedPhotomB);
247 free (badChannelList);
248 freeImageFormat (formatInterf);
249 freeImageFormat (formatPhotomA);
250 freeImageFormat (formatPhotomB);
251 freeFilterInfo (filterInfo);
252 freeDispResult (dispResult);
253 cpl_free(corrFrames);
271 enum ProcessingMode processing,
272 ImageFormat *formatInterf,
273 ImageFormat *formatPhotomA,
274 ImageFormat *formatPhotomB,
275 CompressedData *compressedInterf,
276 CompressedData *compressedPhotomA,
277 CompressedData *compressedPhotomB,
279 CorrectedFrames *corrFrames)
284 const char routine[] =
"cleanupFrgSP";
285 int transitions, f, R, X, n, localError;
286 double *array, fluxAve;
288 char *fileName, *title;
292 if (diagnostic > 4)cpl_msg_info(cpl_func,
"Invoking routine '%s' \n", routine);
293 if (diagnostic > 4) fprintf(midiReportPtr,
"Invoking routine '%s' \n", routine);
295 cpl_msg_info(cpl_func,
"\nCleaning up SCI_PHOT files for batch %d \n", batchNumber);
296 cpl_msg_info(cpl_func,
"------------------------------------ \n");
297 fprintf (midiReportPtr,
"\nCleaning up SCI_PHOT files for batch %d \n", batchNumber);
298 fprintf (midiReportPtr,
"------------------------------------ \n");
307 transitions = countTransitions (
'T', formatInterf->numOfFrames, compressedInterf->tarType);
308 sprintf (midiMessage,
"Target Transitions for Interf = %d", transitions);
309 midiReportInfo (midiReportPtr, routine, __FILE__, __LINE__, midiMessage);
310 if (transitions < 10)
312 sprintf (midiMessage,
"Interferometry data is not chopped");
313 midiReportWarning (midiReportPtr, routine, __FILE__, __LINE__, midiMessage);
319 transitions = countTransitions (
'T', formatPhotomA->numOfFrames, compressedPhotomA->tarType);
320 sprintf (midiMessage,
"Target Transitions for Photom A = %d", transitions);
321 midiReportInfo (midiReportPtr, routine, __FILE__, __LINE__, midiMessage);
322 if (transitions < 10)
324 sprintf (midiMessage,
"Photometry A data is not chopped");
325 midiReportWarning (midiReportPtr, routine, __FILE__, __LINE__, midiMessage);
331 transitions = countTransitions (
'T', formatPhotomB->numOfFrames, compressedPhotomB->tarType);
332 sprintf (midiMessage,
"Target Transitions for Photom B = %d", transitions);
333 midiReportInfo (midiReportPtr, routine, __FILE__, __LINE__, midiMessage);
334 if (transitions < 10)
336 sprintf (midiMessage,
"Photometry B data is not chopped");
337 midiReportWarning (midiReportPtr, routine, __FILE__, __LINE__, midiMessage);
344 formatInterf->chopped = 1;
345 formatPhotomA->chopped = 1;
346 formatPhotomB->chopped = 1;
350 midiReportWarning (midiReportPtr, routine, __FILE__, __LINE__,
"Cannot cleanup SCI_PHOT files");
360 corrFrames->CorrInterf=correctTarType(
"INTERF", compressedInterf->tarType,
361 compressedInterf->time, formatInterf->numOfFrames, &localError);
362 if (localError) *error = 1;
364 corrFrames->CorrPhotomA=correctTarType(
"PHOTOMA", compressedPhotomA->tarType,
365 compressedPhotomA->time, formatPhotomA->numOfFrames, &localError);
366 if (localError) *error = 1;
368 corrFrames->CorrPhotomB=correctTarType(
"PHOTOMB", compressedPhotomB->tarType,
369 compressedPhotomB->time, formatPhotomB->numOfFrames, &localError);
370 if (*error || localError)
378 removeSkyBackground (
"INTERF", processing, formatInterf, compressedInterf, &localError);
379 if (localError) *error = 1;
380 removeSkyBackground (
"PHOTOMA", processing, formatPhotomA, compressedPhotomA, &localError);
381 if (localError) *error = 1;
382 removeSkyBackground (
"PHOTOMB", processing, formatPhotomB, compressedPhotomB, &localError);
383 if (formatInterf->numOfFrames != formatPhotomA->numOfFrames ||
384 formatInterf->numOfFrames != formatPhotomB->numOfFrames || *error || localError)
386 midiReportWarning (midiReportPtr, routine, __FILE__, __LINE__,
"Unequal numOfFrames");
392 for (R = 0; R < formatInterf->numOfRegionsToProcess; R++)
394 for (X = 0; X < formatInterf->iXWidth; X++)
396 if (badChannelList[X])
399 for (f = 0; f < formatInterf->numOfFrames; f++)
413 if (compressedInterf->tarType[f] !=
'T')
414 compressedInterf->rejectList[X][f] |= BSL_SKY_SCAN;
419 for (R = 0; R < formatPhotomA->numOfRegionsToProcess; R++)
421 for (X = 0; X < formatPhotomA->iXWidth; X++)
423 if (badChannelList[X])
426 for (f = 0; f < formatPhotomA->numOfFrames; f++)
445 if (compressedPhotomA->tarType[f] !=
'T')
446 compressedPhotomA->rejectList[X][f] |= BSL_SKY_SCAN;
451 for (R = 0; R < formatPhotomB->numOfRegionsToProcess; R++)
453 for (X = 0; X < formatPhotomB->iXWidth; X++)
455 if (badChannelList[X])
458 for (f = 0; f < formatPhotomB->numOfFrames; f++)
477 if (compressedPhotomB->tarType[f] !=
'T')
478 compressedPhotomB->rejectList[X][f] |= BSL_SKY_SCAN;
495 array = (
double *) calloc (formatInterf->numOfFrames, sizeof (
double));
499 for (f = 0; f < formatInterf->numOfFrames; f++)
501 if (compressedInterf->tarType[f] ==
'T')
503 array[n] = compressedInterf->iFringe1[f];
509 cpl_msg_info(cpl_func,
"Interf DATA2 Average Flux = %f \n", fluxAve);
510 midiCreatePlotFileDouble2D (
"InterfCleanDATA2",
"Interferometry DATA2 (Sky Removed)",
511 "Frame",
"Flux", 0, array, 0, n, 1);
515 for (f = 0; f < formatInterf->numOfFrames; f++)
517 if (compressedInterf->tarType[f] ==
'T')
519 array[n] = compressedInterf->iFringe2[f];
525 cpl_msg_info(cpl_func,
"Interf DATA3 Average Flux = %f \n", fluxAve);
526 midiCreatePlotFileDouble2D (
"InterfCleanDATA3",
"Interferometry DATA3 (Sky Removed)",
527 "Frame",
"Flux", 0, array, 0, n, 1);
530 for (f = 0; f < formatInterf->numOfFrames; f++)
532 if (compressedInterf->tarType[f] ==
'T')
534 array[n] = compressedInterf->iFringe[f];
538 midiCreatePlotFileDouble2D (
"InterfCleanDATA2_DATA3",
"Interferometry DATA2-DATA3 (Sky Removed)",
539 "Frame",
"Flux", 0, array, 0, n, 1);
543 for (f = 0; f < formatPhotomA->numOfFrames; f++)
545 if (compressedPhotomA->tarType[f] ==
'T')
547 array[n] = compressedPhotomA->iFringe1[f];
553 cpl_msg_info(cpl_func,
"PhotomA DATA1 Average Flux = %f \n", fluxAve);
554 midiCreatePlotFileDouble2D (
"PhotomACleanDATA1",
"Photometry A DATA1 (Sky Removed)",
555 "Frame",
"Flux", 0, array, 0, n, 1);
559 for (f = 0; f < formatPhotomB->numOfFrames; f++)
561 if (compressedPhotomB->tarType[f] ==
'T')
563 array[n] = compressedPhotomB->iFringe1[f];
569 cpl_msg_info(cpl_func,
"PhotomB DATA4 Average Flux = %f \n", fluxAve);
570 midiCreatePlotFileDouble2D (
"PhotomBCleanDATA4",
"Photometry B DATA4 (Sky Removed)",
571 "Frame",
"Flux", 0, array, 0, n, 1);
577 if (plotFile && diagnostic > 4)
579 arrayF = (
float *) calloc (formatInterf->numOfFrames, sizeof (
float));
580 fileName = (
char *) calloc (MAX_STRING_LENGTH,
sizeof (
char));
581 title = (
char *) calloc (MAX_STRING_LENGTH,
sizeof (
char));
583 for (R = 0; R < formatInterf->numOfRegionsToProcess; R++)
585 for (X = 0; X < formatInterf->iXWidth; X++)
587 if (badChannelList[X])
591 for (f = 0; f < formatInterf->numOfFrames; f++)
593 if (compressedInterf->tarType[f] ==
'T' && !(compressedInterf->rejectList[X][f]))
595 arrayF[n] = compressedInterf->iDispFringe[R][X][f];
599 sprintf (fileName,
"InterfCleanDATA%d_X%d", R+2, X+1);
600 sprintf (title,
"Interferometry DATA%d for Channel %d (Sky Removed)", R+2, X+1);
601 midiCreatePlotFile2D (fileName, title,
"Frame",
"Flux", 1, arrayF, 0, n, 1, 0);
604 for (R = 0; R < formatPhotomA->numOfRegionsToProcess; R++)
606 for (X = 0; X < formatPhotomA->iXWidth; X++)
608 if (badChannelList[X])
612 for (f = 0; f < formatPhotomA->numOfFrames; f++)
614 if (compressedPhotomA->tarType[f] ==
'T' && !(compressedPhotomA->rejectList[X][f]))
616 arrayF[n] = compressedPhotomA->iDispFringe[R][X][f];
620 sprintf (fileName,
"PhotomACleanDATA1_X%d", X+1);
621 sprintf (title,
"Photometry A DATA1 for Channel %d (Sky Removed)", X+1);
622 midiCreatePlotFile2D (fileName, title,
"Frame",
"Flux", 1, arrayF, 0, n, 1, 0);
625 for (R = 0; R < formatPhotomB->numOfRegionsToProcess; R++)
627 for (X = 0; X < formatPhotomB->iXWidth; X++)
629 if (badChannelList[X])
633 for (f = 0; f < formatPhotomB->numOfFrames; f++)
635 if (compressedPhotomB->tarType[f] ==
'T' && !(compressedPhotomB->rejectList[X][f]))
637 arrayF[n] = compressedPhotomB->iDispFringe[R][X][f];
641 sprintf (fileName,
"PhotomBCleanDATA4_X%d", X+1);
642 sprintf (title,
"Photometry B DATA4 for Channel %d (Sky Removed)", X+1);
643 midiCreatePlotFile2D (fileName, title,
"Frame",
"Flux", 1, arrayF, 0, n, 1, 0);
657 arrayF = (
float *) calloc (formatInterf->iXWidth, sizeof (
float));
658 fileName = (
char *) calloc (MAX_STRING_LENGTH,
sizeof (
char));
659 title = (
char *) calloc (MAX_STRING_LENGTH,
sizeof (
char));
661 for (R = 0; R < formatInterf->numOfRegionsToProcess; R++)
663 for (X = 0; X < formatInterf->iXWidth; X++)
666 if (badChannelList[X])
670 for (f = 0; f < formatInterf->numOfFrames; f++)
672 if (compressedInterf->tarType[f] ==
'T' && !(compressedInterf->rejectList[X][f]))
674 arrayF[X] += compressedInterf->iDispFringe[R][X][f];
678 arrayF[X] /=(float)n;
681 sprintf (fileName,
"MeanInterfCleanDATA%d", R+1);
682 sprintf (title,
"Mean Interferometry DATA%d (Sky Removed)", R+1);
683 midiCreatePlotFile2D (fileName, title,
"Channel",
"Flux", 0, arrayF, 0, formatInterf->iXWidth, 1, 0);
692 finaliseRejectListInterf (
"Combined Interferometry", formatInterf, compressedInterf, error);
694 finaliseRejectListPhotom (
"Photometry A", formatPhotomA, compressedPhotomA, error);
696 finaliseRejectListPhotom (
"Photometry B", formatPhotomB, compressedPhotomB, error);
718 void applyOpticalCompensation (
719 MidiFiles *fileNames,
721 CompressedData *compressedInterf,
722 CompressedData *compressedPhotomA,
723 CompressedData *compressedPhotomB,
725 cpl_parameterlist *parlist,
726 cpl_frameset *frameset)
731 const char routine[] =
"applyOpticalCompensation";
739 cpl_frame * cur_frame;
741 float * kappamatrix11=NULL;
742 float * kappamatrix12=NULL;
743 float * kappamatrix21=NULL;
744 float * kappamatrix22=NULL;
745 float * kappamatrix11_error=NULL;
746 float * kappamatrix12_error=NULL;
747 float * kappamatrix21_error=NULL;
748 float * kappamatrix22_error=NULL;
749 int dimenkappamatrix=0;
750 cpl_errorstate prestate = cpl_errorstate_get();
755 if (diagnostic > 4)cpl_msg_info(cpl_func,
"Invoking routine '%s' \n", routine);
756 if (diagnostic > 4) fprintf(midiReportPtr,
"Invoking routine '%s' \n", routine);
762 cpl_msg_info(cpl_func,
"\nApplying Optical Compensation for batch %d \n", batchNumber);
763 cpl_msg_info(cpl_func,
"--------------------------------------- \n");
764 fprintf (midiReportPtr,
"\nApplying Optical Compensation for batch %d \n", batchNumber);
765 fprintf (midiReportPtr,
"--------------------------------------- \n");
771 if (strcmp(format->grismId,
"GRISM")==0){
772 softag = cpl_sprintf(
"%s",
"MIDI_KAPPAMATRIX_GRISM");
774 if (strcmp(format->grismId,
"PRISM")==0){
775 softag = cpl_sprintf(
"%s",
"MIDI_KAPPAMATRIX_PRISM");
779 cur_frame = cpl_frameset_get_first(frameset);
780 if (cur_frame == NULL) {
781 cpl_msg_error(cpl_func,
"No frame found in the SOF");
789 tag = (
char*)cpl_frame_get_tag(cur_frame);
790 if (strcmp(tag, softag)) {
791 cur_frame = cpl_frameset_get_next( frameset );
795 cpl_msg_info(cpl_func,
"Kappamatrix found in the SOF: %s\n",cpl_frame_get_filename(cur_frame));
801 if (strcmp(tag, softag)) {
802 cpl_msg_info(cpl_func,
"No Kappamatrix found in the SOF!");
803 cpl_msg_warning(cpl_func,
"Subsequent computational values are without Optical Compensation");
812 prestate = cpl_errorstate_get();
813 if((table = cpl_table_load(cpl_frame_get_filename(cur_frame), 1, 1))==NULL)
815 cpl_msg_info(cpl_func,
"No siutable table found in the file %s\n",cpl_frame_get_filename(cur_frame));
816 cpl_msg_warning(cpl_func,
"Subsequent computational values are without Optical Compensation");
817 cpl_errorstate_set(prestate);
824 if (cpl_table_has_column(table,
"kappam11"))
826 dimenkappamatrix=cpl_table_get_column_dimensions(table,
"kappam11");
827 kappamatrix11=cpl_table_get_data_float(table,
"kappam11");
828 kappamatrix12=cpl_table_get_data_float(table,
"kappam12");
829 kappamatrix21=cpl_table_get_data_float(table,
"kappam21");
830 kappamatrix22=cpl_table_get_data_float(table,
"kappam22");
831 kappamatrix11_error=cpl_table_get_data_float(table,
"kappam11_error");
832 kappamatrix12_error=cpl_table_get_data_float(table,
"kappam12_error");
833 kappamatrix21_error=cpl_table_get_data_float(table,
"kappam21_error");
834 kappamatrix22_error=cpl_table_get_data_float(table,
"kappam22_error");
838 cpl_msg_info(cpl_func,
"No siutable table column found in the file %s\n",cpl_frame_get_filename(cur_frame));
839 cpl_msg_warning(cpl_func,
"Subsequent computational values are without Optical Compensation");
844 trr = callocTransferRatios (format->iXWidth);
846 cpl_msg_info(cpl_func,
"Dimension: %d",dimenkappamatrix);
848 for (i=0; i<format->iXWidth;i++){
850 trr->ka1[i]=kappamatrix11[i] ;
851 trr->siga1[i]=kappamatrix11_error[i] ;
852 trr->ka2[i]=kappamatrix12[i] ;
853 trr->siga2[i]=kappamatrix12_error[i] ;
854 trr->kb1[i]=kappamatrix21[i] ;
855 trr->sigb1[i]=kappamatrix21_error[i] ;
856 trr->kb2[i]=kappamatrix22[i] ;
857 trr->sigb2[i]=kappamatrix22_error[i] ;
858 cpl_msg_info(cpl_func,
"%3d %6.2f %6.2f %6.2f %6.2f %6.2f %6.2f %6.2f %6.2f \n", i,
859 trr->ka1[i], trr->siga1[i], trr->ka2[i], trr->siga2[i],
860 trr->kb1[i], trr->sigb1[i], trr->kb2[i], trr->sigb2[i]);
863 for (i=0; i<format->iXWidth;i++){
864 if (!(trr->ka1[i]) || !(trr->ka2[i]) || !(trr->kb1[i]) || !(trr->kb2[i]))
866 badChannelList[i] |= BSL_DATA_ERROR;
867 cpl_msg_info(cpl_func,
"%3d <-- %s --> \n", i, UNAV);
868 fprintf (midiReportPtr,
"%3d <-- %s --> QCLOG \n", i, UNAV);
876 for (X = 0; X < format->iXWidth; X++)
878 if (!(badChannelList[X]))
883 cpl_msg_warning(cpl_func,
"Cannot find any valid Transfer Ratios");
884 cpl_msg_warning(cpl_func,
"Subsequent computational values are without Optical Compensation");
886 freeTransferRatios (trr);
891 getCompensatedBeams (trr, format, compressedInterf, compressedPhotomA, compressedPhotomB);
892 freeTransferRatios (trr);
893 cpl_table_delete(table);
1058 void getCompensatedBeams (
1059 TransferRatios *trr,
1060 ImageFormat *format,
1061 CompressedData *compressedInterf,
1062 CompressedData *compressedPhotomA,
1063 CompressedData *compressedPhotomB)
1068 const char routine[] =
"getCompensatedBeams";
1074 if (diagnostic > 4)cpl_msg_info(cpl_func,
"Invoking routine '%s' \n", routine);
1075 if (diagnostic > 4) fprintf(midiReportPtr,
"Invoking routine '%s' \n", routine);
1078 for (R = 0; R < format->numOfRegionsToProcess; R++)
1081 for (X = 0; X < format->iXWidth; X++)
1083 if (badChannelList[X])
1086 for (f = 0; f < format->numOfFrames; f++)
1089 if (!((compressedInterf->rejectList[X])[f]) )
1099 if(trr->ka1[X] > 0 && trr->ka2[X] > 0 && trr->kb1[X] > 0 && trr->kb2[X] > 0)
1106 ((compressedPhotomA->iDispFringe[0])[X])[f]=(((compressedPhotomA->iDispFringe[0])[X])[f])*(trr->ka1[X] + trr->kb1[X]);
1107 ((compressedPhotomB->iDispFringe[0])[X])[f]=(((compressedPhotomB->iDispFringe[0])[X])[f])*(trr->ka2[X] + trr->kb2[X]);
1111 ((compressedPhotomA->iDispFringe[0])[X])[f]=(((compressedPhotomA->iDispFringe[0])[X])[f]);
1112 ((compressedPhotomB->iDispFringe[0])[X])[f]=(((compressedPhotomB->iDispFringe[0])[X])[f]);
1122 compensate=1. / ( (sqrt(((compressedPhotomA->iDispFringe[R])[X])[f] *
1123 ((compressedPhotomB->iDispFringe[R])[X])[f])) *
1124 (sqrt(trr->ka1[X] * trr->kb1[X])) );
1125 if(isnan(compensate) || isinf(compensate))
1131 ((compressedInterf->iDispFringe[R])[X])[f] = ((compressedInterf->iDispFringe[R])[X])[f] * compensate;
1135 compensate=1. / ( (sqrt(((compressedPhotomA->iDispFringe[R-1])[X])[f] *
1136 ((compressedPhotomB->iDispFringe[R-1])[X])[f])) *
1137 (sqrt(trr->ka2[X] * trr->kb2[X])) );
1139 if(isnan(compensate) || isinf(compensate))
1147 ((compressedInterf->iDispFringe[R])[X])[f] =
1148 ((compressedInterf->iDispFringe[R])[X])[f] * compensate;
1156 sprintf (midiMessage,
"Interferometry data in region %d, channel %3d, frame %4d cannot be compensated",
1158 midiReportWarning (midiReportPtr, routine, __FILE__, __LINE__, midiMessage);