PynPoint package

Submodules

PynPoint.Basis module

class PynPoint.Basis.basis[source]

Bases: PynPoint._BasePynPoint.base_pynpoint

For creating a basis set from a given set of postage stamp images

classmethod create_restore(filename)[source]

Restores data from a hdf5 file previously created using the save method of a basis instance.

Parameters:filename – name of the inputfile
Returns:instance of the basis class
classmethod create_wdir(dir_in, **kwargs)[source]

Creates an instance of the basis class.

Parameters:
  • dir_in – name of the directory with fits files
  • recent – if True, the images will be re-centered
  • resize – if True, the final images will be increased by a factor set by F final
  • cent_remove – if True, the central region will be masked (size set by cent size).
  • F_final – factor increase in resolution of final images (resize must be True).
  • ran_sub – a random subset is used if a number is passed.
  • para_sort – if True, the images will be sorted so that the parallax angles increase through the stack.
  • cent_size – radius of the central mask as fraction of the full image size.
  • edge_size – diameter of the outer mask in fraction of the image size.
  • stackave – if set to an integer (N), then the stack will be reduced by averaging over adjacent N images.
Returns:

instance of the basis class

classmethod create_wfitsfiles(files, **kwargs)[source]

Creates an instance of basis from a list of fits files.

Parameters:
  • files – list of strings with fits filenames
  • kwargs – accepts the same keyword options as create_wdir()
Returns:

instance of the basis class

classmethod create_whdf5input(file_in, **kwargs)[source]

Creates an instance of basis from hdf5 file.

Parameters:
  • file_in – path to the hdf5 file containing the images
  • kwargs – accepts the same keyword options as create_wdir()
Returns:

instance of the basis class

mk_basis_set()[source]

creates basis set attributes using the images stored in im_arr

mk_orig(ind)[source]

Function for producing an original input image

Parameters:ind – index of the image to returned
Returns:2D numpy array with the original input image
mk_psfmodel(num)[source]

Makes a model of the PSF using its PSF basis.

Parameters:num – number of basis coefficients used in the fit

PynPoint.Images module

class PynPoint.Images.images[source]

Bases: PynPoint._BasePynPoint.base_pynpoint

Deals with the postage stamp images that will be analysed. An instance of images can be created in a number of ways. Inputs can be either fits files or hdf5 files. Once read in the data will be processed according to the user specified keyword options.

Once created the instance of images can be saved using its save method. This can later be restored using the restore method.

classmethod create_restore(filename)[source]

Restores data from a hdf5 file previously created using the save method of a images instance.

Parameters:filename – name of the inputfile
Returns:Instance of the images class
classmethod create_wdir(dir_in, **kwargs)[source]

Creates an instance of the images class.

Parameters:
Returns:

instance of the images class

classmethod create_wfitsfiles(*args, **kwargs)[source]

Creates an instance of images class from a list of fits files.

Parameters:
Returns:

instance of the images class

classmethod create_whdf5input(file_in, **kwargs)[source]

Creates an instance from hdf5 file.

Parameters:
mk_psf_realisation(ind, full=False)[source]

Function for making a realisation of the PSF using the data stored in the object

Parameters:
  • ind – index of the image to be modelled
  • full – if set to True then the masked region will be included
Returns:

an image of the PSF model

PynPoint.PynPlot module

PynPoint.PynPlot.anim_im_arr(obj, time_gap=0.04, im_range=[0, 50])[source]

Produces an animation of the im_arr entries, which are the images used in the instance.

Parameters:
  • obj – an instance of images, basis or residual
  • time_gap – pause time between images
  • im_range – if None then all the images will be used (this could take a long time). Otherwise im_range should be set to the range of indecies (e.g. [100,150])
Example::
from PynPoint import PynPlot PynPlot.anim_im_arr(res)
PynPoint.PynPlot.plt_im_arr(obj, ind, returnval=False, savefits=False, mask_nan=True)[source]

Used to plot the im_arr entry

Parameters:
  • savefits – set to a filename is you wish to save a fits file
  • mask_nan – if True then the mask regions will be set to numpy.nan
  • obj – an instance of images, basis or residual
  • ind – index of the image to be plotted
  • returnval – set to True if you want the function to return the 2D array
Returns:

2D array of what was plotted (optional)

PynPoint.PynPlot.plt_psf_basis(obj, ind, returnval=False, savefits=False, mask_nan=True)[source]

Plots the basis images used to model the PSF.

Parameters:
  • savefits – set to a filename is you wish to save a fits file
  • mask_nan – if True then the mask regions will be set to numpy.nan
  • obj – an instance that has psf_basis attribute (basis or residuals)
  • ind – index of the basis image to be plotted
  • returnval – set to True if you want the function to return the 2D array
Returns:

2D array of what was plotted (optional)

PynPoint.PynPlot.plt_psf_model(res, ind, num_coeff, returnval=False, savefits=False, mask_nan=True)[source]

Plots the PSF model

