Table of Contents

Documentation

This page contains an overview of the command-line scripts. For more information on functions, classes, members, and methods; the below autogenerated documentation is available:

Command-line Scripts

When running command-line scripts, use the -h option to see the help messages. The resources page has a overview of help message syntax.

Also, see the resources page for a bash script that performs all steps on a given dataset

Spectral Rebinning

Invoke via python -m aopp_deconv_tool.spectral_rebin.

This routine accepts a FITS file specifier, it will spectrally rebin the fits extension and output a new fits file.

The underlying algorithm does the following:

	#############################################################
	NOTE: This is a general case and not accurate for a FITS file as we don't have bin-edges, just the centres. Therefore we assume bin_width=bin_step.
	input_grid    : |---^---|   |---^---|   |---^---|   |---^---|
				  :       |---^---|   |---^---|   |---^---|   	
	
	bin_width     : |-------|

	bin_step      : |-----|

	#############################################################

	output_grid   :     |--------^-------|    |--------^-------|
				  :                |--------^-------|
	
	offset        : |---|

	new_bin_width :     |----------------|
	
	new_bin_step  :     |----------|


	#############################################################

	"|" = bin edge

	"^" = bin centre

	width
		The distance between the start and end of a bin
	
	step
		The distance between the start of two consecutive bins

	offset
		The distance between the start/end of the new grid and the start/end of the old grid

Module Arguments

note

The argument type is specified by a colon (:) following the argument name, multiple accepted types are separated by the pipe (|) character, some arguments take more than one value these are separated by spaces; arguments with an equals sign (=) take the specified value as a default.

Examples

Using the example data, the datasets.json file lists a dataset called “example neptune observation” with a science target observation in the file “MUSE.2019-10-18T00:01:19.521.fits” and a calibration observation in the file “MUSE.2019-10-17T23:46:14.117.fits”

Run the rebinning for each of the files via the command:

By default, files are rebinned by averaging old bins into new bins, and using the spex preset for bin width and bin step. The equivalent to the above command is python -m aopp_deconv_tool.spectral_rebin ./example_data/ifu_observation_datasets/MUSE.2019-10-17T23\:46\:14.117.fits --rebin_operation mean --rebin_preset spex --output_path ./example_data/ifu_observation_datasets/MUSE.2019-10-17T23\:46\:14.117_rebin.fits

After both commands are complete there should be two new files that contain their output:

Artefact Detection

Invoke via python -m aopp_deconv_tool.artefact_detection.

WARNING: The current implementation of artefact detection is tuned for observations of objects of a significant fraction of the field size. Therefore, it will not give good results for standard star observations.

Accepts a FITS specifier, uses a singular spectrum analysis (SSA) based algorithm to produce a heuristic badness_map that reflects how likely a pixel is to be part of an artefact.

The badness map is calculated as follows for each 2D image in the FITS data:

Module Arguments

NOTE: argument type is specified by a colon (:) following the argument name, multiple accepted types are separated by the pipe (|) character, some arguments take more than one value these are separated by spaces; arguments with an equals sign (=) take the specified value as a default.

Examples

Using the results from the rebinning example:

Bad Pixel Mask

Invoke via python -m aopp_deconv_tool.create_bad_pixel_mask.

NOTE: By setting the value part of --value_cut_at_index argument, this script can be used to only apply dynamic and/or constant regions without applying value cuts. This can be useful when manually removing artifacts from standard star datacubes. However, note that the psf normalisation script does include a routine for removing outliers so creating a bad pixel mask and interpolating is normally not required for a standard star.

Accepts a badness_map heuristic, uses a set of value cuts to produce a boolean mask (the bad_pixel_mask) that describes which pixels are considered “bad” and should be interpolated over using a different script. Also accepts DS9 region files (in IMAGE coords only at the moment), both constant and dynamic region files can be passed. Constant ones apply across all wavelengths, dynamic ones vary with wavelength.

The badness_map is assumed to be a 3D cube, therefore the bad_pixel_mask is calculated from a set of (index,value) pairs. Where index is an index into the badness_map, and value is the value above which a pixel in the badness_map is considered “bad”. Not all indices have to be specified, and values for unspecified indices will be interpolated (with the values clamped at the LHS and RHS). If no pairs are provided, a value of 3 is assumed for all indices. For each 1 above the cutoff value, a bad pixel is binary dilated. This way “very bad” pixels spread their “badness” to neighbouring pixels.

To get a set of (index, value) pairs for use with the artefact badness_map, the following workflow is suggested:

  1. Open the badness_map FITS file in a FITS viewer of some sort (e.g., DS9 or QFitsView), you may need to use a logarithmic scale.
  2. Open the data the badness_map was created from as well so you can compare them.
  3. Choose some representative indices (i.e., wavelengths) to work on. For illustrative purposes we will assume indices, (10, 99, 135).
  4. In the badness_map viewer, alter the minimum value of the data display range (somewhere around 4 or 5 is a good starting point) until the visible pixels select artefacts reliably, but do not select real image features (e.g., the edge of the planetary disk). Once found, record the (index,value) pair.
  5. Repeat (4) for each index you chose in step (3).

