pynrc.detops.det_timing

class pynrc.detops.det_timing(wind_mode='FULL', xpix=2048, ypix=2048, x0=0, y0=0, mode='SLOW', nff=None, **kwargs)[source]

Bases: object

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

Parameters
  • 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.

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 = det_timing(**kwargs)
Set the keywords directly:
>>> d = det_timing(read_mode='RAPID', nint=5, ngroup=10)
__init__(wind_mode='FULL', xpix=2048, ypix=2048, x0=0, y0=0, mode='SLOW', nff=None, **kwargs)[source]

Methods

__init__([wind_mode, xpix, ypix, x0, y0, ...])

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.

pix_timing_map([same_scan_direction, ...])

Create array of pixel times for a single ramp.

pixel_noise([ng, nf, verbose])

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.

Attributes

chsize

Size of Amplifier Channel

mask_act

Active pixel mask for det coordinates

mask_channels

Channel masks for det coordinates

mask_ref

Reference pixel mask for det coordinates

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].

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 chsize

Size of Amplifier Channel

int_times_table(date_start, time_start, offset_seconds=None)[source]

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

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 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)[source]

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 True.

  • return_flat (bool)

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(ng=None, nf=None, 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
  • ng (None or int or image) – Option to explicitly state 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.multiaccum.ngroup.

  • nf (int) – Option to explicitly states number of frames in each group. By default will use self.multiaccum.nf.

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

Keyword Arguments
  • rn (float) – Read Noise per pixel (e-).

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

  • p_excess (array-like) – 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.

  • idark (float) – Dark current in e-/sec/pix.

  • fsrc (float) – Flux of source in e-/sec/pix.

  • fzodi (float) – Zodiacal light emission in e-/sec/pix.

  • fbg (float) – Any additional background (telescope emission or scattered light?)

  • 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 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)[source]

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

to_dict(verbose=False)[source]

Export detector settings to a dictionary.

property wind_mode

Window mode attribute