Parameters:
  • savefits – set to a filename is you wish to save a fits file
  • mask_nan – if True then the mask regions will be set to numpy.nan
  • res – an instance of residuals class
  • ind – index of the image being modeled
  • num_coeff – number of basis sets to use
  • returnval – If True the 2D array that was plotted is returned

Example

from PynPoint import PynPlot
PynPlot.plt_psf_model(res,6,40)
PynPoint.PynPlot.plt_res(res, num_coeff, imtype='mean', smooth=None, returnval=False, savefits=False, mask_nan=True, extra_rot=0.0)[source]

Plots the residual results (either an average or the variance) and gives the image as a return value.

Parameters:
  • extra_rot – extra rotation angle. If set to zero (default) then the images will be rotated to the parallactic angle of the first images.
  • res – An instance of residual class
  • num_coeff – Number of coefficients used in the fit
  • imtype – Type of image to plot. Options are: ‘mean’, ‘mean_clip’, ‘median’, ‘var’, ‘sigma’ and ‘mean_sigma’
  • smooth – If None (default) then no smoothing is done, otherwise supply a 2 elements list (e.g. [2,2]). The image will be smoothed with a 2D Gaussian with this sigma_x and sigma_y (in pixel units).
  • returnval – set to True if you want the function to return the 2D array
  • savefits – Should be either False (nothing happens) or the name of a fits file where the data should be written
  • mask_nan – If set to True (default) masked region will be set to np.nan else set to zero
Returns:

2D array of what was plotted (optional)

Example

PynPlot.plt_res(res,20,imtype='mean',returnval=True)

PynPoint.Residuals module

class PynPoint.Residuals.residuals[source]

Bases: PynPoint._BasePynPoint.base_pynpoint

For dealing with the residual data. This includes object detection and flux measurement. Once created, the simplest way to access and visualise the data is to use PynPoint.PynPlot.plt_res()

classmethod create_restore(filename)[source]

Restores data from a hdf5 file previously created using the save method of a residuals instance.

Parameters:filename – name of the inputfile
Returns:Instance of the residuals class
classmethod create_winstances(images, basis)[source]

Creates an instance of residuals

Parameters:
  • images – instance of the images class
  • basis – instance of the basis class
Returns:

instance of residuals

mk_psfmodel(num)[source]
res_arr(num_coeff)[source]

Returns a 3D data cube of the residuals, i.e. a psf model is removed from every image.

Parameters:num_coeff – number of coefficients used in the PSF modelling
res_rot(num_coeff, extra_rot=0.0)[source]

Returns a 3D data cube of residuals where all the images have been rotated to have the same para angle. (We recommend accessing this functionality through PynPoint.PynPlot.plt_res())

res_rot_mean(num_coeff, extra_rot=0.0)[source]

Returns a 2D image of residuals after averaging (mean) down the stack. All the images in the stack are rotated to that they have the same para angle. (We recommend accessing this functionality through PynPoint.PynPlot.plt_res())

res_rot_mean_clip(num_coeff, extra_rot=0.0)[source]

Returns a 2D image of residuals after averaging down the stack. All the images in the stack are rotated to that they have the same para angle. (3 sigma) (We recommend accessing this functionality through PynPoint.PynPlot.plt_res())

res_rot_median(num_coeff, extra_rot=0.0)[source]

Returns a 2D image of residuals after averaging (median) down the stack. All the images in the stack are rotated to that they have the same para angle. (We recommend accessing this functionality through PynPoint.PynPlot.plt_res())

res_rot_var(num_coeff, extra_rot=0.0)[source]

Returns a 2D image of the variance of the residuals down the stack. All the images in the stack are rotated to that they have the same para angle. (We recommend accessing this functionality through PynPoint.PynPlot.plt_res())

PynPoint.Workflow module

class PynPoint.Workflow.workflow[source]

A simple workflow engine for managing PynPoint runs. This engine takes in a configuration file where the user can specify all the operations that should be run along with keyword options

get(name)[source]

Used to extract instances of images, basis or residuals from the workflow instance

Parameters:name – name of the option to be restored - see get_available() for available options
get_available()[source]

Returns the available module names

Returns:List of modules
static restore(dirin)[source]

Restores a workspace that has previously been calculated by the workflow.

Parameters:dirin – Work directory created by by an earlier calculation (using run method).
Returns:Instance of workflow
static run(config, force_replace=False)[source]

Runs the workflow using config. A copy of the data produced will also be stored to disk in the location specified in the config file.

Parameters:
  • config – name of the config file with details of the run to be executed
  • force_replace – If True then the workspace directory will be overwritten if it already exists
Returns:

Instance of workflow

Module contents

PynPoint.get_data_dir()[source]

Returns the path to the data directory containing the example data sets.

Returns:String with path to the directory
PynPoint.restore(dirin)[source]

Delegates the execution to workflow.restore()

Parameters:dirin – Work directory created by an earlier calculation (using run method).
Returns:the instance of the workflow
PynPoint.run(config, force_replace=False)[source]

Delegates the execution to workflow.run()

Parameters:
  • config – name of the config file with details of the run to be executed
  • force_replace – If True then the workspace directory will be overwritten if it already exists
Returns:

the instance of the workflow