voruby 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +339 -0
- data/REQUIREMENTS +4 -0
- data/Rakefile.rb +296 -0
- data/lib/voruby/adql/adql.rb +2735 -0
- data/lib/voruby/adql/ext.rb +15 -0
- data/lib/voruby/adql/loader.rb +5 -0
- data/lib/voruby/adql/operations.rb +54 -0
- data/lib/voruby/adql/parser.rb +160 -0
- data/lib/voruby/adql/transforms.rb +573 -0
- data/lib/voruby/ext.rb +17 -0
- data/lib/voruby/loader.rb +4 -0
- data/lib/voruby/misc/propertyfile.rb +36 -0
- data/lib/voruby/plastic/applications.rb +174 -0
- data/lib/voruby/plastic/constants.rb +30 -0
- data/lib/voruby/plastic/loader.rb +10 -0
- data/lib/voruby/plastic/plastic.rb +1 -0
- data/lib/voruby/resources/conesearch/conesearch.rb +9 -0
- data/lib/voruby/resources/conesearch/conesearch_v0_2.rb +55 -0
- data/lib/voruby/resources/conesearch/conesearch_v0_3.rb +50 -0
- data/lib/voruby/resources/conesearch/conesearch_v1_0.rb +72 -0
- data/lib/voruby/resources/conesearch/loader.rb +4 -0
- data/lib/voruby/resources/loader.rb +50 -0
- data/lib/voruby/resources/nodes.rb +190 -0
- data/lib/voruby/resources/openskynode/loader.rb +4 -0
- data/lib/voruby/resources/openskynode/openskynode.rb +9 -0
- data/lib/voruby/resources/openskynode/openskynode_v0_1.rb +54 -0
- data/lib/voruby/resources/sia/loader.rb +5 -0
- data/lib/voruby/resources/sia/sia.rb +9 -0
- data/lib/voruby/resources/sia/sia_v0_6.rb +90 -0
- data/lib/voruby/resources/sia/sia_v0_7.rb +89 -0
- data/lib/voruby/resources/sia/sia_v1_0.rb +122 -0
- data/lib/voruby/resources/stsci.rb +59 -0
- data/lib/voruby/resources/vodataservice/coverage_v0_2.rb +195 -0
- data/lib/voruby/resources/vodataservice/coverage_v0_3.rb +158 -0
- data/lib/voruby/resources/vodataservice/loader.rb +5 -0
- data/lib/voruby/resources/vodataservice/vodataservice.rb +9 -0
- data/lib/voruby/resources/vodataservice/vodataservice_v0_4.rb +189 -0
- data/lib/voruby/resources/vodataservice/vodataservice_v0_5.rb +163 -0
- data/lib/voruby/resources/vodataservice/vodataservice_v1_0.rb +221 -0
- data/lib/voruby/resources/voregistry/loader.rb +4 -0
- data/lib/voruby/resources/voregistry/voregistry.rb +9 -0
- data/lib/voruby/resources/voregistry/voregistry_v0_2.rb +40 -0
- data/lib/voruby/resources/voregistry/voregistry_v0_3.rb +30 -0
- data/lib/voruby/resources/voregistry/voregistry_v1_0.rb +86 -0
- data/lib/voruby/resources/voresource/loader.rb +17 -0
- data/lib/voruby/resources/voresource/voresource.rb +9 -0
- data/lib/voruby/resources/voresource/voresource_v0_10.rb +322 -0
- data/lib/voruby/resources/voresource/voresource_v0_9.rb +405 -0
- data/lib/voruby/resources/voresource/voresource_v1_0.rb +230 -0
- data/lib/voruby/services/ext.rb +11 -0
- data/lib/voruby/services/gestalt/footprint.rb +95 -0
- data/lib/voruby/services/gestalt/wcs_fixer.rb +105 -0
- data/lib/voruby/services/gestalt/wesix.rb +155 -0
- data/lib/voruby/services/loader.rb +7 -0
- data/lib/voruby/services/registry/registry.rb +53 -0
- data/lib/voruby/services/resolver/resolver.rb +35 -0
- data/lib/voruby/sesame/loader.rb +6 -0
- data/lib/voruby/sesame/sesame_v1_0.rb +64 -0
- data/lib/voruby/simple/loader.rb +6 -0
- data/lib/voruby/simple/parameters.rb +196 -0
- data/lib/voruby/simple/sap.rb +446 -0
- data/lib/voruby/spacetime/loader.rb +3 -0
- data/lib/voruby/spacetime/spacetime.rb +607 -0
- data/lib/voruby/stc/coords_v1_20.rb +900 -0
- data/lib/voruby/stc/loader.rb +55 -0
- data/lib/voruby/stc/region_v1_20.rb +274 -0
- data/lib/voruby/stc/stc_v1_20.rb +1196 -0
- data/lib/voruby/util.rb +27 -0
- data/lib/voruby/voevent/loader.rb +7 -0
- data/lib/voruby/voevent/voevent_v1_0.rb +213 -0
- data/lib/voruby/voevent/voevent_v1_1.rb +196 -0
- data/lib/voruby/votables/chandra.rb +410 -0
- data/lib/voruby/votables/cnoc.rb +393 -0
- data/lib/voruby/votables/data.rb +179 -0
- data/lib/voruby/votables/galex.rb +390 -0
- data/lib/voruby/votables/hst.rb +391 -0
- data/lib/voruby/votables/int.rb +391 -0
- data/lib/voruby/votables/libxml_parser.rb +411 -0
- data/lib/voruby/votables/libxml_votable.rb +67 -0
- data/lib/voruby/votables/loader.rb +10 -0
- data/lib/voruby/votables/meta.rb +763 -0
- data/lib/voruby/votables/misc.rb +51 -0
- data/lib/voruby/votables/nsa.rb +393 -0
- data/lib/voruby/votables/nsar3.rb +410 -0
- data/lib/voruby/votables/rexml_parser.rb +408 -0
- data/lib/voruby/votables/rexml_votable.rb +67 -0
- data/lib/voruby/votables/sdss.rb +393 -0
- data/lib/voruby/votables/transforms.rb +388 -0
- data/lib/voruby/votables/tree.rb +45 -0
- data/lib/voruby/votables/types.rb +391 -0
- data/lib/voruby/votables/votable.rb +630 -0
- data/lib/voruby/votables/xmm.rb +394 -0
- data/test/adql/test1.adql +49 -0
- data/test/adql/test2.adql +51 -0
- data/test/adql/test3.adql +81 -0
- data/test/adql/test4.adql +53 -0
- data/test/adql/test5.adql +55 -0
- data/test/adql/test6.adql +18 -0
- data/test/adql/test7.adql +48 -0
- data/test/adql/unittest.rb +1672 -0
- data/test/plastic/test.rb +44 -0
- data/test/plastic/test.vot +5385 -0
- data/test/plastic/unittest.rb +66 -0
- data/test/resources/conesearch/conesearch_v0_3.xml +31 -0
- data/test/resources/conesearch/conesearch_v1_0.xml +86 -0
- data/test/resources/conesearch/unittest_v0_3.rb +22 -0
- data/test/resources/conesearch/unittest_v1_0.rb +24 -0
- data/test/resources/openskynode/open_sky_node_v0_1.xml +32 -0
- data/test/resources/openskynode/unittest_v0_1.rb +31 -0
- data/test/resources/sia/simple_image_access_v0_7.xml +36 -0
- data/test/resources/sia/simple_image_access_v1_0.xml +122 -0
- data/test/resources/sia/unittest_v0_7.rb +24 -0
- data/test/resources/sia/unittest_v1_0.rb +29 -0
- data/test/resources/stsci.xml +336 -0
- data/test/resources/unittest_stsci.rb +25 -0
- data/test/resources/vodataservice/catalog_service_resource_v1_0.xml +128 -0
- data/test/resources/vodataservice/data_collection_resource_v0_5.xml +54 -0
- data/test/resources/vodataservice/data_collection_resource_v1_0.xml +117 -0
- data/test/resources/vodataservice/data_service_resource_v1_0.xml +115 -0
- data/test/resources/vodataservice/sky_service_resource_v0_10.xml +45 -0
- data/test/resources/vodataservice/table_service_resource_v1_0.xml +122 -0
- data/test/resources/vodataservice/tabular_sky_service_resource_v0_10.xml +60 -0
- data/test/resources/vodataservice/unittest_v0_5.rb +126 -0
- data/test/resources/vodataservice/unittest_v1_0.rb +151 -0
- data/test/resources/voregistry/authority_resource_v0_3.xml +20 -0
- data/test/resources/voregistry/authority_resource_v1_0.xml +82 -0
- data/test/resources/voregistry/registry_service_v0_3.xml +20 -0
- data/test/resources/voregistry/registry_service_v1_0.xml +107 -0
- data/test/resources/voregistry/unittest_v0_3.rb +31 -0
- data/test/resources/voregistry/unittest_v1_0.rb +34 -0
- data/test/resources/voresource/organisation_resource_v1_0.xml +90 -0
- data/test/resources/voresource/resource_organisation_v0_10.xml +22 -0
- data/test/resources/voresource/resource_service_v0_10.xml +19 -0
- data/test/resources/voresource/resource_v0_10.xml +19 -0
- data/test/resources/voresource/resource_v1_0.xml +79 -0
- data/test/resources/voresource/service_resource_v1_0.xml +91 -0
- data/test/resources/voresource/unittest_v0_10.rb +61 -0
- data/test/resources/voresource/unittest_v0_9.rb +4 -0
- data/test/resources/voresource/unittest_v1_0.rb +190 -0
- data/test/services/gestalt/unittest.rb +74 -0
- data/test/services/registry/unittest.rb +34 -0
- data/test/services/resolver/unittest.rb +38 -0
- data/test/simple/unittest.rb +46 -0
- data/test/spacetime/unittest.rb +39 -0
- data/test/stc/catalog_entry_location_v1_20.xml +112 -0
- data/test/stc/obs_data_location_v1_20.xml +108 -0
- data/test/stc/search_location_v1_20.xml +54 -0
- data/test/stc/stc_resource_profile_v1_20.xml +60 -0
- data/test/stc/unittest_v1_20.rb +620 -0
- data/test/voevent/unittest_v1_0.rb +79 -0
- data/test/voevent/unittest_v1_1.rb +70 -0
- data/test/voevent/voevent_v1_0.xml +96 -0
- data/test/voevent/voevent_v1_1.xml +76 -0
- data/test/votables/test.vot +366 -0
- data/test/votables/unittest.rb +54 -0
- metadata +256 -0
@@ -0,0 +1,620 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
|
3
|
+
require 'voruby/stc/stc_v1_20'
|
4
|
+
|
5
|
+
include VORuby::STC::V1_20
|
6
|
+
|
7
|
+
class STCTest < Test::Unit::TestCase
|
8
|
+
def test_space_frame
|
9
|
+
frame = nil
|
10
|
+
assert_nothing_raised {
|
11
|
+
frame = SpaceFrame.load_from_xml(
|
12
|
+
REXML::Document.new(
|
13
|
+
'<SpaceFrame>' +
|
14
|
+
'<Name>GeoLongLatElev</Name>' +
|
15
|
+
'<GEO_D/>' +
|
16
|
+
'<TOPOCENTER/>' +
|
17
|
+
'<SPHERICAL coord_naxes="3"/>' +
|
18
|
+
'<OffsetCenter><Value>23.2</Value></OffsetCenter>' +
|
19
|
+
'</SpaceFrame>').root
|
20
|
+
)
|
21
|
+
}
|
22
|
+
|
23
|
+
assert_equal('GeoLongLatElev', frame.value.name)
|
24
|
+
assert_equal(true, frame.value.space_ref_frame.is_a?(GEO_D))
|
25
|
+
assert_equal(true, frame.value.reference_position.is_a?(TOPOCENTER))
|
26
|
+
assert_equal(true, frame.value.coord_flavor.is_a?(SPHERICAL))
|
27
|
+
assert_equal(3, frame.value.coord_flavor.value.coord_naxes)
|
28
|
+
assert_equal(23.2, frame.value.offset_center.value)
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_time_frame
|
32
|
+
frame = nil
|
33
|
+
assert_nothing_raised {
|
34
|
+
frame = TimeFrame.load_from_xml(
|
35
|
+
REXML::Document.new(
|
36
|
+
'<TimeFrame>' +
|
37
|
+
'<Name>CrazyTime</Name>' +
|
38
|
+
'<TimeScale>LOCAL</TimeScale>' +
|
39
|
+
'<HELIOCENTER />' +
|
40
|
+
'</TimeFrame>').root
|
41
|
+
)
|
42
|
+
}
|
43
|
+
|
44
|
+
assert_equal('CrazyTime', frame.value.name)
|
45
|
+
assert_equal('LOCAL', frame.value.time_scale.value)
|
46
|
+
assert_equal(true, frame.value.reference_position.is_a?(HELIOCENTER))
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_astro_coord_area
|
50
|
+
area = nil
|
51
|
+
assert_nothing_raised {
|
52
|
+
area = AstroCoordArea.load_from_xml(
|
53
|
+
REXML::Document.new(
|
54
|
+
'<AstroCoordArea ID="myID" coord_system_id="myCoordSystem">' +
|
55
|
+
'<Sphere unit="deg" radius_unit="deg">' +
|
56
|
+
'<Radius>23</Radius>' +
|
57
|
+
'<Center>0 0 0</Center>' +
|
58
|
+
'</Sphere>' +
|
59
|
+
'<VelocityInterval unit="m" vel_time_unit="s">' +
|
60
|
+
'<CoordScalarInterval>' +
|
61
|
+
'<LoLimit>0</LoLimit>' +
|
62
|
+
'<HiLimit>10</HiLimit>' +
|
63
|
+
'</CoordScalarInterval>' +
|
64
|
+
'</VelocityInterval>' +
|
65
|
+
'<CoordScalarInterval>' +
|
66
|
+
'<LoLimit>0</LoLimit>' +
|
67
|
+
'<HiLimit>10</HiLimit>' +
|
68
|
+
'</CoordScalarInterval>' +
|
69
|
+
'<CoordScalarInterval>' +
|
70
|
+
'<LoLimit>10</LoLimit>' +
|
71
|
+
'<HiLimit>50</HiLimit>' +
|
72
|
+
'</CoordScalarInterval>' +
|
73
|
+
'</AstroCoordArea>').root
|
74
|
+
)
|
75
|
+
}
|
76
|
+
|
77
|
+
assert_equal('myID', area.value.coord_area_id)
|
78
|
+
assert_equal('myCoordSystem', area.value.coord_system_id)
|
79
|
+
|
80
|
+
assert_equal('deg', area.value.spatial_interval.value.unit.value)
|
81
|
+
assert_equal('deg', area.value.spatial_interval.value.radius_unit.value)
|
82
|
+
assert_equal(23, area.value.spatial_interval.value.radius)
|
83
|
+
assert_equal([0, 0, 0], area.value.spatial_interval.value.center.value)
|
84
|
+
|
85
|
+
assert_equal(0, area.value.coord_intervals[0].value.lo_limit)
|
86
|
+
assert_equal(10, area.value.coord_intervals[0].value.hi_limit)
|
87
|
+
assert_equal(10, area.value.coord_intervals[1].value.lo_limit)
|
88
|
+
assert_equal(50, area.value.coord_intervals[1].value.hi_limit)
|
89
|
+
|
90
|
+
assert_equal('m', area.value.vel_intervals[0].value.unit.value)
|
91
|
+
assert_equal('s', area.value.vel_intervals[0].value.vel_time_unit.value)
|
92
|
+
assert_equal(10, area.value.vel_intervals[0].value.coord_interval.value.hi_limit)
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_stc_resoure_profile
|
96
|
+
profile = nil
|
97
|
+
assert_nothing_raised {
|
98
|
+
profile = STCResourceProfile.load_from_file('test/stc/stc_resource_profile_v1_20.xml')
|
99
|
+
}
|
100
|
+
|
101
|
+
coord_sys = profile.value.coord_sys[0].value
|
102
|
+
assert_equal('ICRS-TT-CXO', coord_sys.coord_sys_type_id)
|
103
|
+
assert_equal('Time', coord_sys.time_frame.value.name)
|
104
|
+
assert_equal('TT', coord_sys.time_frame.value.time_scale.value)
|
105
|
+
assert_equal(TOPOCENTER, coord_sys.time_frame.value.reference_position.class)
|
106
|
+
assert_equal('Space', coord_sys.space_frame.value.name)
|
107
|
+
assert_equal(ICRS, coord_sys.space_frame.value.space_ref_frame.class)
|
108
|
+
assert_equal(TOPOCENTER, coord_sys.space_frame.value.reference_position.class)
|
109
|
+
assert_equal(SPHERICAL, coord_sys.space_frame.value.coord_flavor.class)
|
110
|
+
assert_equal(2, coord_sys.space_frame.value.coord_flavor.value.coord_naxes)
|
111
|
+
assert_equal('Energy', coord_sys.spectral_frame.value.name)
|
112
|
+
assert_equal(TOPOCENTER, coord_sys.spectral_frame.value.reference_position.class)
|
113
|
+
|
114
|
+
coords = profile.value.coords[0].value
|
115
|
+
assert_equal('ICRS-TT-CXO', coords.coord_system_id)
|
116
|
+
assert_equal('s', coords.time.unit.value)
|
117
|
+
assert_equal('Time', coords.time.name)
|
118
|
+
assert_equal(0.0001, coords.time.error[0].value)
|
119
|
+
assert_equal([0.000016, 3.0], coords.time.resolution.collect{ |res| res.value })
|
120
|
+
assert_equal([1000, 170000], coords.time.size.collect{ |size| size.value })
|
121
|
+
assert_equal('Position', coords.position.name)
|
122
|
+
assert_equal([1.0, 1.0], coords.position.error[0].value.value)
|
123
|
+
assert_equal([0.5, 0.5], coords.position.resolution[0].value.value)
|
124
|
+
assert_equal([1000, 1000], coords.position.size[0].value.value)
|
125
|
+
assert_equal([4000, 4000], coords.position.size[1].value.value)
|
126
|
+
assert_equal('keV', coords.spectral.unit.value)
|
127
|
+
assert_equal('Energy', coords.spectral.name)
|
128
|
+
assert_equal(0.1, coords.spectral.error[0].value)
|
129
|
+
assert_equal(0.02, coords.spectral.resolution[0].value)
|
130
|
+
assert_equal(2.0, coords.spectral.resolution[1].value)
|
131
|
+
assert_equal(2, coords.spectral.size[0].value)
|
132
|
+
assert_equal(10, coords.spectral.size[1].value)
|
133
|
+
|
134
|
+
coord_area = profile.value.coord_area[0].value
|
135
|
+
assert_equal('AllSky-CXO', coord_area.coord_area_id)
|
136
|
+
assert_equal('ICRS-TT-CXO', coord_area.coord_system_id)
|
137
|
+
assert_equal('TT', coord_area.time_intervals[0].start_time.timescale.value)
|
138
|
+
assert_equal('1999-07-23T16:00:00', coord_area.time_intervals[0].start_time.absolute_time.value.strftime('%Y-%m-%dT%H:%M:%S'))
|
139
|
+
assert_equal(true, coord_area.spatial_interval.value.region.is_a?(AllSky))
|
140
|
+
assert_equal(0.02, coord_area.spatial_interval.value.region.value.fill_factor)
|
141
|
+
assert_equal('keV', coord_area.spectral_intervals[0].unit.value)
|
142
|
+
assert_equal(0.12, coord_area.spectral_intervals[0].lo_limit)
|
143
|
+
assert_equal(10.0, coord_area.spectral_intervals[0].hi_limit)
|
144
|
+
end
|
145
|
+
|
146
|
+
def test_catalog_entry_location
|
147
|
+
catalog = nil
|
148
|
+
assert_nothing_raised {
|
149
|
+
catalog = CatalogEntryLocation.load_from_file('test/stc/catalog_entry_location_v1_20.xml')
|
150
|
+
}
|
151
|
+
|
152
|
+
coord_sys1 = catalog.value.coord_sys[0].value
|
153
|
+
assert_equal('B1950-OPTICAL-ET', coord_sys1.coord_sys_type_id)
|
154
|
+
assert_equal('Time', coord_sys1.time_frame.value.name)
|
155
|
+
assert_equal('ET', coord_sys1.time_frame.value.time_scale.value)
|
156
|
+
assert_equal(true, coord_sys1.time_frame.value.reference_position.is_a?(TOPOCENTER))
|
157
|
+
assert_equal('PosEq', coord_sys1.space_frame.value.name)
|
158
|
+
assert_equal('B1950.0', coord_sys1.space_frame.value.space_ref_frame.value.equinox.value)
|
159
|
+
assert_equal(true, coord_sys1.space_frame.value.reference_position.is_a?(BARYCENTER))
|
160
|
+
assert_equal(true, coord_sys1.space_frame.value.coord_flavor.is_a?(SPHERICAL))
|
161
|
+
assert_equal(2, coord_sys1.space_frame.value.coord_flavor.value.coord_naxes)
|
162
|
+
assert_equal(true, coord_sys1.space_frame.value.coord_flavor.value.coord_vel)
|
163
|
+
assert_equal('Optical', coord_sys1.spectral_frame.value.name)
|
164
|
+
assert_equal(true, coord_sys1.spectral_frame.value.reference_position.is_a?(TOPOCENTER))
|
165
|
+
assert_equal('DopplerVelocity', coord_sys1.redshift_frame.value.name)
|
166
|
+
assert_equal('OPTICAL', coord_sys1.redshift_frame.value.doppler_definition.value)
|
167
|
+
assert_equal(true, coord_sys1.redshift_frame.value.reference_position.is_a?(BARYCENTER))
|
168
|
+
|
169
|
+
coord1 = catalog.value.coords[0].value
|
170
|
+
assert_equal('B1950-OPTICAL-ET', coord1.coord_system_id)
|
171
|
+
assert_equal('deg', coord1.position.unit.value)
|
172
|
+
assert_equal('RA,Dec', coord1.position.name)
|
173
|
+
assert_equal('Column3', coord1.position.value.value)
|
174
|
+
assert_equal('Column4', coord1.position.error[0].value)
|
175
|
+
assert_equal('Column5', coord1.position.size[0].value)
|
176
|
+
assert_equal('km', coord1.redshift.unit.value)
|
177
|
+
assert_equal('s', coord1.redshift.vel_time_unit.value)
|
178
|
+
assert_equal('Vrad(barycenter)', coord1.redshift.name)
|
179
|
+
assert_equal('Column6', coord1.redshift.value.value)
|
180
|
+
assert_equal('Column7', coord1.redshift.error[0].value)
|
181
|
+
|
182
|
+
coord_area1 = catalog.value.coord_area[0].value
|
183
|
+
assert_equal('B1950-OPTICAL-ET', coord_area1.coord_system_id)
|
184
|
+
assert_equal('RA6-18hDec20-70deg', coord_area1.coord_area_id)
|
185
|
+
assert_equal('ET', coord_area1.time_intervals[0].start_time.timescale.value)
|
186
|
+
assert_equal('1968-05-23T00:00:00Z', coord_area1.time_intervals[0].start_time.absolute_time.value.to_s)
|
187
|
+
assert_equal('ET', coord_area1.time_intervals[0].end_time.timescale.value)
|
188
|
+
assert_equal('1971-02-17T00:00:00Z', coord_area1.time_intervals[0].end_time.absolute_time.value.to_s)
|
189
|
+
assert_equal(true, coord_area1.spatial_interval.value.region.is_a?(Polygon))
|
190
|
+
assert_equal('deg', coord_area1.spatial_interval.value.region.value.unit.value)
|
191
|
+
assert_equal([270, 70], coord_area1.spatial_interval.value.region.value.vertices[3].position.value)
|
192
|
+
assert_equal(true, coord_area1.spatial_interval.value.region.value.vertices[3].small_circle.is_a?(SmallCircleType))
|
193
|
+
assert_equal('Angstrom', coord_area1.spectral_intervals[0].unit.value)
|
194
|
+
assert_equal(5000, coord_area1.spectral_intervals[0].lo_limit)
|
195
|
+
assert_equal(6500, coord_area1.spectral_intervals[0].hi_limit)
|
196
|
+
assert_equal('km', coord_area1.redshift_intervals[0].unit.value)
|
197
|
+
assert_equal('s', coord_area1.redshift_intervals[0].vel_time_unit.value)
|
198
|
+
assert_equal(10000, coord_area1.redshift_intervals[0].hi_limit)
|
199
|
+
end
|
200
|
+
|
201
|
+
def test_obs_data_location
|
202
|
+
obs_data = nil
|
203
|
+
assert_nothing_raised {
|
204
|
+
obs_data = ObsDataLocation.load_from_file('test/stc/obs_data_location_v1_20.xml')
|
205
|
+
}
|
206
|
+
|
207
|
+
observ_loc = obs_data.value.observatory_location
|
208
|
+
assert_equal('KPNO', observ_loc.type_id)
|
209
|
+
assert_equal('ICRS-TT-TOPO', observ_loc.coord_sys[0].value.coord_sys_type_id)
|
210
|
+
assert_equal('Time', observ_loc.coord_sys[0].value.time_frame.value.name)
|
211
|
+
assert_equal('GeoLongLatElev', observ_loc.coord_sys[0].value.space_frame.value.name)
|
212
|
+
assert_equal('KPNO', observ_loc.coords.value.coord_system_id)
|
213
|
+
assert_equal('deg deg m', observ_loc.coords.value.position.unit.value)
|
214
|
+
assert_equal('LongLatElev', observ_loc.coords.value.position.name)
|
215
|
+
|
216
|
+
obs_loc = obs_data.value.observation_location
|
217
|
+
assert_equal('M81', obs_loc.type_id)
|
218
|
+
assert_equal('ICRS-TT-WAVELENGTH-TOPO', obs_loc.coord_sys[0].value.coord_sys_type_id)
|
219
|
+
assert_equal('TT', obs_loc.coord_sys[0].value.time_frame.value.time_scale.value)
|
220
|
+
assert_equal(true, obs_loc.coord_sys[0].value.space_frame.value.reference_position.is_a?(TOPOCENTER))
|
221
|
+
assert_equal('Wavelength', obs_loc.coord_sys[0].value.spectral_frame.value.name)
|
222
|
+
assert_equal('ICRS-TT-WAVELENGTH-TOPO', obs_loc.coords.value.coord_system_id)
|
223
|
+
assert_equal('2004-07-15T08:23:56', obs_loc.coords.value.time.time_instant.absolute_time.value.strftime('%Y-%m-%dT%H:%M:%S'))
|
224
|
+
assert_equal([148.88821, 69.06529], obs_loc.coords.value.position.value.value.value)
|
225
|
+
assert_equal(400, obs_loc.coords.value.spectral.resolution[0].value)
|
226
|
+
assert_equal('M81Image', obs_loc.coord_area.value.coord_area_id)
|
227
|
+
assert_equal('TT', obs_loc.coord_area.value.time_intervals[0].start_time.timescale.value)
|
228
|
+
assert_equal([148.18821, 68.81529], obs_loc.coord_area.value.spatial_interval.value.coord_interval.value.lo_limit_2vec.value)
|
229
|
+
assert_equal(4400, obs_loc.coord_area.value.spectral_intervals[0].lo_limit)
|
230
|
+
|
231
|
+
pix_space = obs_data.value.pixel_space
|
232
|
+
assert_equal('M81Pix', pix_space.coord_sys.value.coord_sys_type_id)
|
233
|
+
assert_equal('Y', pix_space.coord_sys.value.coord_frames[1].value.name)
|
234
|
+
assert_equal(1024, pix_space.coord_area.value.coord_intervals[0].value.hi_limit)
|
235
|
+
end
|
236
|
+
|
237
|
+
def test_search_location
|
238
|
+
loc = nil
|
239
|
+
assert_nothing_raised {
|
240
|
+
loc = SearchLocation.load_from_file('test/stc/search_location_v1_20.xml')
|
241
|
+
}
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
class RegionTest < Test::Unit::TestCase
|
246
|
+
def test_circle
|
247
|
+
region = nil
|
248
|
+
assert_nothing_raised {
|
249
|
+
region = Circle.load_from_xml(
|
250
|
+
REXML::Document.new(
|
251
|
+
'<Circle unit="deg">' +
|
252
|
+
'<Center>233.73 23.49</Center>' +
|
253
|
+
'<Radius>1.0</Radius>' +
|
254
|
+
'</Circle>').root
|
255
|
+
)
|
256
|
+
}
|
257
|
+
|
258
|
+
assert_equal('deg', region.value.unit.value)
|
259
|
+
assert_equal([233.73, 23.49], region.value.center.value)
|
260
|
+
assert_equal(1.0, region.value.radius)
|
261
|
+
end
|
262
|
+
|
263
|
+
def test_all_sky
|
264
|
+
region = nil
|
265
|
+
assert_nothing_raised {
|
266
|
+
region = AllSky.load_from_xml(
|
267
|
+
REXML::Document.new(
|
268
|
+
'<AllSky fill_factor="0.3" note="My note" />').root
|
269
|
+
)
|
270
|
+
}
|
271
|
+
|
272
|
+
assert_equal(0.3, region.value.fill_factor)
|
273
|
+
assert_equal('My note', region.value.note)
|
274
|
+
end
|
275
|
+
|
276
|
+
def test_ellipse
|
277
|
+
region = nil
|
278
|
+
assert_nothing_raised {
|
279
|
+
region = Ellipse.load_from_xml(
|
280
|
+
REXML::Document.new(
|
281
|
+
'<Ellipse unit="deg">' +
|
282
|
+
'<Center>233.73 23.49</Center>' +
|
283
|
+
'<Radius>1.0</Radius>' +
|
284
|
+
'<MinorRadius>10</MinorRadius>' +
|
285
|
+
'<PosAngle reference="X">23.2</PosAngle>' +
|
286
|
+
'</Ellipse>').root
|
287
|
+
)
|
288
|
+
}
|
289
|
+
|
290
|
+
assert_equal('deg', region.value.unit.value)
|
291
|
+
assert_equal([233.73, 23.49], region.value.center.value)
|
292
|
+
assert_equal(1.0, region.value.radius)
|
293
|
+
assert_equal(10, region.value.minor_radius)
|
294
|
+
assert_equal('X', region.value.pos_angle.reference.value)
|
295
|
+
assert_equal(23.2, region.value.pos_angle.value)
|
296
|
+
end
|
297
|
+
|
298
|
+
def test_polygon
|
299
|
+
region = nil
|
300
|
+
assert_nothing_raised {
|
301
|
+
region = Polygon.load_from_xml(
|
302
|
+
REXML::Document.new(
|
303
|
+
'<Polygon>' +
|
304
|
+
'<Vertex><Position>12.3 3.1</Position></Vertex>' +
|
305
|
+
'<Vertex><Position>13.1 6.2</Position></Vertex>' +
|
306
|
+
'<Vertex><Position>15.6 11.3</Position></Vertex>' +
|
307
|
+
'</Polygon>').root
|
308
|
+
)
|
309
|
+
}
|
310
|
+
|
311
|
+
assert_equal([12.3, 3.1], region.value.vertices[0].position.value)
|
312
|
+
assert_equal([13.1, 6.2], region.value.vertices[1].position.value)
|
313
|
+
assert_equal([15.6, 11.3], region.value.vertices[2].position.value)
|
314
|
+
end
|
315
|
+
|
316
|
+
def test_box
|
317
|
+
region = nil
|
318
|
+
assert_nothing_raised {
|
319
|
+
region = Box.load_from_xml(
|
320
|
+
REXML::Document.new(
|
321
|
+
'<Box>' +
|
322
|
+
'<Center>56 72</Center>' +
|
323
|
+
'<Size>10 23</Size>' +
|
324
|
+
'</Box>').root
|
325
|
+
)
|
326
|
+
}
|
327
|
+
|
328
|
+
assert_equal([56, 72], region.value.center.value)
|
329
|
+
assert_equal([10, 23], region.value.size.value)
|
330
|
+
end
|
331
|
+
|
332
|
+
def test_sector
|
333
|
+
region = nil
|
334
|
+
assert_nothing_raised {
|
335
|
+
region = Sector.load_from_xml(
|
336
|
+
REXML::Document.new(
|
337
|
+
'<Sector>' +
|
338
|
+
'<Position>12.4 10.2</Position>' +
|
339
|
+
'<PosAngle1>2.0</PosAngle1>' +
|
340
|
+
'<PosAngle2>33.1</PosAngle2>' +
|
341
|
+
'</Sector>').root
|
342
|
+
)
|
343
|
+
}
|
344
|
+
|
345
|
+
assert_equal([12.4, 10.2], region.value.position.value)
|
346
|
+
assert_equal(2.0, region.value.pos_angle1.value)
|
347
|
+
assert_equal(33.1, region.value.pos_angle2.value)
|
348
|
+
end
|
349
|
+
|
350
|
+
def test_convex
|
351
|
+
region = nil
|
352
|
+
assert_nothing_raised {
|
353
|
+
region = Convex.load_from_xml(
|
354
|
+
REXML::Document.new(
|
355
|
+
'<Convex>' +
|
356
|
+
'<Constraint><Offset>0.5</Offset><Vector>4 6 8</Vector></Constraint>' +
|
357
|
+
'<Constraint><Offset>0.1</Offset><Vector>10 12 14</Vector></Constraint>' +
|
358
|
+
'</Convex>').root
|
359
|
+
)
|
360
|
+
}
|
361
|
+
|
362
|
+
assert_equal(0.5, region.value.constraints[0].offset)
|
363
|
+
assert_equal([4, 6, 8], region.value.constraints[0].vector.value)
|
364
|
+
assert_equal(0.1, region.value.constraints[1].offset)
|
365
|
+
assert_equal([10, 12, 14], region.value.constraints[1].vector.value)
|
366
|
+
end
|
367
|
+
|
368
|
+
def test_convex_hull
|
369
|
+
region = nil
|
370
|
+
assert_nothing_raised {
|
371
|
+
region = ConvexHull.load_from_xml(
|
372
|
+
REXML::Document.new(
|
373
|
+
'<ConvexHull>' +
|
374
|
+
'<Point>1.2 3.4 5.6</Point><Point>6.7 8.9 10.11</Point>' +
|
375
|
+
'</ConvexHull>').root
|
376
|
+
)
|
377
|
+
}
|
378
|
+
|
379
|
+
assert_equal([1.2, 3.4, 5.6], region.value.points[0].value)
|
380
|
+
assert_equal([6.7, 8.9, 10.11], region.value.points[1].value)
|
381
|
+
end
|
382
|
+
|
383
|
+
def test_union
|
384
|
+
region = nil
|
385
|
+
assert_nothing_raised {
|
386
|
+
region = Union.load_from_xml(
|
387
|
+
REXML::Document.new(
|
388
|
+
'<Union>' +
|
389
|
+
'<Region>' +
|
390
|
+
'<Circle unit="deg">' +
|
391
|
+
'<Center>233.73 23.49</Center>' +
|
392
|
+
'<Radius>1.0</Radius>' +
|
393
|
+
'</Circle>' +
|
394
|
+
'</Region>' +
|
395
|
+
'<Region>' +
|
396
|
+
'<Circle unit="deg">' +
|
397
|
+
'<Center>223.73 53.49</Center>' +
|
398
|
+
'<Radius>20.0</Radius>' +
|
399
|
+
'</Circle>' +
|
400
|
+
'</Region>' +
|
401
|
+
'</Union>').root
|
402
|
+
)
|
403
|
+
}
|
404
|
+
|
405
|
+
assert_equal([233.73, 23.49], region.value.regions[0].center.value)
|
406
|
+
assert_equal(1.0, region.value.regions[0].radius)
|
407
|
+
assert_equal([223.73, 53.49], region.value.regions[1].center.value)
|
408
|
+
assert_equal(20.0, region.value.regions[1].radius)
|
409
|
+
end
|
410
|
+
|
411
|
+
def test_intersection
|
412
|
+
region = nil
|
413
|
+
assert_nothing_raised {
|
414
|
+
region = Intersection.load_from_xml(
|
415
|
+
REXML::Document.new(
|
416
|
+
'<Intersection>' +
|
417
|
+
'<Region>' +
|
418
|
+
'<Circle unit="deg">' +
|
419
|
+
'<Center>233.73 23.49</Center>' +
|
420
|
+
'<Radius>1.0</Radius>' +
|
421
|
+
'</Circle>' +
|
422
|
+
'</Region>' +
|
423
|
+
'<Region>' +
|
424
|
+
'<Box>' +
|
425
|
+
'<Center>56 72</Center>' +
|
426
|
+
'<Size>10 23</Size>' +
|
427
|
+
'</Box>' +
|
428
|
+
'</Region>' +
|
429
|
+
'</Intersection>').root
|
430
|
+
)
|
431
|
+
}
|
432
|
+
|
433
|
+
assert_equal([233.73, 23.49], region.value.regions[0].center.value)
|
434
|
+
assert_equal(1.0, region.value.regions[0].radius)
|
435
|
+
assert_equal([56, 72], region.value.regions[1].center.value)
|
436
|
+
assert_equal([10, 23], region.value.regions[1].size.value)
|
437
|
+
end
|
438
|
+
|
439
|
+
def test_negation
|
440
|
+
region = nil
|
441
|
+
assert_nothing_raised {
|
442
|
+
region = Negation.load_from_xml(
|
443
|
+
REXML::Document.new(
|
444
|
+
'<Negation>' +
|
445
|
+
'<Region>' +
|
446
|
+
'<Circle unit="deg">' +
|
447
|
+
'<Center>233.73 23.49</Center>' +
|
448
|
+
'<Radius>1.0</Radius>' +
|
449
|
+
'</Circle>' +
|
450
|
+
'</Region>' +
|
451
|
+
'</Negation>').root
|
452
|
+
)
|
453
|
+
}
|
454
|
+
|
455
|
+
assert_equal([233.73, 23.49], region.value.region.center.value)
|
456
|
+
assert_equal(1.0, region.value.region.radius)
|
457
|
+
end
|
458
|
+
|
459
|
+
end
|
460
|
+
|
461
|
+
class CoordsTest < Test::Unit::TestCase
|
462
|
+
def test_astron_time_type
|
463
|
+
type = nil
|
464
|
+
assert_nothing_raised {
|
465
|
+
type = AstronTimeType.load_from_xml(
|
466
|
+
REXML::Document.new(
|
467
|
+
'<AstronTime>' +
|
468
|
+
'<Timescale>LOCAL</Timescale>' +
|
469
|
+
'<TimeOffset unit="s">12.2</TimeOffset>' +
|
470
|
+
'<ISOTime>2006-09-07T15:32:51</ISOTime>' +
|
471
|
+
'</AstronTime>').root
|
472
|
+
)
|
473
|
+
}
|
474
|
+
|
475
|
+
assert_equal('LOCAL', type.timescale.value)
|
476
|
+
assert_equal('s', type.relative_time.unit.value)
|
477
|
+
assert_equal(12.2, type.relative_time.value)
|
478
|
+
assert_equal('2006-09-07T15:32:51', type.absolute_time.value.strftime('%Y-%m-%dT%H:%M:%S'))
|
479
|
+
end
|
480
|
+
|
481
|
+
def test_scalar_coordinate_type
|
482
|
+
type = nil
|
483
|
+
assert_nothing_raised {
|
484
|
+
type = ScalarCoordinateType.load_from_xml(
|
485
|
+
REXML::Document.new(
|
486
|
+
'<ScalarCoordinate>' +
|
487
|
+
'<Name>Comment</Name>' +
|
488
|
+
'<Value>23.2</Value>' +
|
489
|
+
'<Error>0.1</Error><Error>0.5</Error>' +
|
490
|
+
'<Resolution>0.5</Resolution><Resolution>0.8</Resolution>' +
|
491
|
+
'<Size>5</Size><Size>10</Size>' +
|
492
|
+
'<PixSize>0.3</PixSize><PixSize>0.4</PixSize>' +
|
493
|
+
'</ScalarCoordinate>').root
|
494
|
+
)
|
495
|
+
}
|
496
|
+
|
497
|
+
assert_equal(23.2, type.value.value)
|
498
|
+
assert_equal(0.1, type.error[0].value)
|
499
|
+
assert_equal(0.5, type.error[1].value)
|
500
|
+
assert_equal(0.5, type.resolution[0].value)
|
501
|
+
assert_equal(0.8, type.resolution[1].value)
|
502
|
+
assert_equal(5, type.size[0].value)
|
503
|
+
assert_equal(10, type.size[1].value)
|
504
|
+
assert_equal(0.3, type.pix_size[0].value)
|
505
|
+
assert_equal(0.4, type.pix_size[1].value)
|
506
|
+
end
|
507
|
+
|
508
|
+
def test_time_coordinate_type
|
509
|
+
type = nil
|
510
|
+
assert_nothing_raised {
|
511
|
+
type = TimeCoordinateType.load_from_xml(
|
512
|
+
REXML::Document.new(
|
513
|
+
'<Time>' +
|
514
|
+
'<Name>Blah</Name>' +
|
515
|
+
'<TimeInstant>' +
|
516
|
+
'<Timescale>LOCAL</Timescale>' +
|
517
|
+
'<TimeOffset unit="s">12.2</TimeOffset>' +
|
518
|
+
'<ISOTime>2006-09-07T15:32:51</ISOTime>' +
|
519
|
+
'</TimeInstant>' +
|
520
|
+
'<Error>0.1</Error><Error>0.5</Error>' +
|
521
|
+
'<Resolution>0.5</Resolution><Resolution>0.8</Resolution>' +
|
522
|
+
'<Size>5</Size><Size>10</Size>' +
|
523
|
+
'<PixSize>0.3</PixSize><PixSize>0.4</PixSize>' +
|
524
|
+
'</Time>').root
|
525
|
+
)
|
526
|
+
}
|
527
|
+
|
528
|
+
assert_equal('LOCAL', type.time_instant.timescale.value)
|
529
|
+
assert_equal('s', type.time_instant.relative_time.unit.value)
|
530
|
+
assert_equal(12.2, type.time_instant.relative_time.value)
|
531
|
+
assert_equal('2006-09-07T15:32:51', type.time_instant.absolute_time.value.strftime('%Y-%m-%dT%H:%M:%S'))
|
532
|
+
assert_equal(0.1, type.error[0].value)
|
533
|
+
assert_equal(0.5, type.error[1].value)
|
534
|
+
assert_equal(0.5, type.resolution[0].value)
|
535
|
+
assert_equal(0.8, type.resolution[1].value)
|
536
|
+
assert_equal(5, type.size[0].value)
|
537
|
+
assert_equal(10, type.size[1].value)
|
538
|
+
assert_equal(0.3, type.pix_size[0].value)
|
539
|
+
assert_equal(0.4, type.pix_size[1].value)
|
540
|
+
end
|
541
|
+
|
542
|
+
def test_size2_type
|
543
|
+
type = nil
|
544
|
+
assert_nothing_raised {
|
545
|
+
type = Size2Type.load_from_xml(
|
546
|
+
REXML::Document.new(
|
547
|
+
'<Size2>' +
|
548
|
+
'<Size>2 4</Size>' +
|
549
|
+
'<PosAngle unit="deg" reference="X">35</PosAngle>' +
|
550
|
+
'</Size2>').root
|
551
|
+
)
|
552
|
+
}
|
553
|
+
|
554
|
+
assert_equal(2, type.size.value[0])
|
555
|
+
assert_equal(4, type.size.value[1])
|
556
|
+
assert_equal('deg', type.pos_angle.unit.value)
|
557
|
+
assert_equal('X', type.pos_angle.reference.value)
|
558
|
+
assert_equal(35, type.pos_angle.value)
|
559
|
+
end
|
560
|
+
|
561
|
+
def test_vector2_coordinate_type
|
562
|
+
type = nil
|
563
|
+
assert_nothing_raised {
|
564
|
+
type = Vector2CoordinateType.load_from_xml(
|
565
|
+
REXML::Document.new(
|
566
|
+
'<Vector2Coordinate>' +
|
567
|
+
'<Name>Blah</Name>' +
|
568
|
+
'<Value2>23.2 2.3</Value2>' +
|
569
|
+
'<Error2>0.1 0.1</Error2><Error2>0.5 0.5</Error2>' +
|
570
|
+
'<Resolution2>0.5 1</Resolution2><Resolution2>0.8 1.1</Resolution2>' +
|
571
|
+
'<Size2>5 4</Size2><Size2>10 2</Size2>' +
|
572
|
+
'<PixSize2>0.3 0.2</PixSize2><PixSize2>0.4 0.2</PixSize2>' +
|
573
|
+
'</Vector2Coordinate>').root
|
574
|
+
)
|
575
|
+
}
|
576
|
+
|
577
|
+
assert_equal(23.2, type.value.value.value[0])
|
578
|
+
assert_equal(2.3, type.value.value.value[1])
|
579
|
+
assert_equal(0.1, type.error[0].value.value[0])
|
580
|
+
assert_equal(0.1, type.error[0].value.value[1])
|
581
|
+
assert_equal(0.5, type.error[1].value.value[0])
|
582
|
+
assert_equal(0.5, type.error[1].value.value[1])
|
583
|
+
assert_equal(0.5, type.resolution[0].value.value[0])
|
584
|
+
assert_equal(1, type.resolution[0].value.value[1])
|
585
|
+
assert_equal(0.8, type.resolution[1].value.value[0])
|
586
|
+
assert_equal(1.1, type.resolution[1].value.value[1])
|
587
|
+
assert_equal(5, type.size[0].value.value[0])
|
588
|
+
assert_equal(4, type.size[0].value.value[1])
|
589
|
+
assert_equal(10, type.size[1].value.value[0])
|
590
|
+
assert_equal(2, type.size[1].value.value[1])
|
591
|
+
assert_equal(0.3, type.pix_size[0].value.value[0])
|
592
|
+
assert_equal(0.2, type.pix_size[0].value.value[1])
|
593
|
+
assert_equal(0.4, type.pix_size[1].value.value[0])
|
594
|
+
assert_equal(0.2, type.pix_size[1].value.value[1])
|
595
|
+
end
|
596
|
+
|
597
|
+
def test_size3_type
|
598
|
+
type = nil
|
599
|
+
assert_nothing_raised {
|
600
|
+
type = Size3Type.load_from_xml(
|
601
|
+
REXML::Document.new(
|
602
|
+
'<Size3>' +
|
603
|
+
'<Size>2 4 6</Size>' +
|
604
|
+
'<PosAngle1 unit="deg" reference="X">35</PosAngle1>' +
|
605
|
+
'<PosAngle2 unit="deg" reference="X">21.1</PosAngle2>' +
|
606
|
+
'</Size3>').root
|
607
|
+
)
|
608
|
+
}
|
609
|
+
|
610
|
+
assert_equal(2, type.size.value[0])
|
611
|
+
assert_equal(4, type.size.value[1])
|
612
|
+
assert_equal(6, type.size.value[2])
|
613
|
+
assert_equal('deg', type.pos_angle1.unit.value)
|
614
|
+
assert_equal('X', type.pos_angle1.reference.value)
|
615
|
+
assert_equal(35, type.pos_angle1.value)
|
616
|
+
assert_equal('deg', type.pos_angle2.unit.value)
|
617
|
+
assert_equal('X', type.pos_angle2.reference.value)
|
618
|
+
assert_equal(21.1, type.pos_angle2.value)
|
619
|
+
end
|
620
|
+
end
|