To get a set of (index, path) pairs for use with the --dynamic_regions argument, the following workflow is suggested:

NOTE: The current implementation using regions to mask out moving artefacts does this by associating regions within region-files across multiple (index, path) pairs by either: the “text” label of the region; or the region’s location within a region-file if it has no text label. Therefore, it is recommended to use text labels for ALL dynamic regions as otherwise you have to never delete or create a region. Region properties are linearly interpolated between the wavelength channel index of the first region file they are present in, the index of any intermediate region files, and the index of the last region file they are present in. Outside the index of the first and last files a region is in, a region is not present and therefore does not mask any pixels. If you want a region to be present in all wavelength channels, include it in the region files for the first wavelength channel and the last wavelength channel.

Module Arguments

note

The argument type is specified by a colon (:) following the argument name, multiple accepted types are separated by the pipe (|) character, some arguments take more than one value these are separated by spaces; arguments with an equals sign (=) take the specified value as a default.

Examples

Using the results from the rebinning example:

Interpolation

Invoke via python -m aopp_deconv_tool.interpolate.

Accepts a FITS file specifier for data to be interpolated and a FITS file specifier for a bad_pixel_mask that specifies which pixels to interpolate. At any NAN and INF values are also interpolated over if these are not included in the bad_pixel_mask.

The interpolation process uses a standard interpolation routine. However, to avoid edge effects the data is:

This process removes hard edges and reduces edge effects in a similar way to a “reflect” boundary condition (which the routine does not support at the time of writing) but the value tends towards zero and high-frequency variations have little impact.

Module Arguments

note

The argument type is specified by a colon (:) following the argument name, multiple accepted types are separated by the pipe (|) character, some arguments take more than one value these are separated by spaces; arguments with an equals sign (=) take the specified value as a default.

Examples

Using the results from the rebinning example. Interpolation is perfomed via:

Unfortunately, the file ./example_data/ifu_observation_datasets/MUSE.2019-10-17T23\:46\:14.117_rebin.fits is not quite standard and lists its sky axes as ‘PIXEL’ axes. Therefore we have to provide the sky axes to the interpolate routine (or alter the FITS file). As axes are denoted using round brackets in a FITS Specifier, we have to wrap the string in single quotes and remove the escaping \s from the colons to enable the terminal to understand the string does not contain commands.

PSF Normalisation

Invoke via python -m aopp_deconv_tool.psf_normalise.

Performs the following operations:

Module Arguments

note

The argument type is specified by a colon (:) following the argument name, multiple accepted types are separated by the pipe (|) character, some arguments take more than one value these are separated by spaces; arguments with an equals sign (=) take the specified value as a default.

Examples

Using the results from the interpolation example. Normalisation is perfomed via:

PSF Model Fitting

Invoke via python -m aopp_deconv_tool.fit_psf_model.

Fits a model, specified by the --model option, using a fitting method specified by the --method option. Fits each wavelength in turn, records the fitted values in a FITS table extension called “FITTED MODEL PARAMS”, and the modelled PSF in the primary extension.

Fitting Methods:

Module Arguments

note

The argument type is specified by a colon (:) following the argument name, multiple accepted types are separated by the pipe (|) character, some arguments take more than one value these are separated by spaces; arguments with an equals sign (=) take the specified value as a default.

Examples

Using results from the normalisation example, fitting is performed via:

Deconvolution

Invoke via python -m aopp_deconv_tool.deconvolve. Use the -h option to see the help message.

Assumes the observation data has no NAN or INF pixels, assumes the PSF data is centreed and sums to 1.

Module Arguments

note

The argument type is specified by a colon (:) following the argument name, multiple accepted types are separated by the pipe (|) character, some arguments take more than one value these are separated by spaces; arguments with an equals sign (=) take the specified value as a default.

Description: CLEAN MODIFIED

At each iteration of the MODIFIED_CLEAN algorithm, the following procedure is performed:

Upon iteration, the components map may be convolved with a gaussian to regularise (smooth) it (set by the --clean_beam_sigma parameter). The smoothing function is referred to as the “clean beam” in radio astronomy sources. Often, careful choice of the threshold can give a smooth components map that does not require regularising in this way. An adaptive threshold, like the maximum fraction difference Otsu threshold, often performs better than a static threshold.

Use the --plot option to see a progress plot that updates every 10 iterations of the MODIFIED_CLEAN algorithm, useful for working out what different parameters do. The plot frames (from left-right, then top-bottom) are:

Parameters: CLEAN MODIFIED

Description: LUCY RICHARDSON

TODO: Write a description of how LR deconvolution works.

Parameters: LUCY RICHARDSON

Examples

Using results from the previous examples, deconvolution is performed via: