definitions.py
20 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
"""This module simply serves to store the XML schema, a 'skeleton' VOEvent
xml document for creation of new instances, and various other minor definitions.
These values may be used in place of literal strings, to allow autocompletion
and document the fact that they are 'standardized' values.
"""
from __future__ import unicode_literals
from six import b
# ############################
# Some useful string defs namespaced via a class container:
class roles:
observation = 'observation'
prediction = 'prediction'
utility = 'utility'
test = 'test'
class sky_coord_system:
"""
Common coordinate system identifiers. See also :class:`.Position2D`.
This is not a simple combinatorial mix of all components, it's a
reproduction of the enumeration in the XML schema. Note some entries in the
schema enumeration are repeated, which leads me to think it may be flawed,
but that's an investigation for another day.
"""
gps_fk5_topo = 'GPS-FK5-TOPO'
gps_icrs_geo = 'GPS-ICRS-GEO'
gps_icrs_topo = 'GPS-ICRS-TOPO'
tdb_fk5_bary = 'TDB-FK5-BARY'
tdb_icrs_bary = 'TDB-ICRS-BARY'
tt_fk5_geo = 'TT-FK5-GEO'
tt_fk5_topo = 'TT-FK5-TOPO'
tt_icrs_geo = 'TT-ICRS-GEO'
tt_icrs_topo = 'TT-ICRS-TOPO'
utc_fk5_geo = 'UTC-FK5-GEO'
utc_fk5_topo = 'UTC-FK5-TOPO'
utc_icrs_geo = 'UTC-ICRS-GEO'
utc_icrs_topo = 'UTC-ICRS-TOPO'
class observatory_location(object):
"""Common generic values for the WhereWhen.ObservatoryLocation attribute."""
geosurface = 'GEOSURFACE'
geolunar = 'GEOLUN'
class units:
"""
Unit abbreviations as defined by CDS (incomplete listing)
cf http://vizier.u-strasbg.fr/doc/catstd-3.2.htx
"""
degree = 'deg'
degrees = degree #Alias for backwards compatibility. Singular otherwise.
arcsecond = 'arcsec'
milliarcsecond = 'mas'
day = 'd'
hour = 'h'
minute = 'min'
year = 'yr'
count = 'ct'
hertz = 'Hz'
jansky = 'Jy'
magnitude = 'mag'
class cite_types:
"""Possible types of :func:`.Citation`"""
followup = 'followup'
supersedes = 'supersedes'
retraction = 'retraction'
####################################
#: Skeleton XML for instantiating a new VOEvent tree
v2_0_skeleton_str = b"""<?xml version="1.0" ?>
<voe:VOEvent xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:voe="http://www.ivoa.net/xml/VOEvent/v2.0"
xsi:schemaLocation="http://www.ivoa.net/xml/VOEvent/v2.0 http://www.ivoa.net/xml/VOEvent/VOEvent-v2.0.xsd"
version="2.0"
role="test"
ivorn="ivo://undefined">
</voe:VOEvent>
"""
####################################
#: VOEvent 2.0 schema for validation
#Schema downloaded from:
#http://www.ivoa.net/xml/VOEvent/VOEvent-v2.0.xsd
v2_0_schema_str = b"""<?xml version="1.0"?>
<xs:schema xmlns="http://www.ivoa.net/xml/VOEvent/v2.0" xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.ivoa.net/xml/VOEvent/v2.0" elementFormDefault="unqualified">
<xs:element name="VOEvent">
<xs:annotation>
<xs:documentation> VOEvent is the root element for describing observations of immediate
astronomical events. For more information, see
http://www.ivoa.net/twiki/bin/view/IVOA/IvoaVOEvent. The event consists of at most one of
each of: Who, What, WhereWhen, How, Why, Citations, Description, and
Reference.</xs:documentation>
</xs:annotation>
<xs:complexType>
<!-- Can have zero or one of each of these, in any order -->
<xs:all>
<xs:element name="Who" type="Who" minOccurs="0" maxOccurs="1"/>
<xs:element name="What" type="What" minOccurs="0" maxOccurs="1"/>
<xs:element name="WhereWhen" type="WhereWhen" minOccurs="0" maxOccurs="1"/>
<xs:element name="How" type="How" minOccurs="0" maxOccurs="1"/>
<xs:element name="Why" type="Why" minOccurs="0" maxOccurs="1"/>
<xs:element name="Citations" type="Citations" minOccurs="0" maxOccurs="1"/>
<xs:element name="Description" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="Reference" type="Reference" minOccurs="0" maxOccurs="1"/>
</xs:all>
<xs:attribute name="version" type="xs:token" fixed="2.0" use="required"/>
<xs:attribute name="ivorn" type="xs:anyURI" use="required"/>
<xs:attribute name="role" type="roleValues" default="observation"/>
</xs:complexType>
</xs:element>
<xs:simpleType name="roleValues">
<xs:restriction base="xs:string">
<xs:enumeration value="observation"/>
<xs:enumeration value="prediction"/>
<xs:enumeration value="utility"/>
<xs:enumeration value="test"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="Who">
<xs:annotation>
<xs:documentation> Who: Curation Metadata </xs:documentation>
</xs:annotation>
<xs:all>
<!-- Can have zero or one of each of these. Schema is loose because
should have AuthorIVORN *or* Author -->
<xs:element name="AuthorIVORN" type="xs:anyURI" minOccurs="0"/>
<xs:element name="Date" type="xs:dateTime" minOccurs="0"/>
<xs:element name="Description" type="xs:string" minOccurs="0"/>
<xs:element name="Reference" type="Reference" minOccurs="0"/>
<xs:element name="Author" minOccurs="0">
<xs:annotation>
<xs:documentation> Author information follows the IVOA curation information schema: the
organization responsible for the packet can have a title, short name or acronym, and a
logo. A contact person has a name, email, and phone number. Other contributors can also
be noted. </xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="title" type="xs:string"/>
<xs:element name="shortName" type="xs:string"/>
<xs:element name="logoURL" type="xs:anyURI"/>
<xs:element name="contactName" type="xs:string"/>
<xs:element name="contactEmail" type="xs:string"/>
<xs:element name="contactPhone" type="xs:string"/>
<xs:element name="contributor" type="xs:string"/>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:all>
</xs:complexType>
<xs:complexType name="What">
<xs:annotation>
<xs:documentation> What: Event Characterization. This is the part of the data model that is
chosen by the Authoer of the event rather than the IVOA. There can be Params, that may be in
Groups, and Tables, and simpleTimeSeries. There can also be Description and Reference as
with most VOEvent elements. </xs:documentation>
</xs:annotation>
<xs:choice maxOccurs="unbounded">
<!-- can have any number of any of these in any order -->
<xs:element name="Param" type="Param" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="Group" type="Group" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="Table" type="Table" minOccurs="0" maxOccurs="unbounded"/>
<!--<xs:element ref="sts:SimpleTimeseries" minOccurs="0" maxOccurs="unbounded"/>-->
<xs:element name="Description" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="Reference" type="Reference" minOccurs="0" maxOccurs="unbounded"/>
</xs:choice>
</xs:complexType>
<xs:complexType name="Param">
<xs:annotation>
<xs:documentation> What/Param definition. A Param has name, value, ucd, unit, dataType; and
may have Description and Reference.</xs:documentation>
</xs:annotation>
<xs:choice maxOccurs="unbounded">
<xs:element name="Description" type="xs:string" minOccurs="0"/>
<xs:element name="Reference" type="Reference" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="Value" type="xs:string" minOccurs="0" maxOccurs="1"/>
</xs:choice>
<xs:attribute name="name" type="xs:string"/>
<xs:attribute name="ucd" type="xs:string"/>
<xs:attribute name="value" type="xs:string"/>
<xs:attribute name="unit" type="xs:string"/>
<xs:attribute name="dataType" type="dataType" default="string"/>
<xs:attribute name="utype" type="xs:string"/>
</xs:complexType>
<xs:simpleType name="dataType">
<xs:restriction base="xs:string">
<xs:enumeration value="string"/>
<xs:enumeration value="float"/>
<xs:enumeration value="int"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="Group">
<xs:annotation>
<xs:documentation> What/Group definition: A group is a collection of Params, with name and
type attributes.</xs:documentation>
</xs:annotation>
<xs:choice maxOccurs="unbounded">
<xs:element name="Param" type="Param" maxOccurs="unbounded"/>
<xs:element name="Description" type="xs:string" minOccurs="0"/>
<xs:element name="Reference" type="Reference" minOccurs="0"/>
</xs:choice>
<xs:attribute name="name" type="xs:string"/>
<xs:attribute name="type" type="xs:string"/>
</xs:complexType>
<xs:complexType name="Table">
<xs:annotation>
<xs:documentation> What/Table definition. This small Table has Fields for the column
definitions, and Data to hold the table data, with TR for row and TD for value of a table
cell.</xs:documentation>
</xs:annotation>
<xs:choice maxOccurs="unbounded">
<xs:element name="Description" type="xs:string" minOccurs="0"/>
<xs:element name="Reference" type="Reference" minOccurs="0"/>
<xs:element name="Param" type="Param" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="Field" type="Field" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="Data" type="Data" minOccurs="1" maxOccurs="1"/>
</xs:choice>
<xs:attribute name="name" type="xs:string"/>
<xs:attribute name="type" type="xs:string"/>
</xs:complexType>
<xs:complexType name="Field">
<xs:choice maxOccurs="unbounded">
<xs:element name="Description" type="xs:string" minOccurs="0"/>
<xs:element name="Reference" type="Reference" minOccurs="0"/>
</xs:choice>
<xs:attribute name="name" type="xs:string"/>
<xs:attribute name="ucd" type="xs:string"/>
<xs:attribute name="unit" type="xs:string"/>
<xs:attribute name="dataType" type="dataType" default="string"/>
<xs:attribute name="utype" type="xs:string"/>
</xs:complexType>
<xs:complexType name="Data">
<xs:choice maxOccurs="unbounded">
<xs:element name="TR" type="TR"/>
</xs:choice>
</xs:complexType>
<xs:complexType name="TR">
<xs:choice maxOccurs="unbounded">
<xs:element name="TD" type="xs:string"/>
</xs:choice>
</xs:complexType>
<xs:complexType name="WhereWhen">
<xs:annotation>
<xs:documentation> WhereWhen: Space-Time Coordinates. Lots and lots of elements here, but the
import is that each event has these: observatory, sky_coord_system, time, timeError, longitude,
latitude, posError.</xs:documentation>
</xs:annotation>
<xs:choice maxOccurs="unbounded">
<xs:element name="ObsDataLocation" type="ObsDataLocation" minOccurs="1" maxOccurs="1"/>
<xs:element name="Description" type="xs:string" minOccurs="0"/>
<xs:element name="Reference" type="Reference" minOccurs="0"/>
</xs:choice>
<xs:attribute name="id" type="xs:ID" use="optional"/>
</xs:complexType>
<xs:complexType name="ObsDataLocation">
<xs:annotation>
<xs:documentation> Part of WhereWhen</xs:documentation>
</xs:annotation>
<xs:all>
<xs:element name="ObservatoryLocation" minOccurs="1" maxOccurs="1" type="ObservatoryLocation"/>
<xs:element name="ObservationLocation" minOccurs="1" maxOccurs="1" type="ObservationLocation"/>
</xs:all>
</xs:complexType>
<xs:complexType name="ObservationLocation">
<xs:annotation>
<xs:documentation> Part of WhereWhen</xs:documentation>
</xs:annotation>
<xs:all>
<xs:element name="AstroCoordSystem" type="AstroCoordSystem" minOccurs="1" maxOccurs="1"/>
<xs:element name="AstroCoords" type="AstroCoords" minOccurs="1" maxOccurs="1"/>
</xs:all>
</xs:complexType>
<xs:complexType name="AstroCoordSystem">
<xs:annotation>
<xs:documentation> Part of WhereWhen</xs:documentation>
</xs:annotation>
<!-- The empty sequence closes this to content -->
<xs:sequence />
<xs:attribute name="id" type="idValues"/>
</xs:complexType>
<xs:simpleType name="idValues">
<xs:restriction base="xs:string">
<xs:enumeration value="TT-ICRS-TOPO"/>
<xs:enumeration value="UTC-ICRS-TOPO"/>
<xs:enumeration value="TT-FK5-TOPO"/>
<xs:enumeration value="UTC-FK5-TOPO"/>
<xs:enumeration value="GPS-ICRS-TOPO"/>
<xs:enumeration value="GPS-ICRS-TOPO"/>
<xs:enumeration value="GPS-FK5-TOPO"/>
<xs:enumeration value="GPS-FK5-TOPO"/>
<xs:enumeration value="TT-ICRS-GEO"/>
<xs:enumeration value="UTC-ICRS-GEO"/>
<xs:enumeration value="TT-FK5-GEO"/>
<xs:enumeration value="UTC-FK5-GEO"/>
<xs:enumeration value="GPS-ICRS-GEO"/>
<xs:enumeration value="GPS-ICRS-GEO"/>
<xs:enumeration value="TDB-ICRS-BARY"/>
<xs:enumeration value="TDB-FK5-BARY"/>
<!-- this one for ObservatoryLocation -->
<xs:enumeration value="UTC-GEOD-TOPO"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="AstroCoords">
<xs:annotation>
<xs:documentation> Part of WhereWhen</xs:documentation>
</xs:annotation>
<xs:all>
<xs:element name="Time" type="Time" minOccurs="0"/>
<xs:element name="Position2D" type="Position2D" minOccurs="0"/>
<xs:element name="Position3D" type="Position3D" minOccurs="0"/>
</xs:all>
<xs:attribute name="coord_system_id" type="idValues"/>
</xs:complexType>
<xs:complexType name="Time">
<xs:annotation>
<xs:documentation> Part of WhereWhen</xs:documentation>
</xs:annotation>
<xs:choice maxOccurs="unbounded">
<xs:element name="TimeInstant" type="TimeInstant"/>
<xs:element name="Error" type="xs:float" minOccurs="0"/>
</xs:choice>
<xs:attribute name="unit" type="xs:string"/>
</xs:complexType>
<xs:complexType name="TimeInstant">
<xs:annotation>
<xs:documentation> Part of WhereWhen</xs:documentation>
</xs:annotation>
<xs:choice maxOccurs="unbounded">
<xs:element name="ISOTime" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="TimeOffset" type="xs:float" minOccurs="0" maxOccurs="1"/>
<xs:element name="TimeScale" type="xs:string" minOccurs="0" maxOccurs="1"/>
</xs:choice>
</xs:complexType>
<xs:complexType name="Position2D">
<xs:annotation>
<xs:documentation> Part of WhereWhen</xs:documentation>
</xs:annotation>
<xs:all>
<xs:element name="Name1" type="xs:string" minOccurs="0"/>
<xs:element name="Name2" type="xs:string" minOccurs="0"/>
<xs:element name="Value2" type="Value2"/>
<xs:element name="Error2Radius" type="xs:float"/>
</xs:all>
<xs:attribute name="unit" type="xs:string"/>
</xs:complexType>
<xs:complexType name="Position3D">
<xs:annotation>
<xs:documentation> Part of WhereWhen</xs:documentation>
</xs:annotation>
<xs:all>
<xs:element name="Name1" type="xs:string" minOccurs="0"/>
<xs:element name="Name2" type="xs:string" minOccurs="0"/>
<xs:element name="Name3" type="xs:string" minOccurs="0"/>
<xs:element name="Value3" type="Value3"/>
</xs:all>
<xs:attribute name="unit" type="xs:string"/>
</xs:complexType>
<xs:complexType name="Value2">
<xs:annotation>
<xs:documentation> Part of WhereWhen</xs:documentation>
</xs:annotation>
<xs:all>
<xs:element name="C1" type="xs:float"/>
<xs:element name="C2" type="xs:float"/>
</xs:all>
</xs:complexType>
<xs:complexType name="Value3">
<xs:annotation>
<xs:documentation> Part of WhereWhen</xs:documentation>
</xs:annotation>
<xs:all>
<xs:element name="C1" type="xs:float"/>
<xs:element name="C2" type="xs:float"/>
<xs:element name="C3" type="xs:float"/>
</xs:all>
</xs:complexType>
<xs:complexType name="ObservatoryLocation">
<xs:annotation>
<xs:documentation> Part of WhereWhen</xs:documentation>
</xs:annotation>
<xs:all>
<xs:element name="AstroCoordSystem" type="AstroCoordSystem" minOccurs="0" maxOccurs="1"/>
<xs:element name="AstroCoords" type="AstroCoords" minOccurs="0" maxOccurs="1"/>
</xs:all>
<xs:attribute name="id" type="xs:string"/>
</xs:complexType>
<xs:complexType name="How">
<xs:annotation>
<xs:documentation> How: Instrument Configuration. Built with some Description and Reference
elements. </xs:documentation>
</xs:annotation>
<xs:choice maxOccurs="unbounded">
<xs:element name="Description" type="xs:string"/>
<xs:element name="Reference" type="Reference"/>
</xs:choice>
</xs:complexType>
<xs:complexType name="Why">
<xs:annotation>
<xs:documentation> Why: Initial Scientific Assessment. Can make simple Concept/Name/Desc/Ref
for the inference or use multiple Inference containers for more semantic sophistication.
</xs:documentation>
</xs:annotation>
<xs:choice maxOccurs="unbounded">
<xs:element name="Name" type="xs:string"/>
<xs:element name="Concept" type="xs:string"/>
<xs:element name="Inference" type="Inference"/>
<xs:element name="Description" type="xs:string"/>
<xs:element name="Reference" type="Reference"/>
</xs:choice>
<xs:attribute name="importance" type="xs:float"/>
<xs:attribute name="expires" type="xs:dateTime"/>
</xs:complexType>
<xs:complexType name="Inference">
<xs:annotation>
<xs:documentation> Why/Inference: A container for a more nuanced expression, including
relationships and probability. </xs:documentation>
</xs:annotation>
<xs:choice maxOccurs="unbounded">
<xs:element name="Name" type="xs:string"/>
<xs:element name="Concept" type="xs:string"/>
<xs:element name="Description" type="xs:string"/>
<xs:element name="Reference" type="Reference"/>
</xs:choice>
<xs:attribute name="probability" type="smallFloat"/>
<xs:attribute name="relation" type="xs:string"/>
</xs:complexType>
<xs:simpleType name="smallFloat">
<xs:restriction base="xs:float">
<xs:minInclusive value="0.0"/>
<xs:maxInclusive value="1.0"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="Citations">
<xs:annotation>
<xs:documentation> Citations: Follow-up Observations. This section is a sequence of EventIVORN
elements, each of which has the IVORN of a cited event. </xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="EventIVORN" type="EventIVORN" maxOccurs="unbounded"/>
<xs:element name="Description" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="EventIVORN">
<xs:annotation>
<xs:documentation> Citations/EventIVORN. The value is the IVORN of the cited event, the 'cite'
attribute is the nature of that relationship, choosing from 'followup', 'supersedes', or
'retraction'.</xs:documentation>
</xs:annotation>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="cite" type="citeValues"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:simpleType name="citeValues">
<xs:restriction base="xs:string">
<xs:enumeration value="followup"/>
<xs:enumeration value="supersedes"/>
<xs:enumeration value="retraction"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="Reference">
<xs:annotation>
<xs:documentation> Reference: External Content. The payload is the uri, and the 'type'
describes the nature of the data under that uri. The Reference can also be named.
</xs:documentation>
</xs:annotation>
<xs:sequence/>
<xs:attribute name="uri" type="xs:anyURI" use="required"/>
<xs:attribute name="type" type="xs:string"/>
<xs:attribute name="mimetype" type="xs:string"/>
<xs:attribute name="meaning" type="xs:anyURI"/>
</xs:complexType>
</xs:schema>
"""