dev_ccmatch Module

This module contains all functionality to perform the astrometric correction of a frame by matching the source catalog to a catalog of reference stars.

dev_ccmatch.apply_correction_to_header(hdulist, best_guess, verbose=False)[source]

Apply the optimzied shift and rotation found during astrometric calibration to the output FITS header.

dev_ccmatch.ccmatch(source_catalog, reference_catalog, input_hdu, mode, max_pointing_error=7, max_rotator_error=[-1, 1.5])[source]

Perform the astrometric correction.

Parameters :
  • source_catalog (ndarray) –

    Catalog of sources in the ODI frames. This needs to be in the proper format, as ccmatch splits the catalog by OTA and eliminates sources with flags.

  • reference_catalog (ndarray) –

    Astrometric reference catalog. The first two columns have to be Ra/Dec.

  • input_hdu (HDUList) –

    HDUlist containing the frame to be calibrated.

  • mode (string) –

    Calibration mode for ccmatch. Currently available are: * “shift” * “rotation” * “distortion”

  • max_pointing_error (double) –

    maximum position uncertainty that can be tolerated. If the data exceeds this value the astrometric calibration is likely to yield wrong results.

  • max_rotator_error (float[2]) –

    maximum error for the rotator angle.

dev_ccmatch.ccmatch_shift(source_cat, reference_cat, center=None, pointing_error=0.13333333333333333)[source]

Perform a simple astrometric calibration, allowing for a shift only

dev_ccmatch.compute_wcs_quality(odi_2mass_matched, hdr=None)[source]
dev_ccmatch.count_matches(src_cat, ref_cat, pointing_error=0.13333333333333333, matching_radius=0.0011111111111111111, debugangle=None)[source]

This is the main routine in ccmatch. First, find for each source in catalog 1 all nearby sources in catalog 2. In a second step, determine the approximate relative position that occurs the most frequently.

dev_ccmatch.count_matches_parallelwrapper(work_queue, return_queue, src_cat, ref_cat, center_ra, center_dec, pointing_error=0.13333333333333333, matching_radius=0.0011111111111111111, debugangle=None)[source]

Just a small wrapper to enable parallel execution of count_matches.

dev_ccmatch.find_best_guess(src_cat, ref_cat, center_ra, center_dec, pointing_error=0.13333333333333333, angle_max=5.0, d_angle=3, matching_radius=0.001388888888888889, allow_parallel=True)[source]

Find the best-guess astrometric correction by finding the shift and rotation angle that yields the most matching stars by iterating over a number of possible rotator angles.

Parameters :
  • src_cat (ndarray) –

    Catalog of sources in ODI image

  • ref_cat (ndarray) –

    Reference catalog of stars from, e.g., 2MASS

  • center_ra (double) –

    center of rotation in RA - this has to be CRVAL1 to make the solution compatible with the FITS WCS convention

  • center_dec (double) –

    center of rotation in Dec - has to be CRVAL2

  • pointing_error (double) –

    Maximum positional uncertainty, in degrees. Larger is safer, but takes more time to compute and doesn’t help if pointing errors are small.

  • angle_max (double or double[2]) –

    Maximum uncertainty in the rotator angle position, in degrees. Can either be a single angle or a float[2], e.g. [-1,2].

  • matching_radius (double) –

    radius to use when computing the density of overlapping points. Smaller numbers give slightly more accurate results, but larger values are more reliable when frames show some distortion.

  • allow_parallel (Bool) –

    Run the catalog matching in parallel (faster, recommended) or as a single process (slower, needs fewer resources)

Returns:

The best_guess shift and rotation angle

dev_ccmatch.fit_best_rotation_shift(src_cat, ref_cat, best_guess, center_ra, center_dec, matching_radius=0.0016666666666666668)[source]

optimize the astroemtric solution by minimizing the difference betweeen source and reference positions in a matched catalog.

dev_ccmatch.global_wcs_quality(odi_2mass_matched, ota_list)[source]
dev_ccmatch.improve_wcs_solution(src_catalog, ref_catalog, hdulist, headers_to_optimize, matching_radius=0.0008333333333333334, min_ota_catalog_size=15, output_catalog=None, allow_parallel=True)[source]

This function is a wrapper around the optimize_wcs_solution routine. It splits up the full catalog into sub-catalogs for each OTA, and optimizes each catalog by fiddling with some of the WCS keywords until the distance between source coordiantes and reference coordiantes is minimized.

dev_ccmatch.kd_match_catalogs(src_cat, ref_cat, matching_radius, max_count=1)[source]

Match two catalogs using kD-trees.

Parameters:

src_cat : ndarray

input catalog 1. first two columns have to be Ra/Dec

ref_cat : ndarray

input catalog 2. again, columns 1 &2 have to be Ra/Dec.

matching_radius : float

matching radius in arcsec. If two sources are closer than this, they are considered a match.

max_count : int

Exclude all sources that have more than (max_count) matches.
Returns:
  • The matched catalog. The columns of this output catalog first contain
  • all columns from the input catalog 1, followed by all columns of the
  • matched sources in catalog 2. If no counterpart is found in catalog 2,
  • this source is omitted from the output catalog.

Currently only the first match is returned for each input source.

dev_ccmatch.log_shift_rotation(hdulist, params, n_step=1, description='', n_random_matches=None, wcs_contrast=None)[source]

Add some additional keywords to primary FITS header to keep track of the shift and rotation found during astrometric calibration of the frame.

dev_ccmatch.optimize_shear_and_position(ota_cat, hdr)[source]

Optimize the WCS by allowing the CRVAL and CD matrix as free parameters

dev_ccmatch.optimize_shift_rotation(p, guessed_match, hdulist, fitting=True)[source]

outdated, don’t use.

dev_ccmatch.optimize_wcs_solution(ota_cat, hdr, optimize_header_keywords)[source]

Optimize the WCS by allowing the given set of header keywords to vary.

dev_ccmatch.parallel_optimize_wcs_solution(queue_in, queue_out)[source]

This is a minimal wrapper around optimize_wcs_solution to enable parallel execution.

All input commands are received via a multiprocessing.JoinableQueue and reported back via a separate multiprocessing.Queue.

dev_ccmatch.pick_isolated_stars(catalog, radius=10.0)[source]

Break down the catalog and eliminate all sources with nearby neighbors.

dev_ccmatch.recompute_radec_from_xy(hdulist, src_catalog)[source]
dev_ccmatch.rotate_shift_catalog(src_cat, center, angle, shift=None, verbose=False)[source]

Apply a rotation and shift to a catalog.

dev_ccmatch.select_brightest(radec, mags, n)[source]

Create a new catalog containing only the n brightest members of the input catalog.

dev_ccmatch.verify_wcs_model(cat, hdulist)[source]

for debugging only, don’t use