Hermes DRS  6.0
reduction software
 All Classes Namespaces Functions Variables Pages
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
hermes.pipeline.components.computeRadialVelocity.computeRadialVelocity Class Reference

computes the radial velocity More...

Inheritance diagram for hermes.pipeline.components.computeRadialVelocity.computeRadialVelocity:
hermes.pipeline.core.pipelinecomponent.PipelineComponent

Public Member Functions

def __init__
 Make a Hermes component and initialize variables.
 
def optionsAreValid
 
def __call__
 runs from here More...
 
def Vrcor
 ---------------------—— computational routine -----------------------——### More...
 
def fwrite
 
def getfilename
 
- Public Member Functions inherited from hermes.pipeline.core.pipelinecomponent.PipelineComponent
def __init__
 
def __call__
 
def optionsAreValid
 
def getOptions
 
def setOptions
 
def checkExistShapeUnits
 
def isOption
 

Public Attributes

 isDebug
 When True, makes computeradialvelocity to not produce any file. More...
 
 offset
 
 Vr
 
 HR
 
 resolution
 
 stepVr
 stepping value
 
 baryCorr
 
 emission
 
 mask
 
 doPlot
 
 firstPass
 
 nVr
 
 flat
 
 wLnScale
 
 ThAr
 
 addFiles
 
 results
 
 noVRfiles
 
 plotOrder
 When True, makes computeradialvelocity to not produce any file. More...
 
 findmask
 
 ROT
 
 WRF
 
 orderLambdaMinMax
 
 sigmaBool
 
- Public Attributes inherited from hermes.pipeline.core.pipelinecomponent.PipelineComponent
 options
 
 logger
 
 ConsoleLogSeverity
 default value
 
 canShowGraphics
 when machine does not run matplotlib. More...
 

Static Public Attributes

string program = "computeRadialVelocity"
 Some useful shortcuts.
 
list header = self.results[ "FITSheader" ]
 
list fiber = header[ "FIBMODE" ]
 
 nameWscale = self.wLnScale
 
tuple masksPath = os.path.join( findHermesPath ( ), model.VRmasksFolder )
 
list star = header[ 'OBJECT' ]
 
list findex = self.results[ "fileindex" ]
 
string nameFlat = "*"
 ---------------— Flatfield processing --------------------------—###
 
tuple absPath = os.path.abspath( self.results [ "FITSFileNames" ] [ 0 ] )
 -------------------— WavelengthScale selection -------------------------------------------—###
 
tuple flatFile = glob.glob( os.path.join ( inpath, nameFlat ) )
 
tuple flatData = readArray( flatFile [ -1 ], self.results )
 
tuple spectrum = N.nan_to_num( N.transpose ( self.results["rawImage"] ) [ : : -1, : : -1 ] )
 ------------------— Revert input image and put zeroes in nans ----------------------------—###
 
tuple wLSfiles = glob.glob( os.path.join ( inpath, nameWscale ) )
 
list wlsFile = wLSfiles[ 0 ]
 
tuple wS = pyfits.open( wlsFile )
 
list wsFrame = wS[ 0 ]
 
 wlsNumber = nameWscale
 
string nameWscale = "*WRF_TH_ext_wavelengthScale.fits"
 
tuple wavLnFiles = glob.glob( os.path.join ( inpath, nameWscale ) )
 
int distance = 999999999
 
tuple fname = os.path.basename( name )
 
tuple ecart = abs( int ( unique ( fname ) ) - int ( findex ) )
 
 distance = ecart
 
 wlsFile = name
 
tuple wlsNumber = unique( os.path.basename ( wlsFile ) )
 
tuple wsFrame = readArray( wlsFile, self.results )
 
list wLnScale = wsFrame[ : : -1, : : -1 ]
 ------------------------— WavelengthScale processing ---------------------------—
 
int ii = i-1
 
 msk = model.FirstVRmaskToUse
 ------------------------— MASK selection -----------------------------—### More...
 
