PRO anomaly ;+ ; ; NAME: ; anomaly ; PURPOSE: ; To determine anomalies in the DISR data set headers ; CATEGORY: ; Verification ; CALLING SEQUENCE: ; anomaly ; INPUTS: ; None ; OPTIONAL INPUT PARAMETERS: ; NONE ; OUTPUTS: ; post/anomaly.dat ; OPTIONAL OUTPUT PARAMETERS: ; None ; KEYWORDS: ; None ; COMMON BLOCKS: ; C_SYSTEM, C_HEADER, and DISR blocks needed. ; SIDE EFFECTS: ; NONE ; RESTRICTIONS: ; NONE ; PROCEDURE: ; Pick up the anomalies table. ; Read the header of each entry in the filelist. ; Test whether it is a good header. ; Test the value. Report. ; MODIFICATION HISTORY: ; 13-01-1994 NT Prototype ; 21-01-1994 NT Bug fix on header error. ; 27-02-1994 NT Inclusion of D_PARSE sub-routine. ; 16-03-1994 NT Removal of spurious print statement. ; 06-06-1994 LED Corrected constraints to be consistent with d_anom.doc ; Eliminated D_EXIST call ; Moved min and max values out of the filelist loop ; Added detail in print statements ; 06-19-1994 GK Changed d_rhead to f_rhead (common block) ; 06-23-1994 LED Restructure to work stand alone ; 06-24-1994 LED Tested against test log "baptism2". Manually read ; in the headers and compared to the d_anom.doc ; and anomaly.dat. Following files were tested: ; Dark #72 ; Housekeeping #57 ; Image #178 ; IR #1 ; Lamp #259 ; ;---------------------------------------------------------------------------- ; D I S R S O F T (C) 1 9 9 4 ;----------------------------------------------------------------------------- ;- @c_system.inc @c_header.inc @disr.inc h=strarr(256) STATUS=STRARR(4) STATUS(0)='S' STATUS(1)='SUCCESS' ; USER enter name of routine inside quotes STATUS(2)='anomaly' ; leave this STATUS(3)='' ; enter version number inside quotes VERSION='V2.0' ; enter the full procedure call in here CALL='anomaly' ; error checking ---- insert maximum and minimum number of parameter IF (N_PARAMS(0) GT 0) THEN BEGIN PRINT,' ' PRINT,STRTRIM(STRUPCASE(STATUS(2)),2)+' : Bad input parameters. EXIT.' PRINT,'Call is '+CALL STATUS(0)='F' STATUS(1)='FAILURE' STATUS(3)='Bad input parameters' GOTO,LEAVE ENDIF ; check keyword settings and set switches CONSTRAINT=0 spawn,'find DB/* -type f -print',FILELIST FILENAME='post/anomaly.dat' print,'Checking out the filelist and reading the anomaly document' ; verify the filelist Z_FILELIST=SIZE(FILELIST) IF (Z_FILELIST(0) NE 1) OR (Z_FILELIST(2) NE 7) THEN BEGIN STATUS(0)='F' STATUS(1)='FAILURE' STATUS(3)='Filelist not a uni-dimensional string array' PRINT,' ' PRINT,STRTRIM(STRUPCASE(STATUS(2)),2)+' : '+STATUS(3)+'. EXIT.' GOTO,LEAVE ENDIF ; read in the anomaly table GET_LUN,UNIT1 ON_IOERROR,CLOSING ANOM_FILE=D_PARSE('DOC','D_ANOM.DOC',STATUS1) IF STRUPCASE(STRMID(STRTRIM(STATUS1(0),2),0,1)) NE 'S' THEN BEGIN STATUS(0)='F' STATUS(1)='FAILURE' STATUS(3)='D_PARSE failure' PRINT,' ' PRINT,STRTRIM(STRUPCASE(STATUS(2)),2)+$ ' : '+STATUS(3)+'. EXIT.' GOTO,LEAVE ENDIF OPENR,UNIT1,ANOM_FILE ANOMALY_FILE='' ALF='' WHILE NOT EOF(UNIT1) DO BEGIN READF,UNIT1,ALF ANOMALY_FILE=[ANOMALY_FILE,STRMID(ALF,25,65)] ENDWHILE CLOSE,UNIT1 ANOMALY_FILE=ANOMALY_FILE(2:*) ; to increase speed determine which entries have anomaly tests TEST_THESE=WHERE(STRTRIM(ANOMALY_FILE,2) NE '') Z_TEST=SIZE(TEST_THESE) IF TEST_THESE(0) EQ -1 THEN BEGIN STATUS(0)='F' STATUS(1)='FAILURE' STATUS(3)='No anomaly criteria set. Check d_anom.doc' PRINT,' ' PRINT,STRTRIM(STRUPCASE(STATUS(2)),2)+' : '+STATUS(3)+'. EXIT.' GOTO,LEAVE ENDIF ; Trim up the min and max for all anomaly entries MINIMUM=strarr(Z_TEST(1)) MAXIMUM=strarr(Z_TEST(1)) FOR J=0,Z_TEST(1)-1 DO BEGIN MINIMUM(J)=STRTRIM(STRMID(ANOMALY_FILE(TEST_THESE(J)),CONSTRAINT*30,15),2) MAXIMUM(J)=STRTRIM(STRMID(ANOMALY_FILE(TEST_THESE(J)),CONSTRAINT*30+15,15),2) ENDFOR ; set a switch SWITCH=0 OPENW,UNIT1,FILENAME print,'I am looping through every data set and verifying the header entries' print,'I will look at ',Z_FILELIST(1),' files' ; now begin to read data FOR I=0,Z_FILELIST(1)-1 DO BEGIN print,format='(".",$) FILE=FILELIST(I) F_RHEAD ; now perform checks FOR J=0,Z_TEST(1)-1 DO BEGIN HEADER_ENTRY=D_VALUE(H,TEST_THESE(J),GOOD,STATUS1) IF STATUS1(0) EQ 'S' THEN BEGIN IF MINIMUM(J) NE '' THEN BEGIN IF FLOAT(HEADER_ENTRY) LT FLOAT(MINIMUM(J)) THEN BEGIN SWITCH=1 ERROR=FILELIST(I)+' '+C_NAMES(TEST_THESE(J))+$ ' low '+STRING(HEADER_ENTRY,'(F11.4)')+' '+$ STRING(MINIMUM(J),'(F11.4)') PRINTF,UNIT1,ERROR ENDIF ENDIF IF MAXIMUM(J) NE '' THEN BEGIN IF FLOAT(HEADER_ENTRY) GT FLOAT(MAXIMUM(J)) THEN BEGIN SWITCH=1 ERROR=FILELIST(I)+' '+C_NAMES(TEST_THESE(J))+$ ' high '+STRING(HEADER_ENTRY,'(F11.4)')+' '+$ STRING(MAXIMUM(J),'(F11.4)') PRINTF,UNIT1,ERROR ENDIF ENDIF ENDIF ENDFOR NEXT: ENDFOR print,'' IF SWITCH EQ 0 THEN BEGIN PRINTF,UNIT1,'No errors found.' ENDIF FREE_LUN,UNIT1 ; cleaning up for file manipulation errors GOTO,LEAVE CLOSING: STATUS(0)='F' STATUS(1)='FAILURE' STATUS(3)='I/O error' ; if the status parameter is not set then print to screen PRINT,' ' PRINT,STRTRIM(STRUPCASE(STATUS(2)),2)+' : '+STATUS(3)+'. Exiting.' FREE_LUN,UNIT1 LEAVE: RETURN ; or RETURN,OUTPUT if the program is a function END