Example #1
0
    def test_xmatch(self):
        from astroNN.datasets import xmatch
        import numpy as np

        # Some coordinates for cat1, J2000.
        cat1_ra = np.array([36., 68., 105., 23., 96., 96.])
        cat1_dec = np.array([72., 56., 54., 55., 88., 88.])

        # Some coordinates for cat2, J2000.
        cat2_ra = np.array([23., 56., 222., 96., 245., 68.])
        cat2_dec = np.array([36., 68., 82., 88., 26., 56.])

        # Using maxdist=2 arcsecond separation threshold, because its default, so not shown here
        # Using epoch1=2000. and epoch2=2000., because its default, so not shown here
        # because both datasets are J2000., so no need to provide pmra and pmdec which represent proper motion
        idx_1, idx_2, sep = xmatch(ra1=cat1_ra,
                                   dec1=cat1_dec,
                                   ra2=cat2_ra,
                                   dec2=cat2_dec)
        self.assertEqual(len(idx_1), len(idx_2))
        self.assertEqual(np.all(sep == 0.), True)
Example #2
0
# ====================================== Ages ====================================== #

# APOKASC processing
apokasc3 = fits.getdata("APOKASC_cat_v6.6.1.fits.zip")
good_ages = apokasc3["APOKASC2_AGE"] != -9999.0
apokasc3 = apokasc3[good_ages]

# ages for low metallicity
f_age_low_M = fits.getdata("kepler_low_metallicity_with_samples.fits")

allstar_f = fits.getdata(allstar_path)
ra = allstar_f["ra"]
dec = allstar_f["dec"]
ra[0] = 0
dec[0] = 0
idx_1, idx_2, sep = xmatch(apokasc3["RA"], apokasc3["DEC"], ra, dec)
idx_3, idx_4, sep = xmatch(f_age_low_M["RA"], f_age_low_M["DEC"], ra, dec)

idx_combined, unique_indices = np.unique(np.concatenate([idx_4, idx_2]),
                                         return_index=True)

all_age = np.concatenate(
    [f_age_low_M["Age_med"] / 1e9, apokasc3["APOKASC2_AGE"]])[unique_indices]
all_age_err = np.concatenate(
    [f_age_low_M["Age_Sd"] / 1e9,
     apokasc3["APOKASC2_AGE_MERR"]])[unique_indices]
all_mass = np.concatenate([f_age_low_M["Mass_med"],
                           apokasc3["APOKASC2_MASS"]])[unique_indices]
all_mass_err = np.concatenate(
    [f_age_low_M["Mass_Sd"], apokasc3["APOKASC2_MASS_RANERR"]])[unique_indices]