SLITMASK module

slitmask is still in development

slitmask is the pyvista module that implements routines for dealing with slit masks.

Several routines are provided to facilitate getting objects into slitlets based on an image of the mask and an image of the field: findholes() finds the location of holes on a slitmask flat field image, findstars() finds stars on an image, and fit() solves for the translation and rotation to put the stars into the holes.

Within a Trace object, findslits() attempts to find the slitlets in a i spectroscopic image.

slitmask functions:

pyvista.slitmask.sim(n=5, rad=4, sky=500, back=1000.0, xr=[500, 1500], yr=[1000, 3000], counts=[5000, 20000], rot=0.05, dx=1, dy=-1)[source]

Simulate a slitmask image for KOSMOS

Parameters
  • n (int, optional, default=5) – Number of slitmask holes

  • rad (float, optional, default=4) – radius of holes, in arcsec

  • sky (float, optional, default=500) – amplitude of image in the holes

  • back (float, optional, default=1000) – background amplitude

  • xr (list, optional, default[500,1500]) – x range for hole locations

  • yr (list, optional, default[1000,3000]) – y range for hole locations

  • counts (list, optional, default=[5000,20000]) – range for counts of artificial stars

  • rot (float, optional, default=0.05) – simulated rotation in degrees

  • dx (float, optional, default=1.) – simulated x offset

  • dy (float, optional, default=-1.) – simulated y offset

Returns

a, b – Data arrays of mask and star images

Return type

array

pyvista.slitmask.findholes(a, thresh=1250, n=5, bandwidth=20)[source]

Find centers of slitmask holes from flat-field image

Parameters
  • data (array) – Flat-field image with slitmask holes illuminated

  • thresh (float, optional, default=1250) – Value above which pixel is flagged to be in the hole

  • n (int, optional,default=5) – number of clusters to find, should be equal to number of holes

Return type

Table of hole centers

pyvista.slitmask.findstars(b, thresh=500, sharp=[0.4, 2])[source]

Find locations of stars on image

Parameters
  • data (array) – image with stars in slitmask holes

  • thresh (float, optional, default=500) – Threshold for finding star

  • sharp (list, optional, default=[0.4,2])) – [min,max] sharpness values to accept as star

Return type

Table of star locations

pyvista.slitmask.fit(holes, locstars, ordered=False, fitscale=False)[source]

Given tables of hole and star locations, find offset and rotation

Parameters
  • holes (astropy Table) – table of hole positions

  • stars (astropy Table) – table of star positions

  • ordered (bool, default=False) –

    if False, match holes to stars by closest distance. if True, stars and holes should match by table order

    (and tables should have the same number of entries)

  • fitscale (bool, default=False) – if True, solve for scale as well as rotation and translation

Returns

  • rotation (degrees)

  • translation (arcsec, assuming .258 arcsec/pix)

  • scale (if fitscale=True)

pyvista.slitmask.test(n=5, rot=0.05, dx=1, dy=-1, display=None)[source]

Run a test of slitmask routines. Simulates image and tries to recover rotation and offset

Parameters
  • n (int, optional, default=5) – Number of slitmask holes

  • rot (float, optional, default=0.05) – simulated rotation in degrees

  • dx (float, optional, default=1.) – simulated x offset

  • dy (float, optional, default=-1.) – simulated y offset

  • display (pyvista TV object, optional, default=None) – if specified, display image in specified object

pyvista.slitmask.findslits(data, smooth=3, thresh=1500, display=None, cent=None, degree=2, skip=50)[source]

Find slits in a multi-slit flat field image

Parameters
  • data (array or Data object, wavelength dimension horizontal) – input data to find slit edges, usually a flat field

  • smooth (float, optional, default=3) – smoothing radius for calculated derivatives

  • thresh (float, optional, default=1500) –

  • skip (integer, optional, default=50) – spacing of where along spectra to identify edges

  • display (TV object, optional) – TV object to display slit locations on

  • cent (int, optional, default=None) – location of center of spectra, if None use chip center

  • degree (int, option, degree=2) – polynomial degree to use to fit edge locations

pyvista.slitmask.fitpeak(data, irow, peaks, smooth=3, width=3, desc=False)[source]

Find slit edges given input set of locations

Parameters
  • data (1D array) – input data to find slit edges, usually a flat field

  • irow (integer) – location in image to find edges at

  • smooth (integer, optional, default=3) – smoothing radius for derivative calculation

  • width (integer, optional, default=3) – window around peak of derivative to do polynomial fit for edge

  • desc (book, optional, default=False) – if True, find descending peaks

pyvista.slitmask.read_kms(file, sort=None)[source]

Read KMS file, return targets, create YAML file

Parameters
  • file (str) – input KMS file name

  • sort (str, optional, default=None) – if specified, return target list sorted by sort