Reading target images#
Reading the target image from a FITS file.
read_target reads it as described by the older parameter layout (toycoronagraph.config, used by Target); read_plane, the FITS reader itself, is also used by the image sources of the scene framework (toycoronagraph.sources.images).
Two input methods:
* "image": a square 2-D FITS image (or a cube with fits_slice), star at the array centre,
described by the header keywords BUNIT, PIXSCALE (or CDELT1/2) and WAVELEN;
* "mcfost": an MCFOST image cube (e.g. data_<wavelength>/RT.fits.gz) as written by
MCFOST, with axes (plane, azimuth, inclination, y, x); the plane is chosen by name
(mcfost_component; "disk" is the total minus the direct starlight) and the
inclination/azimuth by index. Its header (BUNIT, CDELT, WAVE) is understood.
“input_format = auto” recognizes MCFOST cubes from their header (FLUX_1 … FLUX_8).
- toycoronagraph.inputs.target_path(cfg)[source]#
The FITS file of the target: the example, or fits_filename (“.fits” added if it has no extension).
- Parameters:
cfg (SimpleNamespace) – From config.load_config (uses cfg.fits_filename; None for the example).
- Returns:
Path of the FITS file (example_data/example.fits for the example).
- Return type:
str
- toycoronagraph.inputs.is_mcfost(data, header)[source]#
Whether the data look like an MCFOST image cube.
- Parameters:
data (np.ndarray) – The HDU’s data.
header – Its FITS header.
- Returns:
True for 5 axes with 4 or 8 planes on axis 0 and FLUX_1 in the header.
- Return type:
bool
- toycoronagraph.inputs.read_plane(path, input_format='auto', fits_hdu=0, fits_slice='auto', mcfost_component='scattered_star', mcfost_inclination=0, mcfost_azimuth=0)[source]#
Read one 2-D image from a FITS file (a plane of a cube, or of an MCFOST cube).
The plane is chosen by fits_slice if given, else by the MCFOST keys for an MCFOST cube; a plain image is read as it is. A flattened square image (1-D, n*n values) is reshaped to (n, n).
- Parameters:
path (str) – The FITS file.
input_format (str) – “image”, “mcfost”, or “auto” (MCFOST if is_mcfost, else image).
fits_hdu (int) – Index of the HDU holding the data.
fits_slice (list or str) – Indices into the leading axes, e.g. [5, 0, 0] (overrides the MCFOST keys), or “auto”.
mcfost_component (str) – MCFOST plane: a key of config.MCFOST_COMPONENTS, or “disk” (total minus direct_star).
mcfost_inclination (int) – MCFOST: index along the inclination axis.
mcfost_azimuth (int) – MCFOST: index along the azimuth axis.
- Returns:
image (np.ndarray): (ny, nx) float64 data, in the file’s unit (not checked to be square).
header (astropy.io.fits.Header): The HDU’s header.
fmt (str): The input format used, “image” or “mcfost”.
what (str): Description of the selection, e.g. “image” or “MCFOST disk, inclination 0, azimuth 0”.
index (list or str): The indices used (list of int); for “disk”, a text such as “total - direct_star at [0, 0]”.
- Return type:
tuple
- Raises:
ValueError – For a missing HDU, an MCFOST format without 5 axes, an out-of-range MCFOST index, too many fits_slice indices, or data that are not 2-D after the selection.
- toycoronagraph.inputs.read_target(cfg, verbose=True)[source]#
Read the target image, fill the “auto” parameters from it (config.resolve), and convert it to Jy/arcsec^2.
- Parameters:
cfg (SimpleNamespace) – From config.load_config; resolved in place (also sets input_description and used_slice).
verbose (bool) – Print the summary of the input and any warning.
- Returns:
The (N, N) float64 image in Jy/arcsec^2.
- Return type:
np.ndarray
- Raises:
ValueError – From read_plane or config.resolve (e.g. non-square image, unknown unit).