| 1 |
<resource schema="ivoa" resdir="__system"> |
| 2 |
<meta name="creationDate">2011-03-25T10:23:00</meta> |
| 3 |
<meta name="subject">observational-astronomy</meta> |
| 4 |
<meta name="description">Definition and support code for the ObsCore |
| 5 |
data model and table.</meta> |
| 6 |
<meta name="schema-rank">5</meta> |
| 7 |
|
| 8 |
<!-- pull the data product types from the gathered statistics if |
| 9 |
available --> |
| 10 |
<LOOP> |
| 11 |
<codeItems> |
| 12 |
try: |
| 13 |
with base.getTableConn() as conn: |
| 14 |
# don't try this if there is no obscore table |
| 15 |
if not base.UnmanagedQuerier(conn).getTableType("ivoa.obscore"): |
| 16 |
return |
| 17 |
res = conn.query("select vals from dc.discrete_string_values" |
| 18 |
" where tablename='ivoa.ObsCore'" |
| 19 |
" and column_name='dataproduct_type'") |
| 20 |
|
| 21 |
dptypes = next(res)[0] |
| 22 |
def addDptypes(rd, context): |
| 23 |
for dptype in dptypes: |
| 24 |
rd.addMeta("productTypeServed", dptype) |
| 25 |
|
| 26 |
context.addExitFunc(addDptypes) |
| 27 |
except Exception as msg: |
| 28 |
base.ui.notifyInfo("Cannot publish product types served in" |
| 29 |
f" obscore ({msg});" |
| 30 |
" you can probably fix this by running dachs limits //obscore") |
| 31 |
if False: |
| 32 |
yield |
| 33 |
</codeItems> |
| 34 |
<events/> |
| 35 |
</LOOP> |
| 36 |
|
| 37 |
<STREAM id="obscore-columns"> |
| 38 |
<doc> |
| 39 |
The columns of a (standard) obscore table. This can be used |
| 40 |
to define a "native" obscore table (as opposed to the more usual |
| 41 |
mixins below that expose standard products via obscore. |
| 42 |
|
| 43 |
Even if you are sure you want to do this, better ask again... |
| 44 |
</doc> |
| 45 |
|
| 46 |
<index columns="s_ra,s_dec" kind="q3c" metaOnly="True"/> |
| 47 |
<index columns="obs_publisher_did" metaOnly="True"/> |
| 48 |
|
| 49 |
<stc> |
| 50 |
Polygon ICRS [s_region] |
| 51 |
</stc> |
| 52 |
|
| 53 |
<column name="dataproduct_type" type="text" |
| 54 |
utype="obscore:obsdataset.dataproducttype" ucd="meta.code.class" |
| 55 |
tablehead="Product type" |
| 56 |
description="High level scientific classification of the data product, |
| 57 |
taken from an enumeration" |
| 58 |
verbLevel="5"> |
| 59 |
<property name="std">1</property> |
| 60 |
<property name="statistics">enumerate</property> |
| 61 |
</column> |
| 62 |
|
| 63 |
<column name="dataproduct_subtype" type="text" |
| 64 |
utype="obscore:obsdataset.dataproductsubtype" ucd="meta.code.class" |
| 65 |
tablehead="Subtype" |
| 66 |
description="Data product specific type" |
| 67 |
verbLevel="25"/> |
| 68 |
|
| 69 |
<column name="calib_level" type="smallint" required="True" |
| 70 |
utype="obscore:obsdataset.caliblevel" ucd="meta.code;obs.calib" |
| 71 |
tablehead="Calibration level" |
| 72 |
description="Amount of data processing that has been |
| 73 |
applied to the data" |
| 74 |
verbLevel="10" note="calib"> |
| 75 |
<property name="std">1</property> |
| 76 |
<values> |
| 77 |
<option title="raw/custom">0</option> |
| 78 |
<option title="raw/standard format">1</option> |
| 79 |
<option title="calibrated">2</option> |
| 80 |
<option title="derived">3</option> |
| 81 |
</values> |
| 82 |
</column> |
| 83 |
|
| 84 |
<meta name="note" tag="calib"> |
| 85 |
The calib_level flag takes the following values: |
| 86 |
|
| 87 |
=== =========================================================== |
| 88 |
0 Raw Instrumental data requiring instrument-specific tools |
| 89 |
1 Instrumental data processable with standard tools |
| 90 |
2 Calibrated, science-ready data without instrument signature |
| 91 |
3 Enhanced data products (e.g., mosaics) |
| 92 |
=== =========================================================== |
| 93 |
</meta> |
| 94 |
|
| 95 |
<column name="obs_collection" type="text" |
| 96 |
utype="obscore:dataid.collection" ucd="meta.id" |
| 97 |
tablehead="Collection" |
| 98 |
description="Name of a data collection (e.g., project name) this |
| 99 |
data belongs to" |
| 100 |
verbLevel="15"> |
| 101 |
<property name="std">1</property> |
| 102 |
<property name="statistics">enumerate</property> |
| 103 |
</column> |
| 104 |
|
| 105 |
<column name="obs_id" type="text" |
| 106 |
utype="obscore:DataID.observationID" ucd="meta.id" |
| 107 |
tablehead="Obs. Id" |
| 108 |
description="Unique identifier for an observation" |
| 109 |
verbLevel="5"> |
| 110 |
<property name="std">1</property> |
| 111 |
</column> |
| 112 |
|
| 113 |
<column name="obs_title" type="text" |
| 114 |
utype="obscore:dataid.title" ucd="meta.title;obs" |
| 115 |
tablehead="Title" |
| 116 |
description="Free-from title of the data set" |
| 117 |
verbLevel="5"> |
| 118 |
<property name="std">1</property> |
| 119 |
</column> |
| 120 |
|
| 121 |
<column name="obs_publisher_did" type="text" |
| 122 |
utype="obscore:curation.publisherdid" ucd="meta.ref.ivoid" |
| 123 |
tablehead="Pub. DID" |
| 124 |
description="Dataset identifier assigned by the publisher." |
| 125 |
verbLevel="5"> |
| 126 |
<property name="std">1</property> |
| 127 |
</column> |
| 128 |
|
| 129 |
<column name="obs_creator_did" type="text" |
| 130 |
utype="obscore:dataid.creatordid" ucd="meta.id" |
| 131 |
tablehead="Creator DID" |
| 132 |
description="Dataset identifier assigned by the creator." |
| 133 |
verbLevel="15"> |
| 134 |
<property name="std">1</property> |
| 135 |
</column> |
| 136 |
|
| 137 |
<column name="access_url" type="text" |
| 138 |
utype="obscore:access.reference" ucd="meta.ref.url" |
| 139 |
tablehead="Access URL" |
| 140 |
description="The URL at which to obtain the data set." |
| 141 |
verbLevel="1" displayHint="type=product"> |
| 142 |
<property name="std">1</property> |
| 143 |
</column> |
| 144 |
|
| 145 |
<column name="access_format" type="text" |
| 146 |
tablehead="Media Type" |
| 147 |
description="MIME type of the resource at access_url" |
| 148 |
utype="obscore:access.format" ucd="meta.code.mime" |
| 149 |
verbLevel="5"> |
| 150 |
<property name="std">1</property> |
| 151 |
</column> |
| 152 |
|
| 153 |
<column name="access_estsize" type="bigint" |
| 154 |
description="Estimated size of data product" |
| 155 |
tablehead="Size" |
| 156 |
unit="kbyte" utype="obscore:access.size" ucd="phys.size;meta.file" |
| 157 |
verbLevel="5"> |
| 158 |
<property name="std">1</property> |
| 159 |
<values nullLiteral="-1"/> |
| 160 |
</column> |
| 161 |
|
| 162 |
<column name="target_name" type="text" |
| 163 |
description="Object a targeted observation targeted" |
| 164 |
tablehead="Target Name" |
| 165 |
utype="obscore:Target.Name" ucd="meta.id;src" |
| 166 |
verbLevel="15"> |
| 167 |
<property name="std">1</property> |
| 168 |
</column> |
| 169 |
|
| 170 |
<column name="target_class" type="text" |
| 171 |
description="Class of the target object (star, QSO, ...)" |
| 172 |
tablehead="Target Class" |
| 173 |
utype="obscore:target.class" ucd="src.class" |
| 174 |
verbLevel="20"> |
| 175 |
<property name="std">1</property> |
| 176 |
<property name="statistics">enumerate</property> |
| 177 |
</column> |
| 178 |
|
| 179 |
<column name="s_ra" type="double precision" |
| 180 |
unit="deg" ucd="pos.eq.ra" |
| 181 |
utype="obscore:char.spatialaxis.coverage.location.coord.position2d.value2.c1" |
| 182 |
tablehead="RA" |
| 183 |
description="RA of (center of) observation, ICRS" |
| 184 |
verbLevel="1"> |
| 185 |
<property name="std">1</property> |
| 186 |
</column> |
| 187 |
|
| 188 |
<column name="s_dec" type="double precision" |
| 189 |
unit="deg" ucd="pos.eq.dec" |
| 190 |
utype="obscore:char.spatialaxis.coverage.location.coord.position2d.value2.c2" |
| 191 |
tablehead="Dec" |
| 192 |
description="Dec of (center of) observation, ICRS" |
| 193 |
verbLevel="1"> |
| 194 |
<property name="std">1</property> |
| 195 |
</column> |
| 196 |
|
| 197 |
<column name="s_fov" |
| 198 |
unit="deg" ucd="phys.angSize;instr.fov" |
| 199 |
utype="obscore:char.spatialaxis.coverage.bounds.extent.diameter" |
| 200 |
tablehead="FoV" |
| 201 |
description="Approximate spatial extent for the region covered by the |
| 202 |
observation" |
| 203 |
verbLevel="5"> |
| 204 |
<property name="std">1</property> |
| 205 |
</column> |
| 206 |
|
| 207 |
<column name="s_region" type="spoly" xtype="adql:REGION" |
| 208 |
utype="obscore:char.spatialaxis.coverage.support.area" |
| 209 |
ucd="pos.outline;obs.field" |
| 210 |
tablehead="coverage" |
| 211 |
description="Region covered by the observation, as a polygon" |
| 212 |
verbLevel="15"> |
| 213 |
<property name="std">1</property> |
| 214 |
</column> |
| 215 |
|
| 216 |
<column name="s_resolution" |
| 217 |
unit="arcsec" ucd="pos.angResolution" |
| 218 |
utype="obscore:Char.SpatialAxis.Resolution.refval.value" |
| 219 |
tablehead="Space Res." |
| 220 |
description="Best spatial resolution within the data set" |
| 221 |
verbLevel="15"> |
| 222 |
<property name="std">1</property> |
| 223 |
</column> |
| 224 |
|
| 225 |
<column name="t_min" type="double precision" xtype="mjd" |
| 226 |
unit="d" ucd="time.start;obs.exposure" |
| 227 |
utype="obscore:char.timeaxis.coverage.bounds.limits.starttime" |
| 228 |
tablehead="Min. t" |
| 229 |
description="Lower bound of times represented in the data set" |
| 230 |
verbLevel="10" |
| 231 |
displayHint="type=humanDate"> |
| 232 |
<property name="std">1</property> |
| 233 |
</column> |
| 234 |
|
| 235 |
<column name="t_max" type="double precision" xtype="mjd" |
| 236 |
unit="d" ucd="time.end;obs.exposure" |
| 237 |
utype="obscore:char.timeaxis.coverage.bounds.limits.stoptime" |
| 238 |
description="Upper bound of times represented in the data set" |
| 239 |
tablehead="Max. t" |
| 240 |
verbLevel="10" |
| 241 |
displayHint="type=humanDate"> |
| 242 |
<property name="std">1</property> |
| 243 |
</column> |
| 244 |
|
| 245 |
<column name="t_exptime" type="real" |
| 246 |
unit="s" ucd="time.duration;obs.exposure" |
| 247 |
utype="obscore:char.timeaxis.coverage.support.extent" |
| 248 |
tablehead="Exp. Time" |
| 249 |
description="Total exposure time" |
| 250 |
verbLevel="10"> |
| 251 |
<property name="std">1</property> |
| 252 |
</column> |
| 253 |
|
| 254 |
<column name="t_resolution" |
| 255 |
unit="s" ucd="time.resolution" |
| 256 |
utype="obscore:char.timeaxis.resolution.refval.value" |
| 257 |
tablehead="Res. t" |
| 258 |
description="Minimal significant time interval along the time axis" |
| 259 |
verbLevel="15"> |
| 260 |
<property name="std">1</property> |
| 261 |
</column> |
| 262 |
|
| 263 |
<column name="em_min" |
| 264 |
unit="m" ucd="em.wl;stat.min" |
| 265 |
utype="obscore:char.spectralaxis.coverage.bounds.limits.lolimit" |
| 266 |
tablehead="λ_min" |
| 267 |
description="Minimal wavelength represented within the data set" |
| 268 |
verbLevel="10"> |
| 269 |
<property name="std">1</property> |
| 270 |
</column> |
| 271 |
|
| 272 |
<column name="em_max" |
| 273 |
unit="m" ucd="em.wl;stat.max" |
| 274 |
utype="obscore:char.spectralaxis.coverage.bounds.limits.hilimit" |
| 275 |
tablehead="λ_max" |
| 276 |
description="Maximal wavelength represented within the data set" |
| 277 |
verbLevel="10"> |
| 278 |
<property name="std">1</property> |
| 279 |
</column> |
| 280 |
|
| 281 |
<column name="em_res_power" |
| 282 |
ucd="spect.resolution" |
| 283 |
utype="obscore:char.spectralaxis.resolution.resolpower.refval" |
| 284 |
tablehead="λ/Δλ" |
| 285 |
description="Spectral resolving power lambda/delta lambda" |
| 286 |
verbLevel="15"> |
| 287 |
<property name="std">1</property> |
| 288 |
</column> |
| 289 |
|
| 290 |
<column name="o_ucd" type="text" |
| 291 |
ucd="meta.ucd" |
| 292 |
utype="obscore:char.observableaxis.ucd" |
| 293 |
tablehead="Obs. UCD" |
| 294 |
description="UCD for the product's observable" |
| 295 |
verbLevel="15"> |
| 296 |
<property name="std">1</property> |
| 297 |
</column> |
| 298 |
|
| 299 |
<column name="pol_states" type="text" |
| 300 |
ucd="meta.code;phys.polarization" |
| 301 |
utype="obscore:Char.PolarizationAxis.stateList" |
| 302 |
tablehead="Pol. States" |
| 303 |
description="List of polarization states in the data set" |
| 304 |
verbLevel="15"> |
| 305 |
<property name="std">1</property> |
| 306 |
</column> |
| 307 |
|
| 308 |
<column name="facility_name" type="text" |
| 309 |
ucd="meta.id;instr.tel" |
| 310 |
utype="obscore:Provenance.ObsConfig.facility.name" |
| 311 |
tablehead="Facility" |
| 312 |
description="Name of the facility at which data was taken" |
| 313 |
verbLevel="15"> |
| 314 |
<property name="std">1</property> |
| 315 |
<property name="statistics">enumerate</property> |
| 316 |
</column> |
| 317 |
|
| 318 |
<column name="instrument_name" type="text" |
| 319 |
ucd="meta.id;instr" |
| 320 |
utype="obscore:Provenance.ObsConfig.instrument.name" |
| 321 |
tablehead="Instrument" |
| 322 |
description="Name of the instrument that produced the data" |
| 323 |
verbLevel="15"> |
| 324 |
<property name="std">1</property> |
| 325 |
<property name="statistics">enumerate</property> |
| 326 |
</column> |
| 327 |
|
| 328 |
<!-- obscore 1.1 additions --> |
| 329 |
|
| 330 |
<column name="s_xel1" type="integer" |
| 331 |
ucd="meta.number" |
| 332 |
utype="obscore:Char.SpatialAxis.numBins1" |
| 333 |
tablehead="|X|" |
| 334 |
description="Number of elements (typically pixels) along the |
| 335 |
first spatial axis." |
| 336 |
verbLevel="10"> |
| 337 |
<property name="std">1</property> |
| 338 |
<values nullLiteral="-1"/> |
| 339 |
</column> |
| 340 |
|
| 341 |
<column name="s_xel2" type="integer" |
| 342 |
ucd="meta.number" |
| 343 |
utype="obscore:Char.SpatialAxis.numBins2" |
| 344 |
tablehead="|Y|" |
| 345 |
description="Number of elements (typically pixels) along the |
| 346 |
second spatial axis." |
| 347 |
verbLevel="10"> |
| 348 |
<property name="std">1</property> |
| 349 |
<values nullLiteral="-1"/> |
| 350 |
</column> |
| 351 |
|
| 352 |
<column name="t_xel" type="integer" |
| 353 |
ucd="meta.number" |
| 354 |
utype="obscore:Char.TimeAxis.numBins" |
| 355 |
tablehead="|t|" |
| 356 |
description="Number of elements (typically pixels) along the |
| 357 |
time axis." |
| 358 |
verbLevel="10"> |
| 359 |
<property name="std">1</property> |
| 360 |
<values nullLiteral="-1"/> |
| 361 |
</column> |
| 362 |
|
| 363 |
<column name="em_xel" type="integer" |
| 364 |
ucd="meta.number" |
| 365 |
utype="obscore:Char.SpectralAxis.numBins" |
| 366 |
tablehead="|λ|" |
| 367 |
description="Number of elements (typically pixels) along the |
| 368 |
spectral axis." |
| 369 |
verbLevel="10"> |
| 370 |
<property name="std">1</property> |
| 371 |
<values nullLiteral="-1"/> |
| 372 |
</column> |
| 373 |
|
| 374 |
<column name="pol_xel" type="integer" |
| 375 |
ucd="meta.number" |
| 376 |
utype="obscore:Char.PolarizationAxis.numBins" |
| 377 |
tablehead="|Pol|" |
| 378 |
description="Number of elements (typically pixels) along the |
| 379 |
polarization axis." |
| 380 |
verbLevel="10"> |
| 381 |
<property name="std">1</property> |
| 382 |
<values nullLiteral="-1"/> |
| 383 |
</column> |
| 384 |
|
| 385 |
<column name="s_pixel_scale" |
| 386 |
unit="arcsec" ucd="phys.angSize;instr.pixel" |
| 387 |
utype="obscore:Char.SpatialAxis.Sampling.RefVal.SamplingPeriod" |
| 388 |
tablehead="Pix. Scale" |
| 389 |
description="Sampling period in world coordinate units along |
| 390 |
the spatial axis" |
| 391 |
verbLevel="10"> |
| 392 |
<property name="std">1</property> |
| 393 |
</column> |
| 394 |
|
| 395 |
<column name="em_ucd" type="text" |
| 396 |
ucd="meta.ucd" |
| 397 |
utype="obscore:Char.SpectralAxis.ucd" |
| 398 |
tablehead="Spect. UCD" |
| 399 |
description="Nature of the product's spectral axis (typically, em.freq, |
| 400 |
em.wl, or em.energy)" |
| 401 |
verbLevel="15"> |
| 402 |
<property name="std">1</property> |
| 403 |
</column> |
| 404 |
|
| 405 |
<column name="preview" type="text" |
| 406 |
ucd="meta.ref.url;meta.preview" |
| 407 |
description="URL of a preview (low-resolution, quick-to-retrieve |
| 408 |
representation) of the data." |
| 409 |
verbLevel="15" |
| 410 |
displayHint="type=product"/> |
| 411 |
|
| 412 |
<column name="source_table" type="text" |
| 413 |
ucd="meta.id;meta.table" |
| 414 |
tablehead="Source Table" |
| 415 |
description="Name of a TAP-queriable table this data originates from. |
| 416 |
This source table usually provides more information on the |
| 417 |
the data than what is given in obscore. See the TAP_SCHEMA of |
| 418 |
the originating TAP server for details." |
| 419 |
verbLevel="25"/> |
| 420 |
|
| 421 |
<FEED source="%#obscore-extracolumns"/> |
| 422 |
</STREAM> |
| 423 |
|
| 424 |
<table id="ObsCore" adql="True" onDisk="True"> |
| 425 |
<!-- the non-materialised obscore table is a system table, mainly to |
| 426 |
reduce spam from when dependent tables build it. --> |
| 427 |
<LOOP> |
| 428 |
<codeItems> |
| 429 |
if not base.getConfig("ivoa", "materialiseObscore"): |
| 430 |
yield {"materialise": "no"} |
| 431 |
</codeItems> |
| 432 |
<events> |
| 433 |
<system>True</system> |
| 434 |
</events> |
| 435 |
</LOOP> |
| 436 |
|
| 437 |
<property key="supportsModel">Obscore-1.1</property> |
| 438 |
<property key="supportsModelURI" |
| 439 |
>ivo://ivoa.net/std/obscore#core-1.1</property> |
| 440 |
<property key="forceStats">True</property> |
| 441 |
<FEED source="%#obscore-registration"/> |
| 442 |
|
| 443 |
<meta name="utype">ivo://ivoa.net/std/obscore#table-1.1</meta> |
| 444 |
<meta name="title">\getConfig{web}{sitename} Obscore Table</meta> |
| 445 |
<meta name="shortName">\metaString{authority.shortName} Obscore</meta> |
| 446 |
|
| 447 |
<meta name="_associatedDatalinkService"> |
| 448 |
<meta name="serviceId">//obscore#dl</meta> |
| 449 |
<meta name="idColumn">obs_publisher_did</meta> |
| 450 |
</meta> |
| 451 |
|
| 452 |
<meta name="description">The IVOA-defined obscore table, containing |
| 453 |
generic metadata for datasets within this data centre.</meta> |
| 454 |
|
| 455 |
<LOOP> |
| 456 |
<codeItems> |
| 457 |
if base.getConfig("ivoa", "materialiseObscore"): |
| 458 |
yield {"materialise": "materialise"} |
| 459 |
</codeItems> |
| 460 |
<events> |
| 461 |
<FEED source="%#obscore-materialised-indexes"/> |
| 462 |
</events> |
| 463 |
</LOOP> |
| 464 |
|
| 465 |
<!-- the view creation statement is bogus (a fallback used |
| 466 |
in the initial creation, actually; in reality, we create |
| 467 |
the view creation statement from the _obscoresources table in the |
| 468 |
data create --> |
| 469 |
|
| 470 |
<viewStatement> |
| 471 |
create view \qName (\colNames) as (select * from (VALUES( |
| 472 |
NULL, NULL, NULL, NULL, NULL, |
| 473 |
NULL, NULL, NULL, NULL, NULL, |
| 474 |
NULL, NULL, NULL, NULL, NULL, |
| 475 |
NULL, NULL, NULL, NULL, NULL, |
| 476 |
NULL, NULL, NULL, NULL, NULL, |
| 477 |
NULL, NULL, NULL, NULL, NULL, |
| 478 |
NULL, NULL, NULL, NULL, NULL, |
| 479 |
NULL, NULL, NULL)) as q WHERE 0=1); |
| 480 |
</viewStatement> |
| 481 |
|
| 482 |
<FEED source="obscore-columns"/> |
| 483 |
</table> |
| 484 |
|
| 485 |
<coverage><updater sourceTable="ObsCore"/></coverage> |
| 486 |
|
| 487 |
<table id="_obscoresources" onDisk="True" |
| 488 |
dupePolicy="overwrite" primary="tableName" system="True"> |
| 489 |
<meta name="description"> |
| 490 |
This table contains the SQL fragments that make up this installation's |
| 491 |
ivoa.obscore view. Whenever a participating table is re-made, the |
| 492 |
view definition is renewed with a statement made up of a union of |
| 493 |
all sqlFragments present in this table. |
| 494 |
|
| 495 |
Manipulate this table through gavo imp on tables that have an obscore |
| 496 |
mixin, or by dropping RDs or purging tables that are part of obscore. |
| 497 |
</meta> |
| 498 |
<column name="tableName" type="text" |
| 499 |
description="Name of the table that generated this fragment (usually |
| 500 |
through a mixin)"/> |
| 501 |
<column name="sqlFragment" type="text" |
| 502 |
description="The SQL fragment contributed from tableName"/> |
| 503 |
<column name="sourcerd" type="text" |
| 504 |
description="The RD the table was found in at input (this is |
| 505 |
mainly to support dachs drop -f)"/> |
| 506 |
</table> |
| 507 |
|
| 508 |
<STREAM id="create-obscore-view"> |
| 509 |
<doc> |
| 510 |
This stream has the code to turn ivoa._obscoresources into a |
| 511 |
view definition. This is always a preImport script on ivoa.obscore |
| 512 |
and overrides its built-in trivial view creation. For a non-materialised |
| 513 |
obscore view, this is also a postCreation script on anything that |
| 514 |
contributes to ivoa.obscore. |
| 515 |
</doc> |
| 516 |
<script name="createObscoreView" type="\scriptType" lang="python"> |
| 517 |
from gavo.protocols import obscore |
| 518 |
obscore.createObscoreView(table.connection) |
| 519 |
</script> |
| 520 |
</STREAM> |
| 521 |
|
| 522 |
<STREAM id="maintenance-scripts"> |
| 523 |
<doc> |
| 524 |
These scripts must be included in any table that eventually |
| 525 |
ends up as a part of ivoa.obscore. |
| 526 |
</doc> |
| 527 |
|
| 528 |
<script id="addTableToObscoreSources" name="addTableToObscore" |
| 529 |
lang="python" type="afterMeta"> |
| 530 |
obscoreClause = table.tableDef.expand( |
| 531 |
table.tableDef.getProperty("obscoreClause")) |
| 532 |
|
| 533 |
for srcRE, replacement in [ |
| 534 |
# The following is copied in the mixin's processLate |
| 535 |
(r"CAST\(__COMPUTE__ AS text\) AS obs_publisher_did", |
| 536 |
"('ivo://\getConfig{ivoa}{authority}/~?' ||" |
| 537 |
" gavo_urlescape(accref)) AS obs_publisher_did")]: |
| 538 |
obscoreClause = re.sub(srcRE, replacement, obscoreClause) |
| 539 |
|
| 540 |
from gavo import rsc |
| 541 |
ots = rsc.TableForDef( |
| 542 |
base.caches.getRD("//obscore").getById("_obscoresources"), |
| 543 |
connection=table.connection) |
| 544 |
ots.addRow({"tableName": table.tableDef.getQName(), |
| 545 |
"sourcerd": table.tableDef.rd.sourceId, |
| 546 |
"sqlFragment": "SELECT %s FROM %s"%( |
| 547 |
obscoreClause, table.tableDef.getQName())}) |
| 548 |
</script> |
| 549 |
|
| 550 |
<script id="removeTableFromObscoreSources" |
| 551 |
lang="python" |
| 552 |
type="beforeDrop" |
| 553 |
name="removeTableFromObscoreSources"> |
| 554 |
from gavo import rsc |
| 555 |
if table.getTableType("ivoa._obscoresources"): |
| 556 |
table.connection.execute( |
| 557 |
"DELETE FROM ivoa._obscoresources WHERE tableName=%(name)s", |
| 558 |
{"name": table.tableDef.getQName()}) |
| 559 |
# importing this table may take a long time, and we don't want |
| 560 |
# to have obscore offline for so long; so, we immediately recreate |
| 561 |
# it; but only if we're not materialised |
| 562 |
if not base.getConfig("ivoa", "materialiseObscore"): |
| 563 |
rsc.makeData(base.caches.getRD("//obscore").getById("create"), |
| 564 |
connection=table.connection) |
| 565 |
table.connection.commit() |
| 566 |
</script> |
| 567 |
|
| 568 |
<LOOP> |
| 569 |
<codeItems> |
| 570 |
if not base.getConfig("ivoa", "materialiseObscore"): |
| 571 |
yield {"materialise": "no"} |
| 572 |
</codeItems> |
| 573 |
<events> |
| 574 |
<FEED source="//obscore#create-obscore-view" scriptType="postCreation"/> |
| 575 |
</events> |
| 576 |
</LOOP> |
| 577 |
|
| 578 |
</STREAM> |
| 579 |
|
| 580 |
<STREAM id="_manageObscoreClause"> |
| 581 |
<doc> |
| 582 |
Material for all mixins contributing to ivoa.obscore. |
| 583 |
|
| 584 |
At its centre, this gives a table an obscoreClause property. |
| 585 |
The stuff around it is just means to feed it; see the obscoreClause |
| 586 |
for what macros anything embedding this will have to define. |
| 587 |
</doc> |
| 588 |
|
| 589 |
<mixinPar name="source_table" |
| 590 |
alias="sourceTable" |
| 591 |
description="The table this is mixed into (you probably don't want |
| 592 |
to change this)." |
| 593 |
>'\qName'</mixinPar> |
| 594 |
|
| 595 |
<mixinPar name="createDIDIndex" description="Index whatever expression |
| 596 |
you give for the dataset identifier? You probably want this |
| 597 |
on tables with more than a few hundred datasets unless the DID is |
| 598 |
in a column that you already index anyway." |
| 599 |
>False</mixinPar> |
| 600 |
|
| 601 |
<FEED source="%#obscore-extrapars"/> |
| 602 |
|
| 603 |
<events> |
| 604 |
<adql>True</adql> |
| 605 |
<meta name="isServedBy" |
| 606 |
ivoId="ivo://\getConfig{ivoa}{authority}/__system__/obscore/obscore" |
| 607 |
>\getConfig{web}{siteName} Obscore</meta> |
| 608 |
<!-- the casts in the following table are there to keep postgres |
| 609 |
from inferring weird types when parts of the union have NULL |
| 610 |
entries--> |
| 611 |
<property name="obscoreClause"> |
| 612 |
CAST(\dataproduct_type AS text) AS dataproduct_type, |
| 613 |
CAST(\dataproduct_subtype AS text) AS dataproduct_subtype, |
| 614 |
CAST(\calib_level AS smallint) AS calib_level, |
| 615 |
CAST(\obs_collection AS text) AS obs_collection, |
| 616 |
CAST(\obs_id AS text) AS obs_id, |
| 617 |
CAST(\obs_title AS text) AS obs_title, |
| 618 |
CAST(\obs_publisher_did AS text) AS obs_publisher_did, |
| 619 |
CAST(\obs_creator_did AS text) AS obs_creator_did, |
| 620 |
CAST(\access_url AS text) AS access_url, |
| 621 |
CAST(\access_format AS text) AS access_format, |
| 622 |
CAST(\access_estsize AS bigint) AS access_estsize, |
| 623 |
CAST(\target_name AS text) AS target_name, |
| 624 |
CAST(\target_class AS text) AS target_class, |
| 625 |
CAST(\s_ra AS double precision) AS s_ra, |
| 626 |
CAST(\s_dec AS double precision) AS s_dec, |
| 627 |
CAST(\s_fov AS real) AS s_fov, |
| 628 |
CAST(\s_region AS spoly) AS s_region, |
| 629 |
CAST(\s_resolution AS real) AS s_resolution, |
| 630 |
CAST(\t_min AS double precision) AS t_min, |
| 631 |
CAST(\t_max AS double precision) AS t_max, |
| 632 |
CAST(\t_exptime AS double precision) AS t_exptime, |
| 633 |
CAST(\t_resolution AS double precision) AS t_resolution, |
| 634 |
CAST(\em_min AS real) AS em_min, |
| 635 |
CAST(\em_max AS real) AS em_max, |
| 636 |
CAST(\em_res_power AS real) AS em_res_power, |
| 637 |
CAST(\o_ucd AS text) AS o_ucd, |
| 638 |
CAST(\pol_states AS text) AS pol_states, |
| 639 |
CAST(\facility_name AS text) AS facility_name, |
| 640 |
CAST(\instrument_name AS text) AS instrument_name, |
| 641 |
CAST(\s_xel1 AS integer) AS s_xel1, |
| 642 |
CAST(\s_xel2 AS integer) AS s_xel2, |
| 643 |
CAST(\t_xel AS integer) AS t_xel, |
| 644 |
CAST(\em_xel AS integer) AS em_xel, |
| 645 |
CAST(\pol_xel AS integer) AS pol_xel, |
| 646 |
CAST(\s_pixel_scale AS real) AS s_pixel_scale, |
| 647 |
CAST(\em_ucd AS text) AS em_ucd, |
| 648 |
CAST(\preview AS text) AS preview, |
| 649 |
CAST(\source_table AS text) AS source_table |
| 650 |
</property> |
| 651 |
<FEED source="%#obscore-extraevents"/> |
| 652 |
<FEED source="maintenance-scripts"/> |
| 653 |
</events> |
| 654 |
|
| 655 |
<processLate id="obscore-processLate"> |
| 656 |
<doc> |
| 657 |
Minor housekeeping chores for obscore tables. |
| 658 |
</doc> |
| 659 |
<setup imports="gavo.rscdef"/> |
| 660 |
<code><![CDATA[ |
| 661 |
# delay this so we're not raising false alarm when onDisk |
| 662 |
# is declared after the mixin |
| 663 |
if not substrate.onDisk: |
| 664 |
raise base.StructureError("Only onDisk tables can be obscore" |
| 665 |
" published, but %s is not."%substrate.id) |
| 666 |
|
| 667 |
# delay this so everything is already bound. |
| 668 |
if base.parseBooleanLiteral(mixinPars["createDIDIndex"]): |
| 669 |
content = mixinPars["obs_publisher_did"] |
| 670 |
if content=='__COMPUTE__': |
| 671 |
# The following is copied in addTableToObscoreSources |
| 672 |
content = ("('ivo://\getConfig{ivoa}{authority}/~?' ||" |
| 673 |
"gavo_urlescape(accref))") |
| 674 |
substrate.feedObject("index", |
| 675 |
base.makeStruct(rscdef.DBIndex, |
| 676 |
content_=content, |
| 677 |
name="obscore_%s_did_index"%substrate.id)) |
| 678 |
|
| 679 |
# This is a bit of a hack to enable scripts like |
| 680 |
# analyze-obscore.py: If someone puts an attribute |
| 681 |
# obscore_mixin_hook into gavo.rscdef (which is totally |
| 682 |
# random but something all the various mixins see) |
| 683 |
# call it with all the information we have. |
| 684 |
if hasattr(rscdef, "obscore_mixin_hook"): |
| 685 |
rscdef.obscore_mixin_hook(mixinPars, root, substrate, context) |
| 686 |
]]></code> |
| 687 |
</processLate> |
| 688 |
</STREAM> |
| 689 |
|
| 690 |
<STREAM id="_publishCommon"> |
| 691 |
<doc> |
| 692 |
Common elements for (almost all) ObsTAP publication mixins. |
| 693 |
</doc> |
| 694 |
|
| 695 |
<mixinPar name="dataproduct_subtype" |
| 696 |
alias="productSubtype" |
| 697 |
description="File subtype. Details pending" |
| 698 |
>NULL</mixinPar> |
| 699 |
<mixinPar name="calib_level" |
| 700 |
alias="calibLevel" |
| 701 |
description="Calibration level of data, a number between 0 and 3; |
| 702 |
for details, see |
| 703 |
http://dc.g-vo.org/tableinfo/ivoa.obscore#note-calib" |
| 704 |
>2</mixinPar> |
| 705 |
<mixinPar name="obs_collection" |
| 706 |
alias="collectionName" |
| 707 |
description="A human-readable name for this collection. This should |
| 708 |
be short, so don't just use the resource title" |
| 709 |
>'unnamed'</mixinPar> |
| 710 |
<mixinPar name="target_name" |
| 711 |
alias="targetName" |
| 712 |
description="Name of the target object." |
| 713 |
>NULL</mixinPar> |
| 714 |
<mixinPar name="target_class" |
| 715 |
alias="targetClass" |
| 716 |
description="Class of target object(s). You should take |
| 717 |
whatever you put here from |
| 718 |
http://simbad.u-strasbg.fr/guide/chF.htx">NULL</mixinPar> |
| 719 |
<mixinPar name="t_resolution" |
| 720 |
alias="tResolution" |
| 721 |
description="Temporal resolution (in seconds)" |
| 722 |
>NULL</mixinPar> |
| 723 |
<mixinPar name="em_res_power" |
| 724 |
alias="emResPower" |
| 725 |
description="Spectral resolution as lambda/delta lambda" |
| 726 |
>NULL</mixinPar> |
| 727 |
<mixinPar name="t_exptime" |
| 728 |
alias="expTime" |
| 729 |
description="Total time of event counting. This simply is |
| 730 |
t_max-t_min for simple exposures.">NULL</mixinPar> |
| 731 |
<mixinPar name="pol_states" |
| 732 |
alias="polStates" |
| 733 |
description="List of polarization states present in the data; |
| 734 |
if you give something, use the convention of choosing the appropriate |
| 735 |
from {I Q U V RR LL RL LR XX YY XY YX POLI POLA} and write them |
| 736 |
*in alphabetical order* with / separators, e.g. /I/Q/XX/." |
| 737 |
>NULL</mixinPar> |
| 738 |
<mixinPar name="facility_name" |
| 739 |
alias="facilityName" |
| 740 |
description="The institute or observatory at which the data was produced" |
| 741 |
>NULL</mixinPar> |
| 742 |
<mixinPar name="s_xel1" |
| 743 |
alias="sXel1" |
| 744 |
description="Number of pixels along the first spatial axis" |
| 745 |
>NULL</mixinPar> |
| 746 |
<mixinPar name="s_xel2" |
| 747 |
alias="sXel2" |
| 748 |
description="Number of pixels along the second spatial axis" |
| 749 |
>NULL</mixinPar> |
| 750 |
<mixinPar name="t_xel" |
| 751 |
alias="tXel" |
| 752 |
description="Number of samples along the time axis" |
| 753 |
>NULL</mixinPar> |
| 754 |
<mixinPar name="em_xel" |
| 755 |
alias="emXel" |
| 756 |
description="Number of samples along the spectral axis" |
| 757 |
>NULL</mixinPar> |
| 758 |
<mixinPar name="pol_xel" |
| 759 |
alias="polXel" |
| 760 |
description="Number of polarisation states in this product" |
| 761 |
>NULL</mixinPar> |
| 762 |
<mixinPar name="s_pixel_scale" |
| 763 |
alias="sPixelScale" |
| 764 |
description="Size of a spatial pixel (in arcsec)" |
| 765 |
>NULL</mixinPar> |
| 766 |
<mixinPar name="em_ucd" |
| 767 |
alias="emUCD" |
| 768 |
description="UCD of the spectral axis as defined by the spectrum DM, |
| 769 |
plus a few values defined in obscore 1.1 for Doppler axes" |
| 770 |
>NULL</mixinPar> |
| 771 |
<mixinPar name="preview" |
| 772 |
description="URL of a preview for the data. Set to NULL if you |
| 773 |
don't have any previews." |
| 774 |
>NULL</mixinPar> |
| 775 |
|
| 776 |
<LFEED source="_manageObscoreClause"/> |
| 777 |
</STREAM> |
| 778 |
|
| 779 |
<STREAM id="_publishProduct"> |
| 780 |
<doc> |
| 781 |
publish mixin parameters deriving from products#table interface |
| 782 |
fields. |
| 783 |
</doc> |
| 784 |
<mixinPar name="obs_id" |
| 785 |
alias="obsId" |
| 786 |
description="Identifier of the data set. Only change this when |
| 787 |
you do not mix in products." |
| 788 |
>accref</mixinPar> |
| 789 |
<mixinPar name="obs_publisher_did" |
| 790 |
alias="did" |
| 791 |
description="Global identifier of the data set. Leave __COMPUTE__ |
| 792 |
for tables mixing in products." |
| 793 |
>__COMPUTE__</mixinPar> |
| 794 |
<mixinPar name="access_url" |
| 795 |
alias="accessURL" |
| 796 |
description="URL at which the product can be obtained. Leave as is |
| 797 |
for tables mixing in products." |
| 798 |
>accref</mixinPar> |
| 799 |
<mixinPar name="access_format" |
| 800 |
alias="mime" |
| 801 |
description="The MIME type of the product file. Only touch if |
| 802 |
you do not mix in products." |
| 803 |
>mime</mixinPar> |
| 804 |
<mixinPar name="access_estsize" |
| 805 |
alias="size" |
| 806 |
description="The estimated size of the product in kilobytes. |
| 807 |
Only touch when you do not mix in products#table." |
| 808 |
>accsize/1024</mixinPar> |
| 809 |
<mixinPar name="preview" description="The preview URL will |
| 810 |
point to the products service; if you don't have any previews, |
| 811 |
you will have to set this to NULL manually." |
| 812 |
>accref || '?preview=True'</mixinPar> |
| 813 |
</STREAM> |
| 814 |
|
| 815 |
<mixinDef id="publish"> |
| 816 |
<doc> |
| 817 |
Publish this table to ObsTAP. |
| 818 |
|
| 819 |
This means mapping or giving quite a bit of data from the present |
| 820 |
table to ObsCore rows. Internally, this information is converted |
| 821 |
to an SQL select statement used within a create view statement. |
| 822 |
In consequence, you must give *SQL* expressions in the parameter |
| 823 |
values; just naked column names from your input table are ok, |
| 824 |
of course. Most parameters are set to NULL or appropriate |
| 825 |
defaults for tables mixing in //products#table. |
| 826 |
|
| 827 |
Since the mixin generates script elements, it cannot be used |
| 828 |
in untrusted RDs. The fact that you can enter raw SQL also |
| 829 |
means you will get ugly error messages if you give invalid |
| 830 |
parameters. |
| 831 |
|
| 832 |
Some items are filled from product interface fields automatically. |
| 833 |
You must change these if you obscore-publish tables not mixin |
| 834 |
in products. |
| 835 |
|
| 836 |
Note: you must say ``dachs imp //obscore`` before anything |
| 837 |
obscore-related will work. |
| 838 |
</doc> |
| 839 |
|
| 840 |
<LFEED source="_publishCommon"/> |
| 841 |
<LFEED source="_publishProduct"/> |
| 842 |
|
| 843 |
<mixinPar name="dataproduct_type" |
| 844 |
alias="productType" |
| 845 |
description="Data product type; one of image, cube, spectrum, sed, |
| 846 |
timeseries, visibility, event, or NULL if None of the above"/> |
| 847 |
<mixinPar name="obs_title" |
| 848 |
alias="title" |
| 849 |
description="A human-readable title of the data set." |
| 850 |
>NULL</mixinPar> |
| 851 |
<mixinPar name="s_ra" |
| 852 |
alias="ra" |
| 853 |
description="Center RA" |
| 854 |
>NULL</mixinPar> |
| 855 |
<mixinPar name="s_dec" |
| 856 |
alias="dec" |
| 857 |
description="Center Dec" |
| 858 |
>NULL</mixinPar> |
| 859 |
<mixinPar name="s_fov" |
| 860 |
alias="fov" |
| 861 |
description="Approximate diameter of region covered" |
| 862 |
>NULL</mixinPar> |
| 863 |
<mixinPar name="s_region" |
| 864 |
alias="coverage" |
| 865 |
description="A polygon giving the spatial coverage of the data |
| 866 |
set; this must always be in ICRS. This is cast to an pgsphere |
| 867 |
spoly, which currently means that you have to provide an spoly |
| 868 |
(reference), too." |
| 869 |
>NULL</mixinPar> |
| 870 |
<mixinPar name="t_min" |
| 871 |
alias="tMin" |
| 872 |
description="MJD for the lower bound of times covered in the data |
| 873 |
set (e.g. start of exposure). Use ts_to_mjd(ts) to get this |
| 874 |
from a postgres timestamp." |
| 875 |
>NULL</mixinPar> |
| 876 |
<mixinPar name="t_max" |
| 877 |
alias="tMax" |
| 878 |
description="MJD for the upper bound of times covered in the data |
| 879 |
set. See tMin" |
| 880 |
>NULL</mixinPar> |
| 881 |
<mixinPar name="em_min" |
| 882 |
alias="emMin" |
| 883 |
description="Lower bound of wavelengths represented in the |
| 884 |
data set, in meters." |
| 885 |
>NULL</mixinPar> |
| 886 |
<mixinPar name="em_max" |
| 887 |
alias="emMax" |
| 888 |
description="Upper bound of wavelengths represented in the data |
| 889 |
set, in meters." |
| 890 |
>NULL</mixinPar> |
| 891 |
<mixinPar name="o_ucd" |
| 892 |
alias="oUCD" |
| 893 |
description="UCD of the observable quantity, e.g., em.opt for |
| 894 |
wide-band optical frames." |
| 895 |
>NULL</mixinPar> |
| 896 |
<mixinPar name="s_resolution" |
| 897 |
alias="sResolution" description="The (best) angular resolution |
| 898 |
within the data set, in arcsecs" |
| 899 |
>NULL</mixinPar> |
| 900 |
<mixinPar name="instrument_name" |
| 901 |
alias="instrumentName" |
| 902 |
description="The instrument that produced the data" |
| 903 |
>NULL</mixinPar> |
| 904 |
<mixinPar name="obs_creator_did" |
| 905 |
alias="creatorDID" |
| 906 |
description="Global identifier of the data set assigned by the |
| 907 |
creator. Leave NULL unless the creator actually assigned an |
| 908 |
IVO id themselves.">NULL</mixinPar> |
| 909 |
</mixinDef> |
| 910 |
|
| 911 |
<mixinDef id="publishSIAP"> |
| 912 |
<doc> |
| 913 |
Publish a PGS SIAP table to ObsTAP. |
| 914 |
|
| 915 |
This works like //obscore#publish except some defaults apply |
| 916 |
that copy fields that work analogously in SIAP and in ObsTAP. |
| 917 |
|
| 918 |
For special situations, you can, of course, override any |
| 919 |
of the parameters, but most of them should already be all right. |
| 920 |
To find out what the parameters described as "preset for SIAP" |
| 921 |
mean, refer to //obscore#publish. |
| 922 |
|
| 923 |
Note: you must say ``dachs imp //obscore`` before anything |
| 924 |
obscore-related will work. |
| 925 |
</doc> |
| 926 |
|
| 927 |
<LFEED source="_publishCommon"/> |
| 928 |
<LFEED source="_publishProduct"/> |
| 929 |
|
| 930 |
<mixinPar name="dataproduct_type" |
| 931 |
alias="productType" |
| 932 |
description="preset for SIAP" |
| 933 |
>'image'</mixinPar> |
| 934 |
<mixinPar name="obs_title" |
| 935 |
alias="title" |
| 936 |
description="preset for SIAP" |
| 937 |
>imageTitle</mixinPar> |
| 938 |
<mixinPar name="s_ra" |
| 939 |
alias="ra" |
| 940 |
description="preset for SIAP" |
| 941 |
>centerAlpha</mixinPar> |
| 942 |
<mixinPar name="s_dec" |
| 943 |
alias="dec" |
| 944 |
description="preset for SIAP" |
| 945 |
>centerDelta</mixinPar> |
| 946 |
<mixinPar name="s_fov" |
| 947 |
alias="fov" |
| 948 |
description="preset for SIAP; we use the |
| 949 |
extent along the X axis as a very rough estimate for the size. If |
| 950 |
you can do better, by all means do." |
| 951 |
>pixelScale[1]*pixelSize[1]</mixinPar> |
| 952 |
<mixinPar name="s_region" |
| 953 |
alias="coverage" |
| 954 |
description="preset for SIAP" |
| 955 |
>coverage</mixinPar> |
| 956 |
<mixinPar name="t_min" |
| 957 |
alias="tMin" |
| 958 |
description="preset for SIAP; if you want, change this to start |
| 959 |
of observation as available." |
| 960 |
>dateObs</mixinPar> |
| 961 |
<mixinPar name="t_max" |
| 962 |
alias="tMax" |
| 963 |
description="preset for SIAP; if you want, change this to end of |
| 964 |
observation as available." |
| 965 |
>dateObs</mixinPar> |
| 966 |
<mixinPar name="em_min" |
| 967 |
alias="emMin" |
| 968 |
description="preset for SIAP" |
| 969 |
>bandpassLo</mixinPar> |
| 970 |
<mixinPar name="em_max" |
| 971 |
alias="emMax" |
| 972 |
description="preset for SIAP" |
| 973 |
>bandpassHi</mixinPar> |
| 974 |
<mixinPar name="o_ucd" |
| 975 |
alias="oUCD" |
| 976 |
description="preset for SIAP; fix if you either know more about |
| 977 |
the band or if your images are not in the optical." |
| 978 |
>'em.opt'</mixinPar> |
| 979 |
<mixinPar name="s_resolution" |
| 980 |
alias="sResolution" |
| 981 |
description="preset for SIAP; this is just the pixel scale in |
| 982 |
one dimension. If that's seriously wrong or you have uncalibrated |
| 983 |
images in your collection, you may need to be more careful here." |
| 984 |
>pixelScale[1]*3600</mixinPar> |
| 985 |
<mixinPar name="instrument_name" |
| 986 |
alias="instrumentName" |
| 987 |
description="The instrument that produced the data" |
| 988 |
>instId</mixinPar> |
| 989 |
<mixinPar name="obs_creator_did" |
| 990 |
alias="creatorDID" |
| 991 |
description="Global identifier of the data set assigned by |
| 992 |
the creator. Leave NULL unless the creator actually assigned |
| 993 |
an IVO id themselves.">NULL</mixinPar> |
| 994 |
<mixinPar name="s_xel1" |
| 995 |
alias="sXel1" |
| 996 |
description="preset for SIAP" |
| 997 |
>pixelSize[1]</mixinPar> |
| 998 |
<mixinPar name="s_xel2" |
| 999 |
alias="sXel2" |
| 1000 |
description="preset for SIAP" |
| 1001 |
>pixelSize[2]</mixinPar> |
| 1002 |
<mixinPar name="s_pixel_scale" |
| 1003 |
alias="sPixelScale" |
| 1004 |
description="preset for SIAP" |
| 1005 |
>pixelScale[1]*3600</mixinPar> |
| 1006 |
<mixinPar name="facility_name" |
| 1007 |
alias="facilityName" |
| 1008 |
description="Default is to take from resource meta" |
| 1009 |
>\sqlquote{\metaSeq{facility}{NULL}}</mixinPar> |
| 1010 |
</mixinDef> |
| 1011 |
|
| 1012 |
<mixinDef id="publishSSAPHCD"> |
| 1013 |
<doc> |
| 1014 |
Publish a table mixing in //ssap#hcd to ObsTAP. Since //ssap#hcd |
| 1015 |
is deprecated, this should not be used in new RDs, either. For |
| 1016 |
//ssap#mixc tables, use publishSSAPMIXC. |
| 1017 |
|
| 1018 |
This works like `the //obscore#publish mixin`_ except some defaults apply |
| 1019 |
that copy fields that work analogously in SSAP and in ObsTAP. |
| 1020 |
|
| 1021 |
The columns already set in SSAP are marked as UNDOCUMENTED in the |
| 1022 |
parameter list below. For special situations, you can, of course, |
| 1023 |
override any of the parameters. To find out what they actually mean, |
| 1024 |
mean, refer to `the //obscore#publish mixin`_. |
| 1025 |
|
| 1026 |
Note that this mixin does *not* set coverage (obscore: s_region). |
| 1027 |
This is because although we could make a circle from ssa_location |
| 1028 |
and ssa_aperture, circles are not allowed in DaCHS' s_region (which |
| 1029 |
has a fixed type of spoly). The recommended solution to still |
| 1030 |
have s_region is to add (and index) a custom field in the ssa table |
| 1031 |
and compute some sort of spolys for the coverage. |
| 1032 |
|
| 1033 |
Note: you must say ``dachs imp //obscore`` before anything |
| 1034 |
obscore-related will work. |
| 1035 |
</doc> |
| 1036 |
|
| 1037 |
<LFEED source="_publishCommon"/> |
| 1038 |
<LFEED source="_publishProduct"/> |
| 1039 |
|
| 1040 |
<mixinPar name="s_region" alias="coverage" |
| 1041 |
description="Use ssa_region when the |
| 1042 |
table also mixes in //ssap#simpleCoverage" |
| 1043 |
>NULL</mixinPar> |
| 1044 |
<mixinPar name="obs_collection" alias="collectionName" |
| 1045 |
>\sqlquote{\getParam{ssa_collection}{NULL}}</mixinPar> |
| 1046 |
<mixinPar name="obs_creator_did" alias="creatorDID" |
| 1047 |
>ssa_creatorDID</mixinPar> |
| 1048 |
<mixinPar name="s_dec" alias="dec">degrees(lat(ssa_location))</mixinPar> |
| 1049 |
<mixinPar name="s_ra" alias="ra">degrees(long(ssa_location))</mixinPar> |
| 1050 |
<mixinPar name="em_max" alias="emMax">ssa_specend</mixinPar> |
| 1051 |
<mixinPar name="em_min" alias="emMin">ssa_specstart</mixinPar> |
| 1052 |
<mixinPar name="t_exp_time" alias="expTime">ssa_timeExt</mixinPar> |
| 1053 |
<mixinPar name="s_fov" alias="fov">ssa_aperture</mixinPar> |
| 1054 |
<mixinPar name="instrument_name" alias="instrumentName" |
| 1055 |
>\sqlquote{\getParam{ssa_instrument}{NULL}}</mixinPar> |
| 1056 |
<mixinPar name="o_ucd" alias="oUCD" |
| 1057 |
>\sqlquote{\getParam{ssa_fluxucd}}</mixinPar> |
| 1058 |
<mixinPar name="dataproduct_type" alias="productType">'spectrum'</mixinPar> |
| 1059 |
<mixinPar name="s_resolution" alias="sResolution" |
| 1060 |
>\getParam{ssa_spaceRes}{NULL}/3600.</mixinPar> |
| 1061 |
<mixinPar name="t_max" alias="tMax" |
| 1062 |
>ssa_dateObs+ssa_timeExt/43200.</mixinPar> |
| 1063 |
<mixinPar name="t_min" alias="tMin" |
| 1064 |
>ssa_dateObs-ssa_timeExt/43200.</mixinPar> |
| 1065 |
<mixinPar name="target_name" alias="targetName">ssa_targname</mixinPar> |
| 1066 |
<mixinPar name="target_class" alias="targetClass">ssa_targclass</mixinPar> |
| 1067 |
<mixinPar name="obs_title" alias="title">ssa_dstitle</mixinPar> |
| 1068 |
<mixinPar name="em_ucd" alias="emUCD" |
| 1069 |
>\sqlquote{\getParam{ssa_spectralucd}}</mixinPar> |
| 1070 |
<mixinPar name="obs_publisher_did" alias="did">ssa_pubDID</mixinPar> |
| 1071 |
<mixinPar name="em_xel">ssa_length</mixinPar> |
| 1072 |
</mixinDef> |
| 1073 |
|
| 1074 |
<mixinDef id="publishSSAPMIXC"> |
| 1075 |
<doc> |
| 1076 |
Publish a table mixing in //ssap#view (or the deprecated //ssap#mixc) |
| 1077 |
to ObsTAP. |
| 1078 |
|
| 1079 |
This works like `the //obscore#publish mixin`_ except some defaults apply |
| 1080 |
that copy fields that work analogously in SSAP and in ObsTAP. |
| 1081 |
|
| 1082 |
The columns already set in SSAP are marked as UNDOCUMENTED in the |
| 1083 |
parameter list below. For special situations, you can, of course, |
| 1084 |
override any of the parameters. To find out what they actually mean, |
| 1085 |
mean, refer to `the //obscore#publish mixin`_. |
| 1086 |
|
| 1087 |
Note that this mixin does *not* set coverage (obscore: s_region). |
| 1088 |
This is because although we could make a circle from ssa_location |
| 1089 |
and ssa_aperture, circles are not allowed in DaCHS' s_region (which |
| 1090 |
has a fixed type of spoly). The recommended solution to still |
| 1091 |
have s_region is to add (and index) a custom field; the |
| 1092 |
//ssap#simpleCoverage will do this. |
| 1093 |
|
| 1094 |
Note: you must say ``dachs imp //obscore`` before anything |
| 1095 |
obscore-related will work. |
| 1096 |
</doc> |
| 1097 |
|
| 1098 |
<LFEED source="_publishCommon"/> |
| 1099 |
<LFEED source="_publishProduct"/> |
| 1100 |
|
| 1101 |
<mixinPar name="s_region" alias="coverage" |
| 1102 |
description="Use ssa_region when the |
| 1103 |
table also mixes in //ssap#simpleCoverage" |
| 1104 |
>NULL</mixinPar> |
| 1105 |
<mixinPar name="obs_collection" alias="collectionName" |
| 1106 |
description="Default should work for you" |
| 1107 |
>ssa_collection</mixinPar> |
| 1108 |
<mixinPar name="obs_creator_did" alias="creatorDID" |
| 1109 |
description="Default should work for you" |
| 1110 |
>ssa_creatorDID</mixinPar> |
| 1111 |
<mixinPar name="s_dec" alias="dec" |
| 1112 |
description="Default should work for you; for large data collections, |
| 1113 |
consider having a separate Dec column with a q3c index." |
| 1114 |
>degrees(lat(ssa_location))</mixinPar> |
| 1115 |
<mixinPar name="s_ra" alias="ra" |
| 1116 |
description="Default should work for you; for large data collections, |
| 1117 |
consider having a separate RA column with a q3c index." |
| 1118 |
>degrees(long(ssa_location))</mixinPar> |
| 1119 |
<mixinPar name="em_max" alias="emMax" |
| 1120 |
description="Default should work for you" |
| 1121 |
>ssa_specend</mixinPar> |
| 1122 |
<mixinPar name="em_min" alias="emMin" |
| 1123 |
description="Default should work for you" |
| 1124 |
>ssa_specstart</mixinPar> |
| 1125 |
<mixinPar name="em_xel" alias="emXel" |
| 1126 |
description="Default should work for you" |
| 1127 |
>ssa_length</mixinPar> |
| 1128 |
<mixinPar name="t_exp_time" alias="expTime" |
| 1129 |
description="Default should work for you" |
| 1130 |
>ssa_timeExt</mixinPar> |
| 1131 |
<mixinPar name="s_fov" alias="fov" |
| 1132 |
description="Default should work for you" |
| 1133 |
>ssa_aperture</mixinPar> |
| 1134 |
<mixinPar name="instrument_name" alias="instrumentName" |
| 1135 |
description="Default should work for you" |
| 1136 |
>ssa_instrument</mixinPar> |
| 1137 |
<mixinPar name="facility_name" alias="facilityName" |
| 1138 |
description="Default should work for you" |
| 1139 |
>\sqlquote{\metaSeq{facility}{NULL}}</mixinPar> |
| 1140 |
<mixinPar name="o_ucd" alias="oUCD" |
| 1141 |
description="Default should work for you" |
| 1142 |
>\sqlquote{\getParam{ssa_fluxucd}}</mixinPar> |
| 1143 |
<mixinPar name="dataproduct_type" alias="productType" |
| 1144 |
description="Default should work for you" |
| 1145 |
>ssa_dstype</mixinPar> |
| 1146 |
<mixinPar name="s_resolution" alias="sResolution" |
| 1147 |
description="Default should work for you" |
| 1148 |
>\getParam{ssa_spaceRes}{NULL}/3600.</mixinPar> |
| 1149 |
<mixinPar name="t_max" alias="tMax" |
| 1150 |
description="Default should work for you" |
| 1151 |
>ssa_dateObs+ssa_timeExt/43200.</mixinPar> |
| 1152 |
<mixinPar name="t_min" alias="tMin" |
| 1153 |
description="Default should work for you" |
| 1154 |
>ssa_dateObs-ssa_timeExt/43200.</mixinPar> |
| 1155 |
<mixinPar name="target_name" alias="targetName" |
| 1156 |
description="Default should work for you" |
| 1157 |
>ssa_targname</mixinPar> |
| 1158 |
<mixinPar name="target_class" alias="targetClass" |
| 1159 |
description="Default should work for you" |
| 1160 |
>ssa_targclass</mixinPar> |
| 1161 |
<mixinPar name="obs_title" alias="title" |
| 1162 |
description="Default should work for you" |
| 1163 |
>ssa_dstitle</mixinPar> |
| 1164 |
<mixinPar name="em_ucd" alias="emUCD" |
| 1165 |
description="Default should work for you" |
| 1166 |
>\sqlquote{\getParam{ssa_spectralucd}}</mixinPar> |
| 1167 |
<mixinPar name="o_ucd" alias="oUCD" |
| 1168 |
description="Default should work for you" |
| 1169 |
>\sqlquote{\getParam{ssa_fluxucd}}</mixinPar> |
| 1170 |
<mixinPar name="em_res_power" alias="emResPower" |
| 1171 |
description="Default should work for you" |
| 1172 |
>ssa_specstart/ssa_specres</mixinPar> |
| 1173 |
<mixinPar name="obs_publisher_did" alias="did" |
| 1174 |
description="Default should work for you." |
| 1175 |
>ssa_pubDID</mixinPar> |
| 1176 |
<mixinPar name="s_xel1" |
| 1177 |
description="You shouldn't use SSA for cubes.">1</mixinPar> |
| 1178 |
<mixinPar name="s_xel2" |
| 1179 |
description="You shouldn't use SSA for cubes.">1</mixinPar> |
| 1180 |
</mixinDef> |
| 1181 |
|
| 1182 |
<mixinDef id="publishObscoreLike"> |
| 1183 |
<doc> |
| 1184 |
Publish a table that already has large parts of the obscore schema. |
| 1185 |
|
| 1186 |
This has parameters called like the corresponding obscore columns |
| 1187 |
that also default to taking their data columns named like them. |
| 1188 |
Use this when you already have, by and large, and obscore structure |
| 1189 |
in your source table. |
| 1190 |
|
| 1191 |
Note that this will *not* do the right thing with product#table |
| 1192 |
instances by default. For these, you will have to manually |
| 1193 |
map access_url, access_format, and access_estsize. |
| 1194 |
</doc> |
| 1195 |
|
| 1196 |
<LOOP> |
| 1197 |
<codeItems> |
| 1198 |
for column in context.getById("ObsCore").columns: |
| 1199 |
yield {'name': column.name, 'description': column.description} |
| 1200 |
</codeItems> |
| 1201 |
<events> |
| 1202 |
<mixinPar name="\name" |
| 1203 |
description="\description">\name</mixinPar> |
| 1204 |
</events> |
| 1205 |
</LOOP> |
| 1206 |
|
| 1207 |
<LFEED source="_manageObscoreClause"/> |
| 1208 |
</mixinDef> |
| 1209 |
|
| 1210 |
<table id="emptyobscore" onDisk="True" adql="hidden" system="True"> |
| 1211 |
<meta name="description">An empty table having all columns of the |
| 1212 |
obscore table. Useful internally, and sometimes for tricky queries. |
| 1213 |
</meta> |
| 1214 |
<mixin |
| 1215 |
access_url="access_url" |
| 1216 |
calib_level="calib_level" |
| 1217 |
obs_collection="obs_collection" |
| 1218 |
s_region="s_region" |
| 1219 |
obs_creator_did="obs_creator_did" |
| 1220 |
obs_publisher_did="obs_publisher_did" |
| 1221 |
access_format="access_format" |
| 1222 |
dataproduct_type="dataproduct_type" |
| 1223 |
obs_id="obs_id" |
| 1224 |
preview="NULL" |
| 1225 |
access_estsize="access_estsize">publish</mixin> |
| 1226 |
<FEED source="obscore-columns"/> |
| 1227 |
<adql>hidden</adql> |
| 1228 |
</table> |
| 1229 |
|
| 1230 |
<data id="makeSources" updating="True"> |
| 1231 |
<make table="_obscoresources"/> |
| 1232 |
<make table="emptyobscore"/> |
| 1233 |
</data> |
| 1234 |
|
| 1235 |
<data id="create"> |
| 1236 |
<!-- the view is created from prescriptions in _obscoresources --> |
| 1237 |
<make table="ObsCore"> |
| 1238 |
<LOOP> |
| 1239 |
<codeItems> |
| 1240 |
if base.getConfig("ivoa", "materialiseObscore"): |
| 1241 |
yield {"createObscoreType": "preImport"} |
| 1242 |
else: |
| 1243 |
yield {"createObscoreType": "postCreation"} |
| 1244 |
</codeItems> |
| 1245 |
<events passivate="True"> |
| 1246 |
<FEED source="create-obscore-view" scriptType="\createObscoreType"/> |
| 1247 |
</events> |
| 1248 |
</LOOP> |
| 1249 |
|
| 1250 |
<script name="unpublish obscore DM" type="beforeDrop" lang="SQL"> |
| 1251 |
delete from tap_schema.supportedmodels |
| 1252 |
where dmivorn ilike 'ivo://ivoa.net/std/obscore#%' |
| 1253 |
</script> |
| 1254 |
</make> |
| 1255 |
</data> |
| 1256 |
|
| 1257 |
<data id="recover" updating="True" recreateAfter="create" auto="False"> |
| 1258 |
<!-- removes "bad" entries from obscoresources --> |
| 1259 |
<sources items="cleanup"/> |
| 1260 |
<nullGrammar/> |
| 1261 |
<make table="_obscoresources"> |
| 1262 |
<script name="Clean bad entries from obscore sources" |
| 1263 |
type="newSource" lang="python"> |
| 1264 |
q = base.UnmanagedQuerier(table.connection) |
| 1265 |
|
| 1266 |
# first, remove all tables that don't exist any more |
| 1267 |
for tn, in q.connection.query( |
| 1268 |
"select tablename from ivoa._obscoresources"): |
| 1269 |
if not q.getTableType(tn): |
| 1270 |
q.connection.execute("delete from ivoa._obscoresources where" |
| 1271 |
" tablename=%(tn)s", locals()) |
| 1272 |
|
| 1273 |
# then, remove tables with bad view contributions |
| 1274 |
for tn, statement in q.connection.query( |
| 1275 |
"select tablename, sqlfragment from ivoa._obscoresources"): |
| 1276 |
with base.getUntrustedConn() as subconn: |
| 1277 |
try: |
| 1278 |
_ = list(subconn.query(statement+" LIMIT 1")) |
| 1279 |
except base.DBError: |
| 1280 |
q.connection.execute("delete from ivoa._obscoresources where" |
| 1281 |
" tablename=%(tn)s", locals()) |
| 1282 |
</script> |
| 1283 |
</make> |
| 1284 |
</data> |
| 1285 |
|
| 1286 |
<data id="refreshAfterSchemaUpdate" auto="False" updating="True"> |
| 1287 |
<recreateAfter>create</recreateAfter> |
| 1288 |
<sources item="dummy"/> |
| 1289 |
<nullGrammar/> |
| 1290 |
<make table="ObsCore"> |
| 1291 |
<script name="update all obscore definitions" type="newSource" |
| 1292 |
lang="python"> |
| 1293 |
from gavo import rsc |
| 1294 |
from gavo.rscdef import scripting |
| 1295 |
|
| 1296 |
def updateObscore(conn, tableDefs): |
| 1297 |
obscoreRD = base.caches.getRD("//obscore") |
| 1298 |
runner = scripting.PythonScriptRunner( |
| 1299 |
obscoreRD.getById("addTableToObscoreSources")) |
| 1300 |
|
| 1301 |
for tableDef in tableDefs: |
| 1302 |
try: |
| 1303 |
base.ui.notifyNewSource(tableDef.getQName()) |
| 1304 |
depTable = rsc.TableForDef(tableDef, connection=conn) |
| 1305 |
runner.run(depTable) |
| 1306 |
base.ui.notifySourceFinished() |
| 1307 |
except Exception as msg: |
| 1308 |
base.ui.notifyWarning(f"Obscore update failed: {msg}") |
| 1309 |
|
| 1310 |
if table.getTableType("ivoa._obscoresources") is not None: |
| 1311 |
srcTables, mth = [], base.caches.getMTH(None) |
| 1312 |
for r in table.connection.query( |
| 1313 |
"select tablename from ivoa._obscoresources"): |
| 1314 |
try: |
| 1315 |
srcTables.append(mth.getTableDefForTable(r[0])) |
| 1316 |
except base.RDNotFound as exc: |
| 1317 |
base.ui.notifyWarning("While updating obscore: table" |
| 1318 |
" %s declared in vanished RD %s purged from" |
| 1319 |
" ivoa.obscore."%(r[0], exc.args[0])) |
| 1320 |
updateObscore(table.connection, srcTables) |
| 1321 |
</script> |
| 1322 |
</make> |
| 1323 |
</data> |
| 1324 |
|
| 1325 |
<service id="dl" allowed="dlmeta"> |
| 1326 |
<meta name="title">\getConfig{web}{sitename} Obscore Datalink</meta> |
| 1327 |
<meta name="description"> |
| 1328 |
A datalink service accompanying obscore. This will redirect to data |
| 1329 |
collection-specific datalink services if they exist or return extremely |
| 1330 |
basic datalinks otherwise. |
| 1331 |
</meta> |
| 1332 |
|
| 1333 |
<datalinkCore> |
| 1334 |
<descriptorGenerator> |
| 1335 |
<setup> |
| 1336 |
<code> |
| 1337 |
from gavo import svcs |
| 1338 |
from gavo.protocols import products |
| 1339 |
|
| 1340 |
class ObscoreDescriptor(ProductDescriptor): |
| 1341 |
def __init__(self, |
| 1342 |
pubDID, accessURL, accessSize, |
| 1343 |
mime, preview, sourceTable): |
| 1344 |
ProductDescriptor.__init__(self, pubDID, None, |
| 1345 |
accessURL, mime, |
| 1346 |
sourceTable=sourceTable, preview=preview) |
| 1347 |
self.accessSize = accessSize |
| 1348 |
self.suppressAutoLinks = True |
| 1349 |
|
| 1350 |
currentHost = base.getCurrentServerURL() |
| 1351 |
</code> |
| 1352 |
</setup> |
| 1353 |
<code> |
| 1354 |
with base.getTableConn() as conn: |
| 1355 |
res = list(conn.queryToDicts( |
| 1356 |
"SELECT" |
| 1357 |
" access_url, access_format, access_estsize," |
| 1358 |
" preview, source_table" |
| 1359 |
" FROM ivoa.obscore" |
| 1360 |
" WHERE obs_publisher_did=%(pubdid)s", |
| 1361 |
{"pubdid": pubDID})) |
| 1362 |
|
| 1363 |
if not res: |
| 1364 |
return DatalinkFault.NotFoundFault(pubDID, |
| 1365 |
"No data set with pubDID %s known here"%pubDID) |
| 1366 |
ocrow = res[0] |
| 1367 |
|
| 1368 |
td = base.getTableDefForTable(conn, ocrow["source_table"]) |
| 1369 |
dlid = base.getMetaText(td, |
| 1370 |
"_associatedDatalinkService.serviceId", default=None) |
| 1371 |
if dlid: |
| 1372 |
dlsvc = td.rd.getById(dlid) |
| 1373 |
dlurl = dlsvc.getURL("dlmeta") |
| 1374 |
raise svcs.Found(dlurl+"?ID="+urllib.parse.quote(pubDID)) |
| 1375 |
|
| 1376 |
return ObscoreDescriptor( |
| 1377 |
pubDID, |
| 1378 |
products.formatProductLink(ocrow["access_url"], currentHost), |
| 1379 |
ocrow["access_estsize"]*1024, |
| 1380 |
ocrow["access_format"], |
| 1381 |
products.formatProductLink(ocrow["preview"], currentHost), |
| 1382 |
ocrow["source_table"]) |
| 1383 |
</code> |
| 1384 |
</descriptorGenerator> |
| 1385 |
|
| 1386 |
<metaMaker> |
| 1387 |
<code> |
| 1388 |
yield descriptor.makeLink( |
| 1389 |
descriptor.accessPath, |
| 1390 |
description="The main data product", |
| 1391 |
semantics="#this", |
| 1392 |
contentType=descriptor.mime, |
| 1393 |
contentLength=descriptor.accessSize) |
| 1394 |
|
| 1395 |
if descriptor.preview: |
| 1396 |
yield descriptor.makeLink( |
| 1397 |
descriptor.preview, |
| 1398 |
description="A preview or thumbnail of the data", |
| 1399 |
semantics="#preview") |
| 1400 |
</code> |
| 1401 |
</metaMaker> |
| 1402 |
</datalinkCore> |
| 1403 |
</service> |
| 1404 |
|
| 1405 |
<FEED source="%#obscore-overrides"/> |
| 1406 |
</resource> |