pynrc.DetectorOps

class pynrc.DetectorOps(detector=481, wind_mode='FULL', xpix=2048, ypix=2048, x0=0, y0=0, nff=None, **kwargs)[source]

Bases: det_timing

Class to hold detector operations information. Includes SCA attributes such as detector names and IDs as well as multiaccum class for ramp settings.

Parameters:
  • detector (int, str) – NIRCam detector ID (481-490) or SCA ID (A1-B5).

  • wind_mode (str) – Window mode type ‘FULL’, ‘STRIPE’, ‘WINDOW’.

  • xpix (int) – Size of window in x-pixels for frame time calculation.

  • ypix (int) – Size of window in y-pixels for frame time calculation.

  • x0 (int) – Lower-left x-coord position of detector window.

  • y0 (int) – Lower-left y-coord position of detector window.

  • nff (int) – Number of fast row resets.

Keyword Arguments:
  • read_mode (str) – NIRCam Ramp Readout mode such as ‘RAPID’, ‘BRIGHT1’, etc.

  • nint (int) – Number of integrations (ramps).

  • ngroup (int) – Number of groups in a integration.

  • nf (int) – Number of frames per group.

  • nd1 (int) – Number of drop frame after reset (before first group read).

  • nd2 (int) – Number of drop frames within a group (ie., groupgap).

  • nd3 (int) – Number of drop frames after final read frame in ramp.

Examples

Use kwargs functionality to pass keywords to the multiaccum class.

Send via a dictionary of keywords and values:
>>> kwargs = {'read_mode':'RAPID', 'nint':5, 'ngroup':10}
>>> d = DetectorOps(**kwargs)
Set the keywords directly:
>>> d = DetectorOps(read_mode='RAPID', nint=5, ngroup=10)
__init__(detector=481, wind_mode='FULL', xpix=2048, ypix=2048, x0=0, y0=0, nff=None, **kwargs)[source]

Methods

__init__([detector, wind_mode, xpix, ypix, ...])

int_times_table(date_start, time_start[, ...])

Create and populate the INT_TIMES table, which is saved as a separate extension in the output data file.

make_header([filter, pupil_mask, obs_time])

Create a generic NIRCam FITS header.

pix_timing_map([same_scan_direction, ...])

Create array of pixel times for a single ramp.

pixel_noise([fsrc, fzodi, fbg, rn, ktc, ...])

Noise values per pixel.

times_to_dict([verbose])

Export ramp times as dictionary with option to print output to terminal.

to_dict([verbose])

Export detector settings to a dictionary.

xtalk([file_path])

Detector cross talk information

Attributes

channel

Detector channel 'SW' or 'LW' (inferred from detector ID)

chsize

Size of Amplifier Channel

detid

Selected Detector ID from detectors in the detid_list attribute.

detid_list

Allowed Detector IDs

detname

Selected Detector ID from detectors in the scaid_list attribute.

fastaxis

Fast readout direction in sci coords

mask_act

Active pixel mask for det coordinates

mask_channels

Channel masks for det coordinates

mask_ref

Reference pixel mask for det coordinates

module

NIRCam modules A or B (inferred from detector ID)

nff

Number of fast row resets that occur before Reset Frame

nout

Number of simultaneous detector output channels stripes

ref_info

Array of reference pixel borders [lower, upper, left, right].

scaid

Selected SCA ID from detectors in the scaid_list attribute.

scaid_list

Allowed SCA IDs

slowaxis

Slow readout direction in sci coords

time_exp

Total photon collection time for all ramps.

time_frame

Determine frame time (sec) based on xpix, ypix, and wind_mode.

time_group

Time per group based on time_frame, nf, and nd2.

time_int

Same as time_ramp, except that 'int' follows the JWST nomenclature

time_int_eff

Same as time_ramp_eff, except that 'int' follows the JWST nomenclature

time_ramp

Photon collection time for a single ramp.

