예제 #1
0
 def manual_mask_cleanup(self, catalog, filt):
     """Masks regions that were observed to have artefacts upon visual inspection"""
     val = np.zeros(len(catalog))
     col = Column(val, name='IN_MANUAL_MASK',
                  description="In a manual mask region", dtype=int)
     catalog.add_column(col)
     mask_tab = Table.read(self.params.manual_mask_file, format='ascii.basic')
     q, = np.where((self.params.seg_id == mask_tab['SEG']) & (filt == mask_tab['FILTER']))
     if len(q) == 0:
         return catalog
     else:
         for m in q:
             x_vertices = np.array([mask_tab['AX'][m], mask_tab['BX'][m], mask_tab['CX'][m], mask_tab['DX'][m]])
             y_vertices = np.array([mask_tab['AY'][m], mask_tab['BY'][m], mask_tab['CY'][m], mask_tab['DY'][m]])
             Xs = np.array([catalog['XMIN_IMAGE'], catalog['XMAX_IMAGE']],
                           dtype=int)
             Ys = np.array([catalog['YMIN_IMAGE'], catalog['YMAX_IMAGE']],
                           dtype=int)
             bottom_pixels = [[(x, Ys[0][i]) for x in range(Xs[0][i],Xs[1][i])]for i in range(len(catalog))]
             top_pixels = [[(x, Ys[1][i]) for x in range(Xs[0][i], Xs[1][i])]for i in range(len(catalog))]
             left_pixels = [[(Xs[0][i], y) for y in range(Ys[0][i], Ys[1][i])]for i in range(len(catalog))]
             right_pixels = [[(Xs[1][i], y) for y in range(Ys[0][i], Ys[1][i])]for i in range(len(catalog))]
             for i in range(len(catalog)):
                 pixels = bottom_pixels[i] + left_pixels[i] + top_pixels[i] + right_pixels[i]
                 bools = [fn.inpoly(pixel[0], pixel[1], x_vertices, y_vertices) for pixel in pixels]
                 if max(bools) == 1:
                     catalog['IN_MANUAL_MASK'][i] = 1
         return catalog
예제 #2
0
 def manual_mask_cleanup(self, catalog, filt):
     """masks regions that were observed to have artefacts upon visual inspection
     """
     val = np.zeros(len(catalog))
     col = Column(val,
                  name='IN_MANUAL_MASK',
                  description="In a manual mask region",
                  dtype=int)
     catalog.add_column(col)
     mask_tab = Table.read(self.params.manual_mask_file,
                           format='ascii.basic')
     q, = np.where((self.params.seg_id == mask_tab['SEG'])
                   & (filt == mask_tab['FILTER']))
     if len(q) == 0:
         return catalog
     else:
         for m in q:
             x_vertices = np.array([
                 mask_tab['AX'][m], mask_tab['BX'][m], mask_tab['CX'][m],
                 mask_tab['DX'][m]
             ])
             y_vertices = np.array([
                 mask_tab['AY'][m], mask_tab['BY'][m], mask_tab['CY'][m],
                 mask_tab['DY'][m]
             ])
             Xs = np.array([catalog['XMIN_IMAGE'], catalog['XMAX_IMAGE']],
                           dtype=int)
             Ys = np.array([catalog['YMIN_IMAGE'], catalog['YMAX_IMAGE']],
                           dtype=int)
             bottom_pixels = [[(x, Ys[0][i])
                               for x in range(Xs[0][i], Xs[1][i])]
                              for i in range(len(catalog))]
             top_pixels = [[(x, Ys[1][i])
                            for x in range(Xs[0][i], Xs[1][i])]
                           for i in range(len(catalog))]
             left_pixels = [[(Xs[0][i], y)
                             for y in range(Ys[0][i], Ys[1][i])]
                            for i in range(len(catalog))]
             right_pixels = [[(Xs[1][i], y)
                              for y in range(Ys[0][i], Ys[1][i])]
                             for i in range(len(catalog))]
             for i in range(len(catalog)):
                 pixels = bottom_pixels[i] + left_pixels[i] + top_pixels[
                     i] + right_pixels[i]
                 bools = [
                     fn.inpoly(pixel[0], pixel[1], x_vertices, y_vertices)
                     for pixel in pixels
                 ]  # for j in range(len(x_vertices.T))]
                 if max(bools) == 1:
                     catalog['IN_MANUAL_MASK'][i] = 1
         return catalog
