KCWI package

Submodules

KCWI.Blue module

KCWI.Blue.ampmodeb(ampmode=None)[source]

Reads or sets the blue channel science camera amplifer mode

Available modes are:

0 : quad (ALL) 1 : single C 2 : single E 3 : single D 4 : single F 5 : single B 6 : single G 7 : single A 8 : single H 9 : dual (A&B) 10 : dual (C&D)

Parameters:
  • ampmode (int) – Desired amplifier mode
  • modes are (Available) –
  • 1 (single C) –
  • 2 (single E) –
  • 3 (single D) –
  • 4 (single F) –
  • 5 (single B) –
  • 6 (single G) –
  • 7 (single A) –
  • 8 (single H) –
  • 9 (dual (A&B)) –
  • 10 (dual (C&D)) –

Examples

Prints the current amplifier mode

>>> Blue.ampmodeb()

Set the amplifier mode

>>> Blue.ampmodeb(ampmode=2)
KCWI.Blue.autoshutb(mode=None)[source]

Reads or sets the blue channel science camera autoshutter

Parameters:autoshutb (int) – Desired autoshutb mode (1 or 0)

Examples

Prints the current autoshut mode

>>> Blue.autoshutb(mode=1)
KCWI.Blue.binningb(binning=None, get_server=False)[source]

Reads or sets the blue channel science camera binninb

Parameters:binning (string) – Desired binning mode. Available values are ‘1,1’,‘2,2’. Future: ‘1,2’, ‘2,1’

Examples

Prints the current binning mode

>>> Blue.binningb()

Set the binning mode

>>> Blue.binningb(binning='2,2')
KCWI.Blue.binningfpc(binning=None)[source]

Reads or sets the focal plane camera binninb

Parameters:binning (string) – Desired binning mode. Available values are 1,2,4 and so on

Examples

Prints the current binning mode

>>> Blue.binningfpc()

Set the binning mode

>>> Blue.binningfpc(binning='2')
KCWI.Blue.camangleb(angvalue=None, move=True, quiet=False)[source]

Reads or set the blue channel articulation stage angle

Parameters:
  • angvalue (float) – Desired camera angle in degrees
  • move (boolean) – Set to false to only modify the target without moving the camangle
  • quiet (boolean) – Set to disable progress bar

Examples

Prints the name of the current camangle

>>> Blue.camangleb()

Go to 10 degrees

>>> Blue.camangleb(angvalue=10)

Modify the camangle target keyword but do not move

>>> Blue.camangleb(angvalue=10, move=False)
KCWI.Blue.ccdmodeb(ccdmode=None)[source]

Reads or sets the blue channel science camera ccdmode

Parameters:ccdmode (int) – Desired ccdmode Available values are 0 (slow) and 1 (fast)

Examples

Prints the current ccdmode

>>> Blue.ccdmodeb()

Set the ccdmode to fast

>>> Blue.ccdmodeb(ccdmode=1)
KCWI.Blue.ccdspeedb(ccdspeed=None)[source]

Reads or sets the blue channel science camera ccdspeed

Parameters:ccdspeed (int) – Desired ccdspeed. Available values are 0 (slow) and 1 (fast)

Examples

Prints the current ccdspeed

>>> Blue.ccdspeedb()

Set the ccdspeed to fast

>>> Blue.ccdspeedbb(ccdspeed=1)
KCWI.Blue.cwaveb(cwave=None, pwave=None, move=True, quiet=False)[source]

Show or set the central (and optionally the peak) wavelength

Parameters:
  • cwave (float) – Desired central wavelength in Angstroms
  • pwave (float) – Peak wavelength (if desired and different from cwave)
  • move (boolean) – Set to false to only modify the target without moving the stages
  • quiet (boolean) – Set to true to disable progress bar

Examples

set the central wavelength to 6700 Angstrom

>>> Blue.cwaveb(cwave=6700)
KCWI.Blue.filterb(target=None, move=True)[source]

Reads or set the blue channel filter

Parameters:
  • target (string) – Desired filter. Values are: TBD
  • move (boolean) – Set to false to only modify the target without moving the filter

Examples

Prints the name of the current filter

>>> Blue.filterb()

Insert the B1 filter

>>> Blue.filterb(target="B1")

Modify the filter target keyword but do not move

>>> Blue.filterb(target="B1", move=False)
KCWI.Blue.focusb(target=None, move=True, quiet=False)[source]

Reads or set the blue camera focus

Parameters:
  • target (float) – Desired focus value in mm.
  • move (boolean) – Set to False to just set target
  • quiet (boolean) – Set to disable progress bar

Examples

Print the current focus value >>> Blue.focusb

Set the current focus value to 1.5mm >>> Blue.focusb(target=1.5)