time_ramp_eff

Effective ramp time for slope fit tf*(ng-1)

time_row_reset

NFF Row Resets time per integration

time_total

Total exposure acquisition time

time_total_int1

Total time for all frames in first ramp of exposure.

time_total_int2

Total time for all frames in a subsequent ramp.

times_group_avg

Times at each averaged group since reset

wind_mode

Window mode attribute

x0

xpix

y0

ypix

property channel

Detector channel ‘SW’ or ‘LW’ (inferred from detector ID)

property chsize

Size of Amplifier Channel

property detid

Selected Detector ID from detectors in the detid_list attribute. A1, A2, etc.

property detid_list

Allowed Detector IDs

property detname

Selected Detector ID from detectors in the scaid_list attribute. NRCA1, NRCA2, etc.

property fastaxis

Fast readout direction in sci coords

int_times_table(date_start, time_start, offset_seconds=None)

Create and populate the INT_TIMES table, which is saved as a separate extension in the output data file.

Parameters:
  • date_start (str) – Date string of observation (‘2020-02-28’)

  • time_start (str) – Time string of observation (‘12:24:56’)

  • offset_seconds (None or float) – Time from beginning of observation until start of integration.

Returns:

int_times_tab (astropy.table.Table) – Table of starting, mid, and end times for each integration

make_header(filter=None, pupil_mask=None, obs_time=None, **kwargs)[source]

Create a generic NIRCam FITS header.

Parameters:
  • filter (str) – Name of filter element.

  • pupil_mask (str) – Name of pupil element.

  • obs_time (datetime) – Specifies when the observation was considered to be executed. If not specified, then it will choose the current time. This must be a datetime object:

    >>> datetime.datetime(2016, 5, 9, 11, 57, 5, 796686)
    
property mask_act

Active pixel mask for det coordinates

property mask_channels

Channel masks for det coordinates

property mask_ref

Reference pixel mask for det coordinates

property module

NIRCam modules A or B (inferred from detector ID)

property nff

Number of fast row resets that occur before Reset Frame

property nout

Number of simultaneous detector output channels stripes

pix_timing_map(same_scan_direction=None, reverse_scan_direction=None, avg_groups=False, reset_zero=False, return_flat=False)

Create array of pixel times for a single ramp.

Each pixel value corresponds to the precise time at which that pixel was read out during the ramp acquisition. The first pixel(s) have t=0.

Parameters:
  • same_scan_direction (bool) – Are all the output channels read in the same direction? By default fast-scan readout direction is [-->,<--,-->,<--] If same_scan_direction, then all -->

  • reverse_scan_direction (bool) – If reverse_scan_direction, then [<--,-->,<--,-->] or all <--

  • avg_groups (bool) – For groups where nf>1, the telescope data gets averaged via a bit-shifter. Setting avg_groups=True also averages the pixel times in a similar manner. Default is False.

  • return_flat (bool) – Return a single array rather than image array.

Keyword Arguments:

reset_zero (bool) – Return timing relative to when reset to get photon-collection time of each pixel. Otherwise, t=0 corresponds to very first pixel(s) read in the ramp.

Returns:

ndarray – If return_flat=True then the data is a flattened array for a single channel output. Otherwise, the output is a data cube of the same size and shape of the raw data with these detector settings.

Example

Assume you have a cube of raw full frame data (RAPID, ngroup=5). Create a det_timing instance and get channel:

