Skip to content

Instantly share code, notes, and snippets.

@joezuntz
Created May 19, 2021 13:27
Show Gist options
  • Save joezuntz/01980835d6eb51fcc7b5cd34a9f07a68 to your computer and use it in GitHub Desktop.
Save joezuntz/01980835d6eb51fcc7b5cd34a9f07a68 to your computer and use it in GitHub Desktop.
import sqlite3
import numpy as np
import astropy.table
# open DB file
con = sqlite3.connect('baseline_nexp2_v1.7_10yrs.db')
# count rows so we can make numpy arrays
n = list(con.execute("select count(*) from SummaryAllProps"))[0][0]
ra = np.zeros(n)
dec = np.zeros(n)
# loop through data filling in
for i, row in enumerate(con.execute('select fieldRA, fieldDec from SummaryAllProps')):
ra[i], dec[i] = row
# Write to a FITS table
t = astropy.table.Table(names=["ra", "dec"], data=[ra, dec])
t.write("out.fits")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment