-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
248 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
185 changes: 185 additions & 0 deletions
185
schema/sdss5db/catalogdb/sdss_qso/dr16/sdss_dr16_qso.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,185 @@ | ||
CREATE TABLE IF NOT EXISTS catalogdb.sdss_dr16_qso ( | ||
sdss_name TEXT, | ||
ra DOUBLE PRECISION, | ||
dec DOUBLE PRECISION, | ||
plate INTEGER, | ||
mjd INTEGER, | ||
fiberid INTEGER, | ||
autoclass_pqn TEXT, | ||
autoclass_dr14q TEXT, | ||
is_qso_qn INTEGER, | ||
z_qn DOUBLE PRECISION, | ||
random_select INTEGER, | ||
z_10k DOUBLE PRECISION, | ||
z_conf_10k INTEGER, | ||
pipe_corr_10k INTEGER, | ||
is_qso_10k INTEGER, | ||
thing_id BIGINT, | ||
z_vi DOUBLE PRECISION, | ||
z_conf INTEGER, | ||
class_person INTEGER, | ||
z_dr12q DOUBLE PRECISION, | ||
is_qso_dr12q INTEGER, | ||
z_dr7q_sch DOUBLE PRECISION, | ||
is_qso_dr7q INTEGER, | ||
z_dr6q_hw DOUBLE PRECISION, | ||
z_dr7q_hw DOUBLE PRECISION, | ||
is_qso_final INTEGER, | ||
z DOUBLE PRECISION, | ||
source_z TEXT, | ||
z_pipe DOUBLE PRECISION, | ||
zwarning INTEGER, | ||
objid TEXT, | ||
z_pca DOUBLE PRECISION, | ||
zwarn_pca BIGINT, | ||
deltachi2_pca DOUBLE PRECISION, | ||
z_halpha DOUBLE PRECISION, | ||
zwarn_halpha BIGINT, | ||
deltachi2_halpha DOUBLE PRECISION, | ||
z_hbeta DOUBLE PRECISION, | ||
zwarn_hbeta BIGINT, | ||
deltachi2_hbeta DOUBLE PRECISION, | ||
z_mgii DOUBLE PRECISION, | ||
zwarn_mgii BIGINT, | ||
deltachi2_mgii DOUBLE PRECISION, | ||
z_ciii DOUBLE PRECISION, | ||
zwarn_ciii BIGINT, | ||
deltachi2_ciii DOUBLE PRECISION, | ||
z_civ DOUBLE PRECISION, | ||
zwarn_civ BIGINT, | ||
deltachi2_civ DOUBLE PRECISION, | ||
z_lya DOUBLE PRECISION, | ||
zwarn_lya BIGINT, | ||
deltachi2_lya DOUBLE PRECISION, | ||
z_lyawg REAL, | ||
z_dla DOUBLE PRECISION[] | ||
nhi_dla DOUBLE PRECISION[] | ||
conf_dla DOUBLE PRECISION[] | ||
bal_prob REAL, | ||
bi_civ DOUBLE PRECISION, | ||
err_bi_civ DOUBLE PRECISION, | ||
ai_civ DOUBLE PRECISION, | ||
err_ai_civ DOUBLE PRECISION, | ||
bi_siiv DOUBLE PRECISION, | ||
err_bi_siiv DOUBLE PRECISION, | ||
ai_siiv DOUBLE PRECISION, | ||
err_ai_siiv DOUBLE PRECISION, | ||
boss_target1 BIGINT, | ||
eboss_target0 BIGINT, | ||
eboss_target1 BIGINT, | ||
eboss_target2 BIGINT, | ||
ancillary_target1 BIGINT, | ||
ancillary_target2 BIGINT, | ||
nspec_sdss INTEGER, | ||
nspec_boss INTEGER, | ||
nspec INTEGER, | ||
plate_duplicate INTEGER[] | ||
mjd_duplicate INTEGER[] | ||
fiberid_duplicate INTEGER[] | ||
spectro_duplicate INTEGER[] | ||
skyversion uint8, | ||
run_number INTEGER, | ||
rerun_number TEXT, | ||
camcol_number INTEGER, | ||
field_number INTEGER, | ||
id_number INTEGER, | ||
lambda_eff DOUBLE PRECISION, | ||
zoffset DOUBLE PRECISION, | ||
xfocal DOUBLE PRECISION, | ||
yfocal DOUBLE PRECISION, | ||
chunk TEXT, | ||
tile INTEGER, | ||
platesn2 DOUBLE PRECISION, | ||
psfflux REAL[] | ||
psfflux_ivar DOUBLE PRECISION[] | ||
psfmag REAL[] | ||
psfmagerr DOUBLE PRECISION[] | ||
extinction REAL[] | ||
m_i DOUBLE PRECISION, | ||
sn_median_all DOUBLE PRECISION, | ||
galex_matched INTEGER, | ||
fuv DOUBLE PRECISION, | ||
fuv_ivar DOUBLE PRECISION, | ||
nuv DOUBLE PRECISION, | ||
nuv_ivar DOUBLE PRECISION, | ||
ukidss_matched INTEGER, | ||
yflux DOUBLE PRECISION, | ||
yflux_err DOUBLE PRECISION, | ||
jflux DOUBLE PRECISION, | ||
jflux_err DOUBLE PRECISION, | ||
hflux DOUBLE PRECISION, | ||
hflux_err DOUBLE PRECISION, | ||
kflux DOUBLE PRECISION, | ||
kflux_err DOUBLE PRECISION, | ||
w1_flux REAL, | ||
w1_flux_ivar REAL, | ||
w1_mag REAL, | ||
w1_mag_err REAL, | ||
w1_chi2 REAL, | ||
w1_flux_snr REAL, | ||
w1_src_frac REAL, | ||
w1_ext_flux REAL, | ||
w1_ext_frac REAL, | ||
w1_npix INTEGER, | ||
w2_flux REAL, | ||
w2_flux_ivar REAL, | ||
w2_mag REAL, | ||
w2_mag_err REAL, | ||
w2_chi2 REAL, | ||
w2_flux_snr REAL, | ||
w2_src_frac REAL, | ||
w2_ext_flux REAL, | ||
w2_ext_frac REAL, | ||
w2_npix INTEGER, | ||
first_matched INTEGER, | ||
first_flux DOUBLE PRECISION, | ||
first_snr DOUBLE PRECISION, | ||
sdss2first_sep DOUBLE PRECISION, | ||
jmag DOUBLE PRECISION, | ||
jmag_err DOUBLE PRECISION, | ||
jsnr DOUBLE PRECISION, | ||
jrdflag INTEGER, | ||
hmag DOUBLE PRECISION, | ||
hmag_err DOUBLE PRECISION, | ||
hsnr DOUBLE PRECISION, | ||
hrdflag INTEGER, | ||
kmag DOUBLE PRECISION, | ||
kmag_err DOUBLE PRECISION, | ||
ksnr DOUBLE PRECISION, | ||
krdflag INTEGER, | ||
sdss2mass_sep DOUBLE PRECISION, | ||
2rxs_id TEXT, | ||
2rxs_ra DOUBLE PRECISION, | ||
2rxs_dec DOUBLE PRECISION, | ||
2rxs_src_flux REAL, | ||
2rxs_src_flux_err REAL, | ||
sdss2rosat_sep DOUBLE PRECISION, | ||
xmm_src_id BIGINT, | ||
xmm_ra DOUBLE PRECISION, | ||
xmm_dec DOUBLE PRECISION, | ||
xmm_soft_flux REAL, | ||
xmm_soft_flux_err REAL, | ||
xmm_hard_flux REAL, | ||
xmm_hard_flux_err REAL, | ||
xmm_total_flux REAL, | ||
xmm_total_flux_err REAL, | ||
xmm_total_lum REAL, | ||
sdss2xmm_sep DOUBLE PRECISION, | ||
gaia_matched INTEGER, | ||
gaia_designation TEXT, | ||
gaia_ra DOUBLE PRECISION, | ||
gaia_dec DOUBLE PRECISION, | ||
gaia_parallax DOUBLE PRECISION, | ||
gaia_parallax_err DOUBLE PRECISION, | ||
gaia_pm_ra DOUBLE PRECISION, | ||
gaia_pm_ra_err DOUBLE PRECISION, | ||
gaia_pm_dec DOUBLE PRECISION, | ||
gaia_pm_dec_err DOUBLE PRECISION, | ||
gaia_g_mag DOUBLE PRECISION, | ||
gaia_g_flux_snr DOUBLE PRECISION, | ||
gaia_bp_mag DOUBLE PRECISION, | ||
gaia_bp_flux_snr DOUBLE PRECISION, | ||
gaia_rp_mag DOUBLE PRECISION, | ||
gaia_rp_flux_snr DOUBLE PRECISION, | ||
sdss2gaia_sep DOUBLE PRECISION | ||
); |
18 changes: 18 additions & 0 deletions
18
schema/sdss5db/catalogdb/sdss_qso/dr16/sdss_dr16_qso_index.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
ALTER TABLE catalogdb.sdss_dr16_qso ADD PRIMARY KEY (pk); | ||
|
||
-- ALTER TABLE catalogdb.sdss_dr16_qso ADD COLUMN specobjid BIGINT; | ||
-- UPDATE catalogdb.sdss_dr16_qso | ||
-- SET specobjid = (plate::bigint<<50 ) + (fiberid::bigint<<38) + | ||
-- ((mjd-50000)::bigint<<24) + (26::bigint<<10); | ||
|
||
CREATE INDEX CONCURRENTLY ON catalogdb.sdss_dr16_qso USING BTREE (plate); | ||
CREATE INDEX CONCURRENTLY ON catalogdb.sdss_dr16_qso USING BTREE (mjd); | ||
CREATE INDEX CONCURRENTLY ON catalogdb.sdss_dr16_qso USING BTREE (fiberid); | ||
CREATE INDEX CONCURRENTLY ON catalogdb.sdss_dr16_qso (mjd, plate, fiberid); | ||
|
||
-- CREATE INDEX CONCURRENTLY ON catalogdb.sdss_dr16_qso (specobjid); | ||
|
||
-- CREATE INDEX CONCURRENTLY ON catalogdb.sdss_dr16_qso (q3c_ang2ipix(ra, dec)); | ||
-- CLUSTER sdss_dr16_qso_q3c_ang2ipix_idx ON catalogdb.sdss_dr16_qso; | ||
-- ANALYZE catalogdb.sdss_dr16_qso; |
39 changes: 39 additions & 0 deletions
39
schema/sdss5db/catalogdb/sdss_qso/dr16/sdss_dr16_qso_load.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
# | ||
# @Author: José Sánchez-Gallego (gallegoj@uw.edu) | ||
# @Date: 2020-07-17 | ||
# @Filename: sdss_dr16_qso_load.py | ||
# @License: BSD 3-clause (http://www.opensource.org/licenses/BSD-3-Clause) | ||
|
||
import os | ||
|
||
import astropy.table | ||
|
||
from sdssdb.peewee.sdss5db import database | ||
from sdssdb.utils.ingest import to_csv | ||
|
||
|
||
assert database.connected | ||
|
||
|
||
def main(): | ||
|
||
file_ = os.environ['CATALOGDB_DIR'] + '/sdss_qso/dr16q/DR16Q_v4.fits' | ||
|
||
data = astropy.table.Table.read(file_) | ||
data.meta = {} | ||
data.rename_columns(data.colnames, list(map(lambda x: x.lower(), data.colnames))) | ||
to_csv(data, file_ + '.csv', header=True, overwrite=True) | ||
del data | ||
|
||
cursor = database.cursor() | ||
fileobj = open(file_ + '.csv') | ||
fileobj.readline() # Read header | ||
cursor.copy_from(fileobj, 'catalogdb.sdss_dr16_qso', sep=',') | ||
database.commit() | ||
|
||
|
||
if __name__ == '__main__': | ||
|
||
main() |