def testAngleAliases(self):
        with self.assertWarns(FutureWarning):
            self.assertEqual(afwGeom.Angle(1), lsst.geom.Angle(1))

        self.assertIs(afwGeom.radians, lsst.geom.radians)
        self.assertIs(afwGeom.degrees, lsst.geom.degrees)
        self.assertIs(afwGeom.hours, lsst.geom.hours)
        self.assertIs(afwGeom.arcminutes, lsst.geom.arcminutes)
        self.assertIs(afwGeom.arcseconds, lsst.geom.arcseconds)

        self.assertIs(afwGeom.PI, lsst.geom.PI)
        self.assertIs(afwGeom.TWOPI, lsst.geom.TWOPI)
        self.assertIs(afwGeom.HALFPI, lsst.geom.HALFPI)
        self.assertIs(afwGeom.ONE_OVER_PI, lsst.geom.ONE_OVER_PI)
        self.assertIs(afwGeom.SQRTPI, lsst.geom.SQRTPI)
        self.assertIs(afwGeom.INVSQRTPI, lsst.geom.INVSQRTPI)
        self.assertIs(afwGeom.ROOT2, lsst.geom.ROOT2)

        with self.assertWarns(FutureWarning):
            self.assertEqual(afwGeom.degToRad(1), lsst.geom.degToRad(1))
        with self.assertWarns(FutureWarning):
            self.assertEqual(afwGeom.radToDeg(1), lsst.geom.radToDeg(1))
        with self.assertWarns(FutureWarning):
            self.assertEqual(afwGeom.radToArcsec(1), lsst.geom.radToArcsec(1))
        with self.assertWarns(FutureWarning):
            self.assertEqual(afwGeom.radToMas(1), lsst.geom.radToMas(1))
        with self.assertWarns(FutureWarning):
            self.assertEqual(afwGeom.arcsecToRad(1), lsst.geom.arcsecToRad(1))
        with self.assertWarns(FutureWarning):
            self.assertEqual(afwGeom.masToRad(1), lsst.geom.masToRad(1))
Exemple #2
0
PTF11mty_RA, PTF11mty_Dec = 323.521667, 10.423500

sn_coord = afwGeom.SpherePoint(PTF11mty_RA, PTF11mty_Dec, afwGeom.degrees)

distList = []
for s in ref_table:
    this_coord = afwGeom.SpherePoint(s['coord_ra'], s['coord_dec'],
                                     afwGeom.radians)
    angSep = sn_coord.separation(this_coord)
    distList.append(angSep)

distance = np.array(distList)
sn_idx = np.argmin(distance)

print("Found match: Object %d at %f arcsecs" %
      (sn_idx, afwGeom.radToArcsec(distance[sn_idx])))

# Read in the forced-src photometry files that were built off of this same reference table to extract a lightcurve for PTF11mty

# 2018-04-10:  MWV: This presently doesn't pull the correct expnums for each.
cat_dataRefs = butler.subset(datasetType='forced_src', dataId=dId)

dataIds_by_filter = {}
dataIds_by_filter['H'] = [
    {
        'field': field,
        'seq': 'A',
        'filter': 'H',
        'night': 20111025,
        'expnum': 127
    },
# Find PSNJ07250042+2347030 based on RA, Dec: 07:25:00.408 +23:47:03.15 (J2000)

sn_RA, sn_Dec = 111.251700, 23.784208

sn_coord = afwGeom.SpherePoint(sn_RA, sn_Dec, afwGeom.degrees)

distList = []
for s in ref_table:
    this_coord = afwGeom.SpherePoint(s['coord_ra'], s['coord_dec'], afwGeom.radians)
    angSep = sn_coord.separation(this_coord)
    distList.append(angSep)

distance = np.array(distList)
sn_idx = np.argmin(distance)

print("Found match: Object %d at %f arcsecs" % (sn_idx, afwGeom.radToArcsec(distance[sn_idx])))


# Read in the forced-src photometry files that were built off of this same reference table to extract a lightcurve for PSNJ07250042+2347030

# 2018-04-10:  MWV: This presently doesn't pull the correct expnums for each.
cat_dataRefs = butler.subset(datasetType='forced_src', dataId=dId)

dataIds_by_filter = {}
dataIds_by_filter['H'] = [
    {'field': 'PSNJ07250042+2347030', 'seq': 'A', 'filter': 'H', 'night': 20121028, 'expnum': 542},
    {'field': 'PSNJ07250042+2347030', 'seq': 'A', 'filter': 'H', 'night': 20121102, 'expnum': 491},
    {'field': 'PSNJ07250042+2347030', 'seq': 'A', 'filter': 'H', 'night': 20121122, 'expnum': 573},
    {'field': 'PSNJ07250042+2347030', 'seq': 'A', 'filter': 'H', 'night': 20121125, 'expnum': 526},
    {'field': 'PSNJ07250042+2347030', 'seq': 'A', 'filter': 'H', 'night': 20121130, 'expnum': 628},
    {'field': 'PSNJ07250042+2347030', 'seq': 'A', 'filter': 'H', 'night': 20131213, 'expnum': 440},
Exemple #4
0
def make_lc(field, target=None, tract=None, butler=None,
            do_snr_cut=False, verbose=True):
    """Extract a lightcurve from the calexps for the given field, target.

    If target is None, then field name is used as the target.

    if butler is None, then a new one is created.
    """
    if target is None:
        target = field

    if tract is None:
        tract = get_tract_for_field(field)

    repo = os.path.join(os.getenv('DR1BASE'), 'repo', 'test_dr1')
    rerun = os.path.join(repo, 'rerun', 'forcedPhot')
    if butler is None:
        butler = Butler(rerun)

    ref_table, cats = read_cats(field, tract=tract, butler=butler)

    if do_snr_cut:
        snr_threshold = 5
        good = [True for i in range(len(ref_table))]
        for cat in cats:
            filt = cat.meta['filter']
            these_good = cat['%s_SNR' % filt] > snr_threshold
            good = good & these_good

        ref_table = ref_table[good]
        for cat in cats:
            cat = cat[good]

    RA, Dec = get_RA_Dec_for_target(target)
    if verbose:
        print("Making lightcurve for %s at (RA, Dec)=(%f, %f)" %
              (target, RA, Dec))

    target_coord = afwGeom.SpherePoint(RA, Dec, afwGeom.degrees)

    distList = []
    for s in ref_table:
        this_coord = afwGeom.SpherePoint(s['coord_ra'], s['coord_dec'], afwGeom.radians)
        angSep = target_coord.separation(this_coord)
        distList.append(angSep)

    distance = np.array(distList)
    target_idx = np.argmin(distance)
    object_id = ref_table['id'][target_idx]

    print('Found match: Row %d, Object %d at %f arcsecs' %
          (target_idx, object_id, afwGeom.radToArcsec(distance[target_idx])))

    # Extract a lightcurve by reading in the forced-src photometry files
    # that were built off of this same reference table.
    dataIds_by_filter = get_dataIds_for_field(butler, field, tract)

    lc = assemble_catalogs_into_lightcurve(dataIds_by_filter,
                                           butler=butler,
                                           object_id=object_id,
                                           dataset='forced_src')
    # Add coordinate information to lightcurve
    lc.meta['RA'] = RA
    lc.meta['Dec'] = Dec
    lc_file = '{:s}_{:s}.ecsv'.format(field, target)
    lc.write(lc_file, format='ascii.ecsv', overwrite=True)

    lc.pprint(max_width=-1)

    return butler, lc, ref_table, target_idx