>>> d = det_timing(ngroup=5)
>>> tarr = d.pixel_timing_map(return_flat=True, avg_groups=True)
>>> nx, ny = (d.xpix, d.ypix)
>>> nout   = d.nout      # Number of amplifier output channels
>>> chsize = d.chsize    # Channel size (x-direction)
>>> # Reshape into (nz, ny, nout, chsize)
>>> data = data.reshape([-1,ny,nout,chsize])
>>> # Reverse odd channels in x-direction to match even chans
>>> for ch in range(nout):
>>>     if np.mod(ch,2)==1:
>>>         data[:,:,ch,:] = data[:,:,ch,::-1]
>>> # Final data reshaped into 4 flattened output channels
>>> data = data.transpose([0,1,3,2]).reshape([-1,nout])
>>> # Can plot this like plt.plot(tarr, data) to make nout line plots
pixel_noise(fsrc=0.0, fzodi=0.0, fbg=0.0, rn=None, ktc=None, idark=None, p_excess=None, ng=None, nf=None, scale_ints=True, verbose=False, **kwargs)[source]

Noise values per pixel.

Return theoretical noise calculation for the specified MULTIACCUM exposure in terms of e-/sec. This uses the pre-defined detector-specific noise properties. Can specify flux of a source as well as background and zodiacal light (in e-/sec/pix). After getting the noise per pixel per ramp (integration), value(s) are divided by the sqrt(NINT) to return the final noise

Parameters:
  • fsrc (float or image) – Flux of source in e-/sec/pix

  • fzodi (float or image) – Flux of the zodiacal background in e-/sec/pix

  • fbg (float or image) – Flux of telescope background in e-/sec/pix

  • idark (float or image) – Option to specify dark current in e-/sec/pix.

  • rn (float) – Option to specify Read Noise per pixel (e-).

  • ktc (float) – Option to specify kTC noise (in e-). Only valid for single frame (n=1)

  • p_excess (array-like) – Optional. An array or list of two elements that holds the parameters describing the excess variance observed in effective noise plots. By default these are both 0. For NIRCam detectors, recommended values are [1.0,5.0] for SW and [1.5,10.0] for LW.

  • ng (None or int or image) – Option to explicitly states number of groups. This is specifically used to enable the ability of only calculating pixel noise for unsaturated groups for each pixel. If a numpy array, then it should be the same shape as fsrc image. By default will use self.ngroup.

  • scale_ints (bool) – Scale pixel noise by by sqrt(nint)?

  • verbose (bool) – Print out results at the end.

Keyword Arguments:

ideal_Poisson (bool) – If set to True, use total signal for noise estimate, otherwise MULTIACCUM equation is used.

Notes

fsrc, fzodi, and fbg are functionally the same as they are immediately summed. They can also be single values or multiple elements (list, array, tuple, etc.). If multiple inputs are arrays, make sure their array sizes match.

property ref_info

Array of reference pixel borders [lower, upper, left, right].

property scaid

Selected SCA ID from detectors in the scaid_list attribute. 481, 482, etc.

property scaid_list

Allowed SCA IDs

property slowaxis

Slow readout direction in sci coords

property time_exp

Total photon collection time for all ramps.

property time_frame

Determine frame time (sec) based on xpix, ypix, and wind_mode.

property time_group

Time per group based on time_frame, nf, and nd2.

property time_int

Same as time_ramp, except that ‘int’ follows the JWST nomenclature

property time_int_eff

Same as time_ramp_eff, except that ‘int’ follows the JWST nomenclature

property time_ramp

Photon collection time for a single ramp.

property time_ramp_eff

Effective ramp time for slope fit tf*(ng-1)

property time_row_reset

NFF Row Resets time per integration

property time_total

Total exposure acquisition time

property time_total_int1

Total time for all frames in first ramp of exposure.

Includes resets and excess drops, as well as NFF Rows Reset.

property time_total_int2

Total time for all frames in a subsequent ramp.

Includes resets and excess drops, as well as NFF Rows Reset. Only differs from time_total_int1 in case nr1 != nr2

property times_group_avg

Times at each averaged group since reset

times_to_dict(verbose=False)

Export ramp times as dictionary with option to print output to terminal.

to_dict(verbose=False)

Export detector settings to a dictionary.

property wind_mode

Window mode attribute

xtalk(file_path=None)[source]

Detector cross talk information