Commit f5904a06 authored by Ian Boyd's avatar Ian Boyd
Browse files

Replace geoms_tools.pro

parent a12913fa
;Main Program Version: geoms_tools.pro v2.08, 20201122
;Main Program Version: geoms_tools.pro v2.09, 20201211
; Written by Ian Boyd for AVDC/EVDC - iboyd@astro.umass.edu
;
FUNCTION is_a_number_gt,value
......@@ -296,34 +296,39 @@ END ;Procedure GEOMS_One_Off_Check
PRO read_tav_dates, tavdir, min_ver, tavall, tavmjd2k
PRO read_tav_dates, tavdir, min_ver, tavall, tavmjd2k, tavver
;Procedure to create arrays of all available TAV files and their creation dates
; ----------
;Written by Ian Boyd for AVDC/EVDC - iboyd@astro.umass.edu
;
;History:
; 20201122: Introduced to geoms_tools - Version 2.08
; 20201211: Add tavver; include search for '_idl' versions of the TAV files and
; make searches case insensitive; ensure TAV files are saved in
; chronological order - Version 2.09
;
;Inputs: tavdir - Directory containing all the TAV files
; min_ver - Minimum version numner for valid TAV files
;
;Output: tavall - an array containing the fully qualified TAV file names
; tavmjd2k - an array containing the TAV file creation dates in MJD2K form
; tavver - an array containing the TAV version values
;
;Called by: TAV_Files_For_QA
;
;Subroutines Called: None
;
tavall=FILE_SEARCH(tavdir+'tableattrvalue_*.dat',COUNT=tcnt)
pathspec=['tableattrvalue_??R???.dat','tableattrvalue_??R???_idl.dat']
FOR i=0,N_ELEMENTS(pathspec)-1 DO pathspec[i]=tavdir+pathspec[i]
tavall=FILE_SEARCH(pathspec,FOLD_CASE=1,/FULLY_QUALIFY_PATH,/TEST_READ,COUNT=tcnt)
tavymd=[-1L] ;default TAVYMD array
dum=''
IF tcnt NE 0 THEN BEGIN
gdtav=BYTARR(tcnt) & tav_vr_vals=INTARR(2)-1
tavver=STRARR(tcnt) & tav_vr_vals=INTARR(2)-1
FOR i=0,tcnt-1 DO BEGIN
tavname=FILE_BASENAME(tavall[i])
tav_chk=STRSPLIT(tavname,'_.',/EXTRACT,COUNT=rcnt)
tav_chk=[tav_chk,''] ;ensure it has at least 2 values
;Determine version and revision values
IF STRLEN(tav_chk[1]) EQ 6 THEN BEGIN
tav_vr=[STRMID(tav_chk[1],0,2),STRMID(tav_chk[1],3)]
......@@ -331,13 +336,14 @@ IF tcnt NE 0 THEN BEGIN
IF IS_A_NUMBER_GT(tav_vr[fi]) THEN tav_vr_vals[fi]=FIX(tav_vr[fi])
ENDFOR
;Check for valid TAV version and revision
IF (tav_vr_vals[0] GE min_ver) AND (tav_vr_vals[1] GE 0) THEN gdtav[i]=1B
IF (tav_vr_vals[0] GE min_ver) AND (tav_vr_vals[1] GE 0) THEN tavver[i]=tav_chk[1]
ENDIF
ENDFOR
;Create list of all valid TAV files
gi=WHERE(gdtav,gcnt)
gi=WHERE(tavver NE '',gcnt)
IF gcnt NE 0 THEN BEGIN
tavall=tavall[gi]
tavver=tavver[gi]
tavmjd2k=DBLARR(gcnt)
FOR i=0,gcnt-1 DO BEGIN
OPENR,tu,tavall[i],/GET_LUN
......@@ -354,7 +360,7 @@ IF tcnt NE 0 THEN BEGIN
tiso=tymd[0]+tymd[1]+tymd[2]+'T'+thms[0]+thms[1]+thms[2]+'Z'
IF n_chk THEN BEGIN
mjdcalc=JULIAN_DATE(tiso,/I,/M)
TAVMJD2k[i]=mjdcalc
tavmjd2k[i]=mjdcalc
ENDIF
ENDIF
ENDIF
......@@ -362,8 +368,14 @@ IF tcnt NE 0 THEN BEGIN
ENDIF
ENDIF
;Sort tav files into chronological order (in case there are both full and _idl versions of the files)
tmjdi=SORT(tavmjd2k)
tavmjd2k=tavmjd2k[tmjdi] & tavall=tavall[tmjdi] & tavver=tavver[tmjdi]
END
PRO tav_files_for_qa, tav, ga, lu, tavlist, gf_err, cur_tav
;Procedure to determine TAV file versions needed for definition checks when doing QA,
;based on FILE_GENERATION_DATE (FGD) and FILE_META_VERSION (FMV) values
......@@ -372,6 +384,8 @@ PRO tav_files_for_qa, tav, ga, lu, tavlist, gf_err, cur_tav
;
;History:
; 20201122: Introduced to geoms_tools - Version 2.08
; 20201211: Include search for '_idl' versions of the TAV files and make searches
; case insensitive - Version 2.09
;
;Inputs: tav - TAV file used in call to geoms_qa
; ga - Global attributes read in by idlcr8ascii
......@@ -387,11 +401,11 @@ PRO tav_files_for_qa, tav, ga, lu, tavlist, gf_err, cur_tav
;
;Subroutines Called: Read_TAV_Dates
;
tavlist=STRARR(3)
tavlist=STRARR(2)
tavdir=FILE_DIRNAME(tav,/MARK_DIRECTORY)
min_ver=4 ;minimum allowable TAV version
;Read in all the TAV filenames and definition creation dates
READ_TAV_DATES,tavdir,min_ver,tavall,tavmjd2k
READ_TAV_DATES,tavdir,min_ver,tavall,tavmjd2k,tavver
;Identify input TAV file version and revision number
tav_vr_vals=INTARR(2)-1
......@@ -419,7 +433,7 @@ FOR i=0,1 DO BEGIN
IF gfcnt EQ 1 THEN BEGIN
res=STRSPLIT(ga[gfi[0]],' =;',/EXTRACT,COUNT=rcnt)
IF rcnt EQ n_spl[i]+1 THEN BEGIN
gf_val=STRTRIM(STRUPCASE(res[1]),2)
gf_val=STRTRIM(res[1],2)
IF i EQ 0 THEN BEGIN
gf_valh=gf_val
fgd_chk=JULIAN_DATE(gf_valh,/I,/M)
......@@ -436,13 +450,16 @@ FOR i=0,1 DO BEGIN
invalid_gf=0B
IF STRLEN(gf_val) EQ 6 THEN BEGIN
;Check version and revision values
gf_vr=[STRMID(gf_val,0,2),STRMID(gf_val,3)]
FOR fi=0,1 DO BEGIN
IF IS_A_NUMBER_GT(gf_vr[fi]) THEN gf_vr_vals[fi]=FIX(gf_vr[fi])
ENDFOR
test2=(gf_vr_vals[0] GE min_ver) AND (gf_vr_vals[1] GE 0)
gf_tav_chk=tavdir+'tableattrvalue_'+gf_val+'.dat'
IF FILE_TEST(gf_tav_chk) THEN gf_tav=gf_tav_chk
;gf_vr=[STRMID(gf_val,0,2),STRMID(gf_val,3)]
;FOR fi=0,1 DO BEGIN
; IF IS_A_NUMBER_GT(gf_vr[fi]) THEN gf_vr_vals[fi]=FIX(gf_vr[fi])
;ENDFOR
;test2=(gf_vr_vals[0] GE min_ver) AND (gf_vr_vals[1] GE 0)
test2=1B ;test is redundant because tavver version and revision values already checked
gi=WHERE(gf_val EQ tavver,gcnt) ;case sensitive check
IF gcnt EQ 0 THEN $
gi=WHERE(STRUPCASE(gf_val) EQ STRUPCASE(tavver),gcnt) ;case insensitive check
IF gcnt NE 0 THEN gf_tav=tavall[gi[0]]
ENDIF
ENDELSE
ENDIF
......@@ -475,7 +492,7 @@ FOR i=0,1 DO BEGIN
gf_err=1B
ENDIF
ENDFOR
IF STRUPCASE(tavlist[0]) EQ STRUPCASE(tavlist[1]) THEN tavlist[1]=''
IF STRUPCASE(tavlist[0]) EQ STRUPCASE(tavlist[1]) THEN tavlist[1]=''
END ;Procedure tav_files_for_QA
......@@ -1231,7 +1248,7 @@ FUNCTION geoms_tools, optqh, tav, hdfqh, outdir, dataformat, DATETIME=o1, NOTC=o
; geoms-harmon-v1.0_Readme.pdf, available from http://avdc.gsfc.nasa.gov.
; idlcr8ascii-v4.0_Readme.pdf, available from http://avdc.gsfc.nasa.gov.
; idlcr8hdf-v4.0_Readme.pdf, available from http://avdc.gsfc.nasa.gov.
;Program sub-version 2.08 (20201122)
;Program sub-version 2.09 (20201211)
; ----------
;Written by Ian Boyd for AVDC/EVDC - iboyd@astro.umass.edu
;
......@@ -1331,6 +1348,9 @@ FUNCTION geoms_tools, optqh, tav, hdfqh, outdir, dataformat, DATETIME=o1, NOTC=o
; FILE_META_VERSION (FMV), if different. This adds a check for the FMV TAV version
; using definitions that are out-of-date. If either TAV can't be determined or found
; then the input TAV will be used for checks and an error generated - Version 2.08
; 20201211: Apply fixes and improvements to procedures identifying correct TAV version(s) to
; use for checks; Fix IDL Math Error (Floating Illegal Operand) in idlcr8hdf
; - Version 2.09
;
; Input: optqh - Integer defining type of testing 0=QA, 1=Harmonization
; tav - Table Attribute Values file used to test Metadata
......@@ -1367,7 +1387,7 @@ FUNCTION geoms_tools, optqh, tav, hdfqh, outdir, dataformat, DATETIME=o1, NOTC=o
; memory. The output from IDLCR8ASCII is then used in the call to:
; IDLCR8HDF - which performs the QA
gtver='geoms_tools version 2.08, 2020-11-22'
gtver='geoms_tools version 2.09, 2020-12-11'
gt_error_code=3 ;Integer to identify return error code (3 = Invalid input)
par1chk=0 & parchk=0
IF N_PARAMS() GE 1 THEN BEGIN ;test first parameter only
......@@ -1641,7 +1661,12 @@ ENDIF ELSE BEGIN ;Commence QA or Harmonization on HDF files
IF tavcnt EQ 2 THEN BEGIN
tav_err_chk=BYTARR(2)
tavrv=STRARR(2)
FOR j=0,1 DO tavrv[j]=STRMID(tav_name[j],STRPOS(tav_name[j],'_',/REVERSE_SEARCH)+1,6)
FOR j=0,1 DO BEGIN
IF STRMID(tav_name[j],STRLEN(tav_name[j])-8) EQ '_idl.dat' THEN $
tnh=STRMID(tav_name[j],0,STRLEN(tav_name[j])-8) $
ELSE tnh=tav_name[j]
tavrv[j]=STRMID(tnh,STRPOS(tnh,'_',/REVERSE_SEARCH)+1,6)
ENDFOR
;Check QA using FGD or input TAV for errors
FOR j=0,tavi[1]-1 DO $
IF STRMID(STRTRIM(qh_s2[j],2),0,5) EQ 'ERROR' THEN tav_err_chk[0]=1B
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment