CCFCenter
This script is used to find the center an meaure the width of a CCF peak.
Functions | Variables
ccfcenter Namespace Reference

This module finds the center and width of a MARVELS ccf. More...

Functions

def cutccf
 Choose which section of the ccf to fit based on width parameter or automatically using percent.
def gaussfunc
 Takes x points and returns a Gaussian function.
def gausstest
 Creates a Gaussian signal and then fits it to see if I can recover the input parameters.
def fitgauss
 Use a Levenberg-Marquadt non-linear least-squares fitter to fit a Gaussian to Xin and Yin.
def make_gauss
 Generate Gaussian data using Gaussian.
def ccfcenter
 This function is the main() program for this module.

Variables

list filename = sys.argv[1]
 width = None
tuple ret = ccfcenter(filename,width)

Detailed Description

This module finds the center and width of a MARVELS ccf.

This module uses a non-linear least-squares optimizer from scipy to fit a Gaussian to the central pixels of a ccf file.

Author:
Nathan De Lee
Version:
Revision:
1.2
Date:
Date:
2012-01-13 20:12:24

Function Documentation

def ccfcenter::ccfcenter (   filename,
  width = None 
)

This function is the main() program for this module.

Parameters:
filenameString name of MARVELS ccf file to process
widthInteger number of pixels to fit around peak; None: Automatically choose
Returns:
The function returns 0 for success or an error message.
Return values:
ret0 for success or an error message

Definition at line 247 of file ccfcenter.py.

def ccfcenter::cutccf (   pixel,
  ccf,
  width = None,
  percent = 0.30 
)

Choose which section of the ccf to fit based on width parameter or automatically using percent.

Parameters:
pixelNumpy array of pixel positions
ccfNumpy array of ccf values
widthInteger number of pixels to include, if None: then automatically determine.
percentFloating point percentage of the singal amplitude above the noise that a point must be to be included in the fit.
Returns:
This function returns a tuple (pixel,ccf,lmargin,rmargin ,noiselevel).
Return values:
pixelNumpy array of pixel positions
ccfNumpy array of ccf values
lmarginInteger index of the left margin of the input arrays
rmarginInteger index of the right margin of the input arrays
noiselevelFloating point values of the CCF plot noise level

Definition at line 52 of file ccfcenter.py.

def ccfcenter::fitgauss (   xin,
  yin,
  inerror = [],
  inguess = [1 
)

Use a Levenberg-Marquadt non-linear least-squares fitter to fit a Gaussian to Xin and Yin.

The scipy module optimize is used to find the smallest residual to Error Function which is compared to the Gaussian function.

Parameters:
xinNumpy array of x-values
yinNumpy array of y-values
inerrorNumpy array of error values
inguessA 3 element list (Amplitude,Offset,Sigma) of starting values for Gaussian parameters
Returns:
This function returns a tuple (Params, perror , red_chi)
Return values:
ParamsA 3 element Numpy array of Gaussian Parameters (Amplitude,Offset,Sigma)
perrorA 3 element Numpy array of parameter errors calculated from the covariance matrix
red_chiA float giving the reduced \(\chi^{2}\) of the fit.
Remarks:
If there are no measurement errors then the parameter errors must be scaled by the reduced chisq Section 15.2 in Numerical Recipes discusses this.

Definition at line 151 of file ccfcenter.py.

def ccfcenter::gaussfunc (   P,
  x 
)

Takes x points and returns a Gaussian function.

Parameters:
PA 3 element array (Amplitude,Offset,Sigma)
xNumpy array of x positions
Returns:
y values for the x positions and parameters given
Return values:
yNumpy array of y values

Definition at line 77 of file ccfcenter.py.

def ccfcenter::gausstest ( )

Creates a Gaussian signal and then fits it to see if I can recover the input parameters.

Returns:
None
Todo:
Make a histogram of all the parameters

Definition at line 95 of file ccfcenter.py.

def ccfcenter::make_gauss (   npts,
  amp = 1,
  offset = 0,
  sigma = 1,
  error = 0,
  inflate_error = 1.0,
  randpts = False 
)

Generate Gaussian data using Gaussian.

Parameters:
nptsInteger number of points to create
ampFloating point amplitude of the Gaussian
offsetFloating point offset of the Gaussian
sigmaFloating point sigma of the Gaussian
errorFloating point number or a Numpy array of sigmas for the error in each point
inflate_errorFloating point factor to scale the real as versus reported error
randptsBool True: Select x points from a uniform distribution; False Take from a regular grid.
Returns:
This function returns a tuple (x,y,y_err)
Return values:
xNumpy Array of x positions
yNumpy Array of y positions
y_errNumpy Array of y errors

Definition at line 220 of file ccfcenter.py.


Variable Documentation

list ccfcenter::filename = sys.argv[1]

Definition at line 328 of file ccfcenter.py.

tuple ccfcenter::ret = ccfcenter(filename,width)

Definition at line 334 of file ccfcenter.py.

Definition at line 333 of file ccfcenter.py.

 All Namespaces Files Functions Variables