def create_regions_by_dither(): """ Creates a regions file for each dither. :return: True if everything is alright. """ for dither_ in range(1, 5, 1): alpha_list = [] delta_list = [] cat_list = get_cats(dither_) for cat_ in cat_list: catalog = fits.open('{}/{}'.format(prfs_d['fits_dir'], cat_)) catalog_data = Table(catalog[2].data).to_pandas() alpha_tmp = catalog_data['ALPHA_J2000'].tolist() delta_tmp = catalog_data['DELTA_J2000'].tolist() for alpha_ in alpha_tmp: alpha_list.append(alpha_) for delta_ in delta_tmp: delta_list.append(delta_) alpha_series = Series(alpha_list, name='ALPHA_J2000') delta_series = Series(delta_list, name='DELTA_J2000') positions_table = concat([alpha_series, delta_series], axis=1) positions_table.to_csv('regions/extracted_{}.reg'.format(dither_), index=False, header=False, sep=" ") return True
def extract_cats(self): """ :return: """ cats_d = {} for dither_ in range(1, 5, 1): cat_list = get_cats(dither_) cats_d[dither_] = {} for cat_ in cat_list: cat = fits.open('{}/{}'.format(self.prfs_d['fits_dir'], cat_)) cat_df = Table(cat[2].data).to_pandas() cats_d[dither_][cat_] = cat_df return cats_d
def create_regions_by_ccd(): """ Creates a regions file for each CCD. :return: True if everything is alright. """ for dither_ in range(1, 5, 1): cat_list = get_cats(dither_) for cat_ in cat_list: catalog = fits.open('{}/{}'.format(prfs_d['fits_dir'], cat_)) catalog_data = Table(catalog[2].data).to_pandas() alpha_list = Series(catalog_data['ALPHA_J2000'].tolist(), name='ALPHA_J2000') delta_list = Series(catalog_data['DELTA_J2000'].tolist(), name='DELTA_J2000') positions_table = concat([alpha_list, delta_list], axis=1) positions_table.to_csv('{}.reg'.format(cat_[:-4]), index=False, header=False, sep=" ") return True