Counterpart Pairing Fortran Subroutines

Description

This module provides the Fortran code for the final act of cross-matching, in which sources are paired within their respective islands, and counterparts are established.

Quick access

Routines:

calc_combs(), calc_permcombs(), comb(), contam_match_prob(), factorial(), find_island_probabilities(), find_single_island_prob(), perm()

Variables

  • counterpart_pairing_fortran/dp [integer,parameter=kind(0.0d0)]
  • counterpart_pairing_fortran/pi [real,parameter=4.0_dp*atan(1.0_dp)]

Subroutines and functions

subroutine  counterpart_pairing_fortran/find_island_probabilities(a_astro, a_photo, b_astro, b_photo, alist, blist, agrplen, bgrplen, c_array, fa_array, fb_array, c_priors, fa_priors, fb_priors, amagref, bmagref, amodrefind, bmodrefind, abinsarray, abinlengths, bbinsarray, bbinlengths, afrac_grids, aflux_grids, bfrac_grids, bflux_grids, afourier_grids, bfourier_grids, a_sky_inds, b_sky_inds, rho, drho, n_fracs, large_len, cprt_max_len, acountinds, bcountinds, afieldinds, bfieldinds, acontamprob, bcontamprob, etaarray, xiarray, acontamflux, bcontamflux, probcarray, crptseps, probfaarray, afieldfluxs, afieldseps, afieldetas, afieldxis, probfbarray, bfieldfluxs, bfieldseps, bfieldetas, bfieldxis)

Calculate the final cross-matches. For each island, unique permutations of match and non-match are compared, with the highest probability combination stored. The matches and non-matches then have various secondary parameters, such as log-likelihood-ratio of match or their contamination probability derived and returned.

