; ; COMP_uncert_TIME_PUBLIC.PRO Matthew DeLand 05/12/08 ; ; Plot time series of composite UV irradiance data in any requested wavelength ; band, using 1 nm averaged data as input ; ;## 05/05/08 Revise to use V3 data ; ;## 05/12/08 *_UNCERT_TIME_PUBLIC.PRO plots time-dependent uncertainty at ;## selected wavelength ; PROG_NAME = 'comp_uncert_time_public.pro' ; PRINT,'This program plots a time series of composite UV solar irradiance data' PRINT,' uncertainty values averaged over any wavelength region between ' PRINT,' 120-400 nm, and normalized to the start of the data set.' ; ; Load all DATA; Irradiances available for 9764 days from 1978/311 - 2005/213 ; ( 7 Nov 1978 - 1 Aug 2005); Wavelength coverage is 120.5-399.5 nm, binned ; at 1 nm intervals; Data source flag values are also extracted ; ;## 05/12/08 Remove flags, insert time-dependent uncertainty values ; OPENR, UNIT1, 'comp_dates.unf', /get_lun OPENR, UNIT2, 'comp_irrad.unf', /get_lun OPENR, UNIT3, 'comp_uncert_time.unf', /get_lun INFO1 = fstat(UNIT1) & N_DY = INFO1.size / 4 DNUM_ALL = FLTARR(N_DY) & IRRAD_ALL = FLTARR(N_DY,280) & SIG_ALL = IRRAD_ALL READU, UNIT1, DNUM_ALL READU, UNIT2, IRRAD_ALL READU, UNIT3, SIG_ALL ; ; Select wavelength range & extract valid data; Use loop to allow repeats ; ;## 05/12/08 Turn off smoothing option for uncertainty ; STR_NEXT = ' ' WHILE (STR_NEXT NE 'N') DO BEGIN PRINT, ' ' READ, '&&& Enter starting, ending WAVELENGTH to use [e.g. 200,208] ? ', $ WV_STRT, WV_END ;; PRINT, ' ' ;; READ, '%% Enter number of days for SMOOTHING function '+$ ;; '(no smoothing = 1) ? ', N_SMTH n_smth = 1 STR_SMTH = STRTRIM(STRING(format='(I2)', fix(N_SMTH)), 2) ; ; Extract appropriate data & create average; Remember that averaged data are ; stored on 0.5 nm centers ; NUM_WV = fix(WV_END - WV_STRT) SUB_WV1 = fix(WV_STRT-120) SUB_WV2 = SUB_WV1 + (NUM_WV-1) ; IRRAD_AVG = FLTARR(N_DY) FOR I = 0, N_DY-1 DO BEGIN DUM_IRRAD = IRRAD_ALL(I, SUB_WV1:SUB_WV2) SUB_DAY = where((DUM_IRRAD GT 0.0), n_day) IF (N_DAY GT 0) THEN BEGIN IRRAD_AVG(I) = total(DUM_IRRAD(SUB_DAY)) / N_DAY ENDIF ELSE BEGIN IRRAD_AVG(I) = -999.0 ENDELSE ENDFOR ; ; Screen out dates with no good irradiance values, then apply smoothing if ; desired; Also extract data source flags for first wavelength of band, but ; don't plot ; ;## 05/12/08 Get uncertainty values rather than flag values ; SUB_GOOD = where((IRRAD_AVG GT 0.0), n_good) IRRAD_GOOD = IRRAD_AVG(SUB_GOOD) DNUM_GOOD = DNUM_ALL(SUB_GOOD) SIG_GOOD = SIG_ALL(SUB_GOOD,SUB_WV1) ; IF (N_SMTH GT 1) THEN BEGIN IRRAD_SMTH = smooth(IRRAD_GOOD, N_SMTH) ENDIF ELSE BEGIN IRRAD_SMTH = IRRAD_GOOD ENDELSE ; ; Remove any unsmoothed data points, then normalize to first remaining date; ; Create approximate fractional time for plotting ; IF (N_SMTH GT 1) THEN BEGIN S1 = fix(N_SMTH+1)/2 & S2 = N_GOOD-(S1+1) ENDIF ELSE BEGIN S1 = 0 & S2 = N_GOOD-1 ENDELSE ; IRRAD_SMTH_PLOT = IRRAD_SMTH(S1:S2) IRRAD_NORM = IRRAD_SMTH_PLOT/IRRAD_SMTH_PLOT(0) PLOT_TIME = 1978.0 + (DNUM_GOOD(S1:S2)/365.25) ; ; PLOTTING SECTION ; **************** ; !P.CHARSIZE = 1.2 STR_WV1 = STRING(format='(I3)', fix(WV_STRT)) STR_WV2 = STRING(format='(I3)', fix(WV_END)) !X.TITLE = '!6DATE' !Y.TITLE = '!6Relative UNCERTAINTY [!8percent!6]' !P.TITLE = '!6Composite UV Irradiance UNCERTAINTY Time Series: !8'+$ STR_WV1+'-'+STR_WV2+' nm!6' ; ;; PRINT, ' ' PRINT, '%% Specify Y-axis minimum, maximum, # of major & '+$ 'minor ticks' READ, '%% [e.g. 0,12,6,4] ? ', Y_MIN, Y_MAX, Y_MAJOR, Y_MINOR ; ; Create plot, then ask for new plot if desired ; PLOT, PLOT_TIME, SIG_GOOD, /nodata, /xstyle, xrange=[1978,2006], $ xticks=14, xminor=4, /ystyle, yrange=[Y_MIN,Y_MAX], yticks=Y_MAJOR, $ yminor=Y_MINOR OPLOT, PLOT_TIME, SIG_GOOD ; IF (N_SMTH GT 1) THEN BEGIN XYOUTS, 0.87, 0.87, /norm, '!5'+STR_SMTH+' day running average!6', $ chars=1.1, align=1.0 ENDIF ; ;; PRINT, ' ' READ, '@@@ Another plot [Y/N] ? ', STR_NEXT STR_NEXT = STRUPCASE(STR_NEXT) ENDWHILE ; CLOSE, /all END