Source code for gavo.stc.stcx

"""
Building STC-X documents, xmlstan-style.
"""

#c Copyright 2008-2023, the GAVO project <gavo@ari.uni-heidelberg.de>
#c
#c This program is free software, covered by the GNU GPL.  See the
#c COPYING file in the source distribution.


from gavo.stc import common
from gavo.utils.stanxml import Element


[docs]class NamespaceWithSubsGroup(type): """is a metaclass for xmlstan namespaces that contain substitution groups. You get a _addSubsGroup class method on these. """ def _addSubsGroup(cls, baseClass, validNames): """adds baseClass under all of validNames into namespace. """ for n in validNames: class dynamicallyDefined(baseClass): name_ = n setattr(cls, n, dynamicallyDefined)
[docs]class STC(object, metaclass=NamespaceWithSubsGroup): """is a container for classes modelling STC elements. """
[docs] class STCElement(Element): _mayBeEmpty = True _prefix = "stc" # We may not want all of these an all elements, but it's not # worth the effort to discriminate here. _a_href = None _name_a_href = "xlink:href" _a_type = None _name_a_type = "xlink:type" _a_ucd = None _a_ID_type = None _a_IDREF_type = None
[docs] class OptionalSTCElement(STCElement): _mayBeEmpty = False
class _Toplevel(STCElement): _additionalPrefixes = frozenset(["xlink", "xsi"])
[docs] class STCResourceProfile(_Toplevel): pass
[docs] class ObsDataLocation(_Toplevel): pass
[docs] class Name(OptionalSTCElement): pass
[docs] class Name1(Name): pass
[docs] class Name2(Name): pass
[docs] class Name3(Name): pass
[docs] class T_double1(OptionalSTCElement): _stringifyContent = True _a_gen_unit = None _a_pos_angle_unit = None _a_pos_unit = None _a_spectral_unit = None _a_time_unit = None _a_vel_time_unit = None
[docs] class T_double2(OptionalSTCElement): _a_unit = None _a_gen_unit = None _a_vel_unit = None _a_vel_time_unit = None
[docs] class T_double3(T_double2): pass
[docs] class T_size2(OptionalSTCElement): _a_gen_unit = None _a_unit = None _a_vel_time_unit = None
[docs] class T_size3(OptionalSTCElement): _a_gen_unit = None _a_unit = None _a_vel_time_unit = None
[docs] class T_matrix(OptionalSTCElement): pass
[docs] class T_coordinate(T_double2): _a_frame_id = None
# !!! Addition wrt 1.30 STC model
[docs] class Epoch(OptionalSTCElement): _a_yearDef = None
[docs] class Position(T_coordinate): pass
[docs] class Position1D(T_coordinate): pass
[docs] class Velocity1D(T_coordinate): pass
[docs] class Position2D(T_coordinate): pass
[docs] class Velocity2D(T_coordinate): pass
[docs] class Position3D(T_coordinate): pass
[docs] class Velocity3D(T_coordinate): pass
[docs] class Halfspace(STCElement): pass
[docs] class Vector(STCElement): pass
[docs] class Offset(T_double1): pass
[docs] class T_Region(OptionalSTCElement): _a_fill_factor = None _a_hi_include = None _a_lo_include = None _a_unit = None _a_vel_time_unit = None # For most children, this must remain None _a_frame_id = None _a_coord_system_id = None _a_note = None
[docs] class Region(T_Region): pass
[docs] class Union(T_Region): pass
[docs] class Intersection(T_Region): pass
[docs] class Difference(T_Region): pass
[docs] class Negation(T_Region): pass
[docs] class T_Interval(T_Region): pass
[docs] class PositionScalarInterval(T_Interval): pass
[docs] class VelocityScalarInterval(T_Interval): pass
[docs] class Position2VecInterval(T_Interval): pass
[docs] class Velocity2VecInterval(T_Interval): pass
[docs] class Position3VecInterval(T_Interval): pass
[docs] class Velocity3VecInterval(T_Interval): pass
[docs] class Coord3VecInterval(T_Interval): pass
[docs] class Coord2VecInterval(T_Interval): pass
[docs] class CoordScalarInterval(T_Interval): pass
[docs] class PosAngle(T_double1): _a_reference = None
[docs] class Polygon(T_Region): pass
[docs] class Circle(T_Region): pass
[docs] class Sphere(Circle): pass
[docs] class Ellipse(T_Region): pass
[docs] class Box(T_Region): pass
[docs] class Convex(T_Region): pass
[docs] class Pole(STCElement): _a_unit = None _a_vel_time_unit = None
[docs] class Area(STCElement): _a_linearUnit = None _a_validArea = None
[docs] class Vertex(STCElement): pass
[docs] class SmallCircle(STCElement): pass
class _CoordSys(STCElement): pass
[docs] class AstroCoordSystem(_CoordSys): _childSequence = ["CoordFrame", "TimeFrame", "SpaceFrame", "SpectralFrame", "RedshiftFrame"]
[docs] class Equinox(OptionalSTCElement): pass
[docs] class PixelCoordSystem(_CoordSys): _childSequence = ["CoordFrame", "PixelCoordFrame"]
[docs] class TimeFrame(STCElement): pass
[docs] class SpaceFrame(STCElement): pass
[docs] class SpectralFrame(STCElement): pass
[docs] class RedshiftFrame(STCElement): _a_value_type = "VELOCITY"
[docs] class Redshift(OptionalSTCElement): _a_coord_system_id = None _a_frame_id = None _a_unit = None _a_vel_time_unit = None
[docs] class RedshiftInterval(T_Interval): _a_vel_time_unit = None
[docs] class DopplerDefinition(STCElement): pass
[docs] class GenericCoordFrame(STCElement): pass
[docs] class PixelCoordFrame(STCElement): _a_axis1_order = None _a_axis2_order = None _a_axis3_order = None _a_ref_frame_id = None
[docs] class PixelSpace(STCElement): pass
[docs] class ReferencePixel(STCElement): pass
[docs] class T_Pixel(STCElement): _a_frame_id = None
[docs] class Pixel1D(T_Pixel): pass
[docs] class Pixel2D(T_Pixel): pass
[docs] class Pixel3D(T_Pixel): pass
[docs] class T_SpaceRefFrame(STCElement): _a_ref_frame_id = None
[docs] class T_ReferencePosition(STCElement): pass
[docs] class T_CoordFlavor(STCElement): _a_coord_naxes = "2" _a_handedness = None
[docs] class T_Coords(OptionalSTCElement): _a_coord_system_id = None
[docs] class AstroCoords(T_Coords): pass
[docs] class PixelCoords(T_Coords): pass
[docs] class Coordinate(STCElement): _a_frame_id = None
[docs] class Pixel(Coordinate): pass
[docs] class ScalarRefFrame(STCElement): _a_projection = None _a_ref_frame_id = None
[docs] class ScalarCoordinate(Coordinate): _a_unit = None
[docs] class StringCoordinate(Coordinate): _a_unit = None
[docs] class Time(OptionalSTCElement): _a_unit = None _a_coord_system_id = None _a_frame_id = None _a_vel_time_unit = None # must not be changed for Times
[docs] class T_astronTime(Time): _childSequence = ["Timescale", "TimeOffset", "MJDTime", "JDTime", "ISOTime"]
[docs] class StartTime(T_astronTime): pass
[docs] class StopTime(T_astronTime): pass
[docs] class TimeInstant(T_astronTime): pass
[docs] class T(T_astronTime): pass
[docs] class CoordArea(STCElement): _a_coord_system_id = None
[docs] class PixelCoordArea(CoordArea): pass
[docs] class AllSky(T_Interval): _a_coord_system_id = None _a_note = None _mayBeEmpty = True
[docs] class SpatialInterval(T_Interval): _a_fill_factor = "1.0"
[docs] class TimeRefDirection(STCElement): _a_coord_system_id = None
[docs] class TimeInterval(T_Interval): _childSequence = ["StartTime", "StopTime"]
[docs] class TimeScale(STCElement): pass
[docs] class Timescale(STCElement): pass # Confirmed typo.
[docs] class ISOTime(OptionalSTCElement): pass
[docs] class JDTime(OptionalSTCElement): pass
[docs] class MJDTime(OptionalSTCElement): pass
[docs] class TimeOrigin(STCElement): pass
[docs] class Spectral(OptionalSTCElement): _a_coord_system_id = None _a_frame_id = None _a_unit = None _a_vel_time_unit = None # must not be changed for Spectrals
[docs] class SpectralInterval(T_Interval): pass
[docs] class AstroCoordArea(OptionalSTCElement): _a_coord_system_id = None
[docs] class ObservatoryLocation(STCElement): pass
[docs] class ObservationLocation(STCElement): pass
[docs] class STCSpec(STCElement): pass
[docs] class Cart2DRefFrame(STCElement): _a_projection = None _a_ref_frame_id = None
[docs] class Vector2DCoordinate(STCElement): _a_frame_id = None _a_unit = None
[docs] class Center(OptionalSTCElement): pass
[docs] class PlanetaryEphem(OptionalSTCElement): pass
STC._addSubsGroup(STC.T_double1, ["C1", "C2", "C3", "e", "Error", "Size", "Resolution", "PixSize", "Error2Radius", "Error3Radius", "Size2Radius", "Size3Radius", "PixSize2Radius", "PixSize3Radius", "Resolution2Radius", "Resolution3Radius", "M11", "M12", "M13", "M21", "M22", "M23", "M31", "M32", "M33", "HiLimit", "LoLimit", "Radius", "Scale", "SemiMajorAxis", "SemiMinorAxis", "Value"]) STC._addSubsGroup(STC.T_double2, ["HiLimit2Vec", "LoLimit2Vec", "Pole", "Position", "Value2"]) STC._addSubsGroup(STC.T_double3, ["HiLimit3Vec", "LoLimit3Vec", "Point", "Value3", "Vector"]) STC._addSubsGroup(STC.T_size2, ["Error2", "PixSize2", "Resolution2", "Size2", "Transform2", "CValue2"]) STC._addSubsGroup(STC.T_size3, ["Error3", "PixSize3", "Resolution3", "Size3", "Transform3", "CValue3"]) STC._addSubsGroup(STC.T_matrix,["Error2Matrix", "Error3Matrix", "Size2Matrix", "Size3Matrix", "PixSize2Matrix", "PixSize3Matrix", "Resolution2Matrix", "Resolution3Matrix",]) STC._addSubsGroup(STC.T_SpaceRefFrame, common.stcSpaceRefFrames) STC._addSubsGroup(STC.T_ReferencePosition, common.stcRefPositions) STC._addSubsGroup(STC.T_CoordFlavor, common.stcCoordFlavors)