Parameters:
  • a_astro (,) [real,in]

  • a_photo (,) [real,in]

  • b_astro (,) [real,in]

  • b_photo (,) [real,in]

  • alist (,) [integer,in]

  • blist (,) [integer,in]

  • agrplen (*) [integer,in]

  • bgrplen (*) [integer,in]

  • c_array (,,*,*,*) [real,in]

  • fa_array (,,*,*) [real,in]

  • fb_array (,,*,*) [real,in]

  • c_priors (,,*) [real,in]

  • fa_priors (,,*) [real,in]

  • fb_priors (,,*) [real,in]

  • amagref (*) [integer,in]

  • bmagref (*) [integer,in]

  • amodrefind (,) [integer,in]

  • bmodrefind (,) [integer,in]

  • abinsarray (,,*) [real,in]

  • abinlengths (,) [integer,in]

  • bbinsarray (,,*) [real,in]

  • bbinlengths (,) [integer,in]

  • afrac_grids (,,*,*) [real,in]

  • aflux_grids (,,*) [real,in]

  • bfrac_grids (,,*,*) [real,in]

  • bflux_grids (,,*) [real,in]

  • afourier_grids (,,*,*) [real,in]

  • bfourier_grids (,,*,*) [real,in]

  • a_sky_inds (*) [integer,in]

  • b_sky_inds (*) [integer,in]

  • rho (*) [real,in]

  • drho (*) [real,in]

  • n_fracs [integer,in]

  • large_len [integer,in]

  • cprt_max_len [integer,in]

  • acountinds (cprt_max_len) [integer,out]

  • bcountinds (cprt_max_len) [integer,out]

  • afieldinds (size(a_astro, 1) [integer,out]

  • bfieldinds (size(b_astro, 1) [integer,out]

  • acontamprob (n_fracs,cprt_max_len) [real,out]

  • bcontamprob (n_fracs,cprt_max_len) [real,out]

  • etaarray (cprt_max_len) [real,out]

  • xiarray (cprt_max_len) [real,out]

  • acontamflux (cprt_max_len) [real,out]

  • bcontamflux (cprt_max_len) [real,out]

  • probcarray (cprt_max_len) [real,out]

  • crptseps (cprt_max_len) [real,out]

  • probfaarray (size(a_astro, 1) [real,out]

  • afieldfluxs (size(a_astro, 1) [real,out]

  • afieldseps (size(a_astro, 1) [real,out]

  • afieldetas (size(a_astro, 1) [real,out]

  • afieldxis (size(a_astro, 1) [real,out]

  • probfbarray (size(b_astro, 1) [real,out]

  • bfieldfluxs (size(b_astro, 1) [real,out]

  • bfieldseps (size(b_astro, 1) [real,out]

  • bfieldetas (size(b_astro, 1) [real,out]

  • bfieldxis (size(b_astro, 1) [real,out]

Call to:

find_single_island_prob()

subroutine  counterpart_pairing_fortran/find_single_island_prob(a_astro, a_photo, b_astro, b_photo, c_array, fa_array, fb_array, c_priors, fa_priors, fb_priors, abinsarray, bbinsarray, abinlengths, bbinlengths, afrac_grids, aflux_grids, afourier_grids, bfrac_grids, bflux_grids, bfourier_grids, rho, drho, n_fracs, large_len, aperm, bperm, aused, qa, bused, qb, arefinds, brefinds, acrpts, bcrpts, acrptscontp, bcrptscontp, etacrpts, xicrpts, acrptflux, bcrptflux, crptseps, afield, bfield, afieldflux, bfieldflux, afieldseps, afieldeta, afieldxi, bfieldseps, bfieldeta, bfieldxi, prob, integral)

Calculate a single island match and non-match permutation. For each combination of N catalogue “a” and M catalogue “b” sources, find the pairings and non-pairings that maximise the likelihood. Also calculates secondary parameters such as likelihood ratios for astrometry and photometry and contamination probabilities for matches.

Parameters:
  • a_astro (,) [real,in]

  • a_photo (,) [real,in]

  • b_astro (,) [real,in]

  • b_photo (,) [real,in]

  • c_array (,,*,*,*) [real,in]

  • fa_array (,,*,*) [real,in]

  • fb_array (,,*,*) [real,in]

  • c_priors (,,*) [real,in]

  • fa_priors (,,*) [real,in]

  • fb_priors (,,*) [real,in]

  • abinsarray (,,*) [real,in]

  • bbinsarray (,,*) [real,in]

  • abinlengths (,) [integer,in]

  • bbinlengths (,) [integer,in]

  • afrac_grids (,,*,*) [real,in]

  • aflux_grids (,,*) [real,in]

  • afourier_grids (,,*,*) [real,in]

  • bfrac_grids (,,*,*) [real,in]

  • bflux_grids (,,*) [real,in]

  • bfourier_grids (,,*,*) [real,in]

  • rho (*) [real,in]

  • drho (*) [real,in]

  • n_fracs [integer,in]

  • large_len [integer,in]

  • aperm (*) [integer,in]

  • bperm (*) [integer,in]

  • aused (*) [integer,in]

  • qa (*) [integer,in]

  • bused (*) [integer,in]

  • qb (*) [integer,in]

  • arefinds (,) [integer,in]

  • brefinds (,) [integer,in]

  • acrpts (min(size(aperm), size(bperm) [integer,out]

  • bcrpts (min(size(aperm), size(bperm) [integer,out]

  • acrptscontp (n_fracs,min(size(aperm), size(bperm) [real,out]

  • bcrptscontp (n_fracs,min(size(aperm), size(bperm) [real,out]

  • etacrpts (min(size(aperm), size(bperm) [real,out]

  • xicrpts (min(size(aperm), size(bperm) [real,out]

  • acrptflux (min(size(aperm), size(bperm) [real,out]

  • bcrptflux (min(size(aperm), size(bperm) [real,out]

  • crptseps (min(size(aperm), size(bperm) [real,out]

  • afield (size(aperm) [integer,out]

  • bfield (size(bperm) [integer,out]

  • afieldflux (size(aperm) [real,out]

  • bfieldflux (size(bperm) [real,out]

  • afieldseps (size(aperm) [real,out]

  • afieldeta (size(aperm) [real,out]

  • afieldxi (size(aperm) [real,out]

  • bfieldseps (size(bperm) [real,out]

  • bfieldeta (size(bperm) [real,out]

  • bfieldxi (size(bperm) [real,out]

  • prob [real,out]

  • integral [real,out]

Called from:

find_island_probabilities()

Call to:

haversine(), contam_match_prob(), factorial(), calc_combs(), calc_permcombs()

subroutine  counterpart_pairing_fortran/factorial(n, m, g)

Calculates N * (N-1) * (N-2) * … * (N-M+1), equivalent to N! / (N-M)!. If M = N or M = N - 1 this is the same as N! and if M = 1 it is equal to N.

Parameters:
  • n [integer,in]

  • m [integer,in]

  • g [integer,out]

Called from:

find_single_island_prob()

subroutine  counterpart_pairing_fortran/contam_match_prob(fcc, fcn, fnc, fnn, rho, drho, sep, gcc, gcn, gnc, gnn)

Calculate the probability density of two sources being two detections of a single sky object given the separation between them, including the combinations of hypotheses that the sources independently suffer, or do not suffer, from a statistical description of blended source perturbation.

Parameters:
  • fcc (*) [real,in]

  • fcn (*) [real,in]

  • fnc (*) [real,in]

  • fnn (*) [real,in]

  • rho (*) [real,in]

  • drho (*) [real,in]

  • sep [real,in]

  • gcc [real,out]

  • gcn [real,out]

  • gnc [real,out]

  • gnn [real,out]

Called from:

find_single_island_prob()

Call to:

jy01a_j0()

subroutine  counterpart_pairing_fortran/perm(i, a, perm_grid, n, ind)
Parameters:
  • i [integer,in]

  • a (*) [integer,inout]

  • perm_grid (,) [integer,inout]

  • n [integer,in]

  • ind [integer,inout]

Called from:

calc_permcombs()

subroutine  counterpart_pairing_fortran/calc_combs(n, n_combs, m_pick, comb_grid)

Calculate all combinations of length m_pick from an array of length n. Size of array, total number of combinations, and size of sub-set array to select combinations of.

Parameters:
  • n [integer,in]

  • n_combs [integer,in]

  • m_pick [integer,in]

  • comb_grid (m_pick,n_combs) [integer,out]

Called from:

find_single_island_prob()

Call to:

comb()

subroutine  counterpart_pairing_fortran/comb(m, a, comb_grid, n_max, ind, m_pick)
Parameters:
  • m [integer,in]

  • a (*) [integer,inout]

  • comb_grid (,) [integer,inout]

  • n_max [integer,in]

  • ind [integer,inout]

  • m_pick [integer,in]

Called from:

calc_combs(), calc_permcombs()

subroutine  counterpart_pairing_fortran/calc_permcombs(n, m_pick, n_perms, n_combs, combperm_grid)

Calculate all permutations of selecting M items from an array of length N. Length of input array, length of output permutations array, and the number of combinations from :p integer n [in]: pick-m and the number of permutations of each unique combination for the array.

Parameters:
  • m_pick [integer,in]

  • n_perms [integer,in]

  • n_combs [integer,in]

  • combperm_grid (m_pick,n_combs * n_perms) [integer,out]

Called from:

find_single_island_prob()

Call to:

comb(), perm()