Commit 516ab96f authored by Ian Boyd's avatar Ian Boyd
Browse files

Replace cds_tools.pro

parent ac9b5e06
;Main Program Version: cds_tools.pro Release v2.0b55, 20180901
;Main Program Version: cds_tools.pro Release v2.0b56, 20181116
; Written by Ian Boyd for the AVDC/EVDC - iboyd@astro.umass.edu
;Sub-versions:
; 20090828: Initial Release for testing - v0.1
......@@ -145,13 +145,14 @@
; 20170331, Update due to improvements to idlcr8hdf - v2.0b51
; 20171121, Update due to fixes in idlcr8hdf - v2.0b52
; 20180622, Fix to read SHADOZ station name from file when there is an extra comment
; in the entry (e.g. Hanoi, Vietnam (...)); Include updates made in
; in the entry (e.g. Hanoi, Vietnam (...)); Include updates made in
; idlcr8hdf and idlcr8ascii - v2.0b53
; 20180816, Fix for incorrect calculation of O3 number density when the insitu
; 20180816, Fix for incorrect calculation of O3 number density when the insitu
; temperatures are in K. Previously assumed the temperatures were always
; in Celcius (affected NDACC NASA Ames only) - v2.0b54
; 20180901, Previous fix caused crash when checking non-NDACC measurements. Fixed in
; this version - v2.0b55
; 20181116 Update due to fix in idlcr8ascii - v2.0b56
;Program to read in a file or string array created by CDS_Match (or equivalent) and,
;based on the input information, convert NDACC NASA/AMES, WOUDC CSV, SHADOZ, NOAA-ESRL or
......@@ -701,7 +702,7 @@ IF nw EQ 'N' THEN BEGIN
IF ndcnt EQ 0L THEN BEGIN
;determine if database header is present in the file or not
res=STRSPLIT(dum,' ',/EXTRACT,COUNT=hcnt)
IF hcnt EQ 2 THEN dbhdr=0 ELSE dbhdr=1
IF hcnt EQ 2 THEN dbhdr=0 ELSE dbhdr=1
ENDIF
ndcnt++
ENDWHILE
......@@ -712,7 +713,7 @@ IF nw EQ 'N' THEN BEGIN
READF,iu,ndfin
FREE_LUN,iu
ndfin=STRTRIM(ndfin,2) ;remove leading and trailing spaces
;check for and remove any empty lines at the end of the file e.g. so180122.z10
;check for and remove any empty lines at the end of the file e.g. so180122.z10
WHILE ndfin[ndcnt-1L] EQ '' DO BEGIN
ndfin=ndfin[0:ndcnt-2L]
ndcnt--
......@@ -740,7 +741,7 @@ IF nw EQ 'N' THEN BEGIN
ndcnt=ndcnt+3L
ENDIF
ENDIF
;For Ny-Alesund (2018 format) check for missing Radiosonde type information
IF STRMID(STRLOWCASE(infile),0,2) EQ 'na' THEN BEGIN
IF dbhdr EQ 1 THEN chki=153 ELSE chki=152
......@@ -748,9 +749,9 @@ IF nw EQ 'N' THEN BEGIN
IF resncnt EQ 3 THEN BEGIN
ndfin=[ndfin[0:chki-4L],'zzzzzzzzzzzzzzzzzzzz',ndfin[chki-3L:ndcnt-1L]]
ndcnt++
ENDIF
ENDIF
ENDIF
;write data to temporary file - remove any special case errors in the file
OPENW,ou,indir+tempfile,/GET_LUN
FOR i=0L,ndcnt-1L DO BEGIN
......@@ -2018,7 +2019,7 @@ IF conv_test THEN BEGIN
IF pcnt EQ 5 THEN IF STRUPCASE(pres[4]) EQ 'V' THEN vcnt=vcnt+1
ENDREP UNTIL sres[j] EQ STRUPCASE(pres[0])
tempconv=pres[3]
IF nw EQ 'N' THEN BEGIN
pres1=STRSPLIT(pres[1],'|',/EXTRACT,count=nres1) & pres1=STRTRIM(pres1,2)
m=0 & scnt=0
......@@ -3049,7 +3050,7 @@ IF metaok EQ '' THEN BEGIN
sectionb=secbh
ENDIF
ENDIF
ENDIF
ENDIF
ENDIF ELSE IF (nw EQ 'W') OR (nw EQ 'S') OR (nw EQ 'E') THEN BEGIN ;WOUDC, SHADOZ or NOAA style
mv=STRTRIM(LONG(colsclfill[1]),2) ;dummy value in holddata (if changing need to also change value in WRITE_DATA routine)
sbi=INTARR(n_sds-1) ;array to hold the valid section (b) index values for each variable
......@@ -3065,7 +3066,15 @@ IF metaok EQ '' THEN BEGIN
resx=['']
READ_WOUDC_SECTION,ndacc,si[0],resx
nx=N_ELEMENTS(resx)-1L ;& nxprof=nx
ENDIF
ENDIF ELSE BEGIN
;Special case where #PROFILE is at the end of the line as opposed to the start of a new line
si=WHERE(STRPOS(ndacc,res[0]) NE -1,scnt)
IF scnt EQ 1 THEN BEGIN
resx=['']
READ_WOUDC_SECTION,ndacc,si[0],resx
nx=N_ELEMENTS(resx)-1L ;& nxprof=nx
ENDIF ELSE nx=0
ENDELSE
ENDIF ELSE BEGIN ;read in SHADOZ or NOAA profile information
nx=0L & pstart=2L & nhl=-1L
IF nw EQ 'S' THEN BEGIN
......@@ -3668,7 +3677,7 @@ FUNCTION cds_tools, listf, tav, outdir, dataformat, DATETIME=o1
;Initialize statusflag, and exit_code
statusflag='' & dum='' & exit_code=3
cdver='cds_tools version 2.0b55, 2018-09-01'
cdver='cds_tools version 2.0b56, 2018-11-16'
;Check input parameters
IF N_PARAMS() LT 3 THEN $
......
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