예제 #3
0
 def diffraction_mask_cleanup(self, catalog,
                              diff_spike_params,
                              mag_cutoff=19.0):
     """Masks objects within diffraction spikes of saturated stars."""
     m = diff_spike_params[0]  # slope
     b = diff_spike_params[1]  # intercept
     w = diff_spike_params[2] * 0.5  # width
     theta = diff_spike_params[3]  # angle
     val = np.zeros(len(catalog))
     col = Column(val, name='IN_DIFF_MASK',
                  description="Close to saturated star", dtype=int)
     catalog.add_column(col)
     print "Identifying saturated stars"
     cond1 = catalog['MAG_CORR'] < mag_cutoff
     cond2 = catalog['IS_STAR'] == 1
     q, = np.where(cond1 & cond2)
     # exit if no saturated stars present
     if len(q) == 0:
         print 'No saturated objects found'
         return catalog
     x0 = catalog['X_IMAGE'][q]
     y0 = catalog['Y_IMAGE'][q]
     r = np.mean([catalog['A_IMAGE'][q], catalog['B_IMAGE'][q]]) * 5
     flux = catalog['FLUX_AUTO'][q]
     l = m * flux + b
     x_vertices = np.array([x0-w,x0-w,x0+w,x0+w,x0+r,x0+l,x0+l,x0+r,x0+w,x0+w,x0-w,x0-w,x0-r,x0-l,x0-l,x0-r])
     y_vertices = np.array([y0+r,y0+l,y0+l,y0+r,y0+w,y0+w,y0-w,y0-w,y0-r,y0-l,y0-l,y0-r,y0-w,y0-w,y0+w,y0+w])
     (x_vertices, y_vertices) = fn.rotate_table(x_vertices, y_vertices, x0, y0, theta)
     catalog['IN_DIFF_MASK'][q] = 1
     print "Identify objects in diffraction spike"
     Xs = np.array([catalog['XMIN_IMAGE'], catalog['XMAX_IMAGE']],
                   dtype=int)
     Ys = np.array([catalog['YMIN_IMAGE'], catalog['YMAX_IMAGE']],
                   dtype=int)
     bottom_pixels = [[(x, Ys[0][i]) for x in range(Xs[0][i],Xs[1][i])]for i in range(len(catalog))]
     top_pixels = [[(x, Ys[1][i]) for x in range(Xs[0][i], Xs[1][i])]for i in range(len(catalog))]
     left_pixels = [[(Xs[0][i], y) for y in range(Ys[0][i], Ys[1][i])]for i in range(len(catalog))]
     right_pixels = [[(Xs[1][i], y) for y in range(Ys[0][i], Ys[1][i])]for i in range(len(catalog))]
     for i in range(len(catalog)):
         pixels = bottom_pixels[i] + left_pixels[i] + top_pixels[i] + right_pixels[i]
         bools = [fn.inpoly(pixel[0], pixel[1], x_vertices.T[j], y_vertices.T[j]) for pixel in pixels for j in range(len(x_vertices.T))]
         if max(bools) == 1:
             catalog['IN_DIFF_MASK'][i] = 1
     return catalog
예제 #4
0
 def diffraction_mask_cleanup(self,
                              catalog,
                              diff_spike_params,
                              mag_cutoff=19.0):
     """Masks objects within diffraction spikes of saturated stars."""
     m = diff_spike_params[0]  # slope
     b = diff_spike_params[1]  # intercept
     w = diff_spike_params[2] * 0.5  # width
     theta = diff_spike_params[3]  # angle
     val = np.zeros(len(catalog))
     col = Column(val,
                  name='IN_DIFF_MASK',
                  description="Close to saturated star",
                  dtype=int)
     catalog.add_column(col)
     print "Identifying saturated stars"
     cond1 = catalog['MAG_CORR'] < mag_cutoff
     cond2 = catalog['IS_STAR'] == 1
     q, = np.where(cond1 & cond2)
     # exit if no saturated stars present
     if len(q) == 0:
         print 'No saturated objects found'
         return catalog
     x0 = catalog['X_IMAGE'][q]
     y0 = catalog['Y_IMAGE'][q]
     r = np.mean([catalog['A_IMAGE'][q], catalog['B_IMAGE'][q]]) * 5
     flux = catalog['FLUX_AUTO'][q]
     l = m * flux + b
     x_vertices = np.array([
         x0 - w, x0 - w, x0 + w, x0 + w, x0 + r, x0 + l, x0 + l, x0 + r,
         x0 + w, x0 + w, x0 - w, x0 - w, x0 - r, x0 - l, x0 - l, x0 - r
     ])
     y_vertices = np.array([
         y0 + r, y0 + l, y0 + l, y0 + r, y0 + w, y0 + w, y0 - w, y0 - w,
         y0 - r, y0 - l, y0 - l, y0 - r, y0 - w, y0 - w, y0 + w, y0 + w
     ])
     (x_vertices, y_vertices) = fn.rotate_table(x_vertices, y_vertices, x0,
                                                y0, theta)
     catalog['IN_DIFF_MASK'][q] = 1
     print "Identify objects in diffraction spike"
     Xs = np.array([catalog['XMIN_IMAGE'], catalog['XMAX_IMAGE']],
                   dtype=int)
     Ys = np.array([catalog['YMIN_IMAGE'], catalog['YMAX_IMAGE']],
                   dtype=int)
     bottom_pixels = [[(x, Ys[0][i]) for x in range(Xs[0][i], Xs[1][i])]
                      for i in range(len(catalog))]
     top_pixels = [[(x, Ys[1][i]) for x in range(Xs[0][i], Xs[1][i])]
                   for i in range(len(catalog))]
     left_pixels = [[(Xs[0][i], y) for y in range(Ys[0][i], Ys[1][i])]
                    for i in range(len(catalog))]
     right_pixels = [[(Xs[1][i], y) for y in range(Ys[0][i], Ys[1][i])]
                     for i in range(len(catalog))]
     for i in range(len(catalog)):
         pixels = bottom_pixels[i] + left_pixels[i] + top_pixels[
             i] + right_pixels[i]
         bools = [
             fn.inpoly(pixel[0], pixel[1], x_vertices.T[j], y_vertices.T[j])
             for pixel in pixels for j in range(len(x_vertices.T))
         ]
         if max(bools) == 1:
             catalog['IN_DIFF_MASK'][i] = 1
     return catalog