Package gavo :: Package stc :: Module stcx
[frames] | no frames]

Source Code for Module gavo.stc.stcx

  1  """ 
  2  Building STC-X documents, xmlstan-style. 
  3  """ 
  4   
  5  #c Copyright 2008-2019, the GAVO project 
  6  #c 
  7  #c This program is free software, covered by the GNU GPL.  See the 
  8  #c COPYING file in the source distribution. 
  9   
 10   
 11  from gavo.stc import common 
 12  from gavo.utils.stanxml import Element 
 13   
 14   
15 -class NamespaceWithSubsGroup(type):
16 """is a metaclass for xmlstan namespaces that contain substitution 17 groups. 18 19 You get a _addSubsGroup class method on these. 20 """
21 - def _addSubsGroup(cls, baseClass, validNames):
22 """adds baseClass under all of validNames into namespace. 23 """ 24 for n in validNames: 25 class dynamicallyDefined(baseClass): 26 name_ = n
27 setattr(cls, n, dynamicallyDefined)
28 29
30 -class STC(object):
31 """is a container for classes modelling STC elements. 32 """ 33 __metaclass__ = NamespaceWithSubsGroup 34
35 - class STCElement(Element):
36 _mayBeEmpty = True 37 _prefix = "stc" 38 # We may not want all of these an all elements, but it's not 39 # worth the effort to discriminate here. 40 _a_href = None 41 _name_a_href = "xlink:href" 42 _a_type = None 43 _name_a_type = "xlink:type" 44 _a_ucd = None 45 _a_ID_type = None 46 _a_IDREF_type = None
47
48 - class OptionalSTCElement(STCElement):
49 _mayBeEmpty = False
50
51 - class _Toplevel(STCElement):
52 _additionalPrefixes = frozenset(["xlink", "xsi"])
53
54 - class STCResourceProfile(_Toplevel): pass
55 - class ObsDataLocation(_Toplevel): pass
56
57 - class Name(OptionalSTCElement): pass
58 - class Name1(Name): pass
59 - class Name2(Name): pass
60 - class Name3(Name): pass
61
62 - class T_double1(OptionalSTCElement):
63 _stringifyContent = True 64 _a_gen_unit = None 65 _a_pos_angle_unit = None 66 _a_pos_unit = None 67 _a_spectral_unit = None 68 _a_time_unit = None 69 _a_vel_time_unit = None
70
71 - class T_double2(OptionalSTCElement):
72 _a_unit = None 73 _a_gen_unit = None 74 _a_vel_unit = None 75 _a_vel_time_unit = None
76
77 - class T_double3(T_double2): pass
78
79 - class T_size2(OptionalSTCElement):
80 _a_gen_unit = None 81 _a_unit = None 82 _a_vel_time_unit = None
83
84 - class T_size3(OptionalSTCElement):
85 _a_gen_unit = None 86 _a_unit = None 87 _a_vel_time_unit = None
88
89 - class T_matrix(OptionalSTCElement): pass
90
91 - class T_coordinate(T_double2):
92 _a_frame_id = None
93 94 # !!! Addition wrt 1.30 STC model
95 - class Epoch(OptionalSTCElement):
96 _a_yearDef = None
97
98 - class Position(T_coordinate): pass
99 - class Position1D(T_coordinate): pass
100 - class Velocity1D(T_coordinate): pass
101 - class Position2D(T_coordinate): pass
102 - class Velocity2D(T_coordinate): pass
103 - class Position3D(T_coordinate): pass
104 - class Velocity3D(T_coordinate): pass
105 - class Halfspace(STCElement): pass
106 - class Vector(STCElement): pass
107 - class Offset(T_double1): pass
108
109 - class T_Region(OptionalSTCElement):
110 _a_fill_factor = None 111 _a_hi_include = None 112 _a_lo_include = None 113 _a_unit = None 114 _a_vel_time_unit = None # For most children, this must remain None 115 _a_frame_id = None 116 _a_coord_system_id = None 117 _a_note = None
118
119 - class Region(T_Region): pass
120 - class Union(T_Region): pass
121 - class Intersection(T_Region): pass
122 - class Difference(T_Region): pass
123 - class Negation(T_Region): pass
124
125 - class T_Interval(T_Region): pass
126
127 - class PositionScalarInterval(T_Interval): pass
128 - class VelocityScalarInterval(T_Interval): pass
129 - class Position2VecInterval(T_Interval): pass
130 - class Velocity2VecInterval(T_Interval): pass
131 - class Position3VecInterval(T_Interval): pass
132 - class Velocity3VecInterval(T_Interval): pass
133 - class Coord3VecInterval(T_Interval): pass
134 - class Coord2VecInterval(T_Interval): pass
135 - class CoordScalarInterval(T_Interval): pass
136
137 - class PosAngle(T_double1):
138 _a_reference = None
139
140 - class Polygon(T_Region): pass
141 - class Circle(T_Region): pass
142 - class Sphere(Circle): pass
143 - class Ellipse(T_Region): pass
144 - class Box(T_Region): pass
145 - class Convex(T_Region): pass
146
147 - class Pole(STCElement):
148 _a_unit = None 149 _a_vel_time_unit = None
150
151 - class Area(STCElement):
152 _a_linearUnit = None 153 _a_validArea = None
154
155 - class Vertex(STCElement): pass
156 - class SmallCircle(STCElement): pass
157
158 - class _CoordSys(STCElement): pass
159
160 - class AstroCoordSystem(_CoordSys):
161 _childSequence = ["CoordFrame", "TimeFrame", "SpaceFrame", 162 "SpectralFrame", "RedshiftFrame"] 163
164 - class Equinox(OptionalSTCElement): pass
165
166 - class PixelCoordSystem(_CoordSys):
167 _childSequence = ["CoordFrame", "PixelCoordFrame"] 168
169 - class TimeFrame(STCElement):
170 pass
171
172 - class SpaceFrame(STCElement): pass
173
174 - class SpectralFrame(STCElement): pass
175
176 - class RedshiftFrame(STCElement):
177 _a_value_type = "VELOCITY"
178
179 - class Redshift(OptionalSTCElement):
180 _a_coord_system_id = None 181 _a_frame_id = None 182 _a_unit = None 183 _a_vel_time_unit = None
184
185 - class RedshiftInterval(T_Interval):
186 _a_vel_time_unit = None
187
188 - class DopplerDefinition(STCElement): pass
189
190 - class GenericCoordFrame(STCElement): pass
191
192 - class PixelCoordFrame(STCElement):
193 _a_axis1_order = None 194 _a_axis2_order = None 195 _a_axis3_order = None 196 _a_ref_frame_id = None
197
198 - class PixelSpace(STCElement): pass
199 - class ReferencePixel(STCElement): pass
200
201 - class T_Pixel(STCElement):
202 _a_frame_id = None
203 - class Pixel1D(T_Pixel): pass
204 - class Pixel2D(T_Pixel): pass
205 - class Pixel3D(T_Pixel): pass
206
207 - class T_SpaceRefFrame(STCElement):
208 _a_ref_frame_id = None 209
210 - class T_ReferencePosition(STCElement): pass
211
212 - class T_CoordFlavor(STCElement):
213 _a_coord_naxes = "2" 214 _a_handedness = None
215
216 - class T_Coords(OptionalSTCElement):
217 _a_coord_system_id = None
218
219 - class AstroCoords(T_Coords): pass
220
221 - class PixelCoords(T_Coords): pass
222
223 - class Coordinate(STCElement):
224 _a_frame_id = None
225
226 - class Pixel(Coordinate): pass
227
228 - class ScalarRefFrame(STCElement):
229 _a_projection = None 230 _a_ref_frame_id = None
231
232 - class ScalarCoordinate(Coordinate):
233 _a_unit = None
234
235 - class StringCoordinate(Coordinate):
236 _a_unit = None 237
238 - class Time(OptionalSTCElement):
239 _a_unit = None 240 _a_coord_system_id = None 241 _a_frame_id = None 242 _a_vel_time_unit = None # must not be changed for Times
243
244 - class T_astronTime(Time):
245 _childSequence = ["Timescale", "TimeOffset", "MJDTime", "JDTime", "ISOTime"]
246
247 - class StartTime(T_astronTime): pass
248 - class StopTime(T_astronTime): pass
249 - class TimeInstant(T_astronTime): pass
250 - class T(T_astronTime): pass
251
252 - class CoordArea(STCElement):
253 _a_coord_system_id = None
254
255 - class PixelCoordArea(CoordArea): pass
256
257 - class AllSky(T_Interval):
258 _a_coord_system_id = None 259 _a_note = None 260 _mayBeEmpty = True
261
262 - class SpatialInterval(T_Interval):
263 _a_fill_factor = "1.0"
264
265 - class TimeRefDirection(STCElement):
266 _a_coord_system_id = None
267 268
269 - class TimeInterval(T_Interval):
270 _childSequence = ["StartTime", "StopTime"]
271
272 - class TimeScale(STCElement): pass
273 - class Timescale(STCElement): pass # Confirmed typo.
274
275 - class ISOTime(OptionalSTCElement): pass
276 - class JDTime(OptionalSTCElement): pass
277 - class MJDTime(OptionalSTCElement): pass
278 - class TimeOrigin(STCElement): pass
279
280 - class Spectral(OptionalSTCElement):
281 _a_coord_system_id = None 282 _a_frame_id = None 283 _a_unit = None 284 _a_vel_time_unit = None # must not be changed for Spectrals
285
286 - class SpectralInterval(T_Interval): pass
287
288 - class AstroCoordArea(OptionalSTCElement):
289 _a_coord_system_id = None
290
291 - class ObservatoryLocation(STCElement): pass
292 - class ObservationLocation(STCElement): pass
293 - class STCSpec(STCElement): pass
294
295 - class Cart2DRefFrame(STCElement):
296 _a_projection = None 297 _a_ref_frame_id = None
298
299 - class Vector2DCoordinate(STCElement):
300 _a_frame_id = None 301 _a_unit = None
302
303 - class Center(OptionalSTCElement):
304 pass
305
306 - class PlanetaryEphem(OptionalSTCElement):
307 pass
308 309 310 STC._addSubsGroup(STC.T_double1, ["C1", "C2", "C3", "e", 311 "Error", "Size", "Resolution", "PixSize", 312 "Error2Radius", "Error3Radius", 313 "Size2Radius", "Size3Radius", 314 "PixSize2Radius", "PixSize3Radius", 315 "Resolution2Radius", "Resolution3Radius", 316 "M11", "M12", "M13", "M21", "M22", "M23", "M31", "M32", "M33", 317 "HiLimit", "LoLimit", "Radius", 318 "Scale", "SemiMajorAxis", "SemiMinorAxis", 319 "Value"]) 320 321 STC._addSubsGroup(STC.T_double2, ["HiLimit2Vec", "LoLimit2Vec", 322 "Pole", "Position", "Value2"]) 323 324 STC._addSubsGroup(STC.T_double3, ["HiLimit3Vec", "LoLimit3Vec", 325 "Point", "Value3", "Vector"]) 326 327 STC._addSubsGroup(STC.T_size2, ["Error2", "PixSize2", "Resolution2", 328 "Size2", "Transform2", "CValue2"]) 329 330 STC._addSubsGroup(STC.T_size3, ["Error3", "PixSize3", "Resolution3", 331 "Size3", "Transform3", "CValue3"]) 332 333 STC._addSubsGroup(STC.T_matrix,["Error2Matrix", "Error3Matrix", 334 "Size2Matrix", "Size3Matrix", "PixSize2Matrix", "PixSize3Matrix", 335 "Resolution2Matrix", "Resolution3Matrix",]) 336 337 STC._addSubsGroup(STC.T_SpaceRefFrame, common.stcSpaceRefFrames) 338 STC._addSubsGroup(STC.T_ReferencePosition, common.stcRefPositions) 339 STC._addSubsGroup(STC.T_CoordFlavor, common.stcCoordFlavors) 340