[AstroPy] Requesting Help for Matching Source Catalogs Using astropy.coordinates

Eric Jensen ejensen1 at swarthmore.edu
Thu Mar 28 21:31:01 EDT 2019


Hi Samantha, 

You are 90% of the way there, and just need to do a few more things with the variables you already have. 

Regarding your first question, to get the three-way match, just match the first two catalogs as you’re already doing, then take either of the matched sets of coords (your variables c_matches or catalog_matches), and match *those* to the coords from your third catalog.  That way you are starting with only the set of things that match across 1 and 2, and then matching that set to 3.  

To be on the safe side, you may want to match both c_matches and catalog_matches to your third catalog and compare the number of matches.  It probably won’t be exactly the same, since the matching RA and Dec values aren’t exactly the same for a given object, so you could have some matches in catalog 3 that are right on the edge, e.g. close enough to the coords from catalog 1 but not to the coords from catalog 2.  You’ll have to decide how to handle those edge cases. 

For your second question, you can use the same kind of indexing you’re using to get the subsets of matching coordinates, but apply it to the whole catalog.  Right now you are doing this: 

c_matches = c[sep_constraint]

so you can also use that sep_constraint variable (really a boolean mask) to index the entire catalog and get the matching subset, e.g. 

catalog1_matches = my_csv1[sep_constraint, :]

and similarly, 

catalog2_matches = my_csv2[idx[sep_constraint], :]

Good luck, 

Eric

Eric Jensen
Professor of Astronomy
Swarthmore College
 


> On Mar 28, 2019, at 3:34 PM, Samantha Martin <smartin2016 at my.fit.edu <mailto:smartin2016 at my.fit.edu>> wrote:
> 
> Hello all!
> 
> I am working on a project for my undergraduate research where I am using astropy.coordinates and match_coordinates_sky to find source matches between three sets of data in RA and DEC.  I am able to find the source matches between two data sets at a time.  I have two questions about this.  First of all, when I match my first data set to my second data set, they have 2240 matches, but when I match my first data set to my third data set, they have 3400 matches.  My first data set is the one I want to match to specifically because it has the least amount of sources.  How do I ensure that all three data sets all match each other (ie. contain the same sources), not just one of the other data sets?  My second question is, now that I have the source matches, how do I apply this to the rest of the parameters (magnitude, flux etc.) in my data?  After matching, I am able to output the matching RA and DEC values for each data set, but I don’t know how to apply the matches to the other 21 columns of data that correspond to these sources.  In order for me to continue the project I must be able to use all of the data, not just RA and DEC.  Below is the code that I have used to find my matches.  I’ve been trying to search online for answers to these questions for days with no luck.  I am not sure if this a good place to ask this, and if it isn’t then could someone direct me to a good forum for these types of questions?
> 
> 
> 
> 
> import numpy as np
>  
> my_csv1 = np.loadtxt(open("F435W.csv"), delimiter=",")
> my_csv2 = np.loadtxt(open("F550M.csv"), delimiter=",")
>  
> from astropy.coordinates import SkyCoord
> from astropy import units as u
> from astropy.coordinates import match_coordinates_sky
>  
> c = SkyCoord(my_csv1[:, 12], my_csv1[:, 13], frame='icrs', unit='deg')
> catalog = SkyCoord(my_csv2[:, 12], my_csv2[:, 13], frame='icrs', unit='deg')
>  
> max_sep = 1.0*u.arcsec
> idx, sep2d, _ = c.match_to_catalog_sky(catalog)
> sep_constraint = sep2d < max_sep
> c_matches = c[sep_constraint]
> catalog_matches = catalog[idx[sep_constraint]]
>  
> print (len(c_matches), len(catalog_matches))
> 
> 
> 
> Thank you,
> 
> Samantha
> 
> 
> 
> 
> _______________________________________________
> AstroPy mailing list
> AstroPy at python.org <mailto:AstroPy at python.org>
> https://mail.python.org/mailman/listinfo/astropy

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/astropy/attachments/20190328/7eb67128/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3932 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/astropy/attachments/20190328/7eb67128/attachment-0001.bin>


More information about the AstroPy mailing list