PRO pegase2specview, file, p=p, w=w ; IDL procedure for converting PEGASE (version 2) output ; spectra into specview (version 2.9.1) text format files. ; Also, draw plots of all the spectra ; file ; p - draw a plot of all spectra ; w - write out specview compatible files ; e.g. to write out specview compatible files, and make a plot of all spectra ; read_specta, spectra1.dat, /w, /p ; Mark G. Allen, CDS, October 12, 2004 ;----------------------------------------------------------------------------- ; file name of PEGASE spectra output file filename=file ; initialise dummy string variable line='' ; Read the header OPENR, 1, (filename) print, filename REPEAT BEGIN READF,1,format = '(A)', line ENDREP UNTIL (STRMID(line,0,1) EQ '*') ; Variables to hold numbers of time steps and wavelengths n_time_steps=INTARR(1) n_wavelengths=INTARR(1) n_emission_lines=INTARR(1) ; Read the number of time steps and wavelengths READF,1,n_time_steps, n_wavelengths, n_emission_lines ;print, n_time_steps ;print, n_wavelengths ;print, n_emission_lines ; set up wavelength arrays of the correct size wavelengths = DBLARR(n_wavelengths) emission_line_wavelengths = DBLARR(n_emission_lines) ; set up 2 dimensional arrays to hold the fluxes at each timestep continuum_flux = DBLARR(n_wavelengths, n_time_steps) emission_line_flux = DBLARR(n_emission_lines, n_time_steps) ; set up 2 dimensional array to hold details about each time step time_step_details = DBLARR(10, n_time_steps) ; Read the wavelength arrays READF,1,wavelengths READF,1,emission_line_wavelengths ; Read the flux arrays for each time step FOR i=0,n_time_steps[0]-1 DO BEGIN time_step_details_temp = DBLARR(10) READF,1,time_step_details_temp READF,1,format = '(A)', line time_step_details[*,i] = time_step_details_temp continuum_flux_temp = DBLARR(n_wavelengths) emission_line_flux_temp = DBLARR(n_emission_lines) READF,1,continuum_flux_temp READF,1,emission_line_flux_temp continuum_flux[*,i] = continuum_flux_temp emission_line_flux[*,i] = emission_line_flux_temp ENDFOR CLOSE,1 IF KEYWORD_SET(p) THEN BEGIN ; Make a plot of all the continuum spectra plot, alog10(wavelengths), alog10(continuum_flux[*,0]), $ xsty=3, ysty=3,xra=[2.5,6.5], yra=[21,34] FOR j=0,n_time_steps[0]-1,5 DO BEGIN oplot, alog10(wavelengths), alog10(continuum_flux[*,j]) ENDFOR ENDIF ; Write out specview compatible files of each spectra IF KEYWORD_SET(w) THEN BEGIN FOR k=0,n_time_steps[0]-1 DO BEGIN ; String of the time in Myr time_string = strcompress(string(fix(time_step_details[0,k])),/remove_all) ; Construct the filename for the output file filename = 'PEGASE_model_1_' + time_string +'Myr.txt' ; Open the output file and write openw,2,filename printf, 2, 'PEGASE model ' + time_string + ' Myr' printf, 2, 'angstrom' printf, 2, 'erg/s/angstrom' FOR x=0,n_wavelengths[0]-1 DO BEGIN printf, 2, wavelengths[x], continuum_flux[x,k] ENDFOR close, 2 ENDFOR ENDIF END ; of pegase2specview.pro --------------------------------------------------