KCWI.Blue.gainmulb(gainmul=None)[source]

Reads or sets the blue channel science camera gain multiplier

Parameters:gainmul (int) – Desired gain multiplier. Available values are 5 and 10.

Examples

Prints the current gain multiplier

>>> Blue.gainmulb()

Set the binning mode

>>> Blue.gainmulb(gainmul=5)
KCWI.Blue.goib(nexp, dark=False)[source]

Take an exposure or a sequence of exposures with the blue camera.

Parameters:
  • nexp (int) – Desired number of exposure.
  • dark (boolean) – If True, do not open shutter
  • imtype (string) – twiflat will set the parameters for a sky flat

Examples

Take a single exposure with the blue camera

>>> Blue.goib(1)
KCWI.Blue.goifpc(nexp=1)[source]

Take an exposure or a sequence of exposures with the focal plane camera. If the keywords sequence and trigtime are set, then takes a sequence.

Parameters:nexp (int) – Desired number of exposure.

Examples

Take a single exposure with the blue camera

>>> Blue.goifpc(1)
KCWI.Blue.grangleb(angvalue=None, move=True, quiet=False)[source]

Reads or set the blue channel grating angle

Parameters:
  • angvalue (float) – Desired grating angle in degrees
  • move (boolean) – Set to false to only modify the target without moving the grangle
  • quiet (boolean) – Set to disable progress bar

Examples

Prints the name of the current camangle

>>> Blue.grangleb()

Go to 10 degrees

>>> Blue.grangleb(angvalue=10)
class KCWI.Blue.grating(name=None, gnum=None)[source]

Bases: object

Grating class that contains our knowledge of the gratings

alpha = None
beta = None
calc_alpha(grangle)[source]
calc_beta(alpha, camang)[source]
calc_cwave(alpha, beta)[source]
calc_from_angles(alpha=None, beta=None, grangle=None, camang=None)[source]

Calculate grating parameters using angle inputs.

alpha
: float
Angle of incidence in degrees (paired with beta)
beta
: float
Angle of diffraction in degrees (paired with alpha)
grangle
: float
Grating angle in degrees (paired with camang)
camang
: float
Camera articulation angle in degrees (paired with grangle)

Examples

g = Blue.grating(‘bh2’) g.calc_from_angles(50.7, 42.0) # using alpha and beta g.calc_from_angles(grangle=243.7, camang=92.7) # using instrument angles

No return values: see get_wavelengths and get_angles

calc_from_wavelengths(cwave, pwave=None)[source]

Calculate grating parameters using wavelength inputs.

Parameters:
  • cwave (float) – Desired central wavelength in Angstroms
  • Keywords –
  • -------- –
  • pwave (float) – Desired peak wavelength in Angstroms

Examples

g = Blue.grating(‘bh2’) g.calc_from_wavelengths(4400., pwave=4300.)

If pwave is not specified, it will be set to cwave

No return values: see get_wavelengths and get_angles

calc_pwave(alpha)[source]
camang = None
corang = None
cwave = None
d0 = None
d1 = None
get_angles()[source]

Returns alpha, beta, grangle, and camang:

Returns:
  • float Angle of incidence in degrees
  • float Angle of diffraction in degrees
  • float Grating angle in degrees
  • float Camera angle in degrees
get_wavelengths()[source]

Returns central and peak wavelengths:

Parameters:None –
Returns:
  • float Central wavelength in Angstroms
  • float Peak wavelength in Angstroms
gid = None
grangle = None
name = None
pwave = None
rho = None
set_alpha(alpha, quiet=False)[source]
set_beta(beta, quiet=False)[source]
set_camang(camang)[source]
set_cwave(cwave)[source]
set_grangle(grangle)[source]
set_pwave(pwave)[source]
tip = None
KCWI.Blue.gratingb(target=None, move=True)[source]

Reads or set the blue channel grating

Parameters:
  • target (string) – Desired grating. Values are: TBD
  • move (boolean) – Set to false to only modify the target without moving the grating

Examples

Prints the name of the current grating

>>> Blue.gratingb()

Insert the L grating

>>> Blue.gratingb(target="L")

Modify the grating target keyword but do not move

>>> Blue.gratingb(target="H2", move=False)
KCWI.Blue.is_in_filling_position()[source]
KCWI.Blue.nsmaskb(target=None, move=True, quiet=True)[source]

Reads or modify the position of the nod and shuffle mask

Parameters:
  • target (string) – Desired position. Valid values are: “Open”, “Test”, “Mask”
  • move (boolean) – Set to false to only modify the target without moving the N&S mask
  • quiet (boolean) – Set to disable progress bar

Examples

Prints the position of the nod and shuffle mask

>>> Blue.nsmasbk()

Set the nod and shuffle mask to Mask

