FUNCTION READ_SOUNDING, temperature=temperature, dewpt=dewpt, height= height, maxlines=maxlines ; result = READ_SOUNDING([temperature=temperature], [dewpt=dewpt], [height=height], [maxlines=maxlines]) ; ; Upon calling READ_SOUNDING a file dialog prompts the user to select a sounding file ; to read ; ; result: on exit contains data of all the pressures recorded in the sounding (millibars) ; ; KEYWORDS: ; temperature: if present, upon exit contains corresponding values of temeprature from ; the sounding (degrees C) ; dewpt: if present, upon exit contains corresponding values of the dewpoint from the ; the sounding (degrees C) ; height: if present, upon exit contains the corresponding heights from the sounding(in meters) ; maxlines: if present, passes the maximum number of lines to read in the sounding ; ;this is a function that can be used to read a specially formatted sounding file ; it is current setup to return pressure, it can return the value of temperature ; with use of the keyword temperature ;here we prompt the user to open a file, and we insure the file exists, if not ;we exit the function and return -1 infile = DIALOG_PICKFILE(TITLE="Please select a sounding file to read") IF (infile EQ '') THEN BEGIN PRINT,"No File was selectected, exiting procedure" RETURN, -1 ENDIF ; if the user does not call routine with maxlines keyword set, then set maxlines to ; 500 IF NOT KEYWORD_SET(maxlines) THEN maxlines = 500 OPENR, unit, infile, /GET_LUN ;set up the pressure and temperature variables as arrays of size maxlines pvar = DBLARR(maxlines) & tvar = DBLARR(maxlines) hgtvar = DBLARR(maxlines) & dvar = DBLARR(maxlines) ;read the first line which is a header line1='' READF, unit, line1 ;read the data (rest of the lines) and set the variables appropriately countlines = 0 WHILE NOT EOF(unit) DO BEGIN IF (countlines EQ 500) THEN BEGIN PRINT,"Number of lines in sounding file exceeded ",maxlines BREAK ENDIF READF, unit, var1, var2, var3, var4, var5, var6, var7, var8, var9, var10, var11 pvar[countlines] = var1 hgtvar[countlines] = var2 tvar[countlines] = var3 dvar[countlines] = var4 countlines = countlines+1 ENDWHILE CLOSE, unit ;copy temperature and pressure dat ato the variables to be returned temperature = tvar[0:countlines-1] dewpt = dvar[0:countlines-1] height = hgtvar[0:countlines-1] pressure = pvar[0:countlines-1] RETURN, pressure END