962 lines
33 KiB
Prolog
962 lines
33 KiB
Prolog
pro synplot,ispec,iplot,ident,wl,fl,eqw,sp,wlobs=wlobs,flobs=flobs, $
|
|
atmos=atmos,linlist=linlist,input=input,abund=abund, $
|
|
imode=imode,idstd=idstd,iprin=iprin, $
|
|
kurucz=kurucz,oldinp=oldinp,disk=disk, $
|
|
cont=cont,nlte=nlte,lyman=lyman,vturb=vturb, $
|
|
optab=optab,optemp=optemp,opdens=opdens,nlamb=nlamb, $
|
|
bintab=bintab,relabn=relabn,inttab=inttab, $
|
|
wstart=wstart,wend=wend,wdist=wdist, $
|
|
cutoff=cutoff,strength=strength,icontl=icontl,ifhe2=ifhe2, $
|
|
hydprf=hydprf,he1prf=he1prf,he2prf=he2prf, $
|
|
nangles=nangles,anglmin=anglmin, $
|
|
vrot=vrot,vmac=vmac,steprot=steprot,fwhm=fwhm,stepins=stepins, $
|
|
relative=relative,scale=scale,rv=rv, $
|
|
extend=extend,charsize=charsize,lidshift=lidshift, $
|
|
observ=observ,noread=noread,spect=spect,inlist=inlist, $
|
|
save=save,f55=f55,molecules=molecules,ichang=ichang,_extra=e
|
|
;
|
|
;
|
|
; program for ploting spectra calculated by SYNSPEC,
|
|
; with a possibility to change interactively the chemical composition;
|
|
; and interactively convolved with rotation and instrumental broadening;
|
|
; and possibly also annotated by line identifications
|
|
;
|
|
; written by I. Hubeny, Nov-Dec 1994
|
|
; modified - Jul 1996
|
|
; further modified - Nov 1996
|
|
; May 1997
|
|
; modified - Yeisson Osorio Jul 2018
|
|
; - added optab and relabn for constructing opacity tables
|
|
; - added f55 option to use another fort.55 file (use with
|
|
; caution! )
|
|
;
|
|
; ispec = 0 - Synspec is run
|
|
; no change of chemical composition;
|
|
; < 0 - Synspec is not run (only Rotins is run)
|
|
; > 0 - ispec elements change abundance; entered interactively
|
|
; iplot = 0 - original plot
|
|
; = 1 - overplot, IPLOT has the meaning of the color index
|
|
; ident = 0 - identification is not plotted
|
|
;
|
|
; OPTIONAL KEYWORD INPUT:
|
|
;
|
|
; ATMOS - file name(s) for a model atmosphere
|
|
; LINLIST - filename of the line list
|
|
; INPUT - filenames of the additional input (usually not set)
|
|
; OBSERV - filename of the observed spectrum
|
|
; IMODE - basic mode of SYNSPEC
|
|
; KURUCZ - switch for indicating a Kurucz model input (if =1)
|
|
; NLTE - NLTE switch (see SYNSPEC)
|
|
; LYMAN - switch for treating Lyman lines (IOPHLI in Synspec)
|
|
; VTURB - turbulent velocity (in km/s)
|
|
;
|
|
; OPTAB - name of output file with the opacity table
|
|
; optemp - optemp = [NTEMP, TEMP1, TEMP2]
|
|
; opdens - opdens = [IDENS, NDENS, DENS1, DENS2] not defined
|
|
; nlamb - number of wavelength points
|
|
; inttab - transformation mode from internal to universal
|
|
; wavelength points
|
|
; /bintab - output table in binary mode (default ascii)
|
|
; RELABN - pairs (IATOM, RELABN) for op tables
|
|
;
|
|
; WSTART - starting wavelength (in Angstrom)
|
|
; WEND - final wavelength (in A)
|
|
; WDIST - step in wavelength
|
|
; STRENGTH - criterion for selecting lines (RELOP in Synspec)
|
|
; CUTOFF - distance in A to which lines are allow to contribute
|
|
; IFHE2 - He II opacity switch (see SYNSPEC)
|
|
;
|
|
; VROT - rotational velocity - v sin i (in km/s)
|
|
; VMAC - macro-turbulent velocity - (in km/s)
|
|
; STEPROT - step for the rotational convolution (if non-zero)
|
|
; FWHM - FWHM for the instrumental profile (in A)
|
|
; STEPINS - step for instrumental convolution (if non-zero)
|
|
; RELATIVE - switch for computing relative spectrum (if =1)
|
|
; SCALE - a scale factor to multiply the theoretical spectrum
|
|
; RV - radial velocity (in km/s) applied on theor. spectrum
|
|
;
|
|
; EXTEND - switch for drawing vertical lines in identification
|
|
; CHARSIZE - character size in identification
|
|
;
|
|
; ABUND - vector of abundance changes
|
|
; SAVE - core filename for saved files
|
|
;
|
|
; _EXTRA - a set of any extra keywords for PLOT
|
|
;
|
|
if n_params(0) eq 0 then begin
|
|
print,'pro synplot,ispec,iplot,ident,eqw,sp,flobs,wlobs, '
|
|
print,'OPTIONAL KEYWORD PARAMETERS '
|
|
print,' type 1 for a short list;'
|
|
print,' 2 for a long list with explanations;'
|
|
print,' else return'
|
|
read,ii
|
|
if ii eq 1 then begin
|
|
print,'atmos,linlist,input,observ, (filenames)'
|
|
print,'imode,idstd,kurucz,nlte,lyman,vturb (fort.55 for SYNSPEC)'
|
|
print,'wstart,wend,wdist,strength,cutoff,ifhe2,icontl, (still fort.55)'
|
|
print,'hydprf,he1prf,he2prf, (H, HeI, HeII line broadening tables-fort.55)'
|
|
print,'nangles,anglmin (still fort.55)'
|
|
print,'vrot,vmac,steprot,fwhm,stepins,relative, (for ROTINS)'
|
|
print,'scale,rv, (radial velocity and scaling of the final spectrum)'
|
|
print,'optab,optemp,opdens,inttab,nlamb,bintab,relabn, (for opacity tables )'
|
|
print,'extend,charsize, (for LINEID)'
|
|
print,'abund,noread,spect,save,_extra (miscellaneous)'
|
|
endif else begin
|
|
if ii eq 2 then begin
|
|
print,'POSITIONAL PARAMETERS:'
|
|
print,''
|
|
print,'ispec = 0 - normal run of Synspec; <0 - (no run of Synspec),'
|
|
print,' >0 - ispec abundances changed'
|
|
print,'iplot = 0 - first plot; >0 oplot (iplot is the color index)'
|
|
print,' <0 - plot only the observed spectrum'
|
|
print,'ident = 0 - no identification; >0 - identification'
|
|
print,' in that case, lines with eqw > ident mA are marked'
|
|
print,'eqw - output: total equivalent width (in mA)'
|
|
print,'sp - if present, an array of synthetic spectrum (generated'
|
|
print,' by a previous run of Synplot)'
|
|
print,'wlobs - if present, array of wavelengths of the observed spectrum'
|
|
print,'flobs - if present, array of fluxes of the observed spectrum'
|
|
print,''
|
|
print,'KEYWORD PARAMETERS:'
|
|
print,'atmos - names(s) for the input model atmosphere (disk)'
|
|
print,' if absent: either not needed, or assumed to be'
|
|
print,' fort.5 (std input) and fort.8 (model)'
|
|
print,' if a single string: generic name'
|
|
print,' files are atmos.5 and atmos.7'
|
|
print,' if a 2-comp string vector: '
|
|
print,' files are atmos(0) and atmos(1)'
|
|
print,'oldinp - if set, the "old" format of input (up to tlus194,syn41)'
|
|
print,'disk - if set, input accretion disk model is assumed'
|
|
print,'linlist - filename for the line list (default fort.19)'
|
|
print,'input - names(s) for the additional input to Synspec'
|
|
print,' (unit 55) and Rotins (std input)'
|
|
print,' default - SYNPLOT creates these files'
|
|
print,' if present, it must be a 2-comp string vector,'
|
|
print,' [filename for unit55, std input to Rotins]'
|
|
print,'abund - if present, it is another method to change abundances'
|
|
print,' must be vector [first at.number, last a.num., abund],'
|
|
print,' or more triads consecutively'
|
|
print,''
|
|
print,'imode - basic mode of Synspec (default 0)'
|
|
print,'cont - the same as imode=2 - flux in continuum'
|
|
print,'idstd - standard depth; if not set, the program assigns'
|
|
print,' the last depth point where T<Teff'
|
|
print,'kurucz - if =1, Kurucz model atmosphere, otherwise Tlusty'
|
|
print,' (default 0 - Tlusty)'
|
|
print,'nlte - NLTE switch in Synspec'
|
|
print,' (default 1 - NLTE lines, if NLTE populations given)'
|
|
print,'lyman - switch for the treatment of Lyman lines (default 1)'
|
|
print,'vturb - turbulent velocity (in km/s) - default 0'
|
|
print,''
|
|
print,'wstart - starting wavelength (in A)'
|
|
print,'wend - end of the wavelength interval (in A)'
|
|
print,'wdist - (maximum) wavelength step (in A) - default 0.01'
|
|
print,'strength - criterion for rejecting lines - default 1.e-4'
|
|
print,'icontl - switch for considering H lines as continua'
|
|
print,'ifhe2 - switch for treatment He II lines - default 0'
|
|
print,'hydprf - filename for the special H line broadening table'
|
|
print,'he1prf - filename for the special HeI line broadening table'
|
|
print,'he2prf - filename for the special HeII line broadening table'
|
|
print,'nangles- if set, the number of angles for evaluating intensity'
|
|
print,' equidistant mu''s between 1 and anglmin'
|
|
print,'anglmin- minimum mu = cos(angle) for evaluating intensity'
|
|
print,' default = 0.1'
|
|
print,''
|
|
print,'vrot - rotational velocity (in km/s) - default 0'
|
|
print,' < 0 - ROTIN is not called'
|
|
print,'vmac - macroturbulent velocity (in km/s) - default 0'
|
|
print,'steprot - wavelength step for rotated spectra (in A),'
|
|
print,' default = (wstart+wend)*vrot/c/5'
|
|
print,'fwhm - FWHM for (Gaussian) instrumental profile (default 0)'
|
|
print,' < 0 - ROTIN is not called'
|
|
print,'stepins- step for convolved spectra (default fwhm/10)'
|
|
print,'relative - if nonzero, plot relative spectrum (default 0)'
|
|
print,'scale - scale factor for synthetic spectra (default 1)'
|
|
print,'rv - radial velocity (in km/s) to be applied '
|
|
print,' to synthethic spectra (default 0)'
|
|
print,''
|
|
print,'optab - name of the file with the opacity table'
|
|
print,'optemp - [NTEMP, TEMP1, TEMP2]'
|
|
print,'opdens - [IDENS, NDENS, DENS1, DENS2]'
|
|
print,'nlamb - number of waelenght points for the opacity table'
|
|
print,'inttab - transformation mode from internal to universal'
|
|
print,' wavelength points (1 interpolation of wavelenghts '
|
|
print,' default = 0 by integral over wavelengths )'
|
|
print,'bintab - if 1 optable is in binary mode, default 0 (= ascii)'
|
|
print,'relabn - changes in chemical abundances in the opa table'
|
|
print,' is an arrya of pairs:'
|
|
print,' [[z1,rel1],[z2,rel2],...]'
|
|
print,' where zi is atomic number and reli multiplication'
|
|
print,' factor of the input abundance (typically 0)'
|
|
print,''
|
|
print,'extend - swich for drawing lines for identification'
|
|
print,'charsize - character size in identification (default 1)'
|
|
print,'lidshift - if set, identification is shifted with rv'
|
|
print,''
|
|
print,'observ - if present, and is a string, then it is the'
|
|
print,' the filename of the observed spectrum;'
|
|
print,' (simple table wavelength (in A) vers. flux(any units))'
|
|
print,' - if present, and is equal to number 1, '
|
|
print,' then it indicates that the observed spectrum is'
|
|
print,' on positional parameters WLOBS and FLOBS'
|
|
print,'noread - if present and non-zero, the synthetic spectrum is'
|
|
print,' not read from the file fort.10 (must be transfered'
|
|
print,' by positional parameter SP)'
|
|
print,'spect - has an effect only if NOREAD is not set,'
|
|
print,' and if the spectrum is not computed by the present run:'
|
|
print,' the filaneme where the synthetic spectrum is stored'
|
|
print,' (if it is different from fort.10)'
|
|
print,''
|
|
print,'save - if present, filename for saving created files'
|
|
print,' with filenames save+.7, save+.17, etc'
|
|
print,'_extra - any extra keywords for IDL routine PLOT'
|
|
endif else return
|
|
endelse
|
|
return
|
|
endif
|
|
; check op system
|
|
spawn,'uname',opsys
|
|
|
|
opsys=strlowcase(strtrim(opsys,2))
|
|
|
|
case opsys of
|
|
'linux' : begin
|
|
synspec='synspec.linux'
|
|
rotin='rotin.linux'
|
|
end
|
|
'darwin': begin
|
|
synspec='synspec.mac'
|
|
rotin='rotin.mac'
|
|
end
|
|
else: begin
|
|
message,'# WARNING: I am not sure the OS you are running me on... ',/cont
|
|
synspec='synspec.exe'
|
|
end
|
|
endcase
|
|
|
|
|
|
;
|
|
; initialization
|
|
;
|
|
|
|
if n_elements(atmos) eq 1 then begin
|
|
fort5=atmos+".5"
|
|
fort8=atmos+".7"
|
|
endif
|
|
if n_elements(atmos) eq 2 then begin
|
|
fort5=atmos(0)
|
|
if fort5 eq 'cool.5' then oldinp=1
|
|
fort8=atmos(1)
|
|
endif
|
|
;
|
|
if n_elements(inlist) eq 0 then inlist=10
|
|
if n_elements(ichang) eq 0 then ichang=0
|
|
if n_elements(linlist) eq 1 then begin
|
|
if linlist ne 'fort.19' then begin
|
|
a='ln -s -f '+linlist+' fort.19'
|
|
spawn,a
|
|
endif
|
|
endif
|
|
;
|
|
if n_elements(abund) ne 0 then ichemc=1 else ichemc=0
|
|
if n_elements(imode) eq 0 then imode=0
|
|
if keyword_set(cont) then imode=2
|
|
if keyword_set(optab) then iopt=1 else iopt=0
|
|
|
|
if n_elements(kurucz) eq 0 then inmod=1 else begin
|
|
if kurucz ge 0 then inmod=0 & endelse
|
|
if ispec ge 0 then begin
|
|
if strmid(fort8,0,5) eq 'ap00t' then inmod=0
|
|
endif
|
|
if keyword_set(disk) then inmod=2
|
|
if keyword_set(nlte) then nlte=1 else nlte=0
|
|
;if inmod eq 0 then nlte=0
|
|
if n_elements(icontl) eq 0 then icontl=0
|
|
if n_elements(ifhe2) eq 0 then ifhe2=0
|
|
if n_elements(lyman) eq 0 then lyman=0
|
|
;
|
|
; set up parameteres for special line broadening tables
|
|
;
|
|
if n_elements(hydprf) eq 0 then ihydpr=0 else ihydpr=hydprf
|
|
;else begin $
|
|
; ihydpr=20
|
|
; spawn,'rm -f fort.20'
|
|
; hydprf=strtrim(string(hydprf),2)
|
|
; if hydprf ne '1' then begin
|
|
; a='ln -s '+hydprf+' fort.20'
|
|
; spawn,a
|
|
; endif else begin
|
|
; spawn,'ln -s hydprf.dat fort.20'
|
|
; hydprf='hydprf.dat'
|
|
; endelse
|
|
;endelse
|
|
if n_elements(he1prf) eq 0 then ihe1pr=0 else begin $
|
|
ihe1pr=21
|
|
spawn,'rm -f fort.21'
|
|
he1prf=strtrim(string(he1prf),2)
|
|
if he1prf ne '1' then begin
|
|
a='ln -s '+he1prf+' fort.21'
|
|
spawn,a
|
|
endif else begin
|
|
spawn,'ln -s he1prf.dat fort.21'
|
|
he1prf='he1prf.dat'
|
|
endelse
|
|
endelse
|
|
if n_elements(he2prf) eq 0 then ihe2pr=0 else begin $
|
|
ihe2pr=22
|
|
spawn,'rm -f fort.22'
|
|
he2prf=strtrim(string(he2prf),2)
|
|
if he2prf ne '1' then begin
|
|
a='ln -s '+he2prf+' fort.22'
|
|
spawn,a
|
|
endif else begin
|
|
spawn,'ln -s he2prf.dat fort.22'
|
|
he2prf='he2prf.dat'
|
|
endelse
|
|
endelse
|
|
if n_elements(cutoff) eq 0 then if iopt then cutoff=50.0 else cutoff=100.00
|
|
if n_elements(strength) eq 0 then if iopt then strength=1.e-3 else strength =1.e-4
|
|
if n_elements(wdist) eq 0 then begin
|
|
if imode ne 2 then begin
|
|
if iopt then wdist=0.12 else wdist=0.01
|
|
endif else wdist=0.5
|
|
endif
|
|
;
|
|
close,1 ; in case unit 1 is open!
|
|
;
|
|
if ispec ge 0 then begin
|
|
if n_elements(wstart) eq 0 then begin
|
|
spawn,'head -1 fort.19 >| lin1.tmp'
|
|
openr,1,'lin1.tmp'
|
|
readf,1,al1
|
|
close,1
|
|
wstart=al1*10.
|
|
if imode eq 1 then wstart=wstart-cutoff*0.5
|
|
endif
|
|
;
|
|
if n_elements(wend) eq 0 then begin
|
|
spawn,'tail -1 fort.19 >| lin2.tmp'
|
|
openr,1,'lin2.tmp'
|
|
readf,1,al2
|
|
close,1
|
|
wend=al2*10.
|
|
if imode eq 1 then wend=wend+cutoff*0.5
|
|
endif
|
|
endif else begin
|
|
nmlist=fix(n_elements(molecules))
|
|
if n_elements(wstart) eq 0 then begin
|
|
spawn,'head -1 fort.7 >| lin1.tmp'
|
|
openr,1,'lin1.tmp'
|
|
readf,1,al1
|
|
close,1
|
|
wstart=al1
|
|
endif
|
|
;
|
|
if n_elements(wend) eq 0 then begin
|
|
spawn,'tail -1 fort.7 >| lin2.tmp'
|
|
openr,1,'lin2.tmp'
|
|
readf,1,al2
|
|
close,1
|
|
wend=al2
|
|
endif
|
|
endelse
|
|
;
|
|
if n_elements(vrot) eq 0 then vrot=0.
|
|
if n_elements(steprot) eq 0 then steprot=0
|
|
if n_elements(fwhm) eq 0 then fwhm=0.
|
|
if n_elements(stepins) eq 0 then stepins=0
|
|
if n_elements(relative) eq 0 then relative=0
|
|
if n_elements(scale) eq 0 then scale=1.
|
|
if n_elements(rv) eq 0 then rv=0.
|
|
if n_elements(iprin) eq 0 then iprin=0
|
|
;
|
|
;
|
|
if ispec ge 0 then begin
|
|
;
|
|
; construct the input file fort.55 for Synspec
|
|
;
|
|
if n_elements(input) eq 0 then begin
|
|
if iopt then begin
|
|
idstd=1
|
|
imode-=3
|
|
endif
|
|
if n_elements(idstd) gt 0 then idst=idstd else begin
|
|
idst=0
|
|
; if inmod eq 0 or inmod eq 2 then idst=0 else begin
|
|
; a='grep -v "*" '+fort5+' |head -1 >| tetmp'
|
|
; spawn,a
|
|
; close,1 & openr,1,'tetmp'
|
|
; readf,1,teff,grav
|
|
; close,1 & openr,1,fort8
|
|
; readf,1,nd,np
|
|
; np=abs(np) ; check consequenses !!
|
|
; dm=fltarr(nd)
|
|
; readf,1,dm
|
|
; parm=fltarr(np,nd)
|
|
; readf,1,parm
|
|
; temp=parm(0,*)
|
|
; for id=0,nd-1 do if temp(id) lt teff then ids=id
|
|
; idst=ids+1
|
|
; endelse
|
|
endelse
|
|
close,1
|
|
if keyword_set(molecules) then begin
|
|
nmlist=fix(n_elements(molecules)) & mols=fix(molecules)
|
|
endif else begin
|
|
nmlist=0 & mols=0
|
|
endelse
|
|
if ~keyword_set(f55) then begin
|
|
openw,1,'f55'
|
|
zero=0
|
|
one=1
|
|
printf,1,imode,idst,iprin
|
|
printf,1,inmod,zero,ichang,ichemc
|
|
printf,1,lyman,zero,zero,zero,zero
|
|
printf,1,one,nlte,icontl,inlist,ifhe2
|
|
printf,1,ihydpr,ihe1pr,ihe2pr
|
|
if iopt then printf,1,wstart,-abs(wend),cutoff,2000,strength,wdist $
|
|
else printf,1,wstart,wend,cutoff,zero,strength,wdist
|
|
printf,1,nmlist,mols
|
|
noturb=0
|
|
if n_elements(vturb) eq 1 then printf,1,vturb else noturb=1
|
|
if keyword_set(nangles) then begin
|
|
if n_elements(anglmin) eq 0 then anglmin=0.1
|
|
if noturb eq 1 then printf,1,-1
|
|
iflux=1
|
|
printf,1,nangles,anglmin,iflux
|
|
if nangles lt 0 then begin
|
|
print,'enter ',-nangles,' values of mu=cos(angle)'
|
|
ang=fltarr(-nangles)
|
|
read,ang
|
|
printf,1,ang
|
|
endif
|
|
endif
|
|
close,1
|
|
spawn,'/bin/cp f55 fort.55'
|
|
endif else spawn,'/bin/cp '+f55+' fort.55'
|
|
endif
|
|
;
|
|
; construct the input file fort.2 (rel abn for op tables) for Synspec
|
|
;
|
|
if iopt then begin
|
|
if n_elements(inttab) eq 0 then inttab=0
|
|
if n_elements(optemp) ne 3 then begin
|
|
print,'optemp = [NTEMP, TEMP1, TEMP2] not defined'
|
|
return
|
|
endif
|
|
if n_elements(opdens) ne 4 then begin
|
|
print,'opdens = [IDENS, NDENS, DENS1, DENS2] not defined'
|
|
return
|
|
endif
|
|
if n_elements(nlamb) ne 1 then begin
|
|
print,'nlamb = NLAMB not defined'
|
|
return
|
|
endif
|
|
openw,1,'fort.2'
|
|
printf,1,optemp,format='(i-5,2e-15.3e3)'
|
|
printf,1,opdens[0],format='(i-5)'
|
|
printf,1,opdens[1:*],format='(i-5,2e-15.3e3)'
|
|
printf,1,nlamb,inttab,wstart,wend,format='(i-12,i-3,2f15.0)'
|
|
printf,1,"'"+strtrim(optab,2)+"'",fix(keyword_set(bintab))
|
|
;
|
|
; construct the input file fort.3 (rel abn for op tables) for Synspec
|
|
;
|
|
if keyword_set(relabn) and iopt then begin
|
|
dum=size(relabn)
|
|
if dum[1] ne 2 then begin
|
|
print,'relative abundance for opacity table not used (wrong array`s format)'
|
|
endif else begin
|
|
for i=0, n_elements(relabn[0,*])-1 do begin
|
|
printf,1,relabn[*,i],format='(i4,f15.4)'
|
|
endfor
|
|
endelse
|
|
endif
|
|
close,1
|
|
if iopt then begin
|
|
print,'opacity table constructed with'
|
|
print,'FORT.2 : '
|
|
print,'--------------'
|
|
spawn,'cat fort.2'
|
|
print,'--------------'
|
|
print,''
|
|
endif
|
|
endif
|
|
;
|
|
; construct the input file fort.56 for Synspec
|
|
;
|
|
openw,1,'inp.tmp'
|
|
if ispec le 0 then begin
|
|
izer=0
|
|
if n_elements(abund) eq 0 then printf,1,izer
|
|
endif else begin
|
|
;
|
|
; interactive input of abundances
|
|
;
|
|
for i=1,ispec do begin
|
|
print,'enter starting and ending atomic number, abund'
|
|
read,ia0,ia1,abun
|
|
for ia=ia0,ia1 do printf,1,ia,abun,format='(i10,f10.3)'
|
|
endfor
|
|
endelse
|
|
;
|
|
; input of abundances as a parameter ABUND
|
|
;
|
|
if n_elements(abund) ge 3 then begin
|
|
ichemc=1
|
|
ispec=n_elements(abund)/3
|
|
for i=0,ispec-1 do begin
|
|
for ia=abund(3*i),abund(3*i+1) do printf,1,ia,abund(3*i+2),$
|
|
format='(i4,e15.4)'
|
|
endfor
|
|
endif else ichemc=0
|
|
close,1
|
|
if n_elements(abund) gt 0 or ispec gt 0 then begin
|
|
spawn,'wc -l inp.tmp > inum.tmp'
|
|
spawn,'sed s/inp.tmp// inum.tmp > inum1.tmp'
|
|
spawn,'cat inum1.tmp inp.tmp > fort.56'
|
|
endif else begin
|
|
spawn,'/bin/cp inp.tmp fort.56'
|
|
endelse
|
|
;
|
|
; construct the input file fort.1 for Synspec
|
|
;
|
|
i=0
|
|
if keyword_set(oldinp) then i=1
|
|
openw,1,'f1'
|
|
printf,1,i
|
|
close,1
|
|
spawn,'/bin/cp -f f1 fort.1'
|
|
;
|
|
if n_elements(optab) eq 0 then begin
|
|
a='/bin/cp '+fort8+' fort.8'
|
|
spawn,a
|
|
endif
|
|
;
|
|
a='./'+synspec+' < '+fort5+' > sylog.tmp'
|
|
;
|
|
spawn,a
|
|
if n_elements(optab) eq 0 then begin
|
|
spawn,'tail -1 fort.16 > eq.tmp'
|
|
openr,1,'eq.tmp'
|
|
readf,1,t1,t2,t3,t4,eqw1
|
|
print,'total equivalent width: ',eqw1,' milliangstrom'
|
|
close,1
|
|
eqw=eqw1
|
|
endif else begin
|
|
save=strsplit(optab,'.',/extract)
|
|
if n_elements(save) gt 1 then begin
|
|
save=save[0:n_elements(save)-2]
|
|
save=strjoin(save,'.')
|
|
endif
|
|
a='/bin/mv sylog.tmp '+save+".log"
|
|
spawn,a
|
|
return
|
|
endelse
|
|
endif
|
|
;
|
|
; -------------------------------------------------------------------------------
|
|
;
|
|
if ident gt 0 then set_viewport,0.13,0.95,0.1,0.65
|
|
if ~keyword_set(vmac) then vmac=0.0
|
|
if vrot ge 0 and fwhm ge 0 then begin
|
|
;
|
|
; construct the input file for rotins
|
|
;
|
|
openw,1,'r.tmp'
|
|
printf,1," 'fort.7' 'fort.17' 'fort.10' "
|
|
printf,1,vrot,wdist,steprot
|
|
printf,1,fwhm,stepins,vmac
|
|
printf,1,wstart,wend,relative
|
|
close,1
|
|
;
|
|
; run rotins
|
|
;
|
|
spawn,'./'+rotin+' <r.tmp > out.tmp'
|
|
endif else spawn,'/bin/cp -f fort.7 fort.10'
|
|
;
|
|
; -------------------------------------------------------------------------------
|
|
;
|
|
|
|
|
|
if n_elements(noread) eq 0 then begin
|
|
if n_elements(spect) ne 0 then begin
|
|
a='/bin/cp -f '+spect+' fort.10'
|
|
spawn,a
|
|
endif
|
|
spawn,'wc -l fort.10 >| eq.tmp'
|
|
openr,1,'eq.tmp'
|
|
readf,1,npt
|
|
close,1
|
|
openr,1,'fort.10'
|
|
sp=fltarr(2,npt)
|
|
readf,1,sp
|
|
close,1
|
|
endif
|
|
;
|
|
; -------------------------------------------------------------------------------
|
|
;
|
|
ymax=1
|
|
if relative gt 0 and iplot eq 0 then begin
|
|
ym=max(sp(1,*))
|
|
if ym le 1 and ym ge 0.8 then ymax=1.2
|
|
if ym gt 1.2 then ymax=ym
|
|
set_xy,0,0,0,ymax
|
|
endif
|
|
;
|
|
; apply scale factor (scale) and radial velocity (rv) to the convolved spectrum
|
|
; (if required)
|
|
;
|
|
if n_elements(scale) eq 0 then fl=reform(sp(1,*)) else fl=reform(sp(1,*))*scale
|
|
if n_elements(rv) eq 0 then wl=reform(sp(0,*)) else wl=reform(sp(0,*))*(1.+rv[0]/2.9977925e5)
|
|
if iplot le 0 then begin
|
|
;
|
|
; read and plot the observed spectrum (if required)
|
|
;
|
|
if n_elements(observ) eq 0 then plot,wl,fl,_extra=e else begin
|
|
observ=strtrim(string(observ),2)
|
|
if observ ne '1' then begin
|
|
close,1 & openr,1,observ
|
|
i=0L
|
|
wlobs=fltarr(35000) & flobs=wlobs
|
|
while not eof(1) do begin
|
|
readf,1,wl0,fl0
|
|
wlobs(i)=wl0
|
|
flobs(i)=fl0
|
|
i=i+1L
|
|
endwhile
|
|
nobs=i-1L
|
|
wlobs=wlobs(0:nobs)
|
|
flobs=flobs(0:nobs)
|
|
endif
|
|
plot,wlobs,flobs,xr=[wstart,wend],ps=sym(1),symsize=0.5,_extra=e
|
|
if iplot eq 0 then oplot,wl,fl
|
|
endelse
|
|
endif else begin
|
|
; if iplot le 256 then oplot,wl,fl,color=iplot_extra=e else oplot,wl,fl,_extra=e
|
|
oplot,wl,fl,_extra=e
|
|
endelse
|
|
set_xy
|
|
close,1
|
|
;
|
|
;
|
|
; if required (ident > 0), do graphical identification
|
|
;
|
|
|
|
if ident gt 0 then begin
|
|
if n_elements(extend) gt 0 then begin
|
|
if iplot ge 0 then begin
|
|
nln=n_elements(wl)
|
|
wla=fltarr(nln)
|
|
fla=wla
|
|
for i=0,nln-1 do begin wla(i)=wl(i) & fla(i)=fl(i) & endfor
|
|
endif
|
|
if n_elements(observ) eq 1 then begin
|
|
nobs=n_elements(wlobs)-1
|
|
if iplot ge 0 then beyond=wl(nln-1) lt wlobs(0) or wl(0) gt wlobs(nobs-1)
|
|
if iplot lt 0 then beyond=1
|
|
if extend lt 0 then begin
|
|
extend = -extend
|
|
beyond=1
|
|
endif
|
|
nln=n_elements(wlobs)
|
|
wla=fltarr(nln)
|
|
fla=wla
|
|
for i=0,nln-1 do begin wla(i)=wlobs(i) & fla(i)=flobs(i) & endfor
|
|
endif
|
|
endif
|
|
ra=[wstart,wend]
|
|
ewl=ident
|
|
; the new version of synspec has fort.14 with formated
|
|
; the following way:
|
|
; 2 1 3721.935 H I -1.97 82259.250 1.06E-02 0.9 . 2 14
|
|
; and should be
|
|
; 3721.935 H I -1.97 82259.250 1.06E-02 0.9 . 2 14
|
|
;
|
|
; so :
|
|
spawn,"sed 's/^.........../ /' fort.14 > f14"
|
|
if nmlist eq 0 then spawn,'cat fort.12 f14 | sort -n -k 3,3 >| f12' $
|
|
else begin
|
|
spawn,"sed 's/^\(..............\)\(...\) /\1 \2 ./' fort.15 > f15"
|
|
spawn,'cat fort.12 f15 | sort -n -k 3,3 >| f12'
|
|
endelse
|
|
lineid_select,'f12',wli,lid,wst,st,ew,ewlim=ewl,range=ra
|
|
if n_elements(rv) eq 1 and n_elements(lidshift) ne 0 then $
|
|
wli=wli*(1.+rv/2.9977925e5)
|
|
if keyword_set(e) then begin
|
|
dum=where(strpos(tag_names(e),'CO') ne -1)
|
|
if dum ne -1 then dum=e.(dum) else dum=!p.color
|
|
endif
|
|
lineid_annot,wla,fla,wli,ew,lid,wst,charsize=charsize,extend=extend,col=dum
|
|
set_viewport
|
|
endif
|
|
;
|
|
; save files (if parameter SAVE is set)
|
|
;
|
|
if n_elements(save) eq 1 then begin
|
|
a='/bin/mv fort.7 '+save+".7"
|
|
spawn,a
|
|
a='/bin/mv fort.17 '+save+".17"
|
|
spawn,a
|
|
a='/bin/mv fort.10 '+save+".10"
|
|
spawn,a
|
|
a='/bin/mv fort.12 '+save+".12"
|
|
spawn,a
|
|
a='/bin/mv fort.14 '+save+".14"
|
|
spawn,a
|
|
a='/bin/mv fort.16 '+save+".16"
|
|
spawn,a
|
|
a='/bin/mv sylog.tmp '+save+".log"
|
|
spawn,a
|
|
if n_elements(molecules) gt 0 then begin
|
|
a='/bin/mv fort.15 '+save+".15"
|
|
spawn,a
|
|
endif
|
|
if keyword_set(nlte) then begin
|
|
a='/bin/mv fort.11 '+save+".11"
|
|
spawn,a
|
|
endif
|
|
; if n_elements(nangles) gt 0 then begin
|
|
; a='/bin/mv fort.10 '+save+".int"
|
|
; spawn,a
|
|
; a='/bin/mv fort.18 '+save+".contint"
|
|
; spawn,a
|
|
; endif
|
|
endif
|
|
;
|
|
;delete fort.10 if is eq to fort.7
|
|
;
|
|
;spawn,'/bin/diff fort.7 fort.10',kas
|
|
;if strjoin(kas) eq '' then spawn,'/bin/rm -f fort.10'
|
|
;
|
|
;delete link to fort.19 (line list)
|
|
;
|
|
if n_elements(linlist) eq 1 then begin
|
|
if linlist ne 'fort.19' then begin
|
|
; spawn,'/bin/rm -f fort.19'
|
|
endif
|
|
endif
|
|
;
|
|
;delete link to fort.20; fort.21; fort.22 (line broadening)
|
|
;
|
|
;if n_elements(hydprf) eq 1 then begin
|
|
; if hydprf ne 'fort.20' then begin
|
|
;; spawn,'/bin/rm -f fort.20'
|
|
; endif
|
|
;endif
|
|
;if n_elements(he1prf) eq 1 then begin
|
|
; if he1prf ne 'fort.21' then begin
|
|
;; spawn,'/bin/rm -f fort.21'
|
|
; endif
|
|
;endif
|
|
;if n_elements(he2prf) eq 1 then begin
|
|
; if he2prf ne 'fort.22' then begin
|
|
;; spawn,'/bin/rm -f fort.22'
|
|
; endif
|
|
;endif
|
|
;
|
|
end
|
|
|
|
|
|
pro rotin,fin,fcont,fout,xout,yout,vrot=vrot,chard=chard,stepr=stepr,$
|
|
fwhm=fwhm,stepi=stepi,vmac=vmac,$
|
|
wstart=alam0,wend=alam1,relative=irel,help=help
|
|
if n_params() lt 3 then begin
|
|
print,'rotin,fin,fcont,fout[xout,yout,vrot=,chard=,stepr=,fwhm=,stepi=,vmac=,wstart=,wend=,/relative]'
|
|
if ~keyword_set(help) then return
|
|
print,' fin : file with synthetic spectrum (.7)'
|
|
print,' fcont : file with continuum flux (.17)'
|
|
print,' fout : name of the output file'
|
|
print,' xout,yout : read fout and store x and y'
|
|
print,' VROT - v sin i (in km/s, 0)'
|
|
print,' CHARD - characteristic delta lambda (0.01)'
|
|
print,' STEPR - wavelength step for evaluation rotational convolution'
|
|
print,' FWHM - full width at half maximum instrumental profile'
|
|
print,' STEPI - wavelength step for evaluating instrumental convolution '
|
|
print,' VMAC - macroturbulent velocity'
|
|
print,' ALAM0 - initial wavelength'
|
|
print,' ALAM1 - final wavelength'
|
|
print,' /RELATIVE - normalized spectrum '
|
|
return
|
|
endif
|
|
spawn,'uname',opsys
|
|
|
|
; check OS
|
|
opsys=strlowcase(strtrim(opsys,2))
|
|
|
|
case opsys of
|
|
'linux' : begin
|
|
rotin='./rotin.linux'
|
|
end
|
|
'darwin': begin
|
|
rotin='./rotin.mac'
|
|
end
|
|
else: begin
|
|
message,'# WARNING: I am not sure the OS you are running me on... ',/cont
|
|
return
|
|
end
|
|
endcase
|
|
|
|
|
|
|
|
|
|
if n_elements(vrot) eq 0 then vrot=0
|
|
if n_elements(chard) eq 0 then chard=0
|
|
if n_elements(stepr) eq 0 then stepr=0
|
|
if n_elements(fwhm) eq 0 then fwhm=0
|
|
if n_elements(stepi) eq 0 then stepi=0
|
|
if n_elements(vmac) eq 0 then vmac=0
|
|
if n_elements(alam0) eq 0 or n_elements(alam1) eq 0 then begin
|
|
readcol,fcont,x,/silent
|
|
alam0=min(x)
|
|
alam1=max(x)
|
|
endif
|
|
if keyword_set(irel) then irel=1 else irel=0
|
|
; ---------------------------------------------------------------
|
|
; INPUT - from unit 5 - four lines of input
|
|
; ---------------------------------------------------------------
|
|
;
|
|
; 1. filenames:
|
|
;
|
|
; fin - name of the file containing the detailed synthetic spectrum
|
|
; (i.e. fort.7 produced by Synspec )
|
|
;
|
|
; fcont - name of the file containing the continuum flux
|
|
; (i.e. fort.17 produced by Synspec )
|
|
;
|
|
; fout - name of the output file - convolved spectrum
|
|
;
|
|
;
|
|
; 2. parameters for rotational convolution
|
|
;
|
|
; VROT - v sin i (in km/s)
|
|
; if VROT=0 - rotational convolution is
|
|
; a) either not calculated,
|
|
; b) or, if simultaneously FWHM is rather large
|
|
; (vrot/c*lambda < FWHM/20.),
|
|
; vrot is set to FWHM/20*c/lambda;
|
|
; if VROT >0 but the previous condition b) applies, the
|
|
; value of VROT is changed as in the previous case
|
|
; if VROT<0 - the value of abs(VROT) is used regardless of
|
|
; how small compared to FWHM it is
|
|
; CHARD - characteristic scale of the variations of unconvolved
|
|
; stellar spectrum (basically, characteristic distance
|
|
; between two neighbouring wavelength points) - in A
|
|
; - if =0 - program sets up default (0.01 A)
|
|
; STEPR - wavelength step for evaluation rotational convolution;
|
|
; - if =0, the program sets up default (the wavelength
|
|
; interval corresponding to the rotational velocity
|
|
; devided by 3.)
|
|
; if <0, convolved spectrum calculated on the original
|
|
; (detailed) SYNSPEC wavelength mesh
|
|
;
|
|
;
|
|
; 3. parameters for instrumental convolution
|
|
;
|
|
; FWHM - full width at half maximum for Gaussian instrumental
|
|
; profile
|
|
; STEPI - wavelength step for evaluating instrumental convolution
|
|
; - if =0, the program sets up default (FWHM/10.)
|
|
; - if <0, convolved spectrum calculated with the previous
|
|
; wavelength mesh:
|
|
; either the original (SYNSPEC) one if vrot=0,
|
|
; or the one used in rotational convolution (vrot > 0)
|
|
;
|
|
; VMAC - macroturbulent velocity
|
|
;
|
|
; 4. wavelength interval and normalization of spectra
|
|
;
|
|
; ALAM0 - initial wavelength
|
|
; ALAM1 - final wavelength
|
|
; IREL - for =1 relative spectrum
|
|
; =0 absolute spectrum
|
|
;
|
|
openw,1,'rotin3.inp'
|
|
printf,1," '",fin,"' '",fcont,"' '",fout,"' "
|
|
printf,1,vrot,chard,stepr
|
|
printf,1,fwhm,stepi,vmac
|
|
printf,1,alam0,alam1,irel
|
|
close,1
|
|
spawn,rotin+' <rotin3.inp > '+fout+'.log'
|
|
if n_params() eq 5 then readcol,fout,xout,yout,/silent,format='(d,d)'
|
|
return
|
|
end
|
|
|
|
pro mkintfiles,fort,nmu,muind,fileout,mkcont=mkcont
|
|
; fort.10 has the syntetic intensities at different mu
|
|
; fort.18 has the continuum intensities at different mu
|
|
; nmu = number of mu values
|
|
; muind = index(ces) of the mu value to extract (start with 0 i.e.,
|
|
; disk centre mu=1.0)
|
|
; /mkcont = only make continuum
|
|
cc=2.99792458d18 ; speed of light in AA/sec
|
|
if ~keyword_set(mkcont) then begin
|
|
openr,lun,fort+'.10',/get_lun
|
|
lwave=''
|
|
lint=''
|
|
readf,lun,lwave
|
|
kas=strsplit(lwave,' ',/extract)
|
|
wave=double(kas[0])
|
|
readf,lun,lint
|
|
kas=strsplit(lint,' ',/extract)
|
|
nread=0
|
|
while n_elements(kas) lt nmu do begin
|
|
readf,lun,lint
|
|
nread++
|
|
kas=[kas,strsplit(lint,' ',/extract)]
|
|
endwhile
|
|
int=double(kas)
|
|
while(~eof(lun)) do begin
|
|
readf,lun,lwave
|
|
readf,lun,lint
|
|
kas=strsplit(lwave,' ',/extract)
|
|
wave=[wave,double(kas[0])]
|
|
kas=strsplit(lint,' ',/extract)
|
|
for jj=1, nread do begin
|
|
readf,lun,lint
|
|
kas=[kas,strsplit(lint,' ',/extract)]
|
|
endfor
|
|
int=[[int],[double(kas)]]
|
|
endwhile
|
|
close,lun
|
|
openw,lun,fileout+'.int'
|
|
for ii=0, n_elements(wave)-1 do printf,lun,wave[ii],int[muind,ii]*cc/wave[ii]/wave[ii],format='(f12.5,e15.5E3)'
|
|
close,lun
|
|
endif else get_lun,lun
|
|
;;; fort.18 continuum intensity
|
|
openr,lun,fort+'.18'
|
|
lwave=''
|
|
lint=''
|
|
readf,lun,lwave
|
|
kas=strsplit(lwave,' ',/extract)
|
|
wave=double(kas[0])
|
|
readf,lun,lint
|
|
kas=strsplit(lint,' ',/extract)
|
|
nread=0
|
|
while n_elements(kas) lt nmu do begin
|
|
readf,lun,lint
|
|
nread++
|
|
kas=[kas,strsplit(lint,' ',/extract)]
|
|
endwhile
|
|
int=double(kas)
|
|
|
|
while(~eof(lun)) do begin
|
|
readf,lun,lwave
|
|
kas=strsplit(lwave,' ',/extract)
|
|
wave=[wave,double(kas[0])]
|
|
readf,lun,lint
|
|
kas=strsplit(lint,' ',/extract)
|
|
for jj=1, nread do begin
|
|
readf,lun,lint
|
|
kas=[kas,strsplit(lint,' ',/extract)]
|
|
endfor
|
|
int=[[int],[double(kas)]]
|
|
endwhile
|
|
close,lun
|
|
openw,lun,fileout+'.contint'
|
|
for ii=0, n_elements(wave)-1 do if (ii mod 4 eq 2) or (ii mod 4 eq 3) then printf,lun,wave[ii],int[muind,ii]*cc/wave[ii]/wave[ii],format='(f12.5,e15.5E3)'
|
|
; for ii=0, n_elements(wave)-1 do printf,lun,wave[ii],int[muind,ii]*cc/wave[ii]/wave[ii],format='(f12.5,e15.5E3)'
|
|
close,lun
|
|
free_lun,lun
|
|
|
|
end
|