Skip to content

Commit

Permalink
moved table stripping after join to pp_calibrate
Browse files Browse the repository at this point in the history
  • Loading branch information
mommermi committed Nov 17, 2018
1 parent 60ec8a2 commit 890747c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 21 deletions.
11 changes: 3 additions & 8 deletions catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import sys
import logging

from copy import deepcopy
import numpy as np
import sqlite3 as sql
import astropy.units as u
Expand Down Expand Up @@ -857,13 +856,9 @@ def write_database(self, filename):
header.to_pandas().to_sql('header', db_conn,
if_exists='replace', index=False)

# modify data and write to database
data = deepcopy(self.data)
data.remove_columns(['idx', 'ra_deg_2', 'dec_deg_2'])
data.rename_column('ra_deg_1', 'ra_deg')
data.rename_column('dec_deg_1', 'dec_deg')
data.to_pandas().to_sql('data', db_conn,
if_exists='replace', index=False)
# write data to database
self.data.to_pandas().to_sql('data', db_conn,
if_exists='replace', index=False)

db_conn.commit()

Expand Down
17 changes: 4 additions & 13 deletions pp_calibrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,19 +412,10 @@ def fchi2(zp): return np.sum([(zp-residuals)**2/residuals_sig])
cat.data = join(cat.data, db_ref_cat.data,
keys='idx',
join_type='left')
# cal_id = ['' for i in range(cat.shape[0])]
# print(ref_cat.fields)
# cal_coo = np.zeros((cat.shape[0], 2))
# for i in range(len(match[0][0])):
# cal_id[match[1][2][i]] = ref_cat[match[0][5][i]]['ident']
# cal_coo[match[1][2][i][0]] = ref_cat['ra_deg',
# 'dec_deg'][match[0][5][i]]

# # ra[match[1][2][i]] = ref_cat[match[0][5][i]]['ra_deg']
# # cal_dec[match[1][2][i]] = ref_cat[match[0][5][i]]['dec_deg']
# cat.add_fields(['cal_ident', 'cal_ra_deg', 'cal_dec_deg'],
# [cal_id, cal_ra, cal_dec],
# [np.string_, np.float, np.float])
# remove unnecessary fields
cat.data.remove_columns(['idx', 'ra_deg_2', 'dec_deg_2'])
cat.data.rename_column('ra_deg_1', 'ra_deg')
cat.data.rename_column('dec_deg_1', 'dec_deg')

if filterkey not in cat.fields:
cat.add_fields([filterkey, efilterkey],
Expand Down

0 comments on commit 890747c

Please sign in to comment.