RawOifits
- class jwst.ami.oifits.RawOifits(instrument_data, method='mean')[source]
Bases:
objectStore AMI data in the format required to write out to OIFITS files.
Builds the structure needed to write out oifits files according to the schema. Populates the structure with the observables from the fringe fitter. For data arrays, the observables are populated slice-by-slice to enable fitting with FringeFitter and storage as OiFits to take place in the same loop. Angular quantities, initially in radians from fringe fitting, are converted to degrees for saving. Produces averaged and multi-integration versions, with sigma-clipped stats over integrations.
Notes
Based on ObservablesFromText from ImPlaneIA, e.g. https://github.com/anand0xff/ImPlaneIA/blob/master/nrm_analysis/misctools/implane2oifits.py#L32
Initialize the RawOifits object.
- Parameters:
- instrument_datajwst.ami.instrument_data.NIRISS object
Information on the mask geometry (namely # holes), instrument, wavelength obs mode.
- methodstr
Method to average observables: mean or median. Default mean.
Methods Summary
average_observables(averfunc)Average all the observables.
cov_r_theta(rr, theta, averfunc)Calculate covariance in polar coordinates.
err_from_covmat(covmatlist)Derive observable errors from their covariance matrices.
init_oimodel_arrays(oimodel)Set dtypes and initialize shapes for AmiOiModel arrays.
Initialize arrays of observables to empty arrays.
Populate AmiOIModel.
observable_covariances(averfunc)Calculate covariance matrices from each pair of observables.
populate_obsarray(i, nrmslc)Populate arrays of observables with fringe fitter results.
rotate_matrix(cov_mat, theta)Rotate a covariance matrix by an angle.
Methods Documentation
- average_observables(averfunc)[source]
Average all the observables.
Calculate covariance matrices between fringe amplitudes/fringe phases, and between triple product amps/closure phases, and closure amplitudes/quad phases. Convert r, theta (modulus, phase) to x,y. Calculate cov(x,y). Rotate resulting 2x2 matrix back to r, theta. Take sqrt of relevant covariance element to be error. This must be done with phases in radians.
- Parameters:
- averfuncfunction
Function for averaging, either np.mean (default) or np.median
- Returns:
- avg_sqvarray
Averaged squared visibilites
- err_sqvarray
Standard error of the mean of averaged squared visibilities
- avg_faarray
Averaged fringe (visibility) amplitudes
- err_faarray
Standard error of the mean of averaged fringe (visibility) amplitudes
- avg_fparray
Averaged fringe phases (rad)
- err_fparray
Standard error of the mean of averaged fringe phases (rad)
- avg_cparray
Averaged closure phases (rad)
- err_cparray
Standard error of the mean of averaged closure phases (rad)
- avg_t3amparray
Averaged triple amplitudes
- err_t3amparray
Standard error of the mean of averaged triple amplitudes
- avg_caarray
Averaged closure amplitudes
- err_caarray
Standard error of the mean of averaged closure amplitudes
- avg_q4phiarray
Averaged quad phases
- err_q4phiarray
Standard error of the mean of averaged quad phases
- avg_pistarray
Averaged segment pistons
- err_pistarray
Standard error of the mean of averaged segment pistons
- cov_r_theta(rr, theta, averfunc)[source]
Calculate covariance in polar coordinates.
Calculate covariance in x, y coordinates, then rotate covariance matrix by average phase (over integrations) to get matrix in (r,theta).
- Parameters:
- rrarray
Complex number modulus
- thetaarray
Complex number phase
- averfuncfunction
Function for averaging, either np.mean (default) or np.median
- Returns:
- cov_mat_r_thetaarray (2,2)
Covariance matrix in r, theta coordinates
- err_from_covmat(covmatlist)[source]
Derive observable errors from their covariance matrices.
Return sqrt of [0,0] and [1,1] elements of each of a list of covariance matrices, divided by sqrt(N_ints), for use as observable errors (standard error of the mean). If using median, error calculation is questionable because this is NOT the standard error of the median.
- Parameters:
- covmatlistarray
Array of covariance matrices for each baseline/triple/quad shape e.g. (21,2,2) or (35,2,2)
- Returns:
- err_00array
Standard errors of the mean of the first observable. shape e.g. (21)
- err_11array
Standard errors of the mean of the second observable. shape e.g. (21)
- init_oimodel_arrays(oimodel)[source]
Set dtypes and initialize shapes for AmiOiModel arrays.
Supports averaged or multi-integration versions of oimodel.
- Parameters:
- oimodelAmiOIModel object
Empty model
- make_oifits()[source]
Populate AmiOIModel.
Perform final manipulations of observable arrays, calculate uncertainties, and populate AmiOIModel.
- Returns:
- mAmiOIModel
Fully populated datamodel
- observable_covariances(averfunc)[source]
Calculate covariance matrices from each pair of observables.
For each baseline/triple/quad, calculate covariance between each fringe amplitude/phase quantity.
- Parameters:
- averfuncfunction
Function for averaging, either np.mean (default) or np.median
- Returns:
- cov_mat_fringesarray
Array of 21 covariance matrices for fringes (amplitudes, phases)
- cov_mat_triplesarray
Array of 35 covariance matrices for triples (t3 amplitudes, closure phases)
- cov_mat_quadsarray
Array of 35 covariance matrices for quads (closure amplitudes, quad phases)