opticam.reducer

Classes

Reducer

Class for reducing OPTICAM data.

Functions

log_reducer_params(reducer)

set_psf_params(aperture_selector, catalog)

Set the PSF parameters.

parse_alignment_results(results, camera_files, ...)

Parse the alignment results.

create_targets_dict(catalogs)

Create a dictionary of target IDs for all catalog sources.

save_photometry_results(results, catalogs, barycenter, ...)

Save the photometry results to disk.

parse_photometry_results(results)

Merge the multiprocessed photometry results into a single dictionary.

Module Contents

class opticam.reducer.Reducer(out_directory, data_directory=None, c1_directory=None, c2_directory=None, c3_directory=None, rebin_factor=1, flat_corrector=None, background=None, finder=None, threshold=5, aperture_selector=np.median, remove_cosmic_rays=False, barycenter=True, number_of_processors=cpu_count() // 2, show_plots=True, verbose=True)

Class for reducing OPTICAM data.

Parameters:
verbose = True
out_directory
logger
data_directory = None
c1_directory = None
c2_directory = None
c3_directory = None
rebin_factor = 1
flat_corrector = None
aperture_selector
threshold = 5
remove_cosmic_rays = False
barycenter = True
number_of_processors
show_plots = True
reference_files
transforms
unaligned_files = []
catalogs: Dict[str, astropy.table.QTable]
psf_params
create_catalogs(max_catalog_sources=15, n_alignment_sources=15, transform_type='affine', rotation_limit=None, translation_limit=None, scale_limit=None, overwrite=False, show_diagnostic_plots=False)

Initialise the source catalogs for each camera. Some aspects of this method are parallelised for speed.

Parameters

max_catalog_sourcesint, optional

The maximum number of sources to include in the catalog, by default 30. Since source IDs are ordered by brightness, the brightest max_catalog_sources sources are included in the catalog.

n_alignment_sourcesint, optional

The (maximum) number of sources to use for image alignment, by default 30. If transform_type=’translation’, n_alignment_sources must be >= 1, and the brightest n_alignment_sources sources are used for image alignment. If transform_type=’affine’, n_alignment_sources must be >= 3 and represents that maximum number of sources that may be used for image alignment.

transform_typeLiteral[‘affine’, ‘translation’], optional

The type of transform to use for image alignment, by default ‘affine’. ‘translation’ performs simple x, y translations, while ‘affine’ uses astroalign.find_transform(). ‘affine’ is generally more robust (and is therefore the default) while ‘translation’ can work with fewer sources.

rotation_limitfloat, optional

The maximum rotation limit (in degrees) for affine transformations, by default None (no limit).

scale_limitfloat, optional

The maximum scale limit for affine transformations, by default None (no limit).

translation_limitfloat | int | List[float | int] | None, optional

The maximum translation limit for both types of transformations, by default None (no limit). Can be a scalar value that applies to both x- and y-translations, or an iterable where the first value defines the x-translation limit and the second value defines the y-translation limit.

overwritebool, optional

Whether to overwrite existing catalogs, by default False.

show_diagnostic_plotsbool, optional

Whether to show diagnostic plots, by default False. Diagnostic plots are saved to out_directory, so this parameter only affects whether the plots are displayed in the console.

Parameters:
  • max_catalog_sources (int)

  • n_alignment_sources (int)

  • transform_type (Literal['affine', 'translation'])

  • rotation_limit (float | None)

  • translation_limit (float | int | List[float | int] | None)

  • scale_limit (float | None)

  • overwrite (bool)

  • show_diagnostic_plots (bool)

Return type:

None

plot_growth_curves(targets=None, show=True)

Plot the growth curves for the sources identified in the catalog images. The resulting plots are saved to out_directory/diag/growth_curves as PDF files.

Parameters

targetsDict[str, int | List[int]] | None, optional

The targets for which growth curves will be created, by default None (growth curves are created for all catalog sources). To create growth curves for specific targets, pass a dictionary with keys listing the desired filters and values listing each filter’s correpsonding target(s). For example: ``` # plot growth curves for the three brightest sources in each catalog plot_growth_curves(

targets = {

‘g-band’: [1, 2, 3], ‘r-band’: [1, 2, 3], ‘i-band’: [1, 2, 3], },

)

```

showbool, optional

Whether to show the plots, by default True. The resulting plots are saved regardless of this value.

Parameters:
  • targets (Dict[str, int | List[int]] | None)

  • show (bool)

Return type:

None

plot_psfs()

Plot the PSFs for the catalog sources.

Return type:

None

create_gifs(keep_frames=True, overwrite=False)

Create alignment gifs for each camera. Some aspects of this method are parallelised for speed. The frames are saved in out_directory/diag/*-band_gif_frames and the GIFs are saved in out_directory/cat.

Parameters

keep_framesbool, optional

Whether to save the GIF frames in out_directory/diag, by default True. If False, the frames will be deleted after the GIF is saved.

overwritebool, optional

Whether to overwrite existing GIFs, by default False.

Parameters:
  • keep_frames (bool)

  • overwrite (bool)

Return type:

None

photometry(photometer, overwrite=False)

Perform photometry on the catalogs using the provided photometer.

Parameters

photometerBasePhotometer

The photometer. Should be a subclass of BasePhotometer, or implement a compute method that follows the BasePhotometer interface.

overwritebool, optional

Whether to overwrite any existing light curves files computed using the same photometer, by default False.

Parameters:
Return type:

None

opticam.reducer.log_reducer_params(reducer)
Parameters:

reducer (Reducer)

Return type:

None

opticam.reducer.set_psf_params(aperture_selector, catalog)

Set the PSF parameters.

Parameters

aperture_selectorCallable

The aperture selector (e.g., numpy.median).

catalogQTable

The source catalog.

Returns

Dict[str, float]

The PSF parameters.

Parameters:
  • aperture_selector (Callable)

  • catalog (astropy.table.QTable)

Return type:

Dict[str, float]

opticam.reducer.parse_alignment_results(results, camera_files, transforms, unaligned_files, verbose)

Parse the alignment results.

Parameters

resultsTuple

The alignment results.

camera_filesList[str]

The file paths for all files.

transformsDict[str, List[float]]

The image-to-image alignments {file path: transform}.

unaligned_filesList[str]

The paths of the files that could not be aligned.

verbosebool

Whether to include output.

Returns

Tuple[Dict[str, List[float]], List[str], NDArray, Dict[str, float], Dict[str, float]]

The updated transforms, unaligned files, stacked image, median background values and median background RMS values.

Parameters:
  • results (Tuple)

  • camera_files (List[str])

  • transforms (Dict[str, List[float]])

  • unaligned_files (List[str])

  • verbose (bool)

Return type:

Tuple[Dict[str, List[float]], List[str], numpy.typing.NDArray, Dict[str, float], Dict[str, float]]

opticam.reducer.create_targets_dict(catalogs)

Create a dictionary of target IDs for all catalog sources.

Parameters

catalogsDict[str, QTable]

The catalogs.

Returns

Dict[str, List[int]]

The target IDs for all catalog sources.

Parameters:

catalogs (Dict[str, astropy.table.QTable])

Return type:

Dict[str, List[int]]

opticam.reducer.save_photometry_results(results, catalogs, barycenter, save_dir, fltr)

Save the photometry results to disk.

Parameters

resultsTuple[Dict]

The photometry results.

catalogsDict[str, QTable]

The source catalogs.

save_dirstr

The save directory path.

fltrstr

The photometry filter.

Parameters:
  • results (Tuple[Dict])

  • catalogs (Dict[str, astropy.table.QTable])

  • barycenter (bool)

  • save_dir (str)

  • fltr (str)

opticam.reducer.parse_photometry_results(results)

Merge the multiprocessed photometry results into a single dictionary.

Parameters

resultsTuple[Dict[str, List]]

The multiprocessed photometry results.

Returns

Dict[str, List[List[float]]]

The photometry results in a single dictionary.

Parameters:

results (Tuple[Dict[str, List]])

Return type:

Dict[str, List[List[float]]]