tuple msk = os.path.normpath( os.path.join ( masksPath, self.mask ) )
 Build the list without the firstMaskToUse and without the ThAr specific one or the tellurics specific one.
 
tuple masque = readArray( self.maskfile, self.results )
 
tuple maskfile = os.path.basename( self.maskfile )
 ----------------------— FIT ON TELLURIC -----------------------------------—##
 
tuple corrfit = N.zeros( [ nbrBlocs, self.nVr] )
 
tuple Vrad = N.zeros( [ nbrBlocs], float )
 
tuple sigVr = N.zeros( [ nbrBlocs], float )
 
tuple depth = N.zeros( [ nbrBlocs], float )
 
tuple sigm = N.zeros( [ nbrBlocs], float )
 
tuple sigdpth = N.zeros( [ nbrBlocs], float )
 
tuple sigwidth = N.zeros( [ nbrBlocs], float )
 
tuple SN = N.zeros( [ nbrBlocs], float )
 
tuple xcorrMean = N.zeros( [ nbrBlocs], float )
 
tuple errcorr = N.zeros( [ nbrBlocs], float )
 
tuple y0 = N.zeros( self.nVr)
 
tuple y1 = N.zeros( self.nVr)
 
tuple y2 = N.zeros( self.nVr)
 
tuple y3 = N.zeros( self.nVr)
 
tuple y4 = N.zeros( self.nVr)
 
tuple y5 = N.zeros( self.nVr)
 
int corrfit0 = 0
 
int corrfit1 = 0
 
int corrfit2 = 0
 
int corrfit3 = 0
 
int corrfit4 = 0
 
int corrfit5 = 0
 
int Vrtellcorr = 0
 
int sigVrtellcorr = 0
 
int sigVrtell = 0
 
int sigmatell = 0
 
 xcorr5init = False
 
 xcorr4init = False
 
 xcorr3init = False
 
 xcorr2init = False
 
 xcorr1init = False
 
 xcorr0init = False
 
list expTime = header[ 'EXPTIME' ]
 
int expTime = 0
 
tuple HJD = float( header [ 'BJD' ] )
 
list dt = header[ 'HJD' ]
 
tuple day = dateutil.parser.parse( header [ 'DATE-OBS' ] )
 
tuple dt = ephem.julian_date( day )
 
 HJD = dt
 
list otherMasksToTry = []
 
int actuallyTried = 0
 
tuple possibleMasks = glob.glob( os.path.normpath ( os.path.join ( masksPath, "*.fits" ) ) )
 Add all other masks to the list when allowed to.
 
string msg1 = "computeRadialVelocity : all mask scan fitting failed"
 When no mask is found fitting in the available ones, log a warning and stop.
 
string msg2 = 'No radial-velocity found with the current mask'
 
string msg = "Main module compute radial velocity ended."
 
tuple x0array = N.array(x0)
 Header printing for results after trying several masks LDU 25/10/2012.
 
list fitfunc = lambdap,x0,a0:p[3]
 
tuple errfunc = lambdap,x0,y0,a0:fitfunc(p, x0, a0)
 
int nbincorr = 200
 
list y5 = CCForder[:, 5]
 
 x5 = x0
 
int y5array = 1
 
tuple ycorrtest5 = min(y5array)
 
tuple indexmax5 = int(scipy.where(y5array == ycorrtest5)[0])
 
tuple nbincorr = min(indexmax5-1,self.nVr-indexmax5-1)
 
tuple indices5 = scipy.arange(indexmax5 - nbincorr, indexmax5 + nbincorr)
 
tuple xcorr5 = scipy.take(x0array,indices5)
 
tuple ycorr5 = scipy.take(y5array,indices5)
 
tuple a5 = scipy.zeros(scipy.shape(xcorr5))
 
list p00 = scipy.c_[ycorrtest5, scipy.where(ycorr5 == ycorrtest5)[0], 2.5, 0.]
 
list p0 = p00[0,:]
 
tuple corrfit5 = fitfunc(p1, xcorr5, a5)
 
tuple chisq = sum(infodict["fvec"]*infodict["fvec"])
 
tuple dof = len(xcorr5)
 
tuple xint = xcorr5.compress(abs((xcorr5-p1[1])/ p1[2]) < 2.0)
 
tuple xextr = xcorr5.compress(((xcorr5 - p1[1]) / p1[2]) > 5.)
 
tuple xextl = xcorr5.compress(((xcorr5 - p1[1]) / p1[2]) < -5.)
 
string pf = '55-74 (black) : %5.2f +/-%7.2f %8.3f +/-%8.3f %4d %7.2f+/-%7.2f %6.1f %8.2e %4i'
 
list y4 = CCForder[:, 4]
 
 x4 = x0
 
int y4array = 1
 
tuple ycorrtest4 = min(y4array)
 
tuple indexmax4 = int(scipy.where(y4array == ycorrtest4)[0])
 
tuple indices4 = scipy.arange(indexmax4 - nbincorr, indexmax4 + nbincorr)
 
tuple xcorr4 = scipy.take(x0array,indices4)
 
tuple ycorr4 = scipy.take(y4array,indices4)
 
tuple a4 = scipy.zeros(scipy.shape(xcorr4))
 
tuple corrfit4 = fitfunc(p1, xcorr4, a4)
 
list y3 = CCForder[:, 3]
 
 x3 = x0
 
int y3array = 1
 
tuple ycorrtest3 = min(y3array)
 
tuple indexmax3 = int(scipy.where(y3array == ycorrtest3)[0])
 
tuple indices3 = scipy.arange(indexmax3 - nbincorr, indexmax3 + nbincorr)
 
tuple xcorr3 = scipy.take(x0array,indices3)
 
tuple ycorr3 = scipy.take(y3array,indices3)
 
tuple a3 = scipy.zeros(scipy.shape(xcorr3))
 
tuple corrfit3 = fitfunc(p1, xcorr3, a3)
 
list y2 = CCForder[:, 2]
 
 x2 = x0
 
int y2array = 1
 
tuple ycorrtest2 = min(y2array)
 
tuple indexmax2 = int(scipy.where(y2array == ycorrtest2)[0])
 
tuple indices2 = scipy.arange(indexmax2 - nbincorr, indexmax2 + nbincorr)
 
tuple xcorr2 = scipy.take(x0array,indices2)
 
tuple ycorr2 = scipy.take(y2array,indices2)
 
tuple a2 = scipy.zeros(scipy.shape(xcorr2))
 
tuple corrfit2 = fitfunc(p1, xcorr2, a2)
 
list y1 = CCForder[:, 1]
 
 x1 = x0
 
int y1array = 1
 
tuple ycorrtest1 = min(y1array)
 
tuple indexmax1 = int(scipy.where(y1array == ycorrtest1)[0])
 
tuple indices1 = scipy.arange(indexmax1 - nbincorr, indexmax1 + nbincorr)
 
tuple xcorr1 = scipy.take(x0array,indices1)
 
tuple ycorr1 = scipy.take(y1array,indices1)
 
tuple a1 = scipy.zeros(scipy.shape(xcorr1))
 
tuple corrfit1 = fitfunc(p1, xcorr1, a1)
 
list y0 = CCForder[:, 0]
 
int y0array = 1
 
tuple ycorrtest0 = min(y0array)
 
tuple indexmax0 = int(scipy.where(y0array == ycorrtest0)[0])
 
tuple indices0 = scipy.arange( indexmax0 - nbincorr, indexmax0 + nbincorr )
 
tuple xcorr0 = scipy.take( x0array, indices0 )
 
tuple ycorr0 = scipy.take( y0array, indices0 )
 
tuple a = scipy.zeros( scipy.shape ( xcorr0 ) )
 
tuple corrfit0 = fitfunc(p1, xcorr0, a)
 
tuple fig = plt.figure()
 
string staticText = 'Star: %s File: %s %s\n NO BARYCENTRIC CORRECTION \n%s \n'
 
tuple graphTitle = staticText%(star, findex, HJD, "Mask : " + maskfile)
 
tuple ax3 = fig.add_subplot( 211)
 
string titl = "black:55-74 magenta:85-90 blue:75-84 green:65-74 yellow:55-64 red:51-54 \n"
 
tuple ax4 = fig.add_subplot( 212)
 
tuple indicesleft5 = scipy.arange(indexmax5 - nbincorr - 20 , indexmax5 - nbincorr - 2)
 
tuple indicesright5 = scipy.arange(indexmax5 + nbincorr + 2, indexmax5 + nbincorr + 20)
 
tuple xleft5 = scipy.take(x0array, indicesleft5)
 
tuple yleft5 = scipy.take(y5array, indicesleft5)
 
tuple xright5 = scipy.take(x0array, indicesright5)
 
tuple yright5 = scipy.take(y5array, indicesright5)
 
string text = 'Vr= %8.3f +/- %5.3f km/s'
 "if" added by Louis on the 8 march 2012
 
tuple fn1 = buildPath(self.results["AnalysesResults"], findex + '_VR.png')
 
list yorder = CCForderi/CCForderi[0, 25]
 
tuple fig3 = plt.figure()
 
string tit3 = 'CCF: %s %s %s \n Mask : %s \n '
 
tuple ax5 = fig3.add_subplot( 111)
 
string tit5 = "magenta:85-90 blue:75-84 green:65-74 yellow:55-64 red:51-54 \n"
 
tuple v = ( a[0] - ( a[1] - a[0] ) / 20., a[1] + ( a[1] - a[0] ) / 20., a[2], a[3] )
 
int s = 94
 
tuple lab = str(s[i])
 
list xlab = x0[-20]
 
list ylab = yorder[-20, i]
 
int Vrtell = 0
 
tuple SNtell = N.sqrt( avFluxOrdertell [ 4 ] )
 
int y4 = 1
 
tuple ymax4 = max( y4 )
 
list fitfunctell = lambdap,x0:p[ 3 ]
 guess some fit parameters p00 = scipy.c_[ymax4, scipy.where(y4 == ymax4)[0], -0.01] transform array into vector p0 = p00[0, :] indexmax = int(p0[1]) p0[1] = x0[indexmax] indices = scipy.arange(indexmax - 25, indexmax + 25) print indexmax, p0 More...
 
tuple errfunctell = lambdap,x0,y0:fitfunctell( p, x0 )
 
tuple indexmax = int( p0 [ 1 ] )
 
tuple indices = scipy.arange( indexmax - 35, indexmax + 35 )
 
int depthtell = 0
 
int chisq = 0
 
int dof = 0
 
int errcorrtell = 0
 
int sigdpthtell = 0
 
int sigwidthtell = 0
 
tuple corrfittell = fitfunctell(p1, xcorr4)
 
list Vrtell = p1[ 1 ]
 
list depthtell = p1[ 0 ]
 
list sigmatell = p1[ 2 ]
 
tuple errcorrtell = N.sqrt( chisq / dof )
 
tuple sigVrtell = N.sqrt( cov_x [ 1, 1 ] )
 
tuple sigdpthtell = N.sqrt( cov_x [ 0, 0 ] )
 
tuple sigwidthtell = N.sqrt( cov_x [ 2, 2 ] )
 
list Vrtellcorr = Vrad[ 5 ]
 
tuple sigVrtellcorr = N.sqrt( sigVr [ 5 ] ** 2 + sigVrtell ** 2 )
 
tuple valVrtell = str( Vrtellcorr )
 
string comVrtell = 'Vr from tellurics : '
 
string line = comVrtell+valVrtell+' km/s'
 Add VRSTART, VRSTEP and VRNPIX to the result header xcorr0.
 
string graphTitle = 'Telluric CCF: %s %s %s\n MASK : %s \n'
 
tuple ax0 = fig.add_subplot( 111 )
 
tuple fileName = buildPath( self.results [ "AnalysesResults" ], findex + '_AllCCF.data' )
 -------------——— end of telluric processing -----------------———## More...
 
tuple fitsName = buildPath( self.results [ "AnalysesResults" ], findex + '_AllCCF.fits' )
 
tuple resultFile = os.path.join( self.results [ "AnalysesResults" ], fileName )
 
tuple resultFits = os.path.join( self.results [ "AnalysesResults" ], fitsName )
 
tuple fileCCFdata = open( resultFile, "w" )
 
tuple fitsData = CCForderi.copy()
 
tuple ornames = str( N.arange ( 94, 45, -1 ) )
 
tuple hdu = pyfits.PrimaryHDU( fitsData )
 
tuple hduList = pyfits.HDUList( [ hdu ] )
 
 prihdr = header
 
list cold = []
 
tuple tb_hdu = pyfits.new_table( cold )
 
list FFh = flatFile[ -1 ]
 
string FFh = "None"
 
tuple valVr = str( Vrad [ 5 ] )
 
string comVr = 'Vr from orders 55-74 : '
 
tuple drift = str( self.rvDrift )
 
string comDrift = 'Vr Drift (2F frame) : '
 
tuple telloff = str( self.offset )
 
string comtell = 'Telluric offset : '
 
tuple sigmatell = str( sigmatell )
 
string line1 = 'Fitting method = Gaussian \n'
 
string line2 = ' order : depth Vr +/- nLines Vrot sin i +- <S/N> RMS O-C \n'
 
string line3 = ' (spec) sqrt(chi2/dof)\n'
 
tuple line
 
tuple SNorder = N.sqrt( meanFlux )
 
int iorder = 94
 
list yi = CCForderi[ : , i ]
 
int ycorri = 1
 
tuple ycorrtesti = min( ycorri )
 
tuple azero = scipy.zeros( scipy.shape ( x0 ) )
 
int Vri = 0
 
int sigVri = 0
 
int depthi = 0
 
int sigdepthi = 0
 
int xcorrMeani = 0
 
int corrfiti = 0
 
int errcorri = 0
 
tuple corrfiti = fitfunc( p1, x0, azero )
 
list xcorrMeani = p1[ 1 ]
 
list sigmi = p1[ 2 ]
 
list depthi = p1[ 0 ]
 
list Vri = p1[ 1 ]
 
tuple errcorri = N.sqrt( chisq / dof )
 
tuple sigVri = N.sqrt( cov_x [ 1 , 1 ] )
 
tuple sigdepthi = N.sqrt( cov_x [ 0 , 0 ] )
 
tuple sigwidthi = N.sqrt( cov_x [ 2 , 2 ] )
 
string fp = ' order %2d : %5.2f +/-%7.2f %8.3f +/-%8.3f %4d %7.2f+/-%7.2f %6.1f %8.3f \n'
 
list colv = []
 
tuple tb_vri = pyfits.new_table( colv )
 
tuple ax = fig.add_subplot( 111 )
 
list unwanted = [ "NAXIS", "BITPIX", "NAXIS1", "NAXIS2", "SIMPLE", "EXTEND" ]
 we will NOT hold values for those keywords : ["NAXIS", "BITPIX", "NAXIS1", "NAXIS2", "SIMPLE", "EXTEND"] More...
 
 hc = prihdr.ascard
 update new header with all other values from passed one
 
tuple l = len( prihdr.keys ( ) )
 
list k = hc[ i ]
 
string k = "HIERARCH "
 
string fileName = 'tharvelocities.data'
 
tuple waveFile = unique( os.path.basename ( wlsFile ) )
 
tuple analyseFile = open( resultFile, "a" )
 

Detailed Description

computes the radial velocity

PURPOSE :
compute the radial velocity



COMMENTS :




INPUT CONSTANTS FROM INSTRUMENT MODEL :

arcturus
ThArNe
alamminmax
Mgiant
pAGB




INPUT DATA FROM RESULTDICT :

MANDATORY :
    self.results["rawImage"] : the image

    self.results["FITSheader"]            # reference to header dict
        or
        self.results["FITSheaderList"] [0]





OPTIONS READ FROM OPTIONDICT :

MANDATORY :
    -

OPTIONAL :
    isDebug (Boolean : True or False)
        default value : False
        writes a fits file with the results

    Vr0 is an initial guess for the radial velocity

    HR = 84600, Delta v = 300000 / 2.2 / HR = 1.61 km/s
        pixel size in velocity space

    baryCorr is a value for barycentric correction
        default is 0

    emission = False    #   default value
                        #   CCF is absorption

    mask = 1    #   default value
                #   Arcturus mask

    twostep = False     #   default value
                        # when true, scan first

    doPlot  = False     #   default value
                        # when true, plot

    wLnScale  :  a path to an optionnal
            wavelength scale file.
            That path must be complete and is machine-specific.



OUTPUT written in the RESULTDICT :

When success condition is met :


When success condition is not met :





SUCCESS CONDITIONS :

    RESULTDICT should provide the input information, usually
    coming from previously runned components.




STRATEGY :

When no wavelengthScale file is passed as optional parameter,
the routine finds the closer file (by index number) in the same night.

Member Function Documentation

def hermes.pipeline.components.computeRadialVelocity.computeRadialVelocity.__call__ (   self,
  model 
)

runs from here

def hermes.pipeline.components.computeRadialVelocity.computeRadialVelocity.Vrcor (   Vr)

---------------------—— computational routine -----------------------——###

if self.firstPass:

Member Data Documentation

string hermes.pipeline.components.computeRadialVelocity.computeRadialVelocity.fileName = buildPath( self.results [ "AnalysesResults" ], findex + '_AllCCF.data' )
static

-------------——— end of telluric processing -----------------———##

Write CCF in the resultDict (always done) Added 28 may 2014 for new release:

list hermes.pipeline.components.computeRadialVelocity.computeRadialVelocity.fitfunctell = lambdap,x0:p[ 3 ]
static

guess some fit parameters p00 = scipy.c_[ymax4, scipy.where(y4 == ymax4)[0], -0.01] transform array into vector p0 = p00[0, :] indexmax = int(p0[1]) p0[1] = x0[indexmax] indices = scipy.arange(indexmax - 25, indexmax + 25) print indexmax, p0

print type(p0), scipy.shape(p0),p0,xcorr4 print fitfunctell(p0,xcorr4) print errfunctell(p0,xcorr4,ycorr4)

hermes.pipeline.components.computeRadialVelocity.computeRadialVelocity.isDebug

When True, makes computeradialvelocity to not produce any file.

tuple hermes.pipeline.components.computeRadialVelocity.computeRadialVelocity.line
static
Initial value:
1 = pf%( orderNames [ nl ], depth[ nl ], sigdpth [ nl ], xcorrMean [ nl ], sigVr [ nl ],
2  nLinesOrder [ nl ], sigm [ nl ], sigwidth [ nl ], SN [ nl ], errcorr [ nl ] )
tuple hermes.pipeline.components.computeRadialVelocity.computeRadialVelocity.msk = model.FirstVRmaskToUse
static

------------------------— MASK selection -----------------------------—###

Build the list without the firstMaskToUse and without the ThAr specific one or the tellurics specific one.

hermes.pipeline.components.computeRadialVelocity.computeRadialVelocity.plotOrder

When True, makes computeradialvelocity to not produce any file.

list hermes.pipeline.components.computeRadialVelocity.computeRadialVelocity.unwanted = [ "NAXIS", "BITPIX", "NAXIS1", "NAXIS2", "SIMPLE", "EXTEND" ]
static

we will NOT hold values for those keywords : ["NAXIS", "BITPIX", "NAXIS1", "NAXIS2", "SIMPLE", "EXTEND"]

PYFITS has generated the good ones for our image (those present in the received header are not necessarily correct as our programs may have changed the images)


The documentation for this class was generated from the following file: