# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# # Get the ra and dec for each galaxy in CGM$^2$

from astropy.io import fits
import glob
import astropy
from astropy.table import Table

# Lets see what a mask file looks like

file = glob.glob("gn*fits")[0]
mdf = Table.read(file)
mdf


def get_radec(file):
    """ get the RA, DEC from a mask file. Put it into
    an astropy Table object.
    """
    mdf = Table.read(file)
    ID = mdf['ID']
    ra = mdf['RA']
    dec = mdf['DEC']
    radec_tab = Table([ID, ra, dec])
    return radec_tab


file_names = glob.glob("/Users/mwilde/Dropbox/COS-Gemini/gemini_data.G*/raw*/G*.fits")

# +
radec_list = []
for file in file_names:
    radec = get_radec(file)
    radec_list.append(radec)

radec_tab = astropy.table.vstack(radec_list)
# -

radec_tab.info

radec_tab.write('cgmsquared_gal_radec.txt', format='ascii', overwrite=True)

radec_tab



StarcoderdataJupyterScriptsDedupFiltered