Skip to content

Commit 44ad46f

Browse files
committed
add new meta.setparams overload and use it for photometry
1 parent eb2743d commit 44ad46f

3 files changed

Lines changed: 238 additions & 1 deletion

File tree

postgres/migrations/V031__designation_index.sql

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
CREATE INDEX ON designation.data (design);
2+
3+
CREATE OR REPLACE FUNCTION meta.setparams(
4+
p_schema text,
5+
p_table text,
6+
p_column text,
7+
p_key text,
8+
p_value text
9+
)
10+
RETURNS void
11+
AS $$
12+
DECLARE
13+
tab_oid oid;
14+
col_ord int;
15+
current_comment text;
16+
new_param jsonb;
17+
BEGIN
18+
tab_oid := (quote_ident(p_schema) || '.' || quote_ident(p_table))::regclass;
19+
SELECT c.ordinal_position INTO col_ord
20+
FROM information_schema.columns c
21+
WHERE c.table_schema = p_schema
22+
AND c.table_name = p_table
23+
AND c.column_name = p_column;
24+
IF col_ord IS NULL THEN
25+
RAISE EXCEPTION 'column %.%.% does not exist', p_schema, p_table, p_column;
26+
END IF;
27+
28+
current_comment := pg_catalog.col_description(tab_oid, col_ord);
29+
IF current_comment IS NULL THEN
30+
new_param := '{}'::jsonb;
31+
ELSIF current_comment ~ '^\s*\{' THEN
32+
BEGIN
33+
new_param := current_comment::jsonb;
34+
EXCEPTION WHEN OTHERS THEN
35+
new_param := jsonb_build_object('description', current_comment);
36+
END;
37+
ELSE
38+
new_param := jsonb_build_object('description', current_comment);
39+
END IF;
40+
new_param := new_param || jsonb_build_object(p_key, p_value);
41+
42+
EXECUTE format(
43+
'COMMENT ON COLUMN %I.%I.%I IS %L',
44+
p_schema, p_table, p_column,
45+
new_param::text
46+
);
47+
END;
48+
$$ LANGUAGE plpgsql COST 100 VOLATILE STRICT PARALLEL UNSAFE;
49+
Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
CREATE SCHEMA IF NOT EXISTS photometry ;
2+
SELECT meta.setparams('photometry', '{"description": "Photometry catalog"}');
3+
4+
CREATE TYPE photometry.MagSysType AS ENUM ( 'Vega', 'AB', 'ST' ) ;
5+
6+
COMMENT ON TYPE photometry.MagSysType IS '{
7+
"Vega" : "The Vega magnitude system uses Vega as the standard star with an apparent magnitude of zero, regardless of the wavelength filter. The spectrum of Vega used to define this system is a composite spectrum of empirical and synthetic spectra (Bohlin & Gilliland, 2004AJ....127.3508B). m(Vega) = -2.5*log10(F/FVega), where F is the flux of an object and FVega is the calibrated spectrum of Vega.",
8+
"AB" : "The AB magnitude system uses a flat reference spectrum in frequency space. The conversion is chosen such that the V-magnitude corresponds roughly to that in the Johnson system. The monochromatic AB magnitude is defined as m(AB) = 8.9 -2.5*log10(Fv[Jy]) = -48.6 -2.5*log10(Fv[erg s^−1 cm^−2 Hz^−1]), where Fv is the spectral flux density.",
9+
"ST" : "The ST magnitude system uses a flat reference spectrum in wavelength space. The conversion is chosen such that the V-magnitude corresponds roughly to that in the Johnson system. The monochromatic ST magnitude is defined as m(ST) = -21.1 -2.5*log10(Flambda[erg s^−1 cm^−2 Angstrom^−1]), where Flambda is the spectral flux density."
10+
}' ;
11+
12+
CREATE TABLE photometry.systems (
13+
id Text PRIMARY KEY
14+
, description Text NOT NULL
15+
, bibcode Char(19) UNIQUE
16+
, svo_id Text UNIQUE
17+
) ;
18+
19+
SELECT meta.setparams('photometry', 'systems', '{"description": "Photometric systems"}');
20+
SELECT meta.setparams('photometry', 'systems', 'id', 'description', 'Photometric system ID');
21+
SELECT meta.setparams('photometry', 'systems', 'description', 'description', 'Description of the photometric system');
22+
SELECT meta.setparams('photometry', 'systems', 'bibcode', 'description', 'ADS bibcode');
23+
SELECT meta.setparams('photometry', 'systems', 'bibcode', 'url', 'https://ui.adsabs.harvard.edu/abs/');
24+
SELECT meta.setparams('photometry', 'systems', 'bibcode', 'ucd', 'meta.ref.url');
25+
SELECT meta.setparams('photometry', 'systems', 'svo_id', 'description', 'Query to the Spanish Virtual Observatory');
26+
SELECT meta.setparams('photometry', 'systems', 'svo_id', 'url', 'http://svo2.cab.inta-csic.es/theory/fps/index.php?');
27+
SELECT meta.setparams('photometry', 'systems', 'svo_id', 'ucd', 'meta.ref.url');
28+
29+
INSERT INTO photometry.systems VALUES
30+
( 'UBVRIJHKL' , 'Johnson UBVRIJHKL photometric system' , '1965CoLPL...3...73J', 'gname=Generic&gname2=Johnson_UBVRIJHKL' )
31+
, ( 'Cousins' , 'Cousins (Rc,Ic) photometric system' , '1976MmRAS..81...25C', 'gname=Generic&gname2=Cousins' )
32+
, ( 'Bessell' , 'Bessell photometric system' , '1990PASP..102.1181B', 'gname=Generic&gname2=Bessell' )
33+
34+
, ( 'Gaia3' , 'Gaia mission, eDR3 release photometric system' , NULL, 'gname=GAIA&gname2=GAIA3' )
35+
36+
, ( 'ACS_WFC' , 'Hubble Space Telescope (HST), Advanced Camera for Surveys (ACS), Wide Field Channel photometric system' , NULL, 'gname=HST&gname2=ACS_WFC' )
37+
, ( 'WFPC2_WF' , 'Hubble Space Telescope (HST), Wide-Field Planetary Camera 2 (WFPC2), Wide Field photometric system' , NULL, 'gname=HST&gname2=WFPC2_WF' )
38+
, ( 'WFPC3_IR' , 'Hubble Space Telescope (HST), Wide-Field Planetary Camera 3 (WFPC3), IR channel photometric system' , NULL, 'gname=HST&gname2=WFC3_IR' )
39+
40+
, ( 'NIRCam' , 'James Webb Space Telescope (JWST), Near Infrared Camera (NIRCam) photometric system' , NULL, 'gname=JWST&gname2=NIRCam' )
41+
, ( 'MegaCam', 'Canada-France-Hawaii Telescope (CFHT), MegaCam photometric system', NULL, 'gname=CFHT&gname2=MegaCam' )
42+
, ( 'WIRCam', 'Canada-France-Hawaii Telescope (CFHT), Wide-field InfraRed Camera (WIRCam) photometric system', NULL, 'gname=CFHT&gname2=Wircam' )
43+
44+
, ( 'SDSS' , 'Sloan Digital Sky Survey photometric system' , '1998AJ....116.3040G', 'gname=SLOAN&gname2=SDSS' )
45+
, ( 'PS1' , 'Panoramic Survey Telescope and Rapid Response System (Pan-STARRS), PS1 photometric system' , '2012ApJ...750...99T', 'gname=PAN-STARRS' )
46+
, ( 'DECam' , 'Dark Energy Camera (DECam) photometric system (at the prime focus of the Blanco 4-m telescope)' , '2015AJ....150..150F', 'gname=CTIO&gname2=DECam' )
47+
, ( 'HSC' , 'Hyper Suprime-Cam (HSC) photometric system (at the prime focus of Subaru Telescope)' , NULL, 'gname=Subaru&gname2=HSC' )
48+
, ( '2MASS' , 'Two Micron All Sky Survey (2MASS) photometric system' , '2003AJ....126.1090C', 'gname=2MASS' )
49+
, ( 'DENIS' , 'Deep Near Infrared Survey of the Southern Sky (DENIS) photometric system' , '1994Ap&SS.217....3E', 'gname=DENIS' )
50+
, ( 'UKIDSS' , 'United Kingdom Infrared Telescope (UKIRT), Infrared Deep Sky Survey (UKIDSS) ZYJHK photometric system' , NULL, 'gname=UKIRT&gname2=UKIDSS' )
51+
52+
, ( 'GALEX' , 'Galaxy Evolution Explorer (GALEX) photometric system' , '2007ApJS..173..185G', 'gname=GALEX' )
53+
, ( 'IRAS' , 'Infrared Astronomical Satellite (IRAS) photometric system' , '1984ApJ...278L...1N', 'gname=IRAS' )
54+
, ( 'WISE' , 'Wide-field Infrared Survey Explorer (WISE) photometric system' , '2010AJ....140.1868W', 'gname=WISE' )
55+
, ( 'Swift', 'Swift Gamma-Ray Burst Mission photometric system', NULL, 'gname=Swift' )
56+
, ( 'IRAC' , 'Spitzer Space Telescope, the InfraRed Array Camera (IRAC) photometric system', '2004ApJS..154...10F', 'gname=Spitzer&gname2=IRAC' )
57+
58+
, ( 'Holmberg' , 'Holmberg m_pg, m_pv photographic magnitudes' , NULL, NULL )
59+
, ( 'GSC2' , 'Second-Generation Guide Star Catalog, Palomar (north) Bj, Rf, In photographic passbands', '2008AJ....136..735L' , 'gname=Palomar&gname2=GSC2' )
60+
;
61+
62+
CREATE TABLE photometry.bands (
63+
id text PRIMARY KEY
64+
, name text NOT NULL
65+
, photsys text NOT NULL REFERENCES photometry.systems (id) ON DELETE restrict ON UPDATE cascade
66+
, waveref real NOT NULL
67+
, fwhm real NOT NULL
68+
, extinction real
69+
, svo_id text UNIQUE
70+
) ;
71+
CREATE INDEX ON photometry.bands (waveref) ;
72+
CREATE INDEX ON photometry.bands (name) ;
73+
CREATE INDEX ON photometry.bands (photsys) ;
74+
75+
SELECT meta.setparams('photometry', 'bands', '{"description": "List of filters"}');
76+
SELECT meta.setparams('photometry', 'bands', 'id', 'description', 'Filter ID');
77+
SELECT meta.setparams('photometry', 'bands', 'name', 'description', 'Common filter designation');
78+
SELECT meta.setparams('photometry', 'bands', 'photsys', 'description', 'Photometric system');
79+
SELECT meta.setparams('photometry', 'bands', 'waveref', 'description', 'Reference wavelength of the filter transmission');
80+
SELECT meta.setparams('photometry', 'bands', 'fwhm', 'description', 'Full width at half maximum of the filter transmission');
81+
SELECT meta.setparams('photometry', 'bands', 'extinction', 'description', 'Relative extinction: ratio between extinction at λref (Af) and visual extinction (Av)');
82+
SELECT meta.setparams('photometry', 'bands', 'svo_id', 'description', 'The Spanish Virtual Observatory filter ID');
83+
SELECT meta.setparams('photometry', 'bands', 'svo_id', 'url', 'http://svo2.cab.inta-csic.es/theory/fps/index.php?id=');
84+
SELECT meta.setparams('photometry', 'bands', 'svo_id', 'ucd', 'meta.ref.url');
85+
86+
COPY photometry.bands (id,name,photsys,waveref,fwhm,extinction,svo_id) FROM STDIN;
87+
FUV FUV GALEX 1535.08 233.93 2.62759 GALEX/GALEX.FUV
88+
NUV NUV GALEX 2300.78 795.19 2.85878 GALEX/GALEX.NUV
89+
UVW2 UVW2 Swift 2054.61 584.89 2.99964 Swift/UVOT.UVW2
90+
UVM2 UVM2 Swift 2246.43 527.13 3.01684 Swift/UVOT.UVM2
91+
UVW1 UVW1 Swift 2580.74 656.60 2.18468 Swift/UVOT.UVW1
92+
U_Swift U Swift 3467.05 778.49 1.63943 Swift/UVOT.U
93+
B_Swift B Swift 4349.56 978.33 1.31480 Swift/UVOT.B
94+
V_Swift V Swift 5425.33 744.99 1.02056 Swift/UVOT.V
95+
U U UBVRIJHKL 3511.89 683.73 1.61966 Generic/Johnson_UBVRIJHKL.U
96+
B B UBVRIJHKL 4382.77 1011.11 1.30391 Generic/Johnson_UBVRIJHKL.B
97+
V V UBVRIJHKL 5501.40 876.67 1.00171 Generic/Johnson_UBVRIJHKL.V
98+
R R UBVRIJHKL 6819.05 2093.33 0.76112 Generic/Johnson_UBVRIJHKL.R
99+
I I UBVRIJHKL 8657.44 2205.45 0.53488 Generic/Johnson_UBVRIJHKL.I
100+
J J UBVRIJHKL 12317.30 3193.55 0.30707 Generic/Johnson_UBVRIJHKL.J
101+
H H UBVRIJHKL 16396.38 2983.81 0.19401 Generic/Johnson_UBVRIJHKL.H
102+
K K UBVRIJHKL 21735.85 5926.09 0.12389 Generic/Johnson_UBVRIJHKL.K
103+
Rc R Cousins 6414.42 1516.49 0.83459 Generic/Cousins.R
104+
Ic I Cousins 7858.32 1093.68 0.62548 Generic/Cousins.I
105+
U_Bessell U Bessell 3584.78 652.84 1.58844 Generic/Bessell.U
106+
B_Bessell B Bessell 4371.07 947.62 1.30775 Generic/Bessell.B
107+
V_Bessell V Bessell 5477.70 852.44 1.00755 Generic/Bessell.V
108+
R_Bessell R Bessell 6498.09 1567.06 0.81934 Generic/Bessell.R
109+
I_Bessell I Bessell 8020.14 1543.11 0.60552 Generic/Bessell.I
110+
u_SDSS u SDSS 3556.52 565.80 1.60055 SLOAN/SDSS.u
111+
g_SDSS g SDSS 4702.50 1175.63 1.21355 SLOAN/SDSS.g
112+
r_SDSS r SDSS 6175.58 1130.56 0.87774 SLOAN/SDSS.r
113+
i_SDSS i SDSS 7489.98 1253.30 0.66911 SLOAN/SDSS.i
114+
z_SDSS z SDSS 8946.71 998.50 0.51176 SLOAN/SDSS.z
115+
g_PS1 g PS1 4849.11 1148.66 1.17468 PAN-STARRS/PS1.g
116+
r_PS1 r PS1 6201.20 1397.73 0.87305 PAN-STARRS/PS1.r
117+
i_PS1 i PS1 7534.96 1292.39 0.66384 PAN-STARRS/PS1.i
118+
z_PS1 z PS1 8674.20 1038.82 0.53346 PAN-STARRS/PS1.z
119+
y_PS1 y PS1 9627.79 665.08 0.45589 PAN-STARRS/PS1.y
120+
I_DENIS I DENIS 7897.13 1311.11 0.62077 DENIS/DENIS.I
121+
J_DENIS J DENIS 12295.06 1991.11 0.30803 DENIS/DENIS.J
122+
Ks_DENIS Ks DENIS 21561.52 3301.94 0.12529 DENIS/DENIS.Ks
123+
J_2MASS I 2MASS 12350.00 1830.20 0.30566 2MASS/2MASS.J
124+
H_2MASS J 2MASS 16620.00 2580.01 0.18873 2MASS/2MASS.H
125+
Ks_2MASS Ks 2MASS 21590.00 2771.26 0.12505 2MASS/2MASS.Ks
126+
W1 W1 WISE 33526.00 6357.93 0.07166 WISE/WISE.W1
127+
W2 W2 WISE 46028.00 11073.19 0.05049 WISE/WISE.W2
128+
W3 W3 WISE 115608.00 62758.04 0.04304 WISE/WISE.W3
129+
W4 W4 WISE 220883.00 47397.34 0.01960 WISE/WISE.W4
130+
12mu 12mu IRAS 110356.60 69306.43 0.05161 IRAS/IRAS.12mu
131+
25mu 25mu IRAS 230702.01 112542.87 0.01779 IRAS/IRAS.25mu
132+
60mu 60mu IRAS 581903.91 327605.04 0.00288 IRAS/IRAS.60mu
133+
100mu 100mu IRAS 995377.63 322249.87 0.00102 IRAS/IRAS.100mu
134+
F435W_ACS F435W ACS_WFC 4329.85 900.04 1.32127 HST/ACS_WFC.F435W
135+
F475W_ACS F475W ACS_WFC 4746.94 1398.86 1.20185 HST/ACS_WFC.F475W
136+
F555W_ACS F555W ACS_WFC 5361.03 1236.10 1.03724 HST/ACS_WFC.F555W
137+
F606W_ACS F606W ACS_WFC 5921.88 2253.40 0.92404 HST/ACS_WFC.F606W
138+
F625W_ACS F625W ACS_WFC 6311.85 1389.28 0.85309 HST/ACS_WFC.F625W
139+
F775W_ACS F775W ACS_WFC 7693.47 1517.31 0.64523 HST/ACS_WFC.F775W
140+
F814W_ACS F814W ACS_WFC 8045.53 2098.15 0.60232 HST/ACS_WFC.F814W
141+
F850LP_ACS F850LP ACS_WFC 9031.48 1273.50 0.50504 HST/ACS_WFC.F850LP
142+
F300W_WFPC2 F300W WFPC2_WF 2984.47 914.56 1.82725 HST/WFPC2_WF.F300W
143+
F336W_WFPC2 F336W WFPC2_WF 3344.09 486.34 1.69425 HST/WFPC2_WF.F336W
144+
F439W_WFPC2 F439W WFPC2_WF 4311.49 714.01 1.32729 HST/WFPC2_WF.F439W
145+
F450W_WFPC2 F450W WFPC2_WF 4556.22 810.07 1.25247 HST/WFPC2_WF.F450W
146+
F467M_WFPC2 F467M WFPC2_WF 4669.94 214.29 1.22208 HST/WFPC2_WF.F467M
147+
F555W_WFPC2 F555W WFPC2_WF 5442.21 1473.75 1.01636 HST/WFPC2_WF.F555W
148+
F606W_WFPC2 F606W WFPC2_WF 6001.01 2049.98 0.90978 HST/WFPC2_WF.F606W
149+
F675W_WFPC2 F675W WFPC2_WF 6718.09 1259.41 0.77885 HST/WFPC2_WF.F675W
150+
F702W_WFPC2 F702W WFPC2_WF 6918.77 2108.11 0.74476 HST/WFPC2_WF.F702W
151+
F814W_WFPC2 F814W WFPC2_WF 8001.59 1676.13 0.60786 HST/WFPC2_WF.F814W
152+
F090W F090W NIRCam 9021.53 2088.06 0.50583 JWST/NIRCam.F090W
153+
F115W F115W NIRCam 11542.61 2644.25 0.33959 JWST/NIRCam.F115W
154+
F150W F150W NIRCam 15007.44 3349.30 0.22892 JWST/NIRCam.F150W
155+
F200W F200W NIRCam 19886.48 4689.40 0.14166 JWST/NIRCam.F200W
156+
F277W F277W NIRCam 27617.40 7064.64 0.09023 JWST/NIRCam.F277W
157+
F356W F356W NIRCam 35683.62 8326.81 0.06685 JWST/NIRCam.F356W
158+
F444W F444W NIRCam 44043.15 11144.05 0.05304 JWST/NIRCam.F444W
159+
u_MegaCam u MegaCam 3676.12 456.42 1.55256 CFHT/MegaCam.u
160+
g_MegaCam g MegaCam 4763.98 1532.24 1.19736 CFHT/MegaCam.g
161+
r_MegaCam r MegaCam 6382.59 1477.66 0.84035 CFHT/MegaCam.r
162+
i_MegaCam i MegaCam 7682.93 1538.12 0.64647 CFHT/MegaCam.i
163+
z_MegaCam z MegaCam 8979.62 774.01 0.50916 CFHT/MegaCam.z
164+
Y_WIRCam Y WIRCam 10241.51 1105.33 0.41289 CFHT/WIRCam.Y
165+
J_WIRCam J WIRCam 12518.72 1587.53 0.29837 CFHT/WIRCam.J
166+
W_WIRCam W WIRCam 14524.26 884.59 0.24090 CFHT/WIRCam.W
167+
H_WIRCam H WIRCam 16243.54 2911.26 0.19786 CFHT/WIRCam.H
168+
Ks_WIRCam Ks WIRCam 21434.00 3270.46 0.12636 CFHT/WIRCam.Ks
169+
u_DECam u DECam 3814.33 245.32 1.50330 CTIO/DECam.u
170+
g_DECam g DECam 4808.49 1110.21 1.18559 CTIO/DECam.g
171+
r_DECam r DECam 6417.65 1477.92 0.83400 CTIO/DECam.r
172+
i_DECam i DECam 7814.58 1468.81 0.63078 CTIO/DECam.i
173+
z_DECam z DECam 9168.85 1476.78 0.49398 CTIO/DECam.z
174+
Y_DECam Y DECam 9896.11 676.44 0.43505 CTIO/DECam.Y
175+
Z_UKIDSS Z UKIDSS 8817.00 917.02 0.52194 UKIRT/UKIDSS.Z
176+
Y_UKIDSS Y UKIDSS 10305.00 1026.81 0.40917 UKIRT/UKIDSS.Y
177+
J_UKIDSS J UKIDSS 12483.00 1581.88 0.29990 UKIRT/UKIDSS.J
178+
H_UKIDSS H UKIDSS 16313.00 2952.17 0.19609 UKIRT/UKIDSS.H
179+
K_UKIDSS K UKIDSS 22010.00 3511.37 0.12187 UKIRT/UKIDSS.K
180+
I1 I1 IRAC 35378.41 7431.71 0.06748 Spitzer/IRAC.I1
181+
I2 I2 IRAC 44780.49 10096.82 0.05205 Spitzer/IRAC.I2
182+
I3 I3 IRAC 56961.78 13911.89 0.03959 Spitzer/IRAC.I3
183+
I4 I4 IRAC 77978.40 28311.77 0.03466 Spitzer/IRAC.I4
184+
pg pg Holmberg 4300 1300 1.33105 \N
185+
pv pv Holmberg 5500 1000 1.00201 \N
186+
Bj Bj GSC2 3384.97 1059.59 1.67600 Palomar/GSC2.Bj
187+
Rf Rf GSC2 4992.74 647.10 1.13599 Palomar/GSC2.Rf
188+
In In GSC2 6793.20 2132.52 0.76550 Palomar/GSC2.In
189+
\.

0 commit comments

Comments
 (0)