Primitives/API

class kcwidrp.primitives.ApplyFlat.ApplyFlat(action, context)[source]

Generic routine to apply flat fielding. Not yet implemented.

class kcwidrp.primitives.CalcPrelimDisp.CalcPrelimDisp(action, context)[source]

Calculate dispersion based on configuration parameters.

The parameters of the grating equation are calculates as:

alpha = grating_angle - 13 - adjustment_ange (180 for BH, RH and
0 for all other gratings)

beta = camera_angle - alpha

dispersion = cos(beta)/rho/focal_length x (pixel_scale x binning) * 1.e4

class kcwidrp.primitives.CorrectDar.CorrectDar(action, context)[source]

Correct for Differential Atmospheric Refraction

kcwidrp.primitives.CorrectDar.atm_disper(w0, w1, airmass, temperature=10.0, pressure_pa=61100.0, humidity=50.0, co2=400.0)[source]

Calculate atmospheric dispersion at w1 relative to w0

Parameters:
  • w0 (float) – reference wavelength (Angstroms)
  • w1 (float) – offset wavelength (Angstroms)
  • airmass (float) – unitless airmass
  • temperature (float) – atmospheric temperature (C)
  • pressure_pa (float) – atmospheric pressure (Pa)
  • humidity (float) – relative humidity (%)
  • co2 (float) – Carbon-Dioxide (mu-mole/mole)
class kcwidrp.primitives.CorrectDefects.CorrectDefects(action, context)[source]

Remove known bad columns

class kcwidrp.primitives.CorrectGain.CorrectGain(action, context)[source]

Convert raw data numbers to electrons

class kcwidrp.primitives.CorrectIllumination.CorrectIllumination(action, context)[source]

Subtract master bias frame

class kcwidrp.primitives.CreateUncertaintyImage.CreateUncertaintyImage(action, context)[source]

Generate a variance image based on Poisson noise plus readnoise

class kcwidrp.primitives.CubeImage.CubeImage(action, context)[source]

Transform 2D images to 3D data cubes

class kcwidrp.primitives.FluxCalibrate.FluxCalibrate(action, context)[source]
class kcwidrp.primitives.GenerateMaps.GenerateMaps(action, context)[source]

Generate map images

class kcwidrp.primitives.MakeMasterDark.MakeMasterDark(action, context)[source]

Stack dark frames into master dark

class kcwidrp.primitives.NandshuffSubtractSky.NandshuffSubtractSky(action, context)[source]
class kcwidrp.primitives.ProcessArc.ProcessArc(action, context)[source]
class kcwidrp.primitives.ProcessBias.ProcessBias(action, context)[source]
class kcwidrp.primitives.ProcessContbars.ProcessContbars(action, context)[source]
class kcwidrp.primitives.ProcessDark.ProcessDark(action, context)[source]
class kcwidrp.primitives.ProcessFlat.ProcessFlat(action, context)[source]
class kcwidrp.primitives.ProcessObject.ProcessObject(action, context)[source]
class kcwidrp.primitives.RectifyImage.RectifyImage(action, context)[source]

Ensure output image has a consistent orientation

class kcwidrp.primitives.SolveGeom.SolveGeom(action, context)[source]

Solve the overall geometry of the IFU

class kcwidrp.primitives.StackFlats.StackFlats(action, context)[source]

Stack flat images

class kcwidrp.primitives.SubtractBias.SubtractBias(action, context)[source]

Subtract master bias frame

class kcwidrp.primitives.SubtractDark.SubtractDark(action, context)[source]

Subtract master dark frame

class kcwidrp.primitives.SubtractSky.SubtractSky(action, context)[source]
class kcwidrp.primitives.TrimOverscan.TrimOverscan(action, context)[source]

Trim off overscan region

class kcwidrp.primitives.kcwi_file_primitives.ingest_file(action, context)[source]

Constructor

delta_wave_out()[source]

Return output delta lambda in Angstroms for the given grating

map_ccd()[source]

Return CCD section variables useful for processing

Uses FITS keyword NVIDINP to determine how many amplifiers were used to read out the CCD. Then reads the corresponding BSECn, and DSECn keywords, where n is the amplifier number. The indices are converted to Python (0-biased, y axis first) indices and an array is constructed for each of the two useful sections of the CCD as follows:

Bsec[0][0] - First amp, y lower limit Bsec[0][1] - First amp, y upper limit Bsec[0][2] - First amp, x lower limit Bsec[0][3] - First amp, x upper limit Bsec[1][0] - Second amp, y lower limit etc.

Bsec is the full overscan region for the given amplifier and is used to calculate and perform the overscan subtraction.

Dsec is the full CCD region for the given amplifier and is used to trim the image after overscan subtraction has been performed.

Tsec accounts for trimming the image according to Dsec.

Amps are assumed to be organized as follows:

(0,ny) ——— (nx,ny)
3 | 4 |
1 | 2 |

(0,0) ——— (nx, 0)

self: instance of CcdPrimitive class (automatic)
list: (int) y0, y1, x0, x1 for bias section list: (int) y0, y1, x0, x1 for data section list: (int) y0, y1, x0, x1 for trimmed section list: (bool) y-direction, x-direction, True if forward, else False
resolution()[source]

Return FWHM resolution in Angstroms for the given grating

kcwidrp.primitives.kcwi_file_primitives.kcwi_fits_reader(file)[source]

A reader for KeckData objects. Currently this is a separate function, but should probably be registered as a reader similar to fits_ccddata_reader. Arguments: file – The filename (or pathlib.Path) of the FITS file to open.