def test_htm_function(self): from HMpTy import HTM mesh16 = HTM( depth=16, log=log ) mesh20 = HTM( depth=20, log=log ) mesh24 = HTM( depth=24, log=log ) print "DEPTH24:", mesh24.depth print "AREA24:", mesh24.area * 60 * 60 * 60 * 60, " arcsec^2" print "DEPTH16:", mesh16.depth print "AREA16:", mesh16.area * 60 * 60 * 60 * 60, " arcsec^2" print "DEPTH20:", mesh20.depth print "AREA20:", mesh20.area * 60 * 60 * 60 * 60, " arcsec^2" overlappingTrixels = mesh24.intersect( ra="23:25:53.56", dec="+26:54:23.9", radius=0.01, inclusive=False ) # print overlappingTrixels overlappingTrixels = mesh24.intersect( ra="23:25:53.56", dec="+26:54:23.9", radius=10 / (60 * 60), inclusive=True ) # print overlappingTrixels twoArcsec = 2.0 / 3600. raList1 = [200.0, 200.0, 200.0, 175.23, 21.36] decList1 = [24.3, 24.3, 24.3, -28.25, -15.32] raList2 = [200.0, 200.0, 200.0, 175.23, 55.25] decList2 = [24.3 + 0.75 * twoArcsec, 24.3 + 0.25 * twoArcsec, 24.3 - 0.33 * twoArcsec, -28.25 + 0.58 * twoArcsec, 75.22] matchIndices1, matchIndices2, seps = mesh16.match( ra1=raList1, dec1=decList1, ra2=raList2, dec2=decList2, radius=twoArcsec, maxmatch=0 ) for m1, m2, s in zip(matchIndices1, matchIndices2, seps): print raList1[m1], decList1[m1], " -> ", s * 3600., " arcsec -> ", raList2[m2], decList2[m2]
def _extract_one_set_from_list( self, ra, dec, radius, sourceList): """*Crossmatch the first row in the list against the remaining rows* **Key Arguments:** - ``ra`` -- a list of RAs - ``dec`` -- a list of DECs (same length as ``ra``) - ``radius`` -- the radius of the crossmatch - ``sourceList`` -- the list of source imformation to be divided into associated sets (same length as ``ra`` and ``dec``) **Return:** - ``matches`` -- the matches from the cross-match - ``ra`` -- the remaining RAs - ``dec`` -- the remaining DECs """ self.log.info('starting the ``_extract_one_set_from_list`` method') matches = [] from HMpTy import HTM mesh = HTM( depth=12, log=self.log ) matchIndices1, matchIndices2, seps = mesh.match( ra1=ra[0], dec1=dec[0], ra2=ra[1:], dec2=dec[1:], radius=radius, maxmatch=0 # 1 = match closest 1, 0 = match all ) matches = [] matches.append(sourceList[0]) indiciesToRemove = [0] for m1, m2, s in zip(matchIndices1, matchIndices2, seps): matches.append(sourceList[1:][m2]) if (m2 + 1) not in indiciesToRemove: indiciesToRemove.append(m2 + 1) for index in sorted(indiciesToRemove, reverse=True): del ra[index] del dec[index] del sourceList[index] self.log.info('completed the ``_extract_one_set_from_list`` method') return matches, ra, dec, sourceList
def _extract_all_sets_from_list( self): """*Extract all of the sets from the list of coordinates* **Return:** - ``allMatches`` -- a list of lists. All of the assocaited sets of sources """ self.log.info('starting the ``_extract_all_sets_from_list`` method') from HMpTy import HTM mesh = HTM( depth=12, log=self.log ) matchIndices1, matchIndices2, seps = mesh.match( ra1=self.ra, dec1=self.dec, ra2=self.ra, dec2=self.dec, radius=self.radius, maxmatch=0, # 1 = match closest 1, 0 = match all, convertToArray=self.convertToArray ) anchorIndicies = [] childIndicies = [] allMatches = [] thisMatch = None for m1, m2, s in zip(matchIndices1, matchIndices2, seps): if m1 not in anchorIndicies and m1 not in childIndicies: if thisMatch: allMatches.append(thisMatch) thisMatch = [self.sourceList[m1]] anchorIndicies.append(m1) if m2 not in anchorIndicies and m2 not in childIndicies: childIndicies.append(m2) thisMatch.append(self.sourceList[m2]) if thisMatch: allMatches.append(thisMatch) self.log.info('completed the ``_extract_all_sets_from_list`` method') return allMatches
def test_htm_function(self): from HMpTy import HTM mesh16 = HTM(depth=16, log=log) mesh20 = HTM(depth=20, log=log) mesh24 = HTM(depth=24, log=log) print("DEPTH24:", mesh24.depth) print("AREA24:", mesh24.area * 60 * 60 * 60 * 60, " arcsec^2") print("DEPTH16:", mesh16.depth) print("AREA16:", mesh16.area * 60 * 60 * 60 * 60, " arcsec^2") print("DEPTH20:", mesh20.depth) print("AREA20:", mesh20.area * 60 * 60 * 60 * 60, " arcsec^2") overlappingTrixels = mesh24.intersect(ra="23:25:53.56", dec="+26:54:23.9", radius=0.01, inclusive=False) # print overlappingTrixels overlappingTrixels = mesh24.intersect(ra="23:25:53.56", dec="+26:54:23.9", radius=old_div(10, (60 * 60)), inclusive=True) # print overlappingTrixels twoArcsec = 2.0 / 3600. raList1 = [200.0, 200.0, 200.0, 175.23, 21.36] decList1 = [24.3, 24.3, 24.3, -28.25, -15.32] raList2 = [200.0, 200.0, 200.0, 175.23, 55.25] decList2 = [ 24.3 + 0.75 * twoArcsec, 24.3 + 0.25 * twoArcsec, 24.3 - 0.33 * twoArcsec, -28.25 + 0.58 * twoArcsec, 75.22 ] matchIndices1, matchIndices2, seps = mesh16.match(ra1=raList1, dec1=decList1, ra2=raList2, dec2=decList2, radius=twoArcsec, maxmatch=0) for m1, m2, s in zip(matchIndices1, matchIndices2, seps): print(raList1[m1], decList1[m1], " -> ", s * 3600., " arcsec -> ", raList2[m2], decList2[m2])
potSources = len(orbFitRows) raOrb = [] raOrb[:] = [r["ra_deg"] for r in orbFitRows] decOrb = [] decOrb[:] = [r["dec_deg"] for r in orbFitRows] raOrb = np.array(raOrb) decOrb = np.array(decOrb) mesh = HTM(depth=12, log=log) matchIndices1, matchIndices2, seps = mesh.match( ra1=ra, dec1=dec, ra2=raOrb, dec2=decOrb, radius=matchRadius / 3600., convertToArray=False, maxmatch=0 # 1 = match closest 1, 0 = match all ) # FREE MEMORY raOrb = None decOrb = None dophotRows = [] for m1, m2, s in zip(matchIndices1, matchIndices2, seps): # print ra[m1], dec[m1], " -> ", s * 3600., " arcsec -> ", # raOrb[m2], decOrb[m2] dList = dophotLines[m1].split() dDict = {