>>> Blue.nsmaskb(target="Mask")
KCWI.Blue.pwaveb(pwave=None, cwave=None, move=True, quiet=False)[source]

Show or set the peak wavelength

Parameters:
  • cwave (float) – Desired central wavelength in Angstroms
  • pwave (float) – Peak wavelength
  • move (boolean) – Set to false to only modify the target without moving the stages
  • quiet (boolean) – Set to true to disable progress bar

Examples

set the peak wavelength to 6700 Angstrom

>>> Blue.pwaveb(pwave=6700)
KCWI.Blue.sequencefc(sequence=None)[source]

Reads or sets the focal plane camera sequence (number of images, 0 = continuous)

Parameters:sequence (int) – Desired number of exposures

Examples

Prints the current number of exposures

>>> Blue.sequencefc()

Set the number of the exposures

>>> Blue.sequencefc(5)
KCWI.Blue.tintb(exptime=None)[source]

Reads or sets the blue channel science camera exposure time

Parameters:exptime (float) – Desired exposure time.

Examples

Prints the current exposure time

>>> Blue.tintb()

Set the exposure time

>>> Blue.tintb(exptime=10)
KCWI.Blue.tintfc(exptime=None)[source]

Reads or sets the focal plane camera exposure time

Parameters:exptime (float) – Desired exposure time.

Examples

Prints the current exposure time

>>> Blue.tintfc()

Set the exposure time

>>> Blue.tintfc(exptime=10)
KCWI.Blue.triggerfc(trigger_time=None)[source]

Reads or sets the focal plane camera trigger time

Parameters:trigger_time (int) – Desired trigger time (interval between exposures)

Examples

Prints the current trigger time

>>> Blue.triggerfc()

Set the triger time

>>> Blue.triggerfc(5)

KCWI.Calibration module

KCWI.Calibration.cal_mirror(position=None, move=True, quiet=False)[source]

Reads or set the calibration mirror position

Parameters:
  • position (string) – Desired position. Valid values are “Mirror”, “Sky”, or “Filter”
  • move (boolean) – Set to False to only set the target without moving
  • quiet (boolean) – Set to disable progress bar

Examples

Set the current calibration mirror to Sky

>>> Calibration.cal_mirror(position="Sky")

Set the target for the calibration mirror to Filter but don’t move it

>>> Calibration.cal_mirror(position="Filter", move=False)
KCWI.Calibration.cal_object(position=None, move=True, quiet=False)[source]

Reads or set the calibration object

Parameters:
  • position (string) – Desired position. Valid values are: Pin300, Pin500 FinBars, MedBarsA, MedBarsB, LrgBarsA, LrgBarsB DiagLin, HorLin FlatA, FlatB Dark, Tpat, MIRA
  • move (boolean) – Set to False to only set the target without moving
  • quiet (boolean) – Set to disable progress bar

Examples

Set the current calibration object stage to Pin300

>>> Calibration.cal_object(position="Pin300")
KCWI.Calibration.hatch(status=None)[source]

Open or close the instrument hatch

Parameters:status (string) – open or close

Examples

Open the instrument hatch

>>> Calibration.hatch(status="open")
KCWI.Calibration.hex_pupil(position=None, move=True, quiet=False)[source]

Reads or set the hex pupil position

Parameters:
  • position (string) – Desired position. Valid values are “Home”, “Flat”, “Point”, “Zero”
  • move (boolean) – Set to False to only set the target without moving
  • quiet (boolean) – Set to disable progress bar

Examples

Set the current hex pupil

>>> Calibration.hex_pupil(position="Flat")

Set the target for the hex pupil to Flat but don’t move it

>>> Calibration.hex_pupil(position="Flat", move=False)
KCWI.Calibration.image_slicer(target=None, move=True, quiet=False)[source]

Reads or set the image slicer

Parameters:
  • target (string) – Desired slicer. Values are: “Small”, “Medium”, “Large”, “FPCam”, “Aux”
  • move (boolean) – Set to false to only modify the target without moving the slicer
  • quiet (boolean) – Set to disable progress bar

Examples

Prints the name of the current slicer

>>> Calibration.image_slicer()

Insert the small image slicer

>>> Calibration.image_slicer(target="Small")

Modify the slicer target keyword but do not move

>>> Calibration.image_slicer(target="Medium", move=False)
KCWI.Calibration.lamp(lamp=None, action=None)[source]

Turn on/off or query status of calibration lamps

Parameters:
  • lamp (string) – Lamp name. Valid values are “thar”,”fear”,”continuum|led”, and “all” Abbreviated and capitalized names are ok.
  • action (on/off/status) – On: Turns on Off: Turns off If action is missing, the status is returned.

Examples

Turn on the Iron Argon lamp:

