| 1 |
<!-- definitions related to supporting SIAPv2. In DaCHS, you can have |
| 2 |
both a global SIAv2 service over the obscore view and individual, |
| 3 |
collection-specific SIAv2 services; the obscore-based is the |
| 4 |
#sitewide item below that you can publish using dachs pub //siap2. --> |
| 5 |
|
| 6 |
<resource resdir="__system" schema="dc"> |
| 7 |
<STREAM id="POSpar"> |
| 8 |
<doc>A stream defining a SIAPv2-style POS par over an obscore table. |
| 9 |
|
| 10 |
You can pass the name of a pgsphere geometry in the geom_name macro. |
| 11 |
The default is set up for ivoa.obscore. |
| 12 |
</doc> |
| 13 |
<DEFAULTS geom_name="s_region"/> |
| 14 |
<condDesc> |
| 15 |
<inputKey name="POS" type="text" multiplicity="multiple" std="True" |
| 16 |
tablehead="Position" |
| 17 |
description="A spatial constraint using SIAPv2 CIRCLE, RANGE, or |
| 18 |
POLYGON shapes and respective values in decimal degrees."> |
| 19 |
</inputKey> |
| 20 |
<phraseMaker> |
| 21 |
<setup> |
| 22 |
<code> |
| 23 |
from gavo.protocols import siap |
| 24 |
</code> |
| 25 |
</setup> |
| 26 |
<code> |
| 27 |
for inStr in inPars["POS"]: |
| 28 |
yield '\geom_name &&%%(%s)s'%( |
| 29 |
base.getSQLKey("pos", siap.parseSIAP2Geometry(inStr), outPars)) |
| 30 |
</code> |
| 31 |
</phraseMaker> |
| 32 |
</condDesc> |
| 33 |
</STREAM> |
| 34 |
|
| 35 |
<procDef id="intervalMatcher" type="phraseMaker"> |
| 36 |
<doc> |
| 37 |
A DALI-style phrase maker that matches an interval against a pair |
| 38 |
of lower/upper bound columns. |
| 39 |
|
| 40 |
This is for using with multiplicity=multiple inputKeys. |
| 41 |
</doc> |
| 42 |
<setup> |
| 43 |
<par name="loColName" description="Name of the database column |
| 44 |
containing the lower bound"/> |
| 45 |
<par name="hiColName" description="Name of the database column |
| 46 |
containing the upper bound"/> |
| 47 |
</setup> |
| 48 |
<code> |
| 49 |
name = inputKeys[0].name |
| 50 |
for lower, upper in inPars[name]: |
| 51 |
# make BAND0=lowerVal predictable: build dict in two steps |
| 52 |
pars = { |
| 53 |
"lowerVal": base.getSQLKey(name, lower, outPars), |
| 54 |
"upperCol": hiColName, |
| 55 |
"lowerCol": loColName,} |
| 56 |
pars["upperVal"] = base.getSQLKey(name, upper, outPars) |
| 57 |
|
| 58 |
yield ("%%(%(upperVal)s)s >= %(lowerCol)s" |
| 59 |
" AND %(upperCol)s >= %%(%(lowerVal)s)s")%pars |
| 60 |
</code> |
| 61 |
</procDef> |
| 62 |
|
| 63 |
|
| 64 |
<procDef id="intervalConstraint" type="phraseMaker"> |
| 65 |
<doc> |
| 66 |
A DALI-style phrase maker that matches an input interval against a |
| 67 |
a single value in the database. |
| 68 |
|
| 69 |
This is for using with multiplicity=multiple inputKeys. |
| 70 |
</doc> |
| 71 |
<setup> |
| 72 |
<par name="colName" description="Name of the database column |
| 73 |
containing the value constrained."/> |
| 74 |
</setup> |
| 75 |
<code> |
| 76 |
name = inputKeys[0].name |
| 77 |
for lower, upper in inPars[name]: |
| 78 |
yield ("%(colName)s BETWEEN" |
| 79 |
" %%(%(lowerVal)s)s AND %%(%(upperVal)s)s")%{ |
| 80 |
"upperVal": base.getSQLKey(name, upper, outPars), |
| 81 |
"lowerVal": base.getSQLKey(name, lower, outPars), |
| 82 |
"colName": colName } |
| 83 |
</code> |
| 84 |
</procDef> |
| 85 |
|
| 86 |
|
| 87 |
<procDef id="equalityConstraint" type="phraseMaker"> |
| 88 |
<doc> |
| 89 |
A DALI-style phrase maker that matches an input literally. |
| 90 |
|
| 91 |
This is for using with multiplicity=multiple inputKeys. |
| 92 |
</doc> |
| 93 |
<setup> |
| 94 |
<par name="colName" description="Name of the database column |
| 95 |
containing the value constrained."/> |
| 96 |
</setup> |
| 97 |
<code> |
| 98 |
name = inputKeys[0].name |
| 99 |
yield "%(colName)s in %%(%(key)s)s"%{ |
| 100 |
"colName": colName, |
| 101 |
"key": base.getSQLKey(name, inPars[name], outPars)} |
| 102 |
</code> |
| 103 |
</procDef> |
| 104 |
|
| 105 |
|
| 106 |
<STREAM id="BANDpar"> |
| 107 |
<doc>A stream defining the SIAPv2 BAND par over an obscore-like table. |
| 108 |
|
| 109 |
For non-obscore use, you can the min/max column names in the |
| 110 |
min_name and max_name macros. |
| 111 |
</doc> |
| 112 |
<DEFAULTS min_name="em_min" max_name="em_max"/> |
| 113 |
<condDesc> |
| 114 |
<inputKey name="BAND" type="double precision[2]" std="True" |
| 115 |
multiplicity="multiple" xtype="interval" |
| 116 |
tablehead="Wavelength" |
| 117 |
description="Wavelength interval that should intersect with |
| 118 |
the dataset coverage"/> |
| 119 |
<phraseMaker procDef="//siap2#intervalMatcher"> |
| 120 |
<bind key="loColName">"\min_name"</bind> |
| 121 |
<bind key="hiColName">"\max_name"</bind> |
| 122 |
</phraseMaker> |
| 123 |
</condDesc> |
| 124 |
</STREAM> |
| 125 |
|
| 126 |
<STREAM id="TIMEpar"> |
| 127 |
<doc>A stream defining the SIAPv2 TIME par over an obscore-like table. |
| 128 |
|
| 129 |
For non-obscore use, you can the min/max column names in the |
| 130 |
min_name and max_name macros. |
| 131 |
</doc> |
| 132 |
<DEFAULTS min_name="t_min" max_name="t_max"/> |
| 133 |
<condDesc> |
| 134 |
<inputKey name="TIME" type="double precision[2]" std="True" |
| 135 |
multiplicity="multiple" xtype="interval" |
| 136 |
tablehead="Time" |
| 137 |
description="Time interval that should intersect with |
| 138 |
the dataset coverage"/> |
| 139 |
<phraseMaker procDef="//siap2#intervalMatcher"> |
| 140 |
<bind key="loColName">"\min_name"</bind> |
| 141 |
<bind key="hiColName">"\max_name"</bind> |
| 142 |
</phraseMaker> |
| 143 |
</condDesc> |
| 144 |
</STREAM> |
| 145 |
|
| 146 |
<STREAM id="POLpar"> |
| 147 |
<doc>A stream defining the SIAPv2 POL par over an obscore-like table |
| 148 |
(i.e., one with pol_states). |
| 149 |
|
| 150 |
This can have multiple values, and the pol_states in obscore can have |
| 151 |
multiple states. Hence, we need a somewhat tricky phrase maker. |
| 152 |
</doc> |
| 153 |
<DEFAULTS min_name="t_min" _max_name="t_max"/> |
| 154 |
<condDesc> |
| 155 |
<inputKey name="POL" type="text" std="True" |
| 156 |
multiplicity="multiple" |
| 157 |
tablehead="Polarisation" |
| 158 |
description="Polarisation states as per Obscore (i.e., from |
| 159 |
the set I Q U V RR LL RL LR XX YY XY YX POLI POLA"/> |
| 160 |
<phraseMaker> |
| 161 |
<code> |
| 162 |
name = inputKeys[0].name |
| 163 |
for val in inPars[name]: |
| 164 |
yield 'pol_states LIKE %%(%s)s'%( |
| 165 |
base.getSQLKey(name, "%%/%s/%%"%val, outPars)) |
| 166 |
</code> |
| 167 |
</phraseMaker> |
| 168 |
</condDesc> |
| 169 |
</STREAM> |
| 170 |
|
| 171 |
|
| 172 |
<LOOP> |
| 173 |
<csvItems> |
| 174 |
parName, colName, tablehead, unit, description |
| 175 |
FOV, s_fov, Field of View, deg, the field of view of the observation |
| 176 |
SPATRES, s_resolution, Spat. Res., deg, the spatial resolution of the image(s) |
| 177 |
SPECRP, em_res_power,Res. Power, , the spectral resolving power λ/Δλ in spectrally resolved observations |
| 178 |
EXPTIME, t_exptime, Exposure Time, s, the integration times of the observation |
| 179 |
TIMERES, t_resolution,Time res., s, the (absolute) resolution on the time axis |
| 180 |
</csvItems> |
| 181 |
<events passivate="True"> |
| 182 |
<STREAM id="\parName\+par"> |
| 183 |
<doc>A stream defining the SIAPv2 \parName parameter over an |
| 184 |
obscore-like table (i.e., one with \colName). |
| 185 |
|
| 186 |
For non-obscore use, you can override the colName macro to use |
| 187 |
another column than \colName. |
| 188 |
</doc> |
| 189 |
<DEFAULTS colName="\colName"/> |
| 190 |
<condDesc> |
| 191 |
<inputKey name="\parName" type="real[2]" xtype="interval" std="True" |
| 192 |
unit="\unit" |
| 193 |
multiplicity="multiple" |
| 194 |
tablehead="\tablehead" |
| 195 |
description="Lower and upper bound for \description"/> |
| 196 |
<phraseMaker procDef="//siap2#intervalConstraint"> |
| 197 |
<bind key="colName">"\colName"</bind> |
| 198 |
</phraseMaker> |
| 199 |
</condDesc> |
| 200 |
</STREAM> |
| 201 |
</events> |
| 202 |
</LOOP> |
| 203 |
|
| 204 |
|
| 205 |
<LOOP> |
| 206 |
<csvItems> |
| 207 |
parName, colName, tablehead, type, description |
| 208 |
ID, obs_publisher_did, DID, text, "A dataset identifier to match. Note that contrary to the SIAP v2 REC, we do not compare the IVOIDs case-insensitively. This should not be an issue if you got the IVOID from this service. For IVOIDs obtained in other ways, you may need to use ILIKE or a similar facility through ObsTAP." |
| 209 |
COLLECTION, obs_collection, Collection, text, A name of a data collection within the service (use ObsTAP to find out the possible values). |
| 210 |
FACILITY, facility_name, Facility, text, A name of a facility (usually a telescope) used to make the observation. |
| 211 |
INSTRUMENT, instrument_name, Instrument, text, A name of an instrument used to acquire the data. |
| 212 |
DPTYPE, dataproduct_type, Type, text, Select either image or cube. |
| 213 |
CALIB, calib_level, Calib. Level,smallint, "Calibration level of the data (0=raw data .. 3=processed science-ready data)" |
| 214 |
TARGET, target_name, Target, text, A name of an observation target. |
| 215 |
FORMAT, access_format, Format, text, Media type (like application/fits) or similar of the data product searched |
| 216 |
</csvItems> |
| 217 |
<events passivate="True"> |
| 218 |
<STREAM id="\parName\+par"> |
| 219 |
<doc>A stream defining the SIAPv2 \parName parameter over an |
| 220 |
obscore-like table (i.e., one with \colName). |
| 221 |
</doc> |
| 222 |
<DEFAULTS colName="\colName"/> |
| 223 |
<condDesc> |
| 224 |
<inputKey name="\parName" type="\type" std="True" |
| 225 |
multiplicity="multiple" |
| 226 |
tablehead="\tablehead" |
| 227 |
description="\description"/> |
| 228 |
<phraseMaker procDef="//siap2#equalityConstraint"> |
| 229 |
<bind key="colName">"\colName"</bind> |
| 230 |
</phraseMaker> |
| 231 |
</condDesc> |
| 232 |
</STREAM> |
| 233 |
</events> |
| 234 |
</LOOP> |
| 235 |
|
| 236 |
<STREAM id="parameters"> |
| 237 |
<LOOP listItems="POS BAND TIME POL FOV SPATRES SPECRP EXPTIME TIMERES |
| 238 |
ID COLLECTION FACILITY INSTRUMENT DPTYPE CALIB TARGET FORMAT"> |
| 239 |
<events passivate="True"> |
| 240 |
<FEED source="\item\+par"/> |
| 241 |
</events> |
| 242 |
</LOOP> |
| 243 |
</STREAM> |
| 244 |
|
| 245 |
<mixinDef id="pgs"> |
| 246 |
<doc> |
| 247 |
A mixin pulling in all columns necessary to support SIAP2. |
| 248 |
|
| 249 |
This is pulls in all obscore columns, including any you define locally |
| 250 |
in %#obscore-extracolumns. In DaCHS, we additionally have the columns |
| 251 |
coming from the products table. This latter fact means that the grammar |
| 252 |
filling tables mixing this in will need a `//products#define`_ rowfilter. |
| 253 |
|
| 254 |
To feed these tables, use the `//siap2#computePGS`_ and |
| 255 |
the `//siap2#setMeta`_ applies in the rowmaker. |
| 256 |
|
| 257 |
*Added in 2.7.3.* |
| 258 |
</doc> |
| 259 |
<mixinPar key="have_bandpass_id" |
| 260 |
description="Should the target table have an almost SIAP1-compatible |
| 261 |
bandpass_id column containing a free description of the filter |
| 262 |
(or other sort of bandpass)? It doesn't hurt to have it if |
| 263 |
you have that sort of information (since 2.11.1).">False</mixinPar> |
| 264 |
|
| 265 |
<FEED source="//products#hackProductsData"/> |
| 266 |
<events> |
| 267 |
<FEED source="//products#tableRules" accrefName="access_url"/> |
| 268 |
<FEED source="//obscore#obscore-columns"> |
| 269 |
<!-- we don't want explicit preview handling here; for SIAP2, |
| 270 |
people shouldn't store extra URIs for those (almost) ever. |
| 271 |
If we want preview columns in SIA (and nobody looks at them yet), |
| 272 |
let's compute them in the core. --> |
| 273 |
<PRUNE name="preview"/> |
| 274 |
</FEED> |
| 275 |
</events> |
| 276 |
<processEarly><code> |
| 277 |
from gavo import rscdef |
| 278 |
if base.parseBooleanLiteral(mixinPars["have_bandpass_id"]): |
| 279 |
substrate.feedObject("column", |
| 280 |
base.makeStruct( |
| 281 |
rscdef.Column, |
| 282 |
name="bandpass_id", type="text", |
| 283 |
ucd="instr.bandpass", |
| 284 |
tablehead="Bandpass", |
| 285 |
description="Free-form name of the bandpass (filter, detector," |
| 286 |
" whatever else defines the spectral response) this" |
| 287 |
" observation was taken in.", |
| 288 |
verbLevel=10)) |
| 289 |
</code></processEarly> |
| 290 |
</mixinDef> |
| 291 |
|
| 292 |
<procDef type="apply" id="computePGS"> |
| 293 |
<doc> |
| 294 |
Computes the spatial coverage of an image based on WCS keys it |
| 295 |
looks for in the rawdict. |
| 296 |
|
| 297 |
The minimum is CRVAL1, CRVAL2, CRPIX1, CRPIX2, CRVAL1, CRVAL2, CUNIT1, |
| 298 |
CUNIT2, NAXISn, and CDi_j or CDELTn. Interpretation of more |
| 299 |
WCS may or may not happen. You can override the indexes of the |
| 300 |
spatial axes using naxis, which will of course change the |
| 301 |
parameter names, too. |
| 302 |
|
| 303 |
Records without or with insufficient wcs keys are furnished with |
| 304 |
all-NULL spatial columns if the missingIsError setup parameter |
| 305 |
is False, else they bomb out with a DataError (the default). |
| 306 |
|
| 307 |
This writes directly into rowdict; do *not* use ``idmaps="*"`` |
| 308 |
on rowmakers with computePGS. |
| 309 |
|
| 310 |
*Added in 2.7.3.* |
| 311 |
</doc> |
| 312 |
|
| 313 |
<setup imports="gavo.protocols.siap"> |
| 314 |
<par name="missingIsError" description="Throw an exception when |
| 315 |
no WCS information can be located.">True</par> |
| 316 |
<par name="naxis" description="Comma-separated list of integer |
| 317 |
axis indices (1=first) to be considered for WCS">"1,2"</par> |
| 318 |
<par name="ignoreBrokenWCS" |
| 319 |
description="If building the WCS transformation fails, null out |
| 320 |
the WCS parameters and continue with a warning (since 2.9.3)" |
| 321 |
>False</par> |
| 322 |
<code> |
| 323 |
WCSKEYS = ["s_region", "s_ra", "s_dec", "s_fov", "s_pixel_scale", |
| 324 |
"s_resolution"] |
| 325 |
NAXIS = [int(v) for v in naxis.split(",")] |
| 326 |
|
| 327 |
class PixelGauge(object): |
| 328 |
"""is a container for information about pixel sizes. |
| 329 |
|
| 330 |
It is constructed with an wcs.WCS instance and an (x, y) |
| 331 |
pair of pixel coordinates that should be close to the center |
| 332 |
of the frame. |
| 333 |
""" |
| 334 |
def __init__(self, wcs, centerPix): |
| 335 |
self.centerPos = coords.pix2sky(wcs, centerPix) |
| 336 |
self.pixelScale = coords.getPixelSizeDeg(wcs) |
| 337 |
offCenterPos = coords.pix2sky(wcs, |
| 338 |
(centerPix[0]+1, centerPix[1]+1)) |
| 339 |
|
| 340 |
|
| 341 |
def computeFromWCS(vars, wcs, result): |
| 342 |
"""fills the spatial obscore fields in result from what it |
| 343 |
can make out in the wcs header. |
| 344 |
|
| 345 |
vars should be a FITS image header. |
| 346 |
""" |
| 347 |
result["mime"] = "application/fits" |
| 348 |
result["s_ra"], result["s_dec" |
| 349 |
] = coords.getCenterFromWCSFields(wcs) |
| 350 |
result["nAxes"] = int(vars["NAXIS"]) |
| 351 |
axeInds = range(1, result["nAxes"]+1) |
| 352 |
dims = list(int(vars["NAXIS%d"%i]) |
| 353 |
for i in axeInds) |
| 354 |
result["s_xel1"] = dims[0] |
| 355 |
result["s_xel2"] = dims[1] |
| 356 |
|
| 357 |
pixelGauge = PixelGauge(wcs, (dims[0]/2., dims[1]/2.)) |
| 358 |
result["s_resolution"] = min(r*3600 |
| 359 |
for r in coords.getPixelSizeDeg(wcs)) |
| 360 |
result["s_pixel_scale"] = result["s_resolution"] |
| 361 |
result["s_region"] = coords.getSpolyFromWCSFields(wcs) |
| 362 |
# FoV computation assumes we always have rectangular |
| 363 |
# (4-vertex) polygons. Can we do better than that? |
| 364 |
vertices = result["s_region"].asCooPairs() |
| 365 |
result["s_fov"] = coords.getGCDist(vertices[0], vertices[2]) |
| 366 |
|
| 367 |
def nullOutWCS(result): |
| 368 |
"""clears all wcs fields, plus the ones in additonalKeys. |
| 369 |
""" |
| 370 |
for key in WCSKEYS: |
| 371 |
result[key] = None |
| 372 |
|
| 373 |
def addWCS(vars, result): |
| 374 |
wcs = coords.getWCS(vars, naxis=NAXIS) |
| 375 |
if wcs is None: |
| 376 |
result["s_xel1"] = int(vars["NAXIS1"]) |
| 377 |
result["s_xel2"] = int(vars["NAXIS2"]) |
| 378 |
if missingIsError: |
| 379 |
raise base.DataError("No WCS information") |
| 380 |
else: |
| 381 |
nullOutWCS(result) |
| 382 |
else: |
| 383 |
computeFromWCS(vars, wcs, result) |
| 384 |
</code> |
| 385 |
</setup> |
| 386 |
<code> |
| 387 |
try: |
| 388 |
addWCS(vars, result) |
| 389 |
except KeyError: |
| 390 |
# presumably some basic FITS keyword missing |
| 391 |
if missingIsError: |
| 392 |
raise |
| 393 |
except Exception as msg: |
| 394 |
# somehow broken WCS |
| 395 |
if ignoreBrokenWCS: |
| 396 |
nullOutWCS(result) |
| 397 |
base.ui.notifyWarning(f"Broken WCS ignored ({msg})") |
| 398 |
else: |
| 399 |
raise |
| 400 |
</code> |
| 401 |
</procDef> |
| 402 |
|
| 403 |
<procDef type="apply" id="setMeta"> |
| 404 |
<doc> |
| 405 |
Fills non-spatial information in an obscore record for an image. |
| 406 |
|
| 407 |
If you define the bandpasses yourself, do *not* change |
| 408 |
bandpassUnit and give all values in metres. |
| 409 |
|
| 410 |
For optical images, we recommend to fill out bandpassId and then |
| 411 |
let the //siap2#getBandFromFilter apply compute the actual |
| 412 |
limits. |
| 413 |
|
| 414 |
Do *not* use ``idmaps="*"`` when using this procDef; it writes |
| 415 |
directly into result, and you would be clobbering what it does. |
| 416 |
|
| 417 |
The proc parameters use the obscore names wherever possible, |
| 418 |
but accept most of the names of the version 1 ``//siap#setMeta`` |
| 419 |
and the ``//obscore#publishSIAP`` mixins. |
| 420 |
easy migration. |
| 421 |
|
| 422 |
*Added in 2.7.3.* |
| 423 |
</doc> |
| 424 |
<setup> |
| 425 |
<par key="dataproduct_type" alias="productType" |
| 426 |
description="Type of data in |
| 427 |
this table. Must be a constant string taken from |
| 428 |
https://www.ivoa.net/rdf/product-type/">"image"</par> |
| 429 |
<par key="dataproduct_subtype" late="True" |
| 430 |
description="Closer specification of the sort of data this row |
| 431 |
is for. It is almost always a good idea to leave this at None" |
| 432 |
>None</par> |
| 433 |
|
| 434 |
<par key="calib_level" late="True" alias="calibLevel" |
| 435 |
description="Calibration level |
| 436 |
of the image described here (see obscore docs for details). |
| 437 |
Images having WCS will generally have a 2 or 3 (if heavily |
| 438 |
resampled or stacked) here." |
| 439 |
>2</par> |
| 440 |
|
| 441 |
<par key="obs_collection" late="True" alias="collectionName" |
| 442 |
description="A shorthand |
| 443 |
for the data collection this image belongs to. Make it really |
| 444 |
terse. Freetext otherwise." |
| 445 |
/> |
| 446 |
<par key="obs_id" late="True" description="An identifier for |
| 447 |
an observation if that has yielded multiple rows. Keep this |
| 448 |
None otherwise (DaCHS will then fill in the publisher DID)." |
| 449 |
>None</par> |
| 450 |
<par key="obs_title" alias="title" late="True" description="This |
| 451 |
should, in as few characters as possible, convey some idea what |
| 452 |
the image will show (e.g., instrument, object, bandpass)." |
| 453 |
>None</par> |
| 454 |
<par key="obs_publisher_did" late="True" |
| 455 |
description="Dataset identifier assigned by you. If you want |
| 456 |
to re-publish this dataset in obscore, make this non-NULL." |
| 457 |
>\standardPubDID</par> |
| 458 |
<par key="obs_creator_did" late="True" alias="creatorDID" |
| 459 |
description="Identifier assigned by the creator. This is |
| 460 |
rarely used." |
| 461 |
>None</par> |
| 462 |
|
| 463 |
<par key="target_name" late="True" alias="targetName" |
| 464 |
description="Target of a targeted observation. Choose something |
| 465 |
Simbad can resolve if you can.">None</par> |
| 466 |
<par key="target_class" late="True" alias="targetClass" |
| 467 |
description="Class of the target of a targeted observation. |
| 468 |
Choose from http://www.ivoa.net/rdf/object-type (or have |
| 469 |
the vocabulary extended if your object type is missing)" |
| 470 |
>None</par> |
| 471 |
|
| 472 |
<par key="t_min" late="True" alias="tMin" |
| 473 |
description="MJD the first photons on this image were received. |
| 474 |
If you leave this as None, DaCHS will try to fill it up from |
| 475 |
dateObs and t_exptime." |
| 476 |
>None</par> |
| 477 |
<par key="t_max" late="True" alias="tMax" |
| 478 |
description="MJD the last photons on this image were received. |
| 479 |
If you leave this as None, DaCHS will try to fill it up from |
| 480 |
dateObs and t_exptime." |
| 481 |
>None</par> |
| 482 |
<par key="t_exptime" late="True" |
| 483 |
description="Total time in seconds the detector was collecting |
| 484 |
photons." |
| 485 |
>None</par> |
| 486 |
<par key="t_resolution" late="True" alias="tResolution" |
| 487 |
description="Minimal significant resolution on a time axis. |
| 488 |
Unless you have a space-time cube, leave at None." |
| 489 |
>None</par> |
| 490 |
|
| 491 |
<par key="em_min" alias="bandpassLo" late="True" |
| 492 |
description="Lower value of the wavelength covered, in meters |
| 493 |
(you usually want to use `//siap2#getBandFromFilter`_ to fill this |
| 494 |
from bandpassId)." |
| 495 |
>None</par> |
| 496 |
<par key="em_max" alias="bandpassHi" late="True" |
| 497 |
description="Upper value of the wavelength covered, in meters |
| 498 |
(you usually want to use `//siap2#getBandFromFilter`_ to fill this |
| 499 |
from bandpassId)." |
| 500 |
>None</par> |
| 501 |
<par key="em_res_power" late="True" description="Spectral |
| 502 |
resolving power λ/Δλ. Unless you have a spectral cube, leave |
| 503 |
this at None." |
| 504 |
>None</par> |
| 505 |
<par key="em_ucd" description="Nature of the spectral axis |
| 506 |
in this data collection (when you have a spectral cube, |
| 507 |
probably one of em.freq, em.wl, or em.energy)" |
| 508 |
>None</par> |
| 509 |
|
| 510 |
<par key="o_ucd" alias="oUCD" |
| 511 |
description="UCD for the observable in this data collection" |
| 512 |
>"phot.count"</par> |
| 513 |
<par key="pol_states" late="True" alias="polStates" |
| 514 |
description="Polarisation states |
| 515 |
in this image. See Obscore if you have polarimetric observations." |
| 516 |
>None</par> |
| 517 |
<par key="facility_name" late="True" alias="facilityName" |
| 518 |
description="Name of the facility at which data was taken." |
| 519 |
>base.getMetaText(targetTable, "facility", default=None)</par> |
| 520 |
<par key="instrument_name" alias="instrument" late="True" |
| 521 |
description="Name of the instrument that produced that data." |
| 522 |
>base.getMetaText(targetTable, "instrument", default=None)</par> |
| 523 |
|
| 524 |
<par key="t_xel" late="True" description="Number of time |
| 525 |
pixels in this image (make this None for stacked exposures)." |
| 526 |
>1</par> |
| 527 |
<par key="em_xel" late="True" description="Number of spectral |
| 528 |
pixels in this image." |
| 529 |
>1</par> |
| 530 |
<par key="pol_xel" late="True" description="Number of polarisation |
| 531 |
pixels in this image." |
| 532 |
>None</par> |
| 533 |
|
| 534 |
<par key="dateObs" late="True" description="The midpoint of the |
| 535 |
observation; this can either be a datetime instance, or |
| 536 |
a float>1e6 (a julian date) or something else (which is then |
| 537 |
interpreted as an MJD). This is ignored if you give t_min |
| 538 |
and t_max">None</par> |
| 539 |
<par key="bandpass_id" |
| 540 |
alias="bandpassId" |
| 541 |
late="True" |
| 542 |
description="a rough indicator |
| 543 |
of the bandpass, like Johnson bands. Only give if you want |
| 544 |
//siap2#getBandFromFilter to infer em_min and em_max. This |
| 545 |
will only end up in the database table if you set |
| 546 |
have_bandpass_id to True in the mixin.">None</par> |
| 547 |
</setup> |
| 548 |
<code> |
| 549 |
# computed here |
| 550 |
result["source_table"] = @prodtblTable |
| 551 |
result["access_url"] = @prodtblAccref |
| 552 |
result["access_format"] = @prodtblMime |
| 553 |
result["access_estsize"] = @prodtblFsize and @prodtblFsize/1024 |
| 554 |
|
| 555 |
# Stuff passed in by the user. All par-s are copied into the |
| 556 |
# result below, but some of them are manipulated before. |
| 557 |
if dateObs is not None: |
| 558 |
dateObs = toMJD(dateObs) |
| 559 |
if t_exptime is not None: |
| 560 |
if t_min is None: |
| 561 |
t_min = dateObs-t_exptime/86400/2 |
| 562 |
if t_max is None: |
| 563 |
t_max = dateObs+t_exptime/86400/2 |
| 564 |
|
| 565 |
# obs_id needs to be non-NULL for now. Hopefully, this |
| 566 |
# restriction can be lifted soon; in that case, just drop |
| 567 |
# the next line |
| 568 |
if obs_id is None: |
| 569 |
obs_id = obs_publisher_did |
| 570 |
|
| 571 |
for par in procDef.getSetupPars(): |
| 572 |
parName = par.key |
| 573 |
result[parName] = eval(parName) |
| 574 |
</code> |
| 575 |
</procDef> |
| 576 |
|
| 577 |
<procDef type="apply" id="getBandFromFilter"> |
| 578 |
<doc> |
| 579 |
sets the bandpassId, bandpassUnit, bandpassRefval, bandpassHi, |
| 580 |
and bandpassLo from a set of standard band Ids. |
| 581 |
|
| 582 |
The bandpass ids known are contained in a file supplied by |
| 583 |
DaCHS that you should consult for supported values by running |
| 584 |
``dachs admin dumpDF data/filters.txt``. |
| 585 |
|
| 586 |
If you pass in an unknown filter name, no keys will be generated, |
| 587 |
but no diagnostics will be emitted either. Make sure to dachs info |
| 588 |
on the imported table if you expect no NULLs in the bandpass |
| 589 |
columns. |
| 590 |
|
| 591 |
All values filled in here are in meters. |
| 592 |
|
| 593 |
If this is used, it must run after //siap#setMeta since |
| 594 |
setMeta clobbers our result fields. |
| 595 |
|
| 596 |
*Added in 2.7.3.* |
| 597 |
</doc> |
| 598 |
<setup imports="gavo.base"> |
| 599 |
<par key="sourceCol" description="Name of the column containing |
| 600 |
the filter name; leave at default None to take the band from |
| 601 |
result['bandpass_id'], where such information would be left |
| 602 |
by siap2#setMeta.">None</par> |
| 603 |
<code> |
| 604 |
_filterMap, _aliases = base.getFilterMap() |
| 605 |
|
| 606 |
def setBandpass(result, filterId): |
| 607 |
if not _filterMap: |
| 608 |
parseFilterMap() |
| 609 |
try: |
| 610 |
short, mid, long = _filterMap[_aliases.get(filterId, filterId)] |
| 611 |
except KeyError: # nothing known, do nothing |
| 612 |
return |
| 613 |
result["em_min"] = short |
| 614 |
result["em_max"] = long |
| 615 |
</code> |
| 616 |
</setup> |
| 617 |
<code> |
| 618 |
if sourceCol is None: |
| 619 |
val = result['bandpass_id'] |
| 620 |
else: |
| 621 |
val = vars[sourceCol] |
| 622 |
setBandpass(result, val) |
| 623 |
</code> |
| 624 |
</procDef> |
| 625 |
|
| 626 |
<condDesc id="humanInput"> |
| 627 |
<inputKey name="hPOS" type="text" multiplicity="single" |
| 628 |
ucd="pos.eq" |
| 629 |
tablehead="Position" |
| 630 |
description="ICRS Position, RA,DEC, or Simbad object |
| 631 |
(e.g., 234.234,-32.45)."> |
| 632 |
<property name="notForRenderer">siap.xml</property> |
| 633 |
</inputKey> |
| 634 |
<inputKey name="hSIZE" type="real" |
| 635 |
unit="deg" |
| 636 |
tablehead="Field size" |
| 637 |
description="Size in decimal degrees"> |
| 638 |
</inputKey> |
| 639 |
|
| 640 |
<phraseMaker> |
| 641 |
<code> |
| 642 |
pos = inPars["hPOS"] |
| 643 |
try: |
| 644 |
ra, dec = base.parseCooPair(pos) |
| 645 |
except ValueError: |
| 646 |
data = base.caches.getSesame("web").query(pos) |
| 647 |
if not data: |
| 648 |
raise base.ValidationError("%r is neither a RA,DEC pair nor" |
| 649 |
" a simbad resolvable object"%inPars.get("hPOS", "Not given"), |
| 650 |
"hPOS") |
| 651 |
ra, dec = float(data["RA"]), float(data["dec"]) |
| 652 |
yield "s_region && %({})s".format( |
| 653 |
base.getSQLKey("roi", pgsphere.SCircle.fromDALI([ |
| 654 |
ra, dec, inPars["hSIZE"]]), outPars)) |
| 655 |
</code> |
| 656 |
</phraseMaker> |
| 657 |
</condDesc> |
| 658 |
|
| 659 |
<!-- we copy our STC coverage from obscore; run data limits //obscore |
| 660 |
to update the info here --> |
| 661 |
<coverage fallbackTo="__system__/obscore"/> |
| 662 |
|
| 663 |
<service id="sitewide" allowed="siap2.xml,form"> |
| 664 |
<publish render="siap2.xml" sets="ivo_managed"/> |
| 665 |
<meta name="isServedBy" |
| 666 |
ivoId="ivo://\getConfig{ivoa}{authority}/__system__/obscore/obscore" |
| 667 |
>\getConfig{web}{siteName} Obscore</meta> |
| 668 |
|
| 669 |
<dbCore queriedTable="//obscore#ObsCore"> |
| 670 |
<FEED source="parameters"/> |
| 671 |
|
| 672 |
<!-- force results to be images and cubes exclusively --> |
| 673 |
<condDesc combining="True"> |
| 674 |
<phraseMaker> |
| 675 |
<code> |
| 676 |
yield "dataproduct_type in ('image', 'cube')" |
| 677 |
</code> |
| 678 |
</phraseMaker> |
| 679 |
</condDesc> |
| 680 |
</dbCore> |
| 681 |
<FEED source="%#sitewidesiap2-extras"/> |
| 682 |
</service> |
| 683 |
</resource> |