PRO PlotModes ;------------------------------------------------------------------------------ ; Code to take stats.html output from a cov print job and output plots of ; vertical modes of Ap ; ; Ross Bannister, NCEO, University of Reading ; ; February 2009 ;------------------------------------------------------------------------------ Nlevs = 70 Zvalues = FLTARR(Nlevs) Modes = FLTARR(Nlevs,Nlevs) BlankLine = '' TempInt = 0 TempFloat = 0.0 TempFloat1 = 0.0 ;------------------------------------------------------------------------------ ; Open the input file and read level heights ;------------------------------------------------------------------------------ OPENR, 1, 'stats.html' ; Find the appropriate point in the intput file REPEAT BEGIN READF, 1, BlankLine found = STRPOS(BlankLine,'Average pressures and derived inner products') ENDREP UNTIL (found GT -1) READF, 1, BlankLine READF, 1, BlankLine READF, 1, BlankLine READF, 1, BlankLine ; Read the heights of the levels FOR lev = 1, Nlevs DO BEGIN READF, 1, TempInt, TempFloat1, TempFloat Zvalues(lev-1) = TempFloat ;PRINT, lev, Zvalues(lev-1) ENDFOR ;------------------------------------------------------------------------------ ; Read vertical modes ;------------------------------------------------------------------------------ ; Find the appropriate point in the intput file REPEAT BEGIN READF, 1, BlankLine found = (STRPOS(BlankLine,'CovVerticalPrint. Vertical modes for') GT -1) && (STRPOS(BlankLine,'Ap') GT -1) ENDREP UNTIL (found) ; Now find the second occurrence of another string REPEAT BEGIN READF, 1, BlankLine found = STRPOS(BlankLine,'VWRmode Pct Cum') ENDREP UNTIL (found GT -1) REPEAT BEGIN READF, 1, BlankLine found = STRPOS(BlankLine,'VWRmode Pct Cum') ENDREP UNTIL (found GT -1) ; Data is output on lines in batches of 20 ; Find out how many lines corresponds to Nlevs Nlines = FLOOR(Nlevs / 20.0 + 0.999999999999) PRINT, 'There are ', Nlines, 'batches of 20' IF (Nlines GE 2) THEN BEGIN FOR loop = 1, Nlines-1 DO BEGIN READF, 1, BlankLine ENDFOR ENDIF ; Read-in the vertical modes FOR mode = 1, Nlevs DO BEGIN remainder = Nlevs FOR loop1 = 1, Nlines DO BEGIN READF, 1, BlankLine ;PRINT, loop1, ':: ', BlankLine IF (loop1 EQ 1) THEN BEGIN start = 29 ENDIF ELSE BEGIN start = 0 ENDELSE IF (remainder LT 20) THEN BEGIN extent = remainder ENDIF ELSE BEGIN extent = 20 ENDELSE FOR loop2 = 1, extent DO BEGIN from = (loop2-1) * 11 + start sub = STRMID(BlankLine,from,11) ;PRINT, 'sub = ', 20*(loop1-1)+loop2-1, sub READS, sub, TempFloat Modes(20*(loop1-1)+loop2-1,mode-1) = TempFloat remainder = remainder - 1 ENDFOR ENDFOR ENDFOR CLOSE, 1 ;------------------------------------------------------------------------------ ; Plot the vertical modes ;------------------------------------------------------------------------------ ;Can fit 40 plots per page NumPages = CEIL(Nlevs / 40.0) PRINT, 'Plotting ', NumPages,' pages' deltax = 1.0 / 12.0 deltay = 1.0 / 5.0 remainder = Nlevs SET_PLOT, 'ps' FOR page = 1, NumPages DO BEGIN filename = 'ApModes' + STRING(page,FORMAT='(I1)') + '.ps' PRINT, 'Plotting ',filename DEVICE, FILE=filename, /PORTRAIT, /COLOR, XSIZE=21.0, YSIZE=29.0, $ XOFFSET=2.0, YOFFSET=2.0, FONT_SIZE=8, /ENCAPSULATED IF (remainder LT 40) THEN BEGIN extent = remainder ENDIF ELSE BEGIN extent = 40 ENDELSE FOR plotno = 0, extent-1 DO BEGIN mode = (page-1) * 40 + plotno y = FIX(plotno/10) x = plotno - 10*y ;PRINT, mode, x, y Px1 = (x+0.5) * deltax Py1 = 1.0 - (y+1.5) * deltay Px2 = Px1 + 0.8 * deltax Py2 = Py1 + 0.8 * deltay !P.POSITION = [Px1, Py1, Px2, Py2] PLOT, Modes(*,mode), Zvalues(*), /NOERASE remainder = remainder - 1 ENDFOR DEVICE, /CLOSE ENDFOR END