>>> Calibration.lamp("fear","on")
KCWI.Calibration.lamp_shutter(lamp=None, action=None)[source]

Open/Close or query status of calibration lamps shutter

Parameters:
  • lamp (string) – Lamp name. Valid values are “thar”,”fear”,”continuum|led”, and “all” Abbreviated and capitalized names are ok.
  • action (open/close/status) – Open Close If action is missing, the status is returned.

Examples

Open the Iron Argon lamp shutter:

>>> Calibration.lamp_shutter("fear","open")
KCWI.Calibration.polangle(angle=None, move=True, quiet=True)[source]

Reads or modify the angle of the polarizer

Parameters:
  • angle (float) – Desired angle.
  • move (boolean) – Set to false to only modify the target without moving the polarizer angle
  • quiet (boolean) – Set to disable progress bar

Examples

Prints the current polarizer angle

>>> Calibration.polangle()

Set the angle to 90 degrees

>>> Calibration.polangle(target=90)

Set the target angle for the polarizer to 180 but do not move

>>> Calibration.polangle(target=180, move=False)
KCWI.Calibration.polarizer(target=None, move=True, quiet=False)[source]

Reads or modify the position of the polarizer

Parameters:
  • target (string) – Desired position. Valid values are: “Sky”, “Polar”, “Lens” “Lens” refers to the hexagonal pupil
  • move (boolean) – Set to false to only modify the target without moving the polarizer
  • quiet (boolean) – Set to disable progress bar

Examples

Prints the position of the polarizer

>>> Calibration.polarizer()

Set the polarizer to Polar

>>> Calibration.polarizer(target="Polar")

Set the target for the polarizer to Sky but do not move

>>> Calibration.polarizer(target="Sky", move=False)

KCWI.KcwiDS9 module

class KCWI.KcwiDS9.ds9(title)[source]
frameno(frame)[source]

frameno sets the ds9 frame number to [frame]

open(fname, frame)[source]

open opens a fits file [fname] into frame [frame]

title = None

The ds9 class provides wrappers around the unix commands xpaget and xpaset. The class is smart enough to automatically detect a running ds9 and attach automatically displayed images to it

xpaget(cmd)[source]

xpaget is a convenience function around unix xpaget

xpapipe(cmd, pipein)[source]

xpapipe is a convenience wrapper around echo pipein | xpaset ...

xpaset(cmd)[source]

xpaget is a convenience function around unix xpaset

KCWI.Procs module

KCWI.Procs.checkOutputDirs()[source]

Shows a number of keywords related to the detector and focal plane camera servers

KCWI.Procs.exists_and_is_writable(outdir)[source]
KCWI.Procs.exists_remote(host, path)[source]

Check if a directory exists on a remote server

KCWI.Procs.file_list(outdir, host)[source]

Returns the list of files in a directory, local or remote

KCWI.Procs.frame(channel, number=None)[source]

if number is fiven, reset frameno to that number. If not, returns the current frameno

KCWI.Procs.frameroot(channel)[source]

Returns the root name of the files for the current UT date

KCWI.Procs.get_lastfullimage(channel)[source]

Return the full name of the last saved image

KCWI.Procs.get_nextfile(channel)[source]

Return 1+ the frameno of the last saved image

KCWI.Procs.imtype(imtype=None)[source]

Returns or sets the image type

KCWI.Procs.is_writable_remote(host, path)[source]

Check if a directory is writable on a remote server

KCWI.Procs.kcwiPower(serverNumber=None, plugNumber=None, action=None)[source]
KCWI.Procs.kcwiPowerStatus()[source]

Provides access to the power supplies status

KCWI.Procs.moveFpc(x1, y1, x2, y2, nomove=False)[source]
KCWI.Procs.moveGuider(x1, y1, x2, y2, nomove=False)[source]
KCWI.Procs.moveSlicer(direction, number, nomove=False)[source]
KCWI.Procs.newdir(disk=None)[source]
KCWI.Procs.nextimage(channel)[source]

Returns the full name of the next image

KCWI.Procs.object(object=None)[source]

Returns or sets the object

KCWI.Procs.observer(observer=None)[source]

Returns or sets the observer

KCWI.Procs.outdir(outdir=None)[source]

With no arguments, prints the name of the current data directory. With one argument, change the outdir keyword to the named directory, creating it if requested. If files already exist in the outputdirectory, frameno is reset to be 1 higher than the highest existing image number.

KCWI.Procs.set_nextframe(channel, number=None)[source]

if number is given, reset frameno to that number. If not, reset to the last frame available on disk + 1

Module contents

Library functions to simplify common actions with KCWI. .. moduleauthor:: L.Rizzi, K. Lanclos

KCWI.verbose(selection=True)[source]

Enable normal tracebacks from all called functions without automatically catching and logging them as is done for the wrapped functions.