Skip to content

Commit 6560122

Browse files
committed
Linewidth schema
1 parent 16ead3d commit 6560122

1 file changed

Lines changed: 51 additions & 0 deletions

File tree

postgres/drafts/12_hi_schemas.sql

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ COMMENT ON SCHEMA lineflux IS 'Catalog of the spectral line fluxes';
99
CREATE TYPE lineflux.HIMethodType AS ENUM ( 'sum', 'fit' ) ;
1010
COMMENT ON TYPE lineflux.HIMethodType IS '{"sum":"Integrated HI line flux by summing all velocity channels", "fit":"Integrated HI line flux by model line fitting"}' ;
1111

12+
1213
CREATE TABLE lineflux.hi (
1314
record_id Text NOT NULL REFERENCES layer0.records(id) ON UPDATE cascade ON DELETE restrict
1415
, flux real NOT NULL
@@ -26,13 +27,32 @@ COMMENT ON COLUMN lineflux.hi.e_flux IS '{"description":"Error of the integrated
2627
COMMENT ON COLUMN lineflux.hi.method IS 'Measurement type (sum, fit)' ;
2728

2829

30+
CREATE OR REPLACE VIEW lineflux.hiview AS
31+
SELECT
32+
d.flux
33+
, d.e_flux
34+
, d.method
35+
, r.*
36+
FROM
37+
lineflux.hi AS d
38+
LEFT JOIN layer0.recordview AS r USING (record_id)
39+
;
40+
41+
COMMENT ON TABLE lineflux.hiview IS 'Catalog of the HI line fluxes' ;
42+
COMMENT ON COLUMN lineflux.hiview.record_id IS 'Record ID' ;
43+
COMMENT ON COLUMN lineflux.hiview.flux IS '{"description":"Integrated HI line flux", "unit":"Jy.km/s", "ucd":"phot.flux.density;spect.line"}' ;
44+
COMMENT ON COLUMN lineflux.hiview.e_flux IS '{"description":"Error of the integrated HI line flux", "unit":"Jy.km/s", "ucd":"stat.error"}' ;
45+
COMMENT ON COLUMN lineflux.hiview.method IS 'Measurement type (sum, fit)' ;
46+
47+
2948

3049
----------------------------------------------------
3150
-------------- Line Width schema -------------------
3251
----------------------------------------------------
3352
CREATE SCHEMA IF NOT EXISTS linewidth ;
3453
COMMENT ON SCHEMA linewidth IS 'Catalog of the HI line width' ;
3554

55+
3656
CREATE TYPE linewidth.WidthMethodType AS ENUM ( 'max', 'peak', 'w2p', 'mean', 'int', 'edge', 'model' ) ;
3757
COMMENT ON TYPE linewidth.WidthMethodType IS '{"max":"Maximal-value-based width", "peak":"Every peak-based width", "w2p":"Mean of peaks double-horn specific width", "mean":"Mean-flux–based width", "int":"Integrated-flux–based width", "edge":"Edge-based width", "model":"Model-based width"}' ;
3858

@@ -55,4 +75,35 @@ COMMENT ON COLUMN linewidth.data.method IS 'Measurement type' ;
5575
COMMENT ON COLUMN linewidth.data.level IS 'Measurement level in percent' ;
5676

5777

78+
CREATE TABLE linewidth.dataset (
79+
table_id Integer PRIMARY KEY REFERENCES layer0.tables(id) ON UPDATE cascade ON DELETE restrict
80+
, telescope Text NOT NULL
81+
, resolution real NOT NULL
82+
, correction boolean NOT NULL DEFAULT false
83+
);
84+
85+
COMMENT ON TABLE linewidth.dataset IS 'Description of the data on the HI line width' ;
86+
COMMENT ON COLUMN linewidth.dataset.table_id IS 'Table ID' ;
87+
COMMENT ON COLUMN linewidth.dataset.telescope IS 'Rdio telescope' ; -- It seems we need a special table on telescopes
88+
COMMENT ON COLUMN linewidth.dataset.resolution IS '{"description":"Effective spectral resolution for the HI line width correction", "unit":"km/s", "ucd":"spect.resolution"}' ;
89+
COMMENT ON COLUMN linewidth.dataset.correction IS 'The flag describing if the spectral resolution correction is already applied' ;
90+
91+
92+
93+
CREATE OR REPLACE VIEW linewidth.dataview AS
94+
SELECT
95+
d.width
96+
, d.e_width
97+
, d.method
98+
, d.level
99+
, s.telescope
100+
, s.resolution
101+
, s.correction
102+
, r.*
103+
FROM
104+
linewidth.data AS d
105+
LEFT JOIN layer0.recordview AS r USING (record_id)
106+
LEFT JOIN linewidth.dataset AS s USING (table_id)
107+
;
108+
58109
COMMIT;

0 commit comments

Comments
 (0)