GenerateCatalogue Match array
In find_all_peaks() the match parameter is an intra-catalogue match that locates the nearest neighbour to each star. Starting with a single catalogue, say g-band, called 'df' with df.index = [0,1,2,3,...], match takes that index and df['ra'], df['dec'] and looks for the second closet star to each object. For example, match = [3,8,2,0......], so that the star in row 3 is the nearest neighbour on-sky to the star in row 0. Likewise the star in row 0 is also the neighbour to row 3.
The match value is a list of index/row locations, df['neighbour'] = match. This column points to the information for the star closest to each particular row. It's not a parameter that is called again, but is a traceback/information column just in case we'd like to check the average spread of neighbouring stars.
The sep_pix value is used in select_reference_stars() to weed out all the stars that are densely clustered together. A reference star should be bright, isolated and away from the edge of the CCD.
!The Reference stars will need to be located within the pointed_catalogue output (g_df) as an additional information column. i.e g_df['ref_star'] = [True, False, False, False,....]. We could do this with another astropy match, or by feeding the x, y locations from find_all_peaks into the pointed_catalogue function. (I'll work on this in the next few days to see which is more stable and raise a separate issue)
The 'match' in pointed_catalogue is the same astropy separation concept, but is different to the self-referential match in find_all_peaks(). Pointed_catalogue should be run individually on each CCD, and generate a catalogue without reference to any other filter or image. The g and r outputs for CCD ('N16') g_df and r_df will now contain measurements for all stars located on each image and ra, dec values given the separate WCS for each image.
At this stage we should TAP query each star to a common WCS frame such as SMASH DR2 or GAIA. From there the g_df and r_df catalogues will have ['ra', 'dec'] from our images and ['ra_SMASH', 'dec_SMASH'], as well as ['offset_SMASH'] = [0.11, 0.132...] which will the be separation in arcseconds from our local WCS locations and the SMASH TAP query positions for stars.
Finally, the last step is to match between g_df and r_df using the common WCS from SMASH. The collation step pseudo-code would be def generate_master_catalogue(CCD_name):
def generate_master_catalogue(CCD_name):
g_df = pd.read_csv('path_to_CCD_gfilter.csv, ',')
r_df = pd.read_csv('path_to_CCD_rfilter.csv, ',')
match_2, sep_2, d3sep_2 = match_coordinates_sky (Skycoord(g_df['ra_SMASH'].values, g_df['dec_SMASH'].values, frame="ICRS", unit="deg"), Skycoord(r_df['ra_SMASH'].values, r_df['dec_SMASH'].values, frame="ICRS", unit="deg"), nthneighbor = 1)
r_df = r_df.reindex(match_2)
main_cat = pd.concat(g_df, r_df)
return main_cat
such that g_df concats with the r_df catalogue on the ra, dec values. If g_df is the first Skycoord list, then the match is to r_df.
g_df.index = [0,1,2,3,4,5...] and match = [5,19,10,4,3,0....] such that r_df needs to be reindexed according to the order of match before it's added to g_df.
Now the main catalogue will have all flux, pixel and sky positions for g and r bands for the same star.