chandra_aca.transform

The transform modules includes:

  • Coordinate conversions between ACA Pixels and ACA Y-angle, Z-angle

  • Mag to count conversions

  • Science target coordinate to ACA frame conversions

chandra_aca.transform.broadcast_arrays(*args)[source]

Broadcast *args inputs to same shape.

Broadcast *args inputs to same shape and return an is_scalar flag and the broadcasted version of inputs. This lets intermediate code work on arrays that are guaranteed to be the same shape and at least a 1-d array, but reshape the output at the end.

Parameters:

args – tuple of scalar / array inputs

Returns:

[is_scalar, *flat_args]

chandra_aca.transform.broadcast_arrays_flatten(*args)[source]

Broadcast *args inputs to same shape and flatten.

Broadcast *args inputs to same shape.and then return that shape and the flattened view of all the inputs. This lets intermediate code work on all scalars or all arrays that are the same-length 1-d array and then reshape the output at the end (if necessary).

Parameters:

args – tuple of scalar / array inputs

Returns:

[shape, *flat_args]

chandra_aca.transform.calc_aca_from_targ(targ, y_off, z_off, si_align=None)[source]

Calculate PCAD (ACA) pointing attitude.

Calculate the PCAD (ACA) pointing attitude from target attitude and Y,Z offset (per OR-list).

Parameters:
targ

science target from OR/Obscat (Quat-compliant object)

y_off

Y offset (deg, sign per OR-list convention)

z_off

Z offset (deg, sign per OR-list convention)

si_align

SI ALIGN matrix (default=ODB_SI_ALIGN)

Returns:
q_aca (Quat)
chandra_aca.transform.calc_targ_from_aca(aca, y_off, z_off, si_align=None)[source]

Calculate target attitude.

Calculate the target attitude from ACA (PCAD) pointing attitude and Y,Z offset (per OR-list).

Parameters:
aca

ACA (PCAD) pointing attitude (any Quat-compliant object)

y_off

Y offset (deg, sign per OR-list convention)

z_off

Z offset (deg, sign per OR-list convention)

si_align

SI ALIGN matrix

Returns:
q_targ (Quat)
chandra_aca.transform.calc_target_offsets(aca, ra_targ, dec_targ, si_align=None)[source]

Calculate target offsets.

Calculates required Y and Z offsets (deg) required from a target RA, Dec to arrive at the desired PCAD pointing aca.

Parameters:
aca

PCAD attitude (any Quat-compliant initializer)

ra_targ

RA of science target from OR/Obscat

dec_targ

Dec of science target from OR/Obscat

si_align

SI ALIGN matrix (default=ODB)

Returns:
tuple (y_off, z_off) degrees
chandra_aca.transform.count_rate_to_mag(count_rate)[source]

Convert count rate in e- / sec to ACA mag

Based on $CALDB/data/chandra/pcad/ccd_char/acapD1998-12-14ccdN0002.fits columns mag0=10.32 and cnt_rate_mag0=5263.0.

Parameters:
count_rate

count rate (e-/sec)

Returns:
magnitude (ACA mag)
chandra_aca.transform.eci_to_radec(eci)[source]

Convert from ECI vector(s) to RA, Dec.

The input eci value can be an array of 3-vectors having shape (N, 3) in which case the output RA, Dec will be arrays of shape N. The N dimension can actually be any multidimensional shape.

Parameters:
eci

ECI as 3-vector or (N, 3) array

Returns:
scalar or array ra, dec (degrees)
chandra_aca.transform.mag_to_count_rate(mag)[source]

Convert ACA mag to count rate in e- / sec

Based on $CALDB/data/chandra/pcad/ccd_char/acapD1998-12-14ccdN0002.fits columns mag0=10.32 and cnt_rate_mag0=5263.0. To convert to raw telemetered counts (ADU), divide e- by the gain of 5.0 e-/ADU.

Parameters:
mag

star magnitude in ACA mag

Returns:
count rate (e-/sec)
chandra_aca.transform.normalize_vector(vec, ord=None)[source]

Normalize vec over the last dimension.

For an L x M x N input array, this normalizes over the N dimension using np.linalg.norm.

Parameters:
vec

input vector or array of vectors

ord

ord parameter for np.linalg.norm (default=None => 2-norm)

Returns:
normed array of vectors
chandra_aca.transform.pixels_to_yagzag(row, col, allow_bad=False, flight=False, t_aca=20, pix_zero_loc='edge')[source]

Convert ACA row/column positions to ACA y-angle, z-angle.

It is expected that the row and column input arguments have the same length.

