예제 #1
0
 def get_cluster_catalog(self, cluster_catalog, output_name,
                         xformat=None,
                         compare_z=True,
                         export_all=False):
     """
     Get all cluster detections for the catalog.
     """
     self.logger.debug('Get cluster catalog for user %s', cluster_catalog)
     if compare_z:
         z_columns = """f.z as z_orig, c.z z_mine,
         abs(f.z - c.z) as dz, c.z_err,
         case when abs(c.z - f.z) < c.z_err then True
                                            else False end as is_good_z,
         """
     else:
         z_columns = "c.z z_mine, c.z_err,"
     if not export_all:
         extras = """and c.is_ok"""
     else:
         extras = ''
     sqllist.GLOBALS['s'] = cluster_catalog
     if cluster_catalog in self.source_catalogs:
         sql = sqllist.get_sql('cluster-catalog', z_columns, extras)
     else:
         sql = sqllist.get_sql('ext-cluster-catalog', z_columns, extras)
     return self.output_sql(sql, output_name, xformat)
예제 #2
0
 def get_cluster_catalog(self,
                         cluster_catalog,
                         output_name,
                         xformat=None,
                         compare_z=True,
                         export_all=False):
     """
     Get all cluster detections for the catalog.
     """
     self.logger.debug('Get cluster catalog for user %s', cluster_catalog)
     if compare_z:
         z_columns = """f.z as z_orig, c.z z_mine,
         abs(f.z - c.z) as dz, c.z_err,
         case when abs(c.z - f.z) < c.z_err then True
                                            else False end as is_good_z,
         """
     else:
         z_columns = "c.z z_mine, c.z_err,"
     if not export_all:
         extras = """and c.is_ok"""
     else:
         extras = ''
     sqllist.GLOBALS['s'] = cluster_catalog
     if cluster_catalog in self.source_catalogs:
         sql = sqllist.get_sql('cluster-catalog', z_columns, extras)
     else:
         sql = sqllist.get_sql('ext-cluster-catalog', z_columns, extras)
     return self.output_sql(sql, output_name, xformat)
예제 #3
0
 def get_detections(self, user, iid, output_name, format=None):
     """
     Get all cluster detections for a given field.
     """
     self.logger.debug('Get detections for %s of user %s', iid, user)
     sql = sqllist.get_sql('cluster-detections', user, iid,
                           self.catalog.CATALOG)
     return self.output_sql(sql, output_name, format)
예제 #4
0
    def delete_iid(self, user, iid):
        """
        Delete users iid.
        """
        self.logger.debug('Delete iid %s for user %s', iid, user)
        global_iid = self.get_global_iid(user, iid)
        catalogs = self.conn.execute_set(["""
select catalog from fields_properties
where iid = %s""" % global_iid], quiet=False)
        tmp_catalog = sqllist.GLOBALS['c']
        for catalog in catalogs:
            sqllist.GLOBALS['c'] = catalog[0]
            delete_sql = sqllist.get_sql('delete-from-catalog', global_iid)
            self.conn.execute(delete_sql)
        sqllist.GLOBALS['c'] = tmp_catalog
        self.conn.execute(sqllist.get_sql('delete-iid', global_iid, user))
        self.conn.commit()
예제 #5
0
 def get_detections(self, user, iid, output_name, format=None):
     """
     Get all cluster detections for a given field.
     """
     self.logger.debug('Get detections for %s of user %s', iid, user)
     sql = sqllist.get_sql('cluster-detections', user, iid,
                           self.catalog.CATALOG)
     return self.output_sql(sql, output_name, format)
예제 #6
0
 def get_members(self, user, iid, output_name, format=None):
     """
     Output memberships and per-source information.
     """
     self.logger.debug('Get members for %s of user %s', iid, user)
     sqllist.GLOBALS['i'] = self.get_global_iid(user, iid)
     sql = sqllist.get_sql('members', to_str(self.catalog.error_columns,
                                             ','),
                           to_str(self.catalog.magnitude_columns, ','))
     return self.output_sql(sql, output_name, format)
예제 #7
0
 def get_members(self, user, iid, output_name, format=None):
     """
     Output memberships and per-source information.
     """
     self.logger.debug('Get members for %s of user %s', iid, user)
     sqllist.GLOBALS['i'] = self.get_global_iid(user, iid)
     sql = sqllist.get_sql('members',
                           to_str(self.catalog.error_columns, ','),
                           to_str(self.catalog.magnitude_columns, ','))
     return self.output_sql(sql, output_name, format)
예제 #8
0
    def delete_iid(self, user, iid):
        """
        Delete users iid.
        """
        self.logger.debug('Delete iid %s for user %s', iid, user)
        global_iid = self.get_global_iid(user, iid)
        catalogs = self.conn.execute_set([
            """
select catalog from fields_properties
where iid = %s""" % global_iid
        ],
                                         quiet=False)
        tmp_catalog = sqllist.GLOBALS['c']
        for catalog in catalogs:
            sqllist.GLOBALS['c'] = catalog[0]
            delete_sql = sqllist.get_sql('delete-from-catalog', global_iid)
            self.conn.execute(delete_sql)
        sqllist.GLOBALS['c'] = tmp_catalog
        self.conn.execute(sqllist.get_sql('delete-iid', global_iid, user))
        self.conn.commit()
예제 #9
0
 def get_members_iid(self, iid, output_name, xformat=None):
     """
     Get all possible cluster members.
     """
     self.logger.debug('Get members for %s', iid)
     sqllist.GLOBALS['i'] = iid
     if self.catalog.CATALOG == 'xmatch':
         sqlname = 'xmatch-members'
     else:
         sqlname = 'members'
     sql = sqllist.get_sql(sqlname,
                           to_str(self.catalog.magnitude_columns, ','),
                           to_str(self.catalog.error_columns, ','))
     return self.output_sql(sql, output_name, xformat)
예제 #10
0
 def get_members_iid(self, iid, output_name, xformat=None):
     """
     Get all possible cluster members.
     """
     self.logger.debug('Get members for %s', iid)
     sqllist.GLOBALS['i'] = iid
     if self.catalog.CATALOG == 'xmatch':
         sqlname = 'xmatch-members'
     else:
         sqlname = 'members'
     sql = sqllist.get_sql(sqlname,
                           to_str(self.catalog.magnitude_columns, ','),
                           to_str(self.catalog.error_columns, ','))
     return self.output_sql(sql, output_name, xformat)