; NAME: ; photscale ; ; PURPOSE: ; To determine the scale factor to flux calibrate a spectrum. ; ; CATEGORY: ; Data Reduction ; ; CALLING SEQUENCE: ; scale = photscale(wobj,fobj,mobj,wvega,fvega,mvega,wtrans,trans, ; COVERAGE=coverage,PLOT=plot,CANCEL=cancel) ; ; INPUTS: ; wobj - Wavelength array of the object spectrum ; fobj - Flux array of the object spectrum ; mobj - The magnitude of the object for the given filter ; transmission ; wstd - Wavelength array of the Vega spectrum (units same as wobj) ; fstd - Flux array of the Vega spectrum (units same as wobj) ; mstd - The magnitude of Vega for the given filter transmission ; wtrans - Wavelength array of the transmission profile ; trans - Array of the transmission profile (0 to 1) ; ; OUTUTS: ; Returns the scale factor ; ; KEYWORD PARAMETERS: ; COVERAGE - Set on return if the object spectrum does not span ; the entire filter ; PLOT - Set to plot the object spectrum and filter profile ; CANCEL - Set on return if there is a problem ; ; PROCEDURES CALLED: ; Requires the Astronomy User's Library ; ; PROCEDURE: ; Later ; ;REVISION HISTORY: ; 2002-02-10 - Written by M. Cushing, Institute for Astronomy, UH ; function photscale,wobj,fobj,mobj,wvega,fvega,mvega,wtrans,trans,$ COVERAGE=coverage,PLOT=plot,CANCEL=cancel cancel = 0 coverage = 0 if n_params() lt 8 then begin print, 'Syntax - scale = photscale(wobj,fobj,mobj,wvega,fvega,mvega,$' print, ' wtrans,trans,COVERAGE=coverage,$' print, ' PLOT=plot,CANCEL=cancel)' cancel = 1 return,-1 endif zparcheck, 'photscale', wobj, 1, [1,2,3,4,5],1, 'Wobj' zparcheck, 'photscale', fobj, 2, [1,2,3,4,5],1, 'Fobj' zparcheck, 'photscale', mobj, 3, [1,2,3,4,5],0, 'Mobj' zparcheck, 'photscale', wvega, 4, [1,2,3,4,5],1, 'Wvega' zparcheck, 'photscale', fvega, 5, [1,2,3,4,5],1, 'Fvega' zparcheck, 'photscale', mvega, 6, [1,2,3,4,5],0, 'Mvega' zparcheck, 'photscale', wtrans, 7, [1,2,3,4,5],1, 'Wtrans' zparcheck, 'photscale', trans, 8, [1,2,3,4,5],1, 'Trans' twrange = [min(wtrans,max=max),max] owrange = [min(wobj,max=max),max] vwrange = [min(wvega,max=max),max] ; Check to see if the object wavelength coverage encompasses the ; filter's entire wavelength range. if owrange[1] lt twrange[1] or owrange[0] gt twrange[0] then begin COVERAGE = 1 print, 'Warning - Object spectrum does not span full range of filter '+$ 'profile.' endif ; Interpolate Vega and the filter profile onto the object's ; wavelength sampling interpspec,wvega,fvega,wobj,rfvega,CANCEL=cancel interpspec,wtrans,trans,wobj,rtrans,CANCEL=cancel if cancel then return, -1 ztrans = where(finite(rtrans) eq 1 and finite(fobj) eq 1,count) if count ne n_elements(rtrans) then begin rfvega = rfvega[ztrans] fobj = fobj[ztrans] rtrans = rtrans[ztrans] wobj = wobj[ztrans] endif ; Compute intergated fluxes. ifobj = int_tabulated(wobj,fobj*rtrans) ifvega = int_tabulated(wobj,rfvega*rtrans) scale = (ifvega/ifobj) * 10^(-0.4*(mobj-mvega)) if keyword_set(PLOT) then begin window,1 plot, wtrans,trans,xsty=5,ysty=5,color=5,xrange=twrange,psym=10 ticks = strtrim(findgen(11)*.1,2) axis,yaxis=1,yticks=10,ytickname=ticks,yminor=1,color=5 plot, wobj,fobj,/xsty,ysty=9,xrange=twrange,/NOERASE,psym=10 oplot,wtrans,rfobj,color=2,psym=10 endif return, scale end