From c42cc0e090c500711e488ce9ac01efe66161b82b Mon Sep 17 00:00:00 2001 From: Ian Boyd <iboyd@astro.umass.edu> Date: Wed, 18 Dec 2024 03:24:59 +0000 Subject: [PATCH] Replace idlcr8hdf.pro --- idlcr8hdf.pro | 98 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 60 insertions(+), 38 deletions(-) diff --git a/idlcr8hdf.pro b/idlcr8hdf.pro index 0ab1c94..66c24ce 100644 --- a/idlcr8hdf.pro +++ b/idlcr8hdf.pro @@ -1,4 +1,4 @@ -;Main Program Version: idlcr8hdf.pro v4.0b66, 20241126 +;Main Program Version: idlcr8hdf.pro v4.0b67, 20241218 ; Written by Ian Boyd for the EVDC/AVDC - iboyd@bryanscientific.org ; ;Sub-versions (refer to idlcr8hdf-v4.0_Readme.pdf for full history) @@ -113,7 +113,7 @@ PRO intro, intype COMMON WIDGET_WIN nhdr=44 & errtxt=STRARR(nhdr) -vertxt=['idlcr8hdf-v4.0_Readme.pdf','v4.0b66 November 2024'] +vertxt=['idlcr8hdf-v4.0_Readme.pdf','v4.0b67 December 2024'] errtxt[1]='Welcome to IDLcr8HDF. This program creates GEOMS compliant HDF4, HDF5 and netCDF files' errtxt[2]='(also refer to '+vertxt[0]+').' errtxt[4]='Inputs to the program (IDL Virtual Machine (VM) and IDL Licensed (LIC) Versions):' @@ -4650,6 +4650,9 @@ PRO read_data, sds, inf ; for identifying invalid wind speed or direction values - Version 4.0b43 ; 20201020: Add check for negative random uncertainty values (standard or relative only) ; - Version 4.0b56 +; 20241218: Identify fill values before checking that the vertical dimension values are +; monotonically increasing or decreasing. Needed for Pandora off-axis measurements +; - Version 4.0b67 ; ; Inputs: sds - Either a structure containing the Variable Attributes and Data, or the input ; data file @@ -4903,22 +4906,28 @@ FOR vc=0,N_ELEMENTS(bchks)-1 DO BEGIN bvals=DOUBLE(REFORM(dtest,ndm[bci[0],di])) ;put into array order and make numeric IF nbcnt EQ 1 THEN n_sec=ndm[bci[0],nbi[0]] ELSE n_sec=1L ;Number of datasets to be read through IF bi[0] NE 0 THEN bvals=TRANSPOSE(bvals) ;make ALTITUDE or PRESSURE array the first index + ;determine the VAR_FILL_VALUE for the dataset + zci=WHERE(mv_dbl[*,bci[0]] NE 0.d,zccnt) + IF zccnt NE 0 THEN bvtfv=mv_dbl[2,bci[0]] ELSE bvtfv=DOUBLE(mv_lng[2,bci[0]]) FOR i=0L,n_sec-1L DO BEGIN ;e.g. number of DATETIME values or single loop if only one dimension - bvtest=bvals[*,i] ;set of PRESSURES or ALTITUDES to be tested - asc=-1 - IF ARRAY_EQUAL(bvtest,bvtest[SORT(bvtest)]) THEN asc=1 $ ;ascending order - ELSE IF ARRAY_EQUAL(bvtest,bvtest[REVERSE(SORT(bvtest))]) THEN asc=0 ;descending order - IF ascending EQ -1 THEN ascending=asc - IF (asc EQ -1) OR (ascending NE asc) THEN BEGIN ;altitudes/pressures not in any order - IF (ascending NE -1) AND (writeonce[1] EQ 1) THEN BEGIN ;more than one dimension and error in one or more of the sets - IF ascending EQ 1 THEN itxt='increasing' ELSE itxt='decreasing' - infotxt='3 '+bchks[vc]+' values not in '+itxt+' order for every '+vdvals[nbi[0]]+' for '+meta_arr[mi[0]] - INFOTXT_OUTPUT,infotxt - writeonce[1]=0 - ENDIF ELSE IF writeonce[0] EQ 1 THEN BEGIN - infotxt='3 '+bchks[vc]+' values not monotonically increasing or decreasing for '+meta_arr[mi[0]] - INFOTXT_OUTPUT,infotxt - writeonce[0]=0 + gvi=WHERE(bvals[*,i] NE bvtfv,gvcnt) ;check for fill values + IF gvcnt GT 1 THEN BEGIN ;can't do monotonic test if there is only one value + bvtest=bvals[gvi,i] ;set of PRESSURES or ALTITUDES to be tested + asc=-1 + IF ARRAY_EQUAL(bvtest,bvtest[SORT(bvtest)]) THEN asc=1 $ ;ascending order + ELSE IF ARRAY_EQUAL(bvtest,bvtest[REVERSE(SORT(bvtest))]) THEN asc=0 ;descending order + IF ascending EQ -1 THEN ascending=asc + IF (asc EQ -1) OR (ascending NE asc) THEN BEGIN ;altitudes/pressures not in any order + IF (ascending NE -1) AND (writeonce[1] EQ 1) THEN BEGIN ;more than one dimension and error in one or more of the sets + IF ascending EQ 1 THEN itxt='increasing' ELSE itxt='decreasing' + infotxt='3 '+bchks[vc]+' values not in '+itxt+' order for every '+vdvals[nbi[0]]+' for '+meta_arr[mi[0]] + INFOTXT_OUTPUT,infotxt + writeonce[1]=0 + ENDIF ELSE IF writeonce[0] EQ 1 THEN BEGIN + infotxt='3 '+bchks[vc]+' values not monotonically increasing or decreasing for '+meta_arr[mi[0]] + INFOTXT_OUTPUT,infotxt + writeonce[0]=0 + ENDIF ENDIF ENDIF ENDFOR @@ -4978,6 +4987,9 @@ FOR vc=0,N_ELEMENTS(bchks)-1 DO BEGIN ENDIF ELSE option=0 IF option NE 0 THEN BEGIN + ;Determine the VAR_FILL_VALUE + zci=WHERE(mv_dbl[*,bbci[0]] NE 0.d,zccnt) + IF zccnt NE 0 THEN bvtfv=mv_dbl[2,bci[0]] ELSE bvtfv=DOUBLE(mv_lng[2,bci[0]]) writeonceb=[1,1] FOR i=0L,n_sec-1L DO BEGIN FOR j=0,n_ind-1 DO BEGIN ;check that order of the boundary sets matches the axis variable ordering @@ -4987,16 +4999,21 @@ FOR vc=0,N_ELEMENTS(bchks)-1 DO BEGIN 3: bvtest=bvals[*,i,j] 4: bvtest=bvals[j,*,i] ENDCASE - asc=-1 - IF ARRAY_EQUAL(bvtest,bvtest[SORT(bvtest)]) THEN asc=1 $ ;ascending order - ELSE IF ARRAY_EQUAL(bvtest,bvtest[REVERSE(SORT(bvtest))]) THEN asc=0 ;descending order - - IF (ascending NE asc) AND (writeonceb[0] EQ 1) THEN BEGIN - ;order of the boundaries dataset does not match axis dataset - IF ascending EQ 1 THEN itxt='increasing' ELSE itxt='decreasing' - infotxt='3 '+bchks[vc]+'.BOUNDARIES order does not match '+bchks[vc]+' '+itxt+' ordering for '+meta_arr[mi[0]] - INFOTXT_OUTPUT,infotxt - writeonceb[0]=0 + ;check for VAR_FILL_VALUES in bvtest + gvi=WHERE(bvtest NE bvtfv,gvcnt) + IF gvcnt GT 1 THEN BEGIN + bvtest=bvtest[gvi] + asc=-1 + IF ARRAY_EQUAL(bvtest,bvtest[SORT(bvtest)]) THEN asc=1 $ ;ascending order + ELSE IF ARRAY_EQUAL(bvtest,bvtest[REVERSE(SORT(bvtest))]) THEN asc=0 ;descending order + + IF (ascending NE asc) AND (writeonceb[0] EQ 1) THEN BEGIN + ;order of the boundaries dataset does not match axis dataset + IF ascending EQ 1 THEN itxt='increasing' ELSE itxt='decreasing' + infotxt='3 '+bchks[vc]+'.BOUNDARIES order does not match '+bchks[vc]+' '+itxt+' ordering for '+meta_arr[mi[0]] + INFOTXT_OUTPUT,infotxt + writeonceb[0]=0 + ENDIF ENDIF ENDFOR ENDFOR @@ -5009,16 +5026,21 @@ FOR vc=0,N_ELEMENTS(bchks)-1 DO BEGIN 3: bvtest=bvals[j,i,*] 4: bvtest=bvals[*,j,i] ENDCASE - asc=-1 - IF ARRAY_EQUAL(bvtest,bvtest[SORT(bvtest)]) THEN asc=1 $ ;ascending order - ELSE IF ARRAY_EQUAL(bvtest,bvtest[REVERSE(SORT(bvtest))]) THEN asc=0 ;descending order - - IF (ascending NE asc) AND (writeonceb[1] EQ 1) AND (ftirchk EQ 0) THEN BEGIN - ;order of the boundaries values does not match axis dataset - IF ascending EQ 1 THEN itxt='increasing' ELSE itxt='decreasing' - infotxt='3 Boundary index order does not match '+bchks[vc]+' '+itxt+' ordering for '+meta_arr[mi[0]] - INFOTXT_OUTPUT,infotxt - writeonceb[1]=0 + ;check for VAR_FILL_VALUES in bvtest + gvi=WHERE(bvtest NE bvtfv,gvcnt) + IF gvcnt GT 1 THEN BEGIN + bvtest=bvtest[gvi] + asc=-1 + IF ARRAY_EQUAL(bvtest,bvtest[SORT(bvtest)]) THEN asc=1 $ ;ascending order + ELSE IF ARRAY_EQUAL(bvtest,bvtest[REVERSE(SORT(bvtest))]) THEN asc=0 ;descending order + + IF (ascending NE asc) AND (writeonceb[1] EQ 1) AND (ftirchk EQ 0) THEN BEGIN + ;order of the boundaries values does not match axis dataset + IF ascending EQ 1 THEN itxt='increasing' ELSE itxt='decreasing' + infotxt='3 Boundary index order does not match '+bchks[vc]+' '+itxt+' ordering for '+meta_arr[mi[0]] + INFOTXT_OUTPUT,infotxt + writeonceb[1]=0 + ENDIF ENDIF ENDFOR ENDFOR @@ -6166,7 +6188,7 @@ PRO idlcr8hdf, ga, sds, tav, odir, reterr, H5=o1, AVK=o2, LOG=o4, POPUP=o5, QA=o ; ;Program documentation, idlcr8hdf-v4.0_Readme.pdf, available from http://avdc.gsfc.nasa.gov. ; -;Program sub-version 4.0b66 (20241126) +;Program sub-version 4.0b67 (20241218) ; ---------- ;Written by Ian Boyd for the EVDC/AVDC - iboyd@bryanscientific.org ; -- GitLab