| 1 |
<resource schema="ivoa" resdir="__system"> |
| 2 |
<meta name="creationDate">2021-11-11T13:00:00</meta> |
| 3 |
<meta name="title">\getConfig{web}{siteName} obs_radio Table</meta> |
| 4 |
<meta name="subject">observational-astronomy</meta> |
| 5 |
<meta name="subject">interferometry</meta> |
| 6 |
<meta name="description">Radio-specific metadata for suitable data |
| 7 |
products from \getConfig{web}{siteName}'s obscore table. |
| 8 |
</meta> |
| 9 |
|
| 10 |
<!-- The following column definitions are created by machine from the |
| 11 |
definitions in |
| 12 |
[email protected]:ivoa-std/ObsCoreExtensionForRadioData.git |
| 13 |
As of December 2023, there's clearly quite some work to do to improve the |
| 14 |
column metadata; but that should be done in the spec, where I have |
| 15 |
manually purged some particularly broken columns. |
| 16 |
|
| 17 |
I've quickly hacked this program to do that: |
| 18 |
|
| 19 |
import re |
| 20 |
|
| 21 |
with open("ObsCoreExtensionForRadioData.tex") as f: |
| 22 |
src = f.read() |
| 23 |
|
| 24 |
tabsrc = re.search(r"(?s)\\begin{longtable}(.*)\\end{longtable}", src |
| 25 |
).group(1) |
| 26 |
for mat in re.finditer(r"\\texttt.*\\cr", tabsrc): |
| 27 |
name, definition, utype, ucd, unit = re.sub( |
| 28 |
r"\\[a-z]+|[{}]", "", mat.group(0) |
| 29 |
).replace(r"\_", "_").split("&")[:5] |
| 30 |
|
| 31 |
utype = utype.replace(" ", "") |
| 32 |
definition = definition[0].upper()+definition[1:] |
| 33 |
|
| 34 |
print(f'<column name="{name}"\n' |
| 35 |
f'\tunit="{unit}" ucd="{ucd}"\n' |
| 36 |
f'\tutype="{utype}"\n' |
| 37 |
f'\tdescription="{definition}">\n' |
| 38 |
'\t<property name="std">1</property>\n' |
| 39 |
'</column>') |
| 40 |
--> |
| 41 |
|
| 42 |
<STREAM id="obs-radio-columns"> |
| 43 |
<doc> |
| 44 |
The columns of the ObsCore radio extension. You may want |
| 45 |
to replay this into a table intended to mix in //obs-radio#publish |
| 46 |
-- but there is nothing wrong with not doing so. |
| 47 |
</doc> |
| 48 |
|
| 49 |
<!-- that's our foreign key --> |
| 50 |
<column original="//obscore#ObsCore.obs_publisher_did"/> |
| 51 |
|
| 52 |
<column name="s_resolution_min" |
| 53 |
unit="arcsec" ucd="pos.angResolution;stat.min" |
| 54 |
utype="Char.SpatialAxis.Resolution.Bounds.Limits.LoLim" |
| 55 |
description="Angular resolution, longest baseline and max frequency dependent"> |
| 56 |
<property name="std">1</property> |
| 57 |
</column> |
| 58 |
<column name="s_resolution_max" |
| 59 |
unit="arcsec" ucd="pos.angResolution;stat.max" |
| 60 |
utype="Char.SpatialAxis.Resolution.Bounds.Limits.HiLim" |
| 61 |
description="Angular resolution, longest baseline and min frequency dependent"> |
| 62 |
<property name="std">1</property> |
| 63 |
</column> |
| 64 |
<column name="s_fov_min" |
| 65 |
unit="deg" ucd="phys.angSize;instr.fov;stat.min" |
| 66 |
utype="Char.SpatialAxis.Coverage.Bounds.Extent.LowLim" |
| 67 |
description="Field of view diameter, min value, max frequency dependent"> |
| 68 |
<property name="std">1</property> |
| 69 |
</column> |
| 70 |
<column name="s_fov_max" |
| 71 |
unit="deg" ucd="phys.angSize;instr.fov;stat.max" |
| 72 |
utype="Char.SpatialAxis.Coverage.Bounds.Extent.HiLim" |
| 73 |
description="Field of view diameter, max value, min frequency dependent"> |
| 74 |
<property name="std">1</property> |
| 75 |
</column> |
| 76 |
<column name="s_maximum_angular_scale" |
| 77 |
unit="arcsec" ucd="phys.angSize;stat.max" |
| 78 |
utype="Char.SpatialAxis.Resolution.Scale.Limits.HiLim" |
| 79 |
description="Maximum scale in dataset, shortest baseline and frequency dependent"> |
| 80 |
<property name="std">1</property> |
| 81 |
</column> |
| 82 |
<column name="f_resolution" |
| 83 |
unit="kHz" ucd="em.freq;stat.max" |
| 84 |
utype="Char.SpectralAxis.Coverage.BoundsLimits.HiLim" |
| 85 |
description="Absolute spectral resolution in frequency"> |
| 86 |
<property name="std">1</property> |
| 87 |
</column> |
| 88 |
<column name="t_exp_min" |
| 89 |
unit="s" ucd="time.duration;obs.exposure;stat.min" |
| 90 |
utype="Char.TimeAxis.Sampling.ExtentLoLim" |
| 91 |
description="Minimum integration time per sample"> |
| 92 |
<property name="std">1</property> |
| 93 |
</column> |
| 94 |
<column name="t_exp_max" |
| 95 |
unit="s" ucd="time.duration;obs.exposure;stat.max" |
| 96 |
utype="Char.TimeAxis.Sampling.ExtentHiLim" |
| 97 |
description="Maximum integration time per sample"> |
| 98 |
<property name="std">1</property> |
| 99 |
</column> |
| 100 |
<column name="t_exp_mean" |
| 101 |
unit="s" ucd="time.duration;obs.exposure;stat.mean" |
| 102 |
utype="Char.TimeAxis.Sampling.ExtentHiLim" |
| 103 |
description="Average integration time per sample"> |
| 104 |
<property name="std">1</property> |
| 105 |
</column> |
| 106 |
<column name="uv_distance_min" |
| 107 |
unit="m" ucd="stat.fourier;pos;stat.min" |
| 108 |
utype="Char.UVAxis.Coverage.Bounds.Limits.LoLim" |
| 109 |
description="Minimal distance in uv plane"> |
| 110 |
<property name="std">1</property> |
| 111 |
</column> |
| 112 |
<column name="uv_distance_max" |
| 113 |
unit="m" ucd="stat.fourier;pos;stat.max" |
| 114 |
utype="Char.UVAxis.Coverage.Bounds.Limits.LoLim" |
| 115 |
description="Maximal distance in uv plane"> |
| 116 |
<property name="std">1</property> |
| 117 |
</column> |
| 118 |
<column name="uv_distribution_ecc" |
| 119 |
unit="" ucd="stat.fourier;pos" |
| 120 |
utype="Char.UVAxis.Coverage.Bounds.Eccentricity" |
| 121 |
description="Eccentricity of uv distribution"> |
| 122 |
<property name="std">1</property> |
| 123 |
</column> |
| 124 |
<column name="uv_distribution_fill" |
| 125 |
unit="" ucd="stat.fourier;pos;arith.ratio" |
| 126 |
utype="Char.UVAxis.Coverage.Bounds.FillingFactor" |
| 127 |
description="Filling factor of uv distribution"> |
| 128 |
<property name="std">1</property> |
| 129 |
</column> |
| 130 |
<column name="instrument_ant_number" |
| 131 |
unit="" ucd="meta.number;instr.param" |
| 132 |
utype="Provenance.ObsConfig.Instrument.Array.AntNumber" |
| 133 |
description="Number of antennas in array"> |
| 134 |
<property name="std">1</property> |
| 135 |
</column> |
| 136 |
<column name="instrument_ant_min_dist" |
| 137 |
unit="m" ucd="instr.baseline;stat.min" |
| 138 |
utype="Provenance.ObsConfig.Instrument.Array.MinDist" |
| 139 |
description="Minimum distance between antennas in array"> |
| 140 |
<property name="std">1</property> |
| 141 |
</column> |
| 142 |
<column name="instrument_ant_max_dist" |
| 143 |
unit="m" ucd="instr.baseline;stat.max" |
| 144 |
utype="Provenance.ObsConfig.Instrument.Array.MaxDist" |
| 145 |
description="Maximum distance between antennas in array"> |
| 146 |
<property name="std">1</property> |
| 147 |
</column> |
| 148 |
<column name="instrument_ant_diameter" |
| 149 |
unit="m" ucd="instr.param" |
| 150 |
utype="Provenance.ObsConfig.Instrument.Array.Diameter" |
| 151 |
description="Diameter of telecope or antennas in array"> |
| 152 |
<property name="std">1</property> |
| 153 |
</column> |
| 154 |
<column name="instrument_feed" |
| 155 |
unit="" ucd="instr.param" |
| 156 |
utype="Provenance.ObsConfig.Instrument.Feed" |
| 157 |
description="Number of feeds"> |
| 158 |
<property name="std">1</property> |
| 159 |
</column> |
| 160 |
<column name="scan_mode" |
| 161 |
unit="" ucd="instr.param" |
| 162 |
utype="Provenance.Observation.sky_scan_mode" |
| 163 |
description="Scan mode (on-off, raster map, on-the-fly map,...) "> |
| 164 |
<property name="std">1</property> |
| 165 |
</column> |
| 166 |
<column name="tracking_mode" |
| 167 |
unit="" ucd="instr.param" |
| 168 |
utype="Provenance.Observation.tracking_mode" |
| 169 |
description="Targeted, alt-azimuth, wobble, ...) "> |
| 170 |
<property name="std">1</property> |
| 171 |
</column> |
| 172 |
</STREAM> |
| 173 |
|
| 174 |
<!-- TODO: from here on, there's terribly much duplication |
| 175 |
with //obscore. At the latest when we have a second obscore |
| 176 |
extension, we will have to refactor this. --> |
| 177 |
|
| 178 |
<table id="obs_radio" adql="True" onDisk="True" system="True"> |
| 179 |
<meta name="utype">ivo://ivoa.net/std/obsradio#table-1.0</meta> |
| 180 |
|
| 181 |
<property key="forceStats">True</property> |
| 182 |
|
| 183 |
<primary>obs_publisher_did</primary> |
| 184 |
<foreignKey inTable="//obscore#ObsCore" |
| 185 |
source="obs_publisher_did"/> |
| 186 |
|
| 187 |
<meta name="description">An IVOA-defined metadata table for |
| 188 |
radio measurements, with extra metadata for interferometric measurements |
| 189 |
("visibilities") as well as single-dish observations. You |
| 190 |
will almost always want to join this table to ivoa.obscore |
| 191 |
(do a natural join).</meta> |
| 192 |
|
| 193 |
<FEED source="%#obs-radio-registration"/> |
| 194 |
<FEED source="obs-radio-columns"/> |
| 195 |
|
| 196 |
<!-- bogus view creation statetment; the view is actually created |
| 197 |
from the _obs_radio_sources table. It's here only so there is something |
| 198 |
when initially importing things.--> |
| 199 |
|
| 200 |
<viewStatement>create view \qName (missing) AS (SELECT 0)</viewStatement> |
| 201 |
</table> |
| 202 |
|
| 203 |
<data id="create" updating="True" auto="False"> |
| 204 |
<!-- the view is created from prescriptions in _obs_radio_sources --> |
| 205 |
<make table="obs_radio"> |
| 206 |
<script type="postCreation" lang="python" id="create-obs-radio-view"> |
| 207 |
try: |
| 208 |
from gavo import rsc |
| 209 |
ocTable = rsc.TableForDef( |
| 210 |
base.resolveCrossId("//obs-radio#_obs_radio_sources"), |
| 211 |
connection=table.connection) |
| 212 |
parts = ["(%s)"%row["sql_fragment"] |
| 213 |
for row in ocTable.iterQuery(ocTable.tableDef, "")] |
| 214 |
if parts: |
| 215 |
table.connection.execute( |
| 216 |
"DROP VIEW IF EXISTS ivoa.obs_radio") |
| 217 |
table.connection.execute( |
| 218 |
"CREATE VIEW ivoa.obs_radio AS (%s)"%( |
| 219 |
" UNION ALL ".join(parts))) |
| 220 |
rsc.TableForDef( |
| 221 |
base.resolveCrossId("//obs-radio#obs_radio"), |
| 222 |
connection=table.connection).updateMeta() |
| 223 |
except: |
| 224 |
base.ui.notifyError( |
| 225 |
"-------- Try dachs imp //obs-radio recover to fix this -------") |
| 226 |
raise |
| 227 |
</script> |
| 228 |
</make> |
| 229 |
</data> |
| 230 |
|
| 231 |
<table id="_obs_radio_sources" onDisk="True" |
| 232 |
dupePolicy="overwrite" primary="table_name" system="True"> |
| 233 |
<meta name="description"> |
| 234 |
This table contains the SQL fragments that make up this site's |
| 235 |
ivoa.obs_radio view. |
| 236 |
|
| 237 |
Manipulate this table through gavo imp on tables that have an obs_radio |
| 238 |
mixin, or by dropping RDs or purging tables that are part of obscore. |
| 239 |
</meta> |
| 240 |
|
| 241 |
<column name="table_name" type="text" |
| 242 |
description="Name of the table that generated this fragment (usually |
| 243 |
through a mixin)"/> |
| 244 |
<column name="sql_fragment" type="text" |
| 245 |
description="The SQL fragment contributed from table_name"/> |
| 246 |
<column name="sourcerd" type="text" |
| 247 |
description="The RD the table was found in at input (this is |
| 248 |
mainly to support dachs drop -f)"/> |
| 249 |
</table> |
| 250 |
|
| 251 |
<data id="init"> |
| 252 |
<make table="_obs_radio_sources"/> |
| 253 |
</data> |
| 254 |
|
| 255 |
<data id="recover" updating="True" recreateAfter="create" auto="False"> |
| 256 |
<!-- removes "bad" entries from obs_radio_sources --> |
| 257 |
<sources items="cleanup"/> |
| 258 |
<nullGrammar/> |
| 259 |
<make table="_obs_radio_sources"> |
| 260 |
<script name="Clean bad entries from obs-radio sources" |
| 261 |
type="newSource" lang="python"> |
| 262 |
q = base.UnmanagedQuerier(table.connection) |
| 263 |
|
| 264 |
# first, remove all tables that don't exist any more |
| 265 |
for tn, in q.connection.query( |
| 266 |
"select table_name from ivoa._obs_radio_sources"): |
| 267 |
if not q.getTableType(tn): |
| 268 |
q.connection.execute("delete from ivoa._obs_radio_sources where" |
| 269 |
" table_name=%(tn)s", locals()) |
| 270 |
|
| 271 |
# then, remove tables with bad view contributions |
| 272 |
for tn, statement in q.connection.query( |
| 273 |
"select table_name, sql_fragment from ivoa._obs_radio_sources"): |
| 274 |
with base.getUntrustedConn() as subconn: |
| 275 |
try: |
| 276 |
_ = list(subconn.query(statement+" LIMIT 1")) |
| 277 |
except base.DBError: |
| 278 |
q.connection.execute("delete from ivoa._obs_radio_sources where" |
| 279 |
" table_name=%(tn)s", locals()) |
| 280 |
</script> |
| 281 |
</make> |
| 282 |
</data> |
| 283 |
|
| 284 |
<mixinDef id="publish"> |
| 285 |
<doc> |
| 286 |
Mix this into a table that contains radio data to have their |
| 287 |
metadata show up in the obscore extension for radio data. This |
| 288 |
only makes sense together with one of the obscore mixins, as |
| 289 |
the main metadata is kept in the obscore table. |
| 290 |
|
| 291 |
Use the mixin parameters to map whatever is in your table to obs_radio' |
| 292 |
columns. As with obscore, parameter values must be SQL expressions |
| 293 |
evaluatable within the table mixed in. The default is to have |
| 294 |
all extension columns NULL. |
| 295 |
</doc> |
| 296 |
<LOOP> |
| 297 |
<codeItems> |
| 298 |
# for now, just create parameters from the extension table's |
| 299 |
# columns; this probably will need work even if their |
| 300 |
# descriptions are fixed. |
| 301 |
for col in context.getById("obs_radio"): |
| 302 |
if col.name!="obs_publisher_did": |
| 303 |
yield {"name": col.name, "description": col.description} |
| 304 |
</codeItems> |
| 305 |
<events> |
| 306 |
<mixinPar name="\name" description="\description">NULL</mixinPar> |
| 307 |
</events> |
| 308 |
</LOOP> |
| 309 |
<mixinPar name="obs_publisher_did" |
| 310 |
description="The primary key of the dataset in ivoa.obscore. |
| 311 |
You almost certainly do not want to touch this" |
| 312 |
>obs_publisher_did</mixinPar> |
| 313 |
|
| 314 |
<events> |
| 315 |
<LOOP> |
| 316 |
<codeItems> |
| 317 |
items = [] |
| 318 |
for col in context.getById("obs_radio"): |
| 319 |
items.append(r"CAST(\{name} AS {type}) AS {name}".format( |
| 320 |
**col.asInfoDict())) |
| 321 |
yield {"clause": ",\n".join(items)} |
| 322 |
</codeItems> |
| 323 |
<events> |
| 324 |
<property name="obs-radio-clause">\clause</property> |
| 325 |
</events> |
| 326 |
</LOOP> |
| 327 |
|
| 328 |
<script id="add-table-to-obs-radio-sources" |
| 329 |
lang="python" type="afterMeta"> |
| 330 |
obsradioClause = table.tableDef.expand( |
| 331 |
table.tableDef.getProperty("obs-radio-clause")) |
| 332 |
from gavo import rsc |
| 333 |
ots = rsc.TableForDef( |
| 334 |
base.resolveCrossId("//obs-radio#_obs_radio_sources"), |
| 335 |
connection=table.connection) |
| 336 |
ots.addRow({"table_name": table.tableDef.getQName(), |
| 337 |
"sourcerd": table.tableDef.rd.sourceId, |
| 338 |
"sql_fragment": "SELECT %s FROM %s"%( |
| 339 |
obsradioClause, table.tableDef.getQName())}) |
| 340 |
</script> |
| 341 |
|
| 342 |
<script original="//obs-radio#create-obs-radio-view" |
| 343 |
name="create obs_radio view"/> |
| 344 |
|
| 345 |
<script id="remove-table-from-obs-radio-sources" |
| 346 |
lang="python" |
| 347 |
type="beforeDrop"> |
| 348 |
from gavo import rsc |
| 349 |
if table.getTableType("ivoa._obs_radio_sources"): |
| 350 |
table.connection.execute( |
| 351 |
"DELETE FROM ivoa._obs_radio_sources WHERE table_name=%(name)s", |
| 352 |
{"name": table.tableDef.getQName()}) |
| 353 |
# importing this table may take a long time, and we don't want |
| 354 |
# to have obscore offline for so long; so, we immediately recreate |
| 355 |
# it. |
| 356 |
rsc.makeData(base.resolveCrossId("//obs-radio#create"), |
| 357 |
connection=table.connection) |
| 358 |
table.connection.commit() |
| 359 |
</script> |
| 360 |
|
| 361 |
</events> |
| 362 |
</mixinDef> |
| 363 |
|
| 364 |
<!-- we probably should do an extra coverage computation of radio only --> |
| 365 |
<coverage fallbackTo="__system__/obscore"/> |
| 366 |
|
| 367 |
</resource> |