The pix_zero_loc parameter controls whether the input pixel values are assumed to have integral values at the pixel center or at the pixel lower/left edge. The PEA flight coefficients assume lower/left edge, and that is the default. However, it is generally more convenient when doing centroids and other manipulations to use the center.

Parameters:
row

ACA pixel row (single value, list, or 1-d numpy array)

col

ACA pixel column (single value, list, or 1-d numpy array)

allow_badboolean switch. If true, method will not throw errors

if the row/col values are nominally off the ACA CCD.

flight

Use flight EEPROM coefficients instead of default ground values.

t_aca

ACA temperature (degC) for use with flight (default=20C)

pix_zero_loc

row/col coords are integral at ‘edge’ or ‘center’

Returns:
(yang, zang) each vector of the same length as row/col
chandra_aca.transform.radec_to_eci(ra, dec)[source]

Convert from RA,Dec to ECI.

The input ra and dec values can be 1-d arrays of length N in which case the output ECI will be an array with shape (N, 3). The N dimension can actually be any multidimensional shape.

Parameters:
ra

Right Ascension (degrees)

dec

Declination (degrees)

Returns:
numpy array ECI (3-vector or N x 3 array)
chandra_aca.transform.radec_to_yagzag(ra, dec, q_att)[source]

Calculate ACA Y-angle, Z-angle from RA, Dec and pointing quaternion.

The input ra and dec values can be 1-d arrays in which case the output yag and zag will be corresponding arrays of the same length.

Parameters:
ra

Right Ascension (degrees)

dec

Declination (degrees)

q_att

ACA pointing quaternion (Quat or Quat-compatible input)

Returns:
yag, zag (arcsec)
chandra_aca.transform.snr_mag_for_t_ccd(t_ccd, ref_mag, ref_t_ccd, scale_4c=None)[source]

Calculate signal-to-noise equivalent magnitude.

Given a t_ccd, solve for the magnitude that has the same expected signal to noise as ref_mag / ref_t_ccd.

If scale_4c is None, the value from dark_model.DARK_SCALE_4C is used.

To solve for the magnitude that has the expected signal to noise as ref_mag / ref_t_ccd, we use the following derivation:

counts(mag) / noise(t_ccd) = counts(ref_mag) / noise(ref_t_ccd)
noise(t_ccd) = noise(ref_t_ccd) * scale
scale = scale_4c ** ((t_ccd - ref_t_ccd) / 4.0)

Using the definition of counts as a function of magnitude, substituting in, reducing, and solving the original equality for mag gives:

counts(mag) = ACA_CNT_RATE_MAG0 * 10.0 ** ((ACA_MAG0 - mag) / 2.5)
ref_mag = (t_ccd - ref_t_ccd) * np.log10(scale_4c) / 1.6
Parameters:
t_ccdfloat, array

CCD temperature (degC)

ref_magfloat, array

Reference magnitude (mag)

ref_t_ccdfloat, array

Reference CCD temperature (degC)

scale_4cfloat

Scale factor for a 4 degC change in CCD temperature (defaults to DARK_SCALE_4C)

Returns:
float, array
Magnitude(s) with the same expected signal to noise as ref_mag at ref_t_ccd
chandra_aca.transform.yagzag_to_pixels(yang, zang, allow_bad=False, pix_zero_loc='edge')[source]

Convert ACA y-angle/z-angle positions to ACA pixel row, column.

It is expected that the y-angle/z-angle input arguments have the same length.

The pix_zero_loc parameter controls whether the input pixel values are assumed to have integral values at the pixel center or at the pixel lower/left edge. The PEA flight coefficients assume lower/left edge, and that is the default. However, it is generally more convenient when doing centroids and other manipulations to use pix_zero_loc='center'.

Parameters:
yang

ACA y-angle (single value, list, or 1-d numpy array)

zang

ACA z-angle (single value, list, or 1-d numpy array)

allow_badboolean switch. If true, method will not throw errors

if the resulting row/col values are nominally off the ACA CCD.

pix_zero_loc

row/col coords are integral at ‘edge’ or ‘center’

Returns:
(row, col) each vector of the same length as row/col
chandra_aca.transform.yagzag_to_radec(yag, zag, q_att)[source]

Calculate RA, Dec from ACA Y-angle, Z-angle and pointing quaternion.

The input yag and zag values can be 1-d arrays in which case the output ra and dec will be corresponding arrays of the same length.

Parameters:
yag

ACA Y angle (arcsec)

zag

ACA Z angle (arcsec)

q_att

ACA pointing quaternion (Quat or Quat-compatible input)

Returns:
ra, dec (degrees)