voruby 1.1.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (257) hide show
  1. data/Rakefile.rb +107 -224
  2. data/lib/misc.rb +1 -0
  3. data/lib/misc/misc.rb +60 -0
  4. data/lib/misc/propertyfile.rb +31 -0
  5. data/lib/symphony.rb +1 -0
  6. data/lib/symphony/symphony.rb +247 -0
  7. data/lib/voruby.rb +186 -0
  8. data/lib/voruby/active_votable/active_votable.rb +468 -347
  9. data/lib/voruby/adql/1.0/adql.rb +2418 -0
  10. data/lib/voruby/adql/support.rb +2 -0
  11. data/lib/voruby/misc.rb +351 -0
  12. data/lib/voruby/misc/connection_monitor.rb +97 -0
  13. data/lib/voruby/misc/libxml_ext.rb +121 -0
  14. data/lib/voruby/misc/rexml_ext.rb +223 -0
  15. data/lib/voruby/resolver/resolver.rb +12 -0
  16. data/lib/voruby/resolver/sesame.rb +299 -0
  17. data/lib/voruby/sky_query/sky_query.rb +192 -0
  18. data/lib/voruby/stc/1.10/coords.rb +2272 -0
  19. data/lib/voruby/stc/1.10/region.rb +892 -0
  20. data/lib/voruby/stc/1.10/stc.rb +3271 -0
  21. data/lib/voruby/stc/1.30/stc.rb +8666 -0
  22. data/lib/voruby/stc/support.rb +2 -0
  23. data/lib/voruby/ucd/ucd.rb +173 -0
  24. data/lib/voruby/voevent/1.1/voevent.rb +1124 -0
  25. data/lib/voruby/voevent/support.rb +5 -0
  26. data/lib/voruby/votable/1.0/votable.rb +1807 -0
  27. data/lib/voruby/votable/1.1/votable.rb +2100 -0
  28. data/lib/voruby/votable/votable.rb +305 -0
  29. data/lib/voruby/wesix/wesix.rb +491 -0
  30. data/lib/voruby/xlink/1.2/xlink.rb +21 -0
  31. data/test/voruby/active_votable/complex.vot +60 -0
  32. data/test/voruby/active_votable/error.vot +6 -0
  33. data/test/voruby/active_votable/large.vot +130040 -0
  34. data/test/voruby/active_votable/simple1.vot +38 -0
  35. data/test/voruby/active_votable/simple2.vot +38 -0
  36. data/test/voruby/active_votable/test.rb +193 -0
  37. data/test/voruby/adql/1.0/adql-alias.sql +1 -0
  38. data/test/voruby/adql/1.0/adql-alias.xml +26 -0
  39. data/test/voruby/adql/1.0/adql-avg.sql +1 -0
  40. data/test/voruby/adql/1.0/adql-avg.xml +31 -0
  41. data/test/voruby/adql/1.0/adql-circle.sql +1 -0
  42. data/test/voruby/adql/1.0/adql-circle.xml +46 -0
  43. data/test/voruby/adql/1.0/adql-expr.sql +1 -0
  44. data/test/voruby/adql/1.0/adql-expr.xml +34 -0
  45. data/test/voruby/adql/1.0/adql-function.sql +1 -0
  46. data/test/voruby/adql/1.0/adql-function.xml +41 -0
  47. data/test/voruby/adql/1.0/adql-group.sql +1 -0
  48. data/test/voruby/adql/1.0/adql-group.xml +51 -0
  49. data/test/voruby/adql/1.0/adql-having.sql +1 -0
  50. data/test/voruby/adql/1.0/adql-having.xml +25 -0
  51. data/test/voruby/adql/1.0/adql-like.sql +1 -0
  52. data/test/voruby/adql/1.0/adql-like.xml +17 -0
  53. data/test/voruby/adql/1.0/adql-order.sql +1 -0
  54. data/test/voruby/adql/1.0/adql-order.xml +37 -0
  55. data/test/voruby/adql/1.0/adql-simple.sql +1 -0
  56. data/test/voruby/adql/1.0/adql-simple.xml +12 -0
  57. data/test/voruby/adql/1.0/adql-top.sql +1 -0
  58. data/test/voruby/adql/1.0/adql-top.xml +33 -0
  59. data/test/voruby/adql/1.0/test.rb +2220 -0
  60. data/test/voruby/misc/test.rb +32 -0
  61. data/test/voruby/resolver/sesame/test.rb +56 -0
  62. data/test/voruby/sky_query/test.rb +107 -0
  63. data/test/voruby/stc/1.10/coords_test.rb +3704 -0
  64. data/test/voruby/stc/1.10/region_test.rb +993 -0
  65. data/test/voruby/stc/1.10/stc-catalog-entry-location.xml +112 -0
  66. data/test/voruby/stc/1.10/stc-obs-data-location.xml +126 -0
  67. data/test/voruby/stc/1.10/stc-region-circle.xml +5 -0
  68. data/test/voruby/stc/1.10/stc-region-convex.xml +11 -0
  69. data/test/voruby/stc/1.10/stc-region-convexhull.xml +5 -0
  70. data/test/voruby/stc/1.10/stc-region-ellipse.xml +7 -0
  71. data/test/voruby/stc/1.10/stc-region-intersection.xml +25 -0
  72. data/test/voruby/stc/1.10/stc-region-negation.xml +7 -0
  73. data/test/voruby/stc/1.10/stc-region-polygon.xml +13 -0
  74. data/test/voruby/stc/1.10/stc-region-sector.xml +6 -0
  75. data/test/voruby/stc/1.10/stc-region-union.xml +25 -0
  76. data/test/voruby/stc/1.10/stc-resource-profile.xml +60 -0
  77. data/test/voruby/stc/1.10/stc-search-location.xml +54 -0
  78. data/test/voruby/stc/1.10/stc_test.rb +4626 -0
  79. data/test/voruby/stc/1.30/stc-catalog-entry-location.xml +210 -0
  80. data/test/voruby/stc/1.30/stc-obs-data-location-arecibo.xml +353 -0
  81. data/test/voruby/stc/1.30/stc-obs-data-location-fits.xml +250 -0
  82. data/test/voruby/stc/1.30/stc-obs-data-location-xlink.xml +63 -0
  83. data/test/voruby/stc/1.30/stc-obs-data-location.xml +216 -0
  84. data/test/voruby/stc/1.30/stc-resource-profile-unusual-ref-pos.xml +39 -0
  85. data/test/voruby/stc/1.30/stc-resource-profile.xml +129 -0
  86. data/test/voruby/stc/1.30/stc-search-location-arecibo.xml +86 -0
  87. data/test/voruby/stc/1.30/stc-search-location.xml +101 -0
  88. data/test/voruby/stc/1.30/test.rb +6274 -0
  89. data/test/voruby/ucd/test.rb +48 -0
  90. data/test/voruby/voevent/1.1/test.rb +812 -0
  91. data/test/{voevent/voevent_v1_1.xml → voruby/voevent/1.1/voevent.xml} +2 -2
  92. data/test/voruby/voregistry/0.3/test.rb +137 -0
  93. data/test/voruby/votable/1.0/test.rb +714 -0
  94. data/test/voruby/votable/1.0/votable.basic.xml +660 -0
  95. data/test/voruby/votable/1.0/votable.html +86 -0
  96. data/test/voruby/votable/1.0/votable.ns.xml +56 -0
  97. data/test/voruby/votable/1.1/test.rb +785 -0
  98. data/test/voruby/votable/1.1/votable.basic.xml +38 -0
  99. data/test/voruby/votable/1.1/votable.html +86 -0
  100. data/test/voruby/votable/1.1/votable.ns.xml +56 -0
  101. data/test/voruby/votable/test.rb +15 -0
  102. data/test/voruby/wesix/test.rb +268 -0
  103. data/test/voruby/wesix/testr.fits +28 -0
  104. metadata +234 -247
  105. data/REQUIREMENTS +0 -6
  106. data/lib/voruby/active_votable/loader.rb +0 -5
  107. data/lib/voruby/adql/adql.rb +0 -2787
  108. data/lib/voruby/adql/ext.rb +0 -14
  109. data/lib/voruby/adql/loader.rb +0 -6
  110. data/lib/voruby/adql/operations.rb +0 -54
  111. data/lib/voruby/adql/parser.rb +0 -160
  112. data/lib/voruby/adql/transforms.rb +0 -573
  113. data/lib/voruby/ext.rb +0 -17
  114. data/lib/voruby/loader.rb +0 -4
  115. data/lib/voruby/misc/propertyfile.rb +0 -36
  116. data/lib/voruby/plastic/applications.rb +0 -174
  117. data/lib/voruby/plastic/constants.rb +0 -30
  118. data/lib/voruby/plastic/loader.rb +0 -10
  119. data/lib/voruby/plastic/plastic.rb +0 -1
  120. data/lib/voruby/resources/conesearch/conesearch.rb +0 -9
  121. data/lib/voruby/resources/conesearch/conesearch_v0_2.rb +0 -55
  122. data/lib/voruby/resources/conesearch/conesearch_v0_3.rb +0 -50
  123. data/lib/voruby/resources/conesearch/conesearch_v1_0.rb +0 -72
  124. data/lib/voruby/resources/conesearch/loader.rb +0 -4
  125. data/lib/voruby/resources/loader.rb +0 -50
  126. data/lib/voruby/resources/nodes.rb +0 -190
  127. data/lib/voruby/resources/openskynode/loader.rb +0 -4
  128. data/lib/voruby/resources/openskynode/openskynode.rb +0 -9
  129. data/lib/voruby/resources/openskynode/openskynode_v0_1.rb +0 -54
  130. data/lib/voruby/resources/sia/loader.rb +0 -5
  131. data/lib/voruby/resources/sia/sia.rb +0 -9
  132. data/lib/voruby/resources/sia/sia_v0_6.rb +0 -90
  133. data/lib/voruby/resources/sia/sia_v0_7.rb +0 -89
  134. data/lib/voruby/resources/sia/sia_v1_0.rb +0 -122
  135. data/lib/voruby/resources/stsci.rb +0 -59
  136. data/lib/voruby/resources/vodataservice/coverage_v0_2.rb +0 -195
  137. data/lib/voruby/resources/vodataservice/coverage_v0_3.rb +0 -158
  138. data/lib/voruby/resources/vodataservice/loader.rb +0 -5
  139. data/lib/voruby/resources/vodataservice/vodataservice.rb +0 -9
  140. data/lib/voruby/resources/vodataservice/vodataservice_v0_4.rb +0 -189
  141. data/lib/voruby/resources/vodataservice/vodataservice_v0_5.rb +0 -163
  142. data/lib/voruby/resources/vodataservice/vodataservice_v1_0.rb +0 -221
  143. data/lib/voruby/resources/voregistry/loader.rb +0 -4
  144. data/lib/voruby/resources/voregistry/voregistry.rb +0 -9
  145. data/lib/voruby/resources/voregistry/voregistry_v0_2.rb +0 -40
  146. data/lib/voruby/resources/voregistry/voregistry_v0_3.rb +0 -30
  147. data/lib/voruby/resources/voregistry/voregistry_v1_0.rb +0 -86
  148. data/lib/voruby/resources/voresource/loader.rb +0 -17
  149. data/lib/voruby/resources/voresource/voresource.rb +0 -9
  150. data/lib/voruby/resources/voresource/voresource_v0_10.rb +0 -327
  151. data/lib/voruby/resources/voresource/voresource_v0_9.rb +0 -405
  152. data/lib/voruby/resources/voresource/voresource_v1_0.rb +0 -230
  153. data/lib/voruby/services/ext.rb +0 -11
  154. data/lib/voruby/services/gestalt/footprint.rb +0 -95
  155. data/lib/voruby/services/gestalt/wcs_fixer.rb +0 -105
  156. data/lib/voruby/services/gestalt/wesix.rb +0 -155
  157. data/lib/voruby/services/loader.rb +0 -7
  158. data/lib/voruby/services/registry/registry.rb +0 -53
  159. data/lib/voruby/services/resolver/resolver.rb +0 -35
  160. data/lib/voruby/services/schema/schema.rb +0 -644
  161. data/lib/voruby/sesame/loader.rb +0 -6
  162. data/lib/voruby/sesame/sesame_v1_0.rb +0 -64
  163. data/lib/voruby/simple/loader.rb +0 -6
  164. data/lib/voruby/simple/parameters.rb +0 -196
  165. data/lib/voruby/simple/sap.rb +0 -446
  166. data/lib/voruby/spacetime/loader.rb +0 -3
  167. data/lib/voruby/spacetime/spacetime.rb +0 -607
  168. data/lib/voruby/stc/coords_v1_20.rb +0 -900
  169. data/lib/voruby/stc/loader.rb +0 -55
  170. data/lib/voruby/stc/region_v1_20.rb +0 -274
  171. data/lib/voruby/stc/stc_v1_20.rb +0 -1196
  172. data/lib/voruby/util.rb +0 -27
  173. data/lib/voruby/voevent/loader.rb +0 -7
  174. data/lib/voruby/voevent/voevent_v1_0.rb +0 -213
  175. data/lib/voruby/voevent/voevent_v1_1.rb +0 -196
  176. data/lib/voruby/votables/chandra.rb +0 -373
  177. data/lib/voruby/votables/data.rb +0 -179
  178. data/lib/voruby/votables/galex.rb +0 -377
  179. data/lib/voruby/votables/int.rb +0 -354
  180. data/lib/voruby/votables/libxml_parser.rb +0 -411
  181. data/lib/voruby/votables/libxml_votable.rb +0 -67
  182. data/lib/voruby/votables/loader.rb +0 -10
  183. data/lib/voruby/votables/meta.rb +0 -763
  184. data/lib/voruby/votables/misc.rb +0 -51
  185. data/lib/voruby/votables/nsa.rb +0 -410
  186. data/lib/voruby/votables/rexml_parser.rb +0 -408
  187. data/lib/voruby/votables/rexml_votable.rb +0 -67
  188. data/lib/voruby/votables/sdss.rb +0 -356
  189. data/lib/voruby/votables/transforms.rb +0 -388
  190. data/lib/voruby/votables/tree.rb +0 -45
  191. data/lib/voruby/votables/types.rb +0 -391
  192. data/lib/voruby/votables/votable.rb +0 -687
  193. data/test/active_votable/database.yml +0 -6
  194. data/test/active_votable/test.vot +0 -168492
  195. data/test/active_votable/unittest.rb +0 -41
  196. data/test/adql/test1.adql +0 -49
  197. data/test/adql/test2.adql +0 -51
  198. data/test/adql/test3.adql +0 -81
  199. data/test/adql/test4.adql +0 -53
  200. data/test/adql/test5.adql +0 -55
  201. data/test/adql/test6.adql +0 -18
  202. data/test/adql/test7.adql +0 -48
  203. data/test/adql/unittest.rb +0 -1672
  204. data/test/plastic/test.rb +0 -44
  205. data/test/plastic/test.vot +0 -5385
  206. data/test/plastic/unittest.rb +0 -66
  207. data/test/resources/conesearch/conesearch_v0_3.xml +0 -31
  208. data/test/resources/conesearch/conesearch_v1_0.xml +0 -86
  209. data/test/resources/conesearch/unittest_v0_3.rb +0 -22
  210. data/test/resources/conesearch/unittest_v1_0.rb +0 -24
  211. data/test/resources/openskynode/open_sky_node_v0_1.xml +0 -32
  212. data/test/resources/openskynode/unittest_v0_1.rb +0 -31
  213. data/test/resources/sia/simple_image_access_v0_7.xml +0 -36
  214. data/test/resources/sia/simple_image_access_v1_0.xml +0 -122
  215. data/test/resources/sia/unittest_v0_7.rb +0 -24
  216. data/test/resources/sia/unittest_v1_0.rb +0 -29
  217. data/test/resources/stsci.xml +0 -336
  218. data/test/resources/unittest_stsci.rb +0 -25
  219. data/test/resources/vodataservice/catalog_service_resource_v1_0.xml +0 -128
  220. data/test/resources/vodataservice/data_collection_resource_v0_5.xml +0 -54
  221. data/test/resources/vodataservice/data_collection_resource_v1_0.xml +0 -117
  222. data/test/resources/vodataservice/data_service_resource_v1_0.xml +0 -115
  223. data/test/resources/vodataservice/sky_service_resource_v0_10.xml +0 -45
  224. data/test/resources/vodataservice/table_service_resource_v1_0.xml +0 -122
  225. data/test/resources/vodataservice/tabular_sky_service_resource_v0_10.xml +0 -60
  226. data/test/resources/vodataservice/unittest_v0_5.rb +0 -126
  227. data/test/resources/vodataservice/unittest_v1_0.rb +0 -151
  228. data/test/resources/voregistry/authority_resource_v0_3.xml +0 -20
  229. data/test/resources/voregistry/authority_resource_v1_0.xml +0 -82
  230. data/test/resources/voregistry/registry_service_v0_3.xml +0 -20
  231. data/test/resources/voregistry/registry_service_v1_0.xml +0 -107
  232. data/test/resources/voregistry/unittest_v0_3.rb +0 -31
  233. data/test/resources/voregistry/unittest_v1_0.rb +0 -34
  234. data/test/resources/voresource/organisation_resource_v1_0.xml +0 -90
  235. data/test/resources/voresource/resource_organisation_v0_10.xml +0 -22
  236. data/test/resources/voresource/resource_service_v0_10.xml +0 -19
  237. data/test/resources/voresource/resource_v0_10.xml +0 -19
  238. data/test/resources/voresource/resource_v1_0.xml +0 -79
  239. data/test/resources/voresource/service_resource_v1_0.xml +0 -91
  240. data/test/resources/voresource/unittest_v0_10.rb +0 -61
  241. data/test/resources/voresource/unittest_v0_9.rb +0 -4
  242. data/test/resources/voresource/unittest_v1_0.rb +0 -190
  243. data/test/services/gestalt/unittest.rb +0 -74
  244. data/test/services/registry/unittest.rb +0 -34
  245. data/test/services/resolver/unittest.rb +0 -38
  246. data/test/simple/unittest.rb +0 -46
  247. data/test/spacetime/unittest.rb +0 -39
  248. data/test/stc/catalog_entry_location_v1_20.xml +0 -112
  249. data/test/stc/obs_data_location_v1_20.xml +0 -108
  250. data/test/stc/search_location_v1_20.xml +0 -54
  251. data/test/stc/stc_resource_profile_v1_20.xml +0 -60
  252. data/test/stc/unittest_v1_20.rb +0 -620
  253. data/test/voevent/unittest_v1_0.rb +0 -79
  254. data/test/voevent/unittest_v1_1.rb +0 -70
  255. data/test/voevent/voevent_v1_0.xml +0 -96
  256. data/test/votables/test.vot +0 -366
  257. data/test/votables/unittest.rb +0 -54
@@ -0,0 +1,4626 @@
1
+ require 'voruby/stc/1.10/stc'
2
+ require 'test/unit'
3
+
4
+ include VORuby::STC::V1_10::STC
5
+
6
+ module VORuby
7
+ module STC
8
+ module V1_10
9
+ module STC
10
+ module Test
11
+
12
+ class CoordFrameTypeTest < ::Test::Unit::TestCase
13
+ def test_construction
14
+ assert_nothing_raised {
15
+ CoordFrameType.new
16
+ CoordFrameType.new(:name => 'CoordFrame1')
17
+ }
18
+ end
19
+
20
+ def test_accessors
21
+ f = CoordFrameType.new(:name => 'CoordFrame1')
22
+
23
+ assert_equal 'CoordFrame1', f.name
24
+ f.name = 'CoordFrame2'
25
+ assert_equal 'CoordFrame2', f.name
26
+ end
27
+
28
+ def test_xml
29
+ f = CoordFrameType.new(:name => 'CoordFrame1')
30
+ assert_equal(
31
+ "<stc:CoordFrameType xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'><stc:Name>CoordFrame1</stc:Name></stc:CoordFrameType>",
32
+ f.to_xml.to_s
33
+ )
34
+ end
35
+ end
36
+
37
+ class CoordEquinoxTest < ::Test::Unit::TestCase
38
+ def test_construction
39
+ assert_nothing_raised {
40
+ CoordEquinox.new('J2000.0')
41
+ CoordEquinox.new('B2000.00')
42
+ }
43
+
44
+ assert_raises ArgumentError do
45
+ CoordEquinox.new('2000.0')
46
+ end
47
+ assert_raises ArgumentError do
48
+ CoordEquinox.new('B1950')
49
+ end
50
+ end
51
+
52
+ def test_accessors
53
+ c = CoordEquinox.new('J2000.0')
54
+ assert_equal 'J2000.0', c.value
55
+ end
56
+ end
57
+
58
+ class FkTypeTest < ::Test::Unit::TestCase
59
+ def test_construction
60
+ assert_nothing_raised {
61
+ FkType.new('J2000.0')
62
+ FkType.new(CoordEquinox.new('J2000.0'))
63
+ }
64
+
65
+ assert_raises ArgumentError do
66
+ FkType.new(CoordEquinox.new('2000.0'))
67
+ end
68
+ assert_raises ArgumentError do
69
+ FkType.new
70
+ end
71
+ end
72
+
73
+ def test_accessors
74
+ f = FkType.new('J2000.0')
75
+
76
+ assert_equal CoordEquinox.new('J2000.0'), f.equinox
77
+ f.equinox = 'B1950.0'
78
+ assert_equal CoordEquinox.new('B1950.0'), f.equinox
79
+ end
80
+
81
+ def test_relationships
82
+ assert_kind_of SpaceRefFrameType, FkType.new('J2000.0')
83
+ end
84
+
85
+ def test_xml
86
+ f1 = FkType.new('J2000.0')
87
+ assert_equal "<stc:FkType xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'><stc:Equinox>J2000.0</stc:Equinox></stc:FkType>", f1.to_xml.to_s
88
+
89
+ f2 = FkType.from_xml(f1.to_xml)
90
+ assert_equal f1, f2
91
+ end
92
+ end
93
+
94
+ class CustomSpaceRefFrameTypeTest < ::Test::Unit::TestCase
95
+ def test_construction
96
+ assert_nothing_raised {
97
+ CustomSpaceRefFrameType.new(
98
+ :frame => 'frame1',
99
+ :pole_zaxis => AstroCoords.new(
100
+ :coord_system_id => 'FK5-UTC-VEL',
101
+ :time => TimeCoordinate.new(:name => 'Time'),
102
+ :position => Position1D.new(:name => 'FK5Cart', :unit => PosUnit.new('m')),
103
+ :velocity => Velocity1D.new(:name => 'Vel', :unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('h')),
104
+ :spectral => Spectral.new(:name => 'Spectrum'),
105
+ :redshift => Redshift.new(:name => 'Redshift'),
106
+ :coord_file => AstroCoordsFile.new(:file => Fits.new(:uri => 'http://www.noao.edu/'))
107
+ ),
108
+ :xaxis => AstroCoords.new(
109
+ :coord_system_id => 'FK5-UTC-VEL',
110
+ :time => TimeCoordinate.new(:name => 'Time'),
111
+ :position => Position1D.new(:name => 'FK5Cart', :unit => PosUnit.new('lyr')),
112
+ :velocity => Velocity1D.new(:name => 'Vel', :unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('h')),
113
+ :spectral => Spectral.new(:name => 'Spectrum2'),
114
+ :redshift => Redshift.new(:name => 'Redshift2'),
115
+ :coord_file => AstroCoordsFile.new(:file => Fits.new(:uri => 'http://www.stsci.edu/'))
116
+ )
117
+ )
118
+ }
119
+
120
+ assert_raises ArgumentError do
121
+ CustomSpaceRefFrameType.new(:frame => 'frame1')
122
+ end
123
+
124
+ assert_raises ArgumentError do
125
+ CustomSpaceRefFrameType.new(
126
+ :pole_zaxis => AstroCoords.new(
127
+ :coord_system_id => 'FK5-UTC-VEL',
128
+ :time => TimeCoordinate.new(:name => 'Time'),
129
+ :position => Position1D.new(:name => 'FK5Cart', :unit => PosUnit.new('m')),
130
+ :velocity => Velocity1D.new(:name => 'Vel', :unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('h')),
131
+ :spectral => Spectral.new(:name => 'Spectrum'),
132
+ :redshift => Redshift.new(:name => 'Redshift'),
133
+ :coord_file => AstroCoordsFile.new(:file => Fits.new(:uri => 'http://www.noao.edu/'))
134
+ )
135
+ )
136
+ end
137
+
138
+ assert_raises ArgumentError do
139
+ CustomSpaceRefFrameType.new(
140
+ :xaxis => AstroCoords.new(
141
+ :coord_system_id => 'FK5-UTC-VEL',
142
+ :time => TimeCoordinate.new(:name => 'Time'),
143
+ :position => Position1D.new(:name => 'FK5Cart', :unit => PosUnit.new('lyr')),
144
+ :velocity => Velocity1D.new(:name => 'Vel', :unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('h')),
145
+ :spectral => Spectral.new(:name => 'Spectrum2'),
146
+ :redshift => Redshift.new(:name => 'Redshift2'),
147
+ :coord_file => AstroCoordsFile.new(:file => Fits.new(:uri => 'http://www.stsci.edu/'))
148
+ )
149
+ )
150
+ end
151
+
152
+ assert_raises TypeError do
153
+ CustomSpaceRefFrameType.new(
154
+ :frame => 'frame1',
155
+ :pole_zaxis => 'blah',
156
+ :xaxis => AstroCoords.new(
157
+ :coord_system_id => 'FK5-UTC-VEL',
158
+ :time => TimeCoordinate.new(:name => 'Time'),
159
+ :position => Position1D.new(:name => 'FK5Cart', :unit => PosUnit.new('lyr')),
160
+ :velocity => Velocity1D.new(:name => 'Vel', :unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('h')),
161
+ :spectral => Spectral.new(:name => 'Spectrum2'),
162
+ :redshift => Redshift.new(:name => 'Redshift2'),
163
+ :coord_file => AstroCoordsFile.new(:file => Fits.new(:uri => 'http://www.stsci.edu/'))
164
+ )
165
+ )
166
+ end
167
+
168
+ assert_raises TypeError do
169
+ CustomSpaceRefFrameType.new(
170
+ :frame => 'frame1',
171
+ :pole_zaxis => AstroCoords.new(
172
+ :coord_system_id => 'FK5-UTC-VEL',
173
+ :time => TimeCoordinate.new(:name => 'Time'),
174
+ :position => Position1D.new(:name => 'FK5Cart', :unit => PosUnit.new('m')),
175
+ :velocity => Velocity1D.new(:name => 'Vel', :unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('h')),
176
+ :spectral => Spectral.new(:name => 'Spectrum'),
177
+ :redshift => Redshift.new(:name => 'Redshift'),
178
+ :coord_file => AstroCoordsFile.new(:file => Fits.new(:uri => 'http://www.noao.edu/'))
179
+ ),
180
+ :xaxis => 'blah'
181
+ )
182
+ end
183
+ end
184
+
185
+ def test_accessors
186
+ f = CustomSpaceRefFrameType.new(
187
+ :frame => 'frame1',
188
+ :pole_zaxis => AstroCoords.new(
189
+ :coord_system_id => 'FK5-UTC-VEL',
190
+ :time => TimeCoordinate.new(:name => 'Time'),
191
+ :position => Position1D.new(:name => 'FK5Cart', :unit => PosUnit.new('m')),
192
+ :velocity => Velocity1D.new(:name => 'Vel', :unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('h')),
193
+ :spectral => Spectral.new(:name => 'Spectrum'),
194
+ :redshift => Redshift.new(:name => 'Redshift'),
195
+ :coord_file => AstroCoordsFile.new(:file => Fits.new(:uri => 'http://www.noao.edu/'))
196
+ ),
197
+ :xaxis => AstroCoords.new(
198
+ :coord_system_id => 'FK5-UTC-VEL',
199
+ :time => TimeCoordinate.new(:name => 'Time'),
200
+ :position => Position1D.new(:name => 'FK5Cart', :unit => PosUnit.new('lyr')),
201
+ :velocity => Velocity1D.new(:name => 'Vel', :unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('h')),
202
+ :spectral => Spectral.new(:name => 'Spectrum2'),
203
+ :redshift => Redshift.new(:name => 'Redshift2'),
204
+ :coord_file => AstroCoordsFile.new(:file => Fits.new(:uri => 'http://www.stsci.edu/'))
205
+ )
206
+ )
207
+
208
+ assert_equal 'frame1', f.frame
209
+ assert_equal(
210
+ AstroCoords.new(
211
+ :coord_system_id => 'FK5-UTC-VEL',
212
+ :time => TimeCoordinate.new(:name => 'Time'),
213
+ :position => Position1D.new(:name => 'FK5Cart', :unit => PosUnit.new('m')),
214
+ :velocity => Velocity1D.new(:name => 'Vel', :unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('h')),
215
+ :spectral => Spectral.new(:name => 'Spectrum'),
216
+ :redshift => Redshift.new(:name => 'Redshift'),
217
+ :coord_file => AstroCoordsFile.new(:file => Fits.new(:uri => 'http://www.noao.edu/'))
218
+ ),
219
+ f.pole_zaxis
220
+ )
221
+ assert_equal(
222
+ AstroCoords.new(
223
+ :coord_system_id => 'FK5-UTC-VEL',
224
+ :time => TimeCoordinate.new(:name => 'Time'),
225
+ :position => Position1D.new(:name => 'FK5Cart', :unit => PosUnit.new('lyr')),
226
+ :velocity => Velocity1D.new(:name => 'Vel', :unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('h')),
227
+ :spectral => Spectral.new(:name => 'Spectrum2'),
228
+ :redshift => Redshift.new(:name => 'Redshift2'),
229
+ :coord_file => AstroCoordsFile.new(:file => Fits.new(:uri => 'http://www.stsci.edu/'))
230
+ ),
231
+ f.xaxis
232
+ )
233
+
234
+ f.frame = 'frame2'
235
+ assert_equal 'frame2', f.frame
236
+ f.pole_zaxis = AstroCoords.new(
237
+ :coord_system_id => 'FK5-UTC-VEL',
238
+ :time => TimeCoordinate.new(:name => 'Time2'),
239
+ :position => Position1D.new(:name => 'FK5Cart2', :unit => PosUnit.new('m')),
240
+ :velocity => Velocity1D.new(:name => 'Vel2', :unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('h')),
241
+ :spectral => Spectral.new(:name => 'Spectrum2'),
242
+ :redshift => Redshift.new(:name => 'Redshift2'),
243
+ :coord_file => AstroCoordsFile.new(:file => Fits.new(:uri => 'http://www.noao.edu/'))
244
+ )
245
+ assert_equal(
246
+ AstroCoords.new(
247
+ :coord_system_id => 'FK5-UTC-VEL',
248
+ :time => TimeCoordinate.new(:name => 'Time2'),
249
+ :position => Position1D.new(:name => 'FK5Cart2', :unit => PosUnit.new('m')),
250
+ :velocity => Velocity1D.new(:name => 'Vel2', :unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('h')),
251
+ :spectral => Spectral.new(:name => 'Spectrum2'),
252
+ :redshift => Redshift.new(:name => 'Redshift2'),
253
+ :coord_file => AstroCoordsFile.new(:file => Fits.new(:uri => 'http://www.noao.edu/'))
254
+ ),
255
+ f.pole_zaxis
256
+ )
257
+ f.xaxis = AstroCoords.new(
258
+ :coord_system_id => 'FK5-UTC-VEL',
259
+ :time => TimeCoordinate.new(:name => 'Time3'),
260
+ :position => Position1D.new(:name => 'FK5Cart3', :unit => PosUnit.new('lyr')),
261
+ :velocity => Velocity1D.new(:name => 'Vel3', :unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('h')),
262
+ :spectral => Spectral.new(:name => 'Spectrum2'),
263
+ :redshift => Redshift.new(:name => 'Redshift2'),
264
+ :coord_file => AstroCoordsFile.new(:file => Fits.new(:uri => 'http://www.stsci.edu/'))
265
+ )
266
+ assert_equal(
267
+ AstroCoords.new(
268
+ :coord_system_id => 'FK5-UTC-VEL',
269
+ :time => TimeCoordinate.new(:name => 'Time3'),
270
+ :position => Position1D.new(:name => 'FK5Cart3', :unit => PosUnit.new('lyr')),
271
+ :velocity => Velocity1D.new(:name => 'Vel3', :unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('h')),
272
+ :spectral => Spectral.new(:name => 'Spectrum2'),
273
+ :redshift => Redshift.new(:name => 'Redshift2'),
274
+ :coord_file => AstroCoordsFile.new(:file => Fits.new(:uri => 'http://www.stsci.edu/'))
275
+ ),
276
+ f.xaxis
277
+ )
278
+ end
279
+
280
+ def test_xml
281
+ f1 = CustomSpaceRefFrameType.new(
282
+ :frame => 'frame1',
283
+ :pole_zaxis => AstroCoords.new(
284
+ :coord_system_id => 'FK5-UTC-VEL',
285
+ :time => TimeCoordinate.new(:name => 'Time'),
286
+ :position => Position1D.new(:name => 'FK5Cart', :unit => PosUnit.new('m')),
287
+ :velocity => Velocity1D.new(:name => 'Vel', :unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('h')),
288
+ :spectral => Spectral.new(:name => 'Spectrum'),
289
+ :redshift => Redshift.new(:name => 'Redshift'),
290
+ :coord_file => AstroCoordsFile.new(:file => Fits.new(:uri => 'http://www.noao.edu/'))
291
+ ),
292
+ :xaxis => AstroCoords.new(
293
+ :coord_system_id => 'FK5-UTC-VEL',
294
+ :time => TimeCoordinate.new(:name => 'Time'),
295
+ :position => Position1D.new(:name => 'FK5Cart', :unit => PosUnit.new('lyr')),
296
+ :velocity => Velocity1D.new(:name => 'Vel', :unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('h')),
297
+ :spectral => Spectral.new(:name => 'Spectrum2'),
298
+ :redshift => Redshift.new(:name => 'Redshift2'),
299
+ :coord_file => AstroCoordsFile.new(:file => Fits.new(:uri => 'http://www.stsci.edu/'))
300
+ )
301
+ )
302
+
303
+ f2 = CustomSpaceRefFrameType.from_xml(f1.to_xml)
304
+ assert_equal f1, f2
305
+ end
306
+ end
307
+
308
+ class SpaceRefFrameTest < ::Test::Unit::TestCase
309
+ def test_icrs
310
+ f = Icrs.new
311
+ assert_equal "<stc:ICRS xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'/>", f.to_xml.to_s
312
+ assert_kind_of IcrsType, f
313
+ assert_kind_of SpaceRefFrame, f
314
+ end
315
+
316
+ def test_fk4
317
+ f = Fk4.new('B1950.0')
318
+ assert_equal CoordEquinox.new('B1950.0'), f.equinox
319
+ assert_equal(
320
+ "<stc:FK4 xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'><stc:Equinox>B1950.0</stc:Equinox></stc:FK4>",
321
+ f.to_xml.to_s
322
+ )
323
+ assert_kind_of FkType, f
324
+ assert_kind_of SpaceRefFrame, f
325
+ end
326
+
327
+ def test_fk5
328
+ f = Fk5.new('J2000.0')
329
+ assert_equal CoordEquinox.new('J2000.0'), f.equinox
330
+ assert_equal(
331
+ "<stc:FK5 xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'><stc:Equinox>J2000.0</stc:Equinox></stc:FK5>",
332
+ f.to_xml.to_s
333
+ )
334
+ assert_kind_of FkType, f
335
+ assert_kind_of SpaceRefFrame, f
336
+ end
337
+
338
+ def test_ecliptic
339
+ f = Ecliptic.new('J2000.0')
340
+ assert_equal CoordEquinox.new('J2000.0'), f.equinox
341
+ assert_equal(
342
+ "<stc:ECLIPTIC xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'><stc:Equinox>J2000.0</stc:Equinox></stc:ECLIPTIC>",
343
+ f.to_xml.to_s
344
+ )
345
+ assert_kind_of FkType, f
346
+ assert_kind_of SpaceRefFrame, f
347
+ end
348
+
349
+ def test_galactic_I
350
+ f = GalacticI.new
351
+ assert_equal "<stc:GALACTIC_I xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'/>", f.to_xml.to_s
352
+ assert_kind_of IcrsType, f
353
+ assert_kind_of SpaceRefFrame, f
354
+ end
355
+
356
+ def test_galactic_II
357
+ f = GalacticII.new
358
+ assert_equal "<stc:GALACTIC_II xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'/>", f.to_xml.to_s
359
+ assert_kind_of IcrsType, f
360
+ assert_kind_of SpaceRefFrame, f
361
+ end
362
+
363
+ def test_super_galactic
364
+ f = SuperGalactic.new
365
+ assert_equal "<stc:SUPER_GALACTIC xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'/>", f.to_xml.to_s
366
+ assert_kind_of IcrsType, f
367
+ assert_kind_of SpaceRefFrame, f
368
+ end
369
+
370
+ def test_az_el
371
+ f = AzEl.new
372
+ assert_equal "<stc:AZ_EL xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'/>", f.to_xml.to_s
373
+ assert_kind_of IcrsType, f
374
+ assert_kind_of SpaceRefFrame, f
375
+ end
376
+
377
+ def test_body
378
+ f = Body.new
379
+ assert_equal "<stc:BODY xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'/>", f.to_xml.to_s
380
+ assert_kind_of IcrsType, f
381
+ assert_kind_of SpaceRefFrame, f
382
+ end
383
+
384
+ def test_geo
385
+ f = Geo.new
386
+ assert_equal "<stc:GEO xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'/>", f.to_xml.to_s
387
+ assert_kind_of IcrsType, f
388
+ assert_kind_of SpaceRefFrame, f
389
+ end
390
+
391
+ def test_geod
392
+ f = Geod.new
393
+ assert_equal "<stc:GEOD xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'/>", f.to_xml.to_s
394
+ assert_kind_of IcrsType, f
395
+ assert_kind_of SpaceRefFrame, f
396
+ end
397
+
398
+ def test_mag
399
+ f = Mag.new
400
+ assert_equal "<stc:MAG xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'/>", f.to_xml.to_s
401
+ assert_kind_of IcrsType, f
402
+ assert_kind_of SpaceRefFrame, f
403
+ end
404
+
405
+ def test_gse
406
+ f = Gse.new
407
+ assert_equal "<stc:GSE xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'/>", f.to_xml.to_s
408
+ assert_kind_of IcrsType, f
409
+ assert_kind_of SpaceRefFrame, f
410
+ end
411
+
412
+ def test_gsm
413
+ f = Gsm.new
414
+ assert_equal "<stc:GSM xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'/>", f.to_xml.to_s
415
+ assert_kind_of IcrsType, f
416
+ assert_kind_of SpaceRefFrame, f
417
+ end
418
+
419
+ def test_sm
420
+ f = Sm.new
421
+ assert_equal "<stc:SM xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'/>", f.to_xml.to_s
422
+ assert_kind_of IcrsType, f
423
+ assert_kind_of SpaceRefFrame, f
424
+ end
425
+
426
+ def test_hgc
427
+ f = Hgc.new
428
+ assert_equal "<stc:HGC xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'/>", f.to_xml.to_s
429
+ assert_kind_of IcrsType, f
430
+ assert_kind_of SpaceRefFrame, f
431
+ end
432
+
433
+ def test_hee
434
+ f = Hee.new
435
+ assert_equal "<stc:HEE xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'/>", f.to_xml.to_s
436
+ assert_kind_of IcrsType, f
437
+ assert_kind_of SpaceRefFrame, f
438
+ end
439
+
440
+ def test_heeq
441
+ f = Heeq.new
442
+ assert_equal "<stc:HEEQ xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'/>", f.to_xml.to_s
443
+ assert_kind_of IcrsType, f
444
+ assert_kind_of SpaceRefFrame, f
445
+ end
446
+
447
+ def test_hci
448
+ f = Hci.new
449
+ assert_equal "<stc:HCI xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'/>", f.to_xml.to_s
450
+ assert_kind_of IcrsType, f
451
+ assert_kind_of SpaceRefFrame, f
452
+ end
453
+
454
+ def test_hcd
455
+ f = Hcd.new
456
+ assert_equal "<stc:HCD xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'/>", f.to_xml.to_s
457
+ assert_kind_of IcrsType, f
458
+ assert_kind_of SpaceRefFrame, f
459
+ end
460
+
461
+ def test_mercury_c
462
+ f = MercuryC.new
463
+ assert_equal "<stc:MERCURY_C xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'/>", f.to_xml.to_s
464
+ assert_kind_of IcrsType, f
465
+ assert_kind_of SpaceRefFrame, f
466
+ end
467
+
468
+ def test_venus_c
469
+ f = VenusC.new
470
+ assert_equal "<stc:VENUS_C xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'/>", f.to_xml.to_s
471
+ assert_kind_of IcrsType, f
472
+ assert_kind_of SpaceRefFrame, f
473
+ end
474
+
475
+ def test_luna_c
476
+ f = LunaC.new
477
+ assert_equal "<stc:LUNA_C xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'/>", f.to_xml.to_s
478
+ assert_kind_of IcrsType, f
479
+ assert_kind_of SpaceRefFrame, f
480
+ end
481
+
482
+ def test_mars_c
483
+ f = MarsC.new
484
+ assert_equal "<stc:MARS_C xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'/>", f.to_xml.to_s
485
+ assert_kind_of IcrsType, f
486
+ assert_kind_of SpaceRefFrame, f
487
+ end
488
+
489
+ def test_jupiter_c
490
+ f = JupiterCIII.new
491
+ assert_equal "<stc:JUPITER_C_III xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'/>", f.to_xml.to_s
492
+ assert_kind_of IcrsType, f
493
+ assert_kind_of SpaceRefFrame, f
494
+ end
495
+
496
+ def test_saturn_c
497
+ f = SaturnCIII.new
498
+ assert_equal "<stc:SATURN_C_III xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'/>", f.to_xml.to_s
499
+ assert_kind_of IcrsType, f
500
+ assert_kind_of SpaceRefFrame, f
501
+ end
502
+
503
+ def test_uranus_c
504
+ f = UranusCIII.new
505
+ assert_equal "<stc:URANUS_C_III xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'/>", f.to_xml.to_s
506
+ assert_kind_of IcrsType, f
507
+ assert_kind_of SpaceRefFrame, f
508
+ end
509
+
510
+ def test_neptun_c
511
+ f = NeptuneCIII.new
512
+ assert_equal "<stc:NEPTUNE_C_III xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'/>", f.to_xml.to_s
513
+ assert_kind_of IcrsType, f
514
+ assert_kind_of SpaceRefFrame, f
515
+ end
516
+
517
+ def test_pluto_c
518
+ f = PlutoC.new
519
+ assert_equal "<stc:PLUTO_C xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'/>", f.to_xml.to_s
520
+ assert_kind_of IcrsType, f
521
+ assert_kind_of SpaceRefFrame, f
522
+ end
523
+
524
+ def test_mercury_g
525
+ f = MercuryG.new
526
+ assert_equal "<stc:MERCURY_G xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'/>", f.to_xml.to_s
527
+ assert_kind_of IcrsType, f
528
+ assert_kind_of SpaceRefFrame, f
529
+ end
530
+
531
+ def test_venus_g
532
+ f = VenusG.new
533
+ assert_equal "<stc:VENUS_G xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'/>", f.to_xml.to_s
534
+ assert_kind_of IcrsType, f
535
+ assert_kind_of SpaceRefFrame, f
536
+ end
537
+
538
+ def test_luna_g
539
+ f = LunaG.new
540
+ assert_equal "<stc:LUNA_G xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'/>", f.to_xml.to_s
541
+ assert_kind_of IcrsType, f
542
+ assert_kind_of SpaceRefFrame, f
543
+ end
544
+
545
+ def test_mars_g
546
+ f = MarsG.new
547
+ assert_equal "<stc:MARS_G xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'/>", f.to_xml.to_s
548
+ assert_kind_of IcrsType, f
549
+ assert_kind_of SpaceRefFrame, f
550
+ end
551
+
552
+ def test_jupiter_g
553
+ f = JupiterGIII.new
554
+ assert_equal "<stc:JUPITER_G_III xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'/>", f.to_xml.to_s
555
+ assert_kind_of IcrsType, f
556
+ assert_kind_of SpaceRefFrame, f
557
+ end
558
+
559
+ def test_saturn_g
560
+ f = SaturnGIII.new
561
+ assert_equal "<stc:SATURN_G_III xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'/>", f.to_xml.to_s
562
+ assert_kind_of IcrsType, f
563
+ assert_kind_of SpaceRefFrame, f
564
+ end
565
+
566
+ def test_uranus_g
567
+ f = UranusGIII.new
568
+ assert_equal "<stc:URANUS_G_III xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'/>", f.to_xml.to_s
569
+ assert_kind_of IcrsType, f
570
+ assert_kind_of SpaceRefFrame, f
571
+ end
572
+
573
+ def test_neptune_g
574
+ f = NeptuneGIII.new
575
+ assert_equal "<stc:NEPTUNE_G_III xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'/>", f.to_xml.to_s
576
+ assert_kind_of IcrsType, f
577
+ assert_kind_of SpaceRefFrame, f
578
+ end
579
+
580
+ def test_pluto_g
581
+ f = PlutoG.new
582
+ assert_equal "<stc:PLUTO_G xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'/>", f.to_xml.to_s
583
+ assert_kind_of IcrsType, f
584
+ assert_kind_of SpaceRefFrame, f
585
+ end
586
+
587
+ def test_unknown_frame
588
+ f = UnknownFrame.new
589
+ assert_equal "<stc:UNKNOWNFrame xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'/>", f.to_xml.to_s
590
+ assert_kind_of IcrsType, f
591
+ assert_kind_of SpaceRefFrame, f
592
+ end
593
+ end
594
+
595
+ class CustomSpaceRefFrameTest < ::Test::Unit::TestCase
596
+ def test_xml
597
+ f1 = CustomSpaceRefFrame.new(
598
+ :frame => 'frame1',
599
+ :pole_zaxis => AstroCoords.new(
600
+ :coord_system_id => 'FK5-UTC-VEL',
601
+ :time => TimeCoordinate.new(:name => 'Time'),
602
+ :position => Position1D.new(:name => 'FK5Cart', :unit => PosUnit.new('m')),
603
+ :velocity => Velocity1D.new(:name => 'Vel', :unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('h')),
604
+ :spectral => Spectral.new(:name => 'Spectrum'),
605
+ :redshift => Redshift.new(:name => 'Redshift'),
606
+ :coord_file => AstroCoordsFile.new(:file => Fits.new(:uri => 'http://www.noao.edu/'))
607
+ ),
608
+ :xaxis => AstroCoords.new(
609
+ :coord_system_id => 'FK5-UTC-VEL',
610
+ :time => TimeCoordinate.new(:name => 'Time'),
611
+ :position => Position1D.new(:name => 'FK5Cart', :unit => PosUnit.new('lyr')),
612
+ :velocity => Velocity1D.new(:name => 'Vel', :unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('h')),
613
+ :spectral => Spectral.new(:name => 'Spectrum2'),
614
+ :redshift => Redshift.new(:name => 'Redshift2'),
615
+ :coord_file => AstroCoordsFile.new(:file => Fits.new(:uri => 'http://www.stsci.edu/'))
616
+ )
617
+ )
618
+
619
+ f2 = CustomSpaceRefFrame.from_xml(f1.to_xml)
620
+ assert_equal f1, f2
621
+ end
622
+ end
623
+
624
+ class PlanetaryEphemTest < ::Test::Unit::TestCase
625
+ def test_construction
626
+ assert_nothing_raised {
627
+ PlanetaryEphem.new('JPL-DE200')
628
+ PlanetaryEphem.new('JPL-DE405')
629
+ }
630
+
631
+ assert_raises ArgumentError do
632
+ PlanetaryEphem.new('blah')
633
+ end
634
+ end
635
+
636
+ def test_accessors
637
+ p = PlanetaryEphem.new('JPL-DE200')
638
+ assert_equal 'JPL-DE200', p.value
639
+
640
+ p.value = 'JPL-DE405'
641
+ assert_equal 'JPL-DE405', p.value
642
+ end
643
+ end
644
+
645
+ class StdRefPosTest < ::Test::Unit::TestCase
646
+ def test_construction
647
+ assert_nothing_raised {
648
+ StdRefPos.new
649
+ StdRefPos.new('JPL-DE200')
650
+ StdRefPos.new(PlanetaryEphem.new('JPL-DE200'))
651
+ }
652
+
653
+ assert_raises ArgumentError do
654
+ StdRefPos.new('blah')
655
+ end
656
+ end
657
+
658
+ def test_accessors
659
+ p = StdRefPos.new('JPL-DE200')
660
+ assert_equal PlanetaryEphem.new('JPL-DE200'), p.planetary_ephem
661
+
662
+ p.planetary_ephem = 'JPL-DE405'
663
+ assert_equal PlanetaryEphem.new('JPL-DE405'), p.planetary_ephem
664
+ end
665
+
666
+ def test_xml
667
+ p1 = StdRefPos.new('JPL-DE200')
668
+ assert_equal(
669
+ "<stc:StdRefPos xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'><stc:PlanetaryEphem>JPL-DE200</stc:PlanetaryEphem></stc:StdRefPos>",
670
+ p1.to_xml.to_s
671
+ )
672
+
673
+ p2 = StdRefPos.from_xml(p1.to_xml)
674
+ assert_equal p1, p2
675
+ end
676
+ end
677
+
678
+ class CustomRefPosTest < ::Test::Unit::TestCase
679
+ def test_construction
680
+ assert_nothing_raised {
681
+ CustomRefPosType.new(
682
+ AstroCoords.new(
683
+ :coord_system_id => 'FK5-UTC-VEL',
684
+ :time => TimeCoordinate.new(:name => 'Time'),
685
+ :position => Position1D.new(:name => 'FK5Cart', :unit => PosUnit.new('lyr')),
686
+ :velocity => Velocity1D.new(:name => 'Vel', :unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('h')),
687
+ :spectral => Spectral.new(:name => 'Spectrum2'),
688
+ :redshift => Redshift.new(:name => 'Redshift2'),
689
+ :coord_file => AstroCoordsFile.new(:file => Fits.new(:uri => 'http://www.stsci.edu/'))
690
+ )
691
+ )
692
+ }
693
+
694
+ assert_raises ArgumentError do
695
+ CustomRefPosType.new
696
+ end
697
+ assert_raises TypeError do
698
+ CustomRefPosType.new('blah')
699
+ end
700
+ end
701
+
702
+ def test_accessors
703
+ p = CustomRefPosType.new(
704
+ AstroCoords.new(
705
+ :coord_system_id => 'FK5-UTC-VEL',
706
+ :time => TimeCoordinate.new(:name => 'Time'),
707
+ :position => Position1D.new(:name => 'FK5Cart', :unit => PosUnit.new('lyr')),
708
+ :velocity => Velocity1D.new(:name => 'Vel', :unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('h')),
709
+ :spectral => Spectral.new(:name => 'Spectrum2'),
710
+ :redshift => Redshift.new(:name => 'Redshift2'),
711
+ :coord_file => AstroCoordsFile.new(:file => Fits.new(:uri => 'http://www.stsci.edu/'))
712
+ )
713
+ )
714
+ assert_equal(
715
+ AstroCoords.new(
716
+ :coord_system_id => 'FK5-UTC-VEL',
717
+ :time => TimeCoordinate.new(:name => 'Time'),
718
+ :position => Position1D.new(:name => 'FK5Cart', :unit => PosUnit.new('lyr')),
719
+ :velocity => Velocity1D.new(:name => 'Vel', :unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('h')),
720
+ :spectral => Spectral.new(:name => 'Spectrum2'),
721
+ :redshift => Redshift.new(:name => 'Redshift2'),
722
+ :coord_file => AstroCoordsFile.new(:file => Fits.new(:uri => 'http://www.stsci.edu/'))
723
+ ),
724
+ p.coord_origin
725
+ )
726
+
727
+ p.coord_origin = AstroCoords.new(
728
+ :coord_system_id => 'FK5-UTC-VEL',
729
+ :time => TimeCoordinate.new(:name => 'Time2'),
730
+ :position => Position1D.new(:name => 'FK5Cart2', :unit => PosUnit.new('lyr')),
731
+ :velocity => Velocity1D.new(:name => 'Vel2', :unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('h')),
732
+ :spectral => Spectral.new(:name => 'Spectrum2'),
733
+ :redshift => Redshift.new(:name => 'Redshift2'),
734
+ :coord_file => AstroCoordsFile.new(:file => Fits.new(:uri => 'http://www.stsci.edu/'))
735
+ )
736
+ assert_equal(
737
+ AstroCoords.new(
738
+ :coord_system_id => 'FK5-UTC-VEL',
739
+ :time => TimeCoordinate.new(:name => 'Time2'),
740
+ :position => Position1D.new(:name => 'FK5Cart2', :unit => PosUnit.new('lyr')),
741
+ :velocity => Velocity1D.new(:name => 'Vel2', :unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('h')),
742
+ :spectral => Spectral.new(:name => 'Spectrum2'),
743
+ :redshift => Redshift.new(:name => 'Redshift2'),
744
+ :coord_file => AstroCoordsFile.new(:file => Fits.new(:uri => 'http://www.stsci.edu/'))
745
+ ),
746
+ p.coord_origin
747
+ )
748
+ end
749
+
750
+ def test_xml
751
+ p1 = CustomRefPosType.new(
752
+ AstroCoords.new(
753
+ :coord_system_id => 'FK5-UTC-VEL',
754
+ :time => TimeCoordinate.new(:name => 'Time'),
755
+ :position => Position1D.new(:name => 'FK5Cart', :unit => PosUnit.new('lyr')),
756
+ :velocity => Velocity1D.new(:name => 'Vel', :unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('h')),
757
+ :spectral => Spectral.new(:name => 'Spectrum2'),
758
+ :redshift => Redshift.new(:name => 'Redshift2'),
759
+ :coord_file => AstroCoordsFile.new(:file => Fits.new(:uri => 'http://www.stsci.edu/'))
760
+ )
761
+ )
762
+
763
+ p2 = CustomRefPosType.from_xml(p1.to_xml)
764
+ assert_equal p1, p2
765
+ end
766
+ end
767
+
768
+ class ReferencePositionTest < ::Test::Unit::TestCase
769
+ def test_topocenter
770
+ p1 = Topocenter.new
771
+ assert_equal "<stc:TOPOCENTER xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'/>", p1.to_xml.to_s
772
+
773
+ p2 = Topocenter.from_xml(p1.to_xml)
774
+ assert_equal p1, p2
775
+
776
+ assert_kind_of StdRefPos, p1
777
+ assert_kind_of ReferencePosition, p1
778
+ end
779
+
780
+ def test_barycenter
781
+ p1 = Barycenter.new
782
+ assert_equal "<stc:BARYCENTER xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'/>", p1.to_xml.to_s
783
+
784
+ p2 = Barycenter.from_xml(p1.to_xml)
785
+ assert_equal p1, p2
786
+
787
+ assert_kind_of StdRefPos, p1
788
+ assert_kind_of ReferencePosition, p1
789
+ end
790
+
791
+ def test_heliocenter
792
+ p1 = Heliocenter.new
793
+ assert_equal "<stc:HELIOCENTER xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'/>", p1.to_xml.to_s
794
+
795
+ p2 = Heliocenter.from_xml(p1.to_xml)
796
+ assert_equal p1, p2
797
+
798
+ assert_kind_of StdRefPos, p1
799
+ assert_kind_of ReferencePosition, p1
800
+ end
801
+
802
+ def test_geocenter
803
+ p1 = Geocenter.new
804
+ assert_equal "<stc:GEOCENTER xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'/>", p1.to_xml.to_s
805
+
806
+ p2 = Geocenter.from_xml(p1.to_xml)
807
+ assert_equal p1, p2
808
+
809
+ assert_kind_of StdRefPos, p1
810
+ assert_kind_of ReferencePosition, p1
811
+ end
812
+
813
+ def test_lsr
814
+ p1 = Lsr.new
815
+ assert_equal "<stc:LSR xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'/>", p1.to_xml.to_s
816
+
817
+ p2 = Lsr.from_xml(p1.to_xml)
818
+ assert_equal p1, p2
819
+
820
+ assert_kind_of StdRefPos, p1
821
+ assert_kind_of ReferencePosition, p1
822
+ end
823
+
824
+ def test_galactic_center
825
+ p1 = GalacticCenter.new
826
+ assert_equal "<stc:GALACTIC_CENTER xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'/>", p1.to_xml.to_s
827
+
828
+ p2 = GalacticCenter.from_xml(p1.to_xml)
829
+ assert_equal p1, p2
830
+
831
+ assert_kind_of StdRefPos, p1
832
+ assert_kind_of ReferencePosition, p1
833
+ end
834
+
835
+ def test_super_galactic_center
836
+ p1 = SuperGalacticCenter.new
837
+ assert_equal "<stc:SUPER_GALACTIC_CENTER xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'/>", p1.to_xml.to_s
838
+
839
+ p2 = SuperGalacticCenter.from_xml(p1.to_xml)
840
+ assert_equal p1, p2
841
+
842
+ assert_kind_of StdRefPos, p1
843
+ assert_kind_of ReferencePosition, p1
844
+ end
845
+
846
+ def test_moon
847
+ p1 = Moon.new
848
+ assert_equal "<stc:MOON xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'/>", p1.to_xml.to_s
849
+
850
+ p2 = Moon.from_xml(p1.to_xml)
851
+ assert_equal p1, p2
852
+
853
+ assert_kind_of StdRefPos, p1
854
+ assert_kind_of ReferencePosition, p1
855
+ end
856
+
857
+ def test_embarycenter
858
+ p1 = Embarycenter.new
859
+ assert_equal "<stc:EMBARYCENTER xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'/>", p1.to_xml.to_s
860
+
861
+ p2 = Embarycenter.from_xml(p1.to_xml)
862
+ assert_equal p1, p2
863
+
864
+ assert_kind_of StdRefPos, p1
865
+ assert_kind_of ReferencePosition, p1
866
+ end
867
+
868
+ def test_mercury
869
+ p1 = Mercury.new
870
+ assert_equal "<stc:MERCURY xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'/>", p1.to_xml.to_s
871
+
872
+ p2 = Mercury.from_xml(p1.to_xml)
873
+ assert_equal p1, p2
874
+
875
+ assert_kind_of StdRefPos, p1
876
+ assert_kind_of ReferencePosition, p1
877
+ end
878
+
879
+ def test_venus
880
+ p1 = Venus.new
881
+ assert_equal "<stc:VENUS xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'/>", p1.to_xml.to_s
882
+
883
+ p2 = Venus.from_xml(p1.to_xml)
884
+ assert_equal p1, p2
885
+
886
+ assert_kind_of StdRefPos, p1
887
+ assert_kind_of ReferencePosition, p1
888
+ end
889
+
890
+ def test_mars
891
+ p1 = Mars.new
892
+ assert_equal "<stc:MARS xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'/>", p1.to_xml.to_s
893
+
894
+ p2 = Mars.from_xml(p1.to_xml)
895
+ assert_equal p1, p2
896
+
897
+ assert_kind_of StdRefPos, p1
898
+ assert_kind_of ReferencePosition, p1
899
+ end
900
+
901
+ def test_jupiter
902
+ p1 = Jupiter.new
903
+ assert_equal "<stc:JUPITER xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'/>", p1.to_xml.to_s
904
+
905
+ p2 = Jupiter.from_xml(p1.to_xml)
906
+ assert_equal p1, p2
907
+
908
+ assert_kind_of StdRefPos, p1
909
+ assert_kind_of ReferencePosition, p1
910
+ end
911
+
912
+ def test_saturn
913
+ p1 = Saturn.new
914
+ assert_equal "<stc:SATURN xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'/>", p1.to_xml.to_s
915
+
916
+ p2 = Saturn.from_xml(p1.to_xml)
917
+ assert_equal p1, p2
918
+
919
+ assert_kind_of StdRefPos, p1
920
+ assert_kind_of ReferencePosition, p1
921
+ end
922
+
923
+ def test_uranus
924
+ p1 = Uranus.new
925
+ assert_equal "<stc:URANUS xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'/>", p1.to_xml.to_s
926
+
927
+ p2 = Uranus.from_xml(p1.to_xml)
928
+ assert_equal p1, p2
929
+
930
+ assert_kind_of StdRefPos, p1
931
+ assert_kind_of ReferencePosition, p1
932
+ end
933
+
934
+ def test_neptune
935
+ p1 = Neptune.new
936
+ assert_equal "<stc:NEPTUNE xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'/>", p1.to_xml.to_s
937
+
938
+ p2 = Neptune.from_xml(p1.to_xml)
939
+ assert_equal p1, p2
940
+
941
+ assert_kind_of StdRefPos, p1
942
+ assert_kind_of ReferencePosition, p1
943
+ end
944
+
945
+ def test_pluto
946
+ p1 = Pluto.new
947
+ assert_equal "<stc:PLUTO xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'/>", p1.to_xml.to_s
948
+
949
+ p2 = Pluto.from_xml(p1.to_xml)
950
+ assert_equal p1, p2
951
+
952
+ assert_kind_of StdRefPos, p1
953
+ assert_kind_of ReferencePosition, p1
954
+ end
955
+
956
+ def test_relocatable
957
+ p1 = Relocatable.new
958
+ assert_equal "<stc:RELOCATABLE xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'/>", p1.to_xml.to_s
959
+
960
+ p2 = Relocatable.from_xml(p1.to_xml)
961
+ assert_equal p1, p2
962
+
963
+ assert_kind_of StdRefPos, p1
964
+ assert_kind_of ReferencePosition, p1
965
+ end
966
+
967
+ def test_unknown_ref_pos
968
+ p1 = UnknownRefPos.new
969
+ assert_equal "<stc:UNKNOWNRefPos xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd'/>", p1.to_xml.to_s
970
+
971
+ p2 = UnknownRefPos.from_xml(p1.to_xml)
972
+ assert_equal p1, p2
973
+
974
+ assert_kind_of StdRefPos, p1
975
+ assert_kind_of ReferencePosition, p1
976
+ end
977
+ end
978
+
979
+ class CustomRefPosTest < ::Test::Unit::TestCase
980
+ def test_relationships
981
+ p = CustomRefPos.new(
982
+ AstroCoords.new(
983
+ :coord_system_id => 'FK5-UTC-VEL',
984
+ :time => TimeCoordinate.new(:name => 'Time'),
985
+ :position => Position1D.new(:name => 'FK5Cart', :unit => PosUnit.new('lyr')),
986
+ :velocity => Velocity1D.new(:name => 'Vel', :unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('h')),
987
+ :spectral => Spectral.new(:name => 'Spectrum2'),
988
+ :redshift => Redshift.new(:name => 'Redshift2'),
989
+ :coord_file => AstroCoordsFile.new(:file => Fits.new(:uri => 'http://www.stsci.edu/'))
990
+ )
991
+ )
992
+
993
+ assert_kind_of CustomRefPosType, p
994
+ assert_kind_of ReferencePosition, p
995
+ end
996
+
997
+ def test_xml
998
+ p1 = CustomRefPos.new(
999
+ AstroCoords.new(
1000
+ :coord_system_id => 'FK5-UTC-VEL',
1001
+ :time => TimeCoordinate.new(:name => 'Time'),
1002
+ :position => Position1D.new(:name => 'FK5Cart', :unit => PosUnit.new('lyr')),
1003
+ :velocity => Velocity1D.new(:name => 'Vel', :unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('h')),
1004
+ :spectral => Spectral.new(:name => 'Spectrum2'),
1005
+ :redshift => Redshift.new(:name => 'Redshift2'),
1006
+ :coord_file => AstroCoordsFile.new(:file => Fits.new(:uri => 'http://www.stsci.edu/'))
1007
+ )
1008
+ )
1009
+
1010
+ p2 = CustomRefPos.from_xml(p1.to_xml)
1011
+ assert_equal p1, p2
1012
+ end
1013
+ end
1014
+
1015
+ class CoordFlavorTypeTest < ::Test::Unit::TestCase
1016
+ def test_construction
1017
+ assert_nothing_raised {
1018
+ CoordFlavorType.new
1019
+ CoordFlavorType.new(3)
1020
+ CoordFlavorType.new(1, true)
1021
+ }
1022
+
1023
+ assert_raises ArgumentError do
1024
+ CoordFlavorType.new(4)
1025
+ end
1026
+ end
1027
+
1028
+ def test_accessors
1029
+ f = CoordFlavorType.new(3, true)
1030
+ assert_equal 3, f.coord_naxes
1031
+ assert_equal true, f.coord_vel
1032
+
1033
+ f.coord_naxes = 2
1034
+ assert_equal 2, f.coord_naxes
1035
+ f.coord_vel = false
1036
+ assert_equal false, f.coord_vel
1037
+ end
1038
+
1039
+ def test_xml
1040
+ f1 = CoordFlavorType.new(1, false)
1041
+ assert_equal(
1042
+ "<stc:CoordFlavorType stc:coord_naxes='1' xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd' stc:coord_vel='false'/>",
1043
+ f1.to_xml.to_s
1044
+ )
1045
+
1046
+ f2 = CoordFlavorType.from_xml(f1.to_xml)
1047
+ assert_equal f1, f2
1048
+ end
1049
+ end
1050
+
1051
+ class CoordFlavorTest < ::Test::Unit::TestCase
1052
+ def test_spherical
1053
+ f1 = Spherical.new
1054
+ assert_equal(
1055
+ "<stc:SPHERICAL stc:coord_naxes='2' xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd' stc:coord_vel='false'/>",
1056
+ f1.to_xml.to_s
1057
+ )
1058
+
1059
+ f2 = Spherical.from_xml(f1.to_xml)
1060
+ assert_equal f1, f2
1061
+
1062
+ assert_kind_of CoordFlavorType, f1
1063
+ assert_kind_of CoordFlavor, f1
1064
+ end
1065
+
1066
+ def test_cartesion
1067
+ f1 = Cartesian.new
1068
+ assert_equal(
1069
+ "<stc:CARTESIAN stc:coord_naxes='2' xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd' stc:coord_vel='false'/>",
1070
+ f1.to_xml.to_s
1071
+ )
1072
+
1073
+ f2 = Cartesian.from_xml(f1.to_xml)
1074
+ assert_equal f1, f2
1075
+
1076
+ assert_kind_of CoordFlavorType, f1
1077
+ assert_kind_of CoordFlavor, f1
1078
+ end
1079
+
1080
+ def test_unit_sphere
1081
+ f1 = UnitSphere.new
1082
+ assert_equal(
1083
+ "<stc:UNITSPHERE stc:coord_naxes='2' xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd' stc:coord_vel='false'/>",
1084
+ f1.to_xml.to_s
1085
+ )
1086
+
1087
+ f2 = UnitSphere.from_xml(f1.to_xml)
1088
+ assert_equal f1, f2
1089
+
1090
+ assert_kind_of CoordFlavorType, f1
1091
+ assert_kind_of CoordFlavor, f1
1092
+ end
1093
+
1094
+ def test_geographic
1095
+ f1 = Geographic.new
1096
+ assert_equal(
1097
+ "<stc:GEOGRAPHIC stc:coord_naxes='2' xmlns:stc='http://www.ivoa.net/xml/STC/stc-v1.10.xsd' stc:coord_vel='false'/>",
1098
+ f1.to_xml.to_s
1099
+ )
1100
+
1101
+ f2 = Geographic.from_xml(f1.to_xml)
1102
+ assert_equal f1, f2
1103
+
1104
+ assert_kind_of CoordFlavorType, f1
1105
+ assert_kind_of CoordFlavor, f1
1106
+ end
1107
+ end
1108
+
1109
+ class SpaceFrameTypeTest < ::Test::Unit::TestCase
1110
+ def test_construction
1111
+ assert_nothing_raised {
1112
+ SpaceFrameType.new(
1113
+ :name => 'MySpaceFrame',
1114
+ :space_ref_frame => Fk5.new('J2000.0'),
1115
+ :reference_position => Heliocenter.new,
1116
+ :offset_center => Value.new(110.1),
1117
+ :coord_flavor => Cartesian.new
1118
+ )
1119
+ SpaceFrameType.new(
1120
+ :name => 'MySpaceFrame',
1121
+ :space_ref_frame => Fk5.new('J2000.0'),
1122
+ :reference_position => Heliocenter.new,
1123
+ :coord_flavor => Cartesian.new
1124
+ )
1125
+ }
1126
+
1127
+ assert_raises ArgumentError do
1128
+ SpaceFrameType.new(
1129
+ :name => 'MySpaceFrame',
1130
+ :reference_position => Heliocenter.new,
1131
+ :offset_center => Value.new(110.1),
1132
+ :coord_flavor => Cartesian.new
1133
+ )
1134
+ end
1135
+ assert_raises ArgumentError do
1136
+ SpaceFrameType.new(
1137
+ :name => 'MySpaceFrame',
1138
+ :space_ref_frame => Fk5.new('J2000.0'),
1139
+ :offset_center => Value.new(110.1),
1140
+ :coord_flavor => Cartesian.new
1141
+ )
1142
+ end
1143
+ assert_raises ArgumentError do
1144
+ SpaceFrameType.new(
1145
+ :name => 'MySpaceFrame',
1146
+ :space_ref_frame => Fk5.new('J2000.0'),
1147
+ :reference_position => Heliocenter.new,
1148
+ :offset_center => Value.new(110.1)
1149
+ )
1150
+ end
1151
+
1152
+ assert_raises TypeError do
1153
+ SpaceFrameType.new(
1154
+ :name => 'MySpaceFrame',
1155
+ :space_ref_frame => 'blah',
1156
+ :reference_position => Heliocenter.new,
1157
+ :offset_center => Value.new(110.1),
1158
+ :coord_flavor => Cartesian.new
1159
+ )
1160
+ end
1161
+ assert_raises TypeError do
1162
+ SpaceFrameType.new(
1163
+ :name => 'MySpaceFrame',
1164
+ :space_ref_frame => Fk5.new('J2000.0'),
1165
+ :reference_position => 'blah',
1166
+ :offset_center => Value.new(110.1),
1167
+ :coord_flavor => Cartesian.new
1168
+ )
1169
+ end
1170
+ assert_raises TypeError do
1171
+ SpaceFrameType.new(
1172
+ :name => 'MySpaceFrame',
1173
+ :space_ref_frame => Fk5.new('J2000.0'),
1174
+ :reference_position => Heliocenter.new,
1175
+ :offset_center => 'blah',
1176
+ :coord_flavor => Cartesian.new
1177
+ )
1178
+ end
1179
+ assert_raises TypeError do
1180
+ SpaceFrameType.new(
1181
+ :name => 'MySpaceFrame',
1182
+ :space_ref_frame => Fk5.new('J2000.0'),
1183
+ :reference_position => Heliocenter.new,
1184
+ :offset_center => Value.new(110.1),
1185
+ :coord_flavor => 'blah'
1186
+ )
1187
+ end
1188
+ end
1189
+
1190
+ def test_accessors
1191
+ f = SpaceFrameType.new(
1192
+ :name => 'MySpaceFrame',
1193
+ :space_ref_frame => Fk5.new('J2000.0'),
1194
+ :reference_position => Heliocenter.new,
1195
+ :offset_center => Value.new(110.1),
1196
+ :coord_flavor => Cartesian.new
1197
+ )
1198
+
1199
+ assert_equal 'MySpaceFrame', f.name
1200
+ assert_equal Fk5.new('J2000.0'), f.space_ref_frame
1201
+ assert_equal Heliocenter.new, f.reference_position
1202
+ assert_equal Value.new(110.1), f.offset_center
1203
+ assert_equal Cartesian.new, f.coord_flavor
1204
+
1205
+ f.space_ref_frame = Fk4.new('B1950.0')
1206
+ assert_equal Fk4.new('B1950.0'), f.space_ref_frame
1207
+ f.reference_position = Geocenter.new
1208
+ assert_equal Geocenter.new, f.reference_position
1209
+ f.offset_center = Value2.new([1.1, 2.2])
1210
+ assert_equal Value2.new([1.1, 2.2]), f.offset_center
1211
+ f.coord_flavor = Spherical.new
1212
+ assert_equal Spherical.new, f.coord_flavor
1213
+ end
1214
+
1215
+ def test_relationships
1216
+ f = SpaceFrameType.new(
1217
+ :name => 'MySpaceFrame',
1218
+ :space_ref_frame => Fk5.new('J2000.0'),
1219
+ :reference_position => Heliocenter.new,
1220
+ :offset_center => Value.new(110.1),
1221
+ :coord_flavor => Cartesian.new
1222
+ )
1223
+
1224
+ assert_kind_of CoordFrameType, f
1225
+ end
1226
+
1227
+ def test_xml
1228
+ f1 = SpaceFrameType.new(
1229
+ :name => 'MySpaceFrame',
1230
+ :space_ref_frame => Fk5.new('J2000.0'),
1231
+ :reference_position => Heliocenter.new,
1232
+ :offset_center => Value2.new([1.1, 2.2]),
1233
+ :coord_flavor => Cartesian.new
1234
+ )
1235
+
1236
+ f2 = SpaceFrameType.from_xml(f1.to_xml)
1237
+ assert_equal f1, f2
1238
+ end
1239
+ end
1240
+
1241
+ class TimeFrameTypeTest < ::Test::Unit::TestCase
1242
+ def test_construction
1243
+ assert_nothing_raised {
1244
+ TimeFrameType.new(
1245
+ :name => 'MyTimeFrame',
1246
+ :time_scale => TimeScale.new('UTC'),
1247
+ :reference_position => Topocenter.new,
1248
+ :time_ref_direction => AstroCoords.new(
1249
+ :coord_system_id => 'FK5-UTC-VEL',
1250
+ :time => TimeCoordinate.new(:name => 'Time'),
1251
+ :position => Position1D.new(:name => 'FK5Cart', :unit => PosUnit.new('m')),
1252
+ :velocity => Velocity1D.new(:name => 'Vel', :unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('h')),
1253
+ :spectral => Spectral.new(:name => 'Spectrum'),
1254
+ :redshift => Redshift.new(:name => 'Redshift'),
1255
+ :coord_file => AstroCoordsFile.new(:file => Fits.new(:uri => 'http://www.noao.edu/'))
1256
+ )
1257
+ )
1258
+ TimeFrameType.new(
1259
+ :name => 'MyTimeFrame',
1260
+ :reference_position => Topocenter.new,
1261
+ :time_ref_direction => AstroCoords.new(
1262
+ :coord_system_id => 'FK5-UTC-VEL',
1263
+ :time => TimeCoordinate.new(:name => 'Time'),
1264
+ :position => Position1D.new(:name => 'FK5Cart', :unit => PosUnit.new('m')),
1265
+ :velocity => Velocity1D.new(:name => 'Vel', :unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('h')),
1266
+ :spectral => Spectral.new(:name => 'Spectrum'),
1267
+ :redshift => Redshift.new(:name => 'Redshift'),
1268
+ :coord_file => AstroCoordsFile.new(:file => Fits.new(:uri => 'http://www.noao.edu/'))
1269
+ )
1270
+ )
1271
+ TimeFrameType.new(
1272
+ :name => 'MyTimeFrame',
1273
+ :time_scale => TimeScale.new('UTC'),
1274
+ :reference_position => Topocenter.new
1275
+ )
1276
+ }
1277
+
1278
+ assert_raises ArgumentError do
1279
+ TimeFrameType.new(
1280
+ :name => 'MyTimeFrame',
1281
+ :time_scale => 'blah',
1282
+ :reference_position => Topocenter.new,
1283
+ :time_ref_direction => AstroCoords.new(
1284
+ :coord_system_id => 'FK5-UTC-VEL',
1285
+ :time => TimeCoordinate.new(:name => 'Time'),
1286
+ :position => Position1D.new(:name => 'FK5Cart', :unit => PosUnit.new('m')),
1287
+ :velocity => Velocity1D.new(:name => 'Vel', :unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('h')),
1288
+ :spectral => Spectral.new(:name => 'Spectrum'),
1289
+ :redshift => Redshift.new(:name => 'Redshift'),
1290
+ :coord_file => AstroCoordsFile.new(:file => Fits.new(:uri => 'http://www.noao.edu/'))
1291
+ )
1292
+ )
1293
+ end
1294
+ assert_raises TypeError do
1295
+ TimeFrameType.new(
1296
+ :name => 'MyTimeFrame',
1297
+ :time_scale => TimeScale.new('UTC'),
1298
+ :reference_position => 'blah',
1299
+ :time_ref_direction => AstroCoords.new(
1300
+ :coord_system_id => 'FK5-UTC-VEL',
1301
+ :time => TimeCoordinate.new(:name => 'Time'),
1302
+ :position => Position1D.new(:name => 'FK5Cart', :unit => PosUnit.new('m')),
1303
+ :velocity => Velocity1D.new(:name => 'Vel', :unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('h')),
1304
+ :spectral => Spectral.new(:name => 'Spectrum'),
1305
+ :redshift => Redshift.new(:name => 'Redshift'),
1306
+ :coord_file => AstroCoordsFile.new(:file => Fits.new(:uri => 'http://www.noao.edu/'))
1307
+ )
1308
+ )
1309
+ end
1310
+ assert_raises TypeError do
1311
+ TimeFrameType.new(
1312
+ :name => 'MyTimeFrame',
1313
+ :time_scale => TimeScale.new('UTC'),
1314
+ :reference_position => Topocenter.new,
1315
+ :time_ref_direction => 'blah'
1316
+ )
1317
+ end
1318
+ end
1319
+
1320
+ def test_accessors
1321
+ f = TimeFrameType.new(
1322
+ :name => 'MyTimeFrame',
1323
+ :time_scale => TimeScale.new('UTC'),
1324
+ :reference_position => Topocenter.new,
1325
+ :time_ref_direction => AstroCoords.new(
1326
+ :coord_system_id => 'FK5-UTC-VEL',
1327
+ :time => TimeCoordinate.new(:name => 'Time'),
1328
+ :position => Position1D.new(:name => 'FK5Cart', :unit => PosUnit.new('m')),
1329
+ :velocity => Velocity1D.new(:name => 'Vel', :unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('h')),
1330
+ :spectral => Spectral.new(:name => 'Spectrum'),
1331
+ :redshift => Redshift.new(:name => 'Redshift'),
1332
+ :coord_file => AstroCoordsFile.new(:file => Fits.new(:uri => 'http://www.noao.edu/'))
1333
+ )
1334
+ )
1335
+
1336
+ assert_equal 'MyTimeFrame', f.name
1337
+ assert_equal TimeScale.new('UTC'), f.time_scale
1338
+ assert_equal Topocenter.new, f.reference_position
1339
+ assert_equal(
1340
+ AstroCoords.new(
1341
+ :coord_system_id => 'FK5-UTC-VEL',
1342
+ :time => TimeCoordinate.new(:name => 'Time'),
1343
+ :position => Position1D.new(:name => 'FK5Cart', :unit => PosUnit.new('m')),
1344
+ :velocity => Velocity1D.new(:name => 'Vel', :unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('h')),
1345
+ :spectral => Spectral.new(:name => 'Spectrum'),
1346
+ :redshift => Redshift.new(:name => 'Redshift'),
1347
+ :coord_file => AstroCoordsFile.new(:file => Fits.new(:uri => 'http://www.noao.edu/'))
1348
+ ),
1349
+ f.time_ref_direction
1350
+ )
1351
+
1352
+ f.name = 'MySecondTimeFrame'
1353
+ assert_equal 'MySecondTimeFrame', f.name
1354
+ f.time_scale = TimeScale.new('LST')
1355
+ assert_equal TimeScale.new('LST'), f.time_scale
1356
+ f.reference_position = Heliocenter.new
1357
+ assert_equal Heliocenter.new, f.reference_position
1358
+ f.time_ref_direction = AstroCoords.new(
1359
+ :coord_system_id => 'FK5-UTC-VEL',
1360
+ :time => TimeCoordinate.new(:name => 'Time2'),
1361
+ :position => Position1D.new(:name => 'FK5Cart2', :unit => PosUnit.new('m')),
1362
+ :velocity => Velocity1D.new(:name => 'Vel2', :unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('h')),
1363
+ :spectral => Spectral.new(:name => 'Spectrum2'),
1364
+ :redshift => Redshift.new(:name => 'Redshift2'),
1365
+ :coord_file => AstroCoordsFile.new(:file => Fits.new(:uri => 'http://www.noao.edu/'))
1366
+ )
1367
+ assert_equal(
1368
+ AstroCoords.new(
1369
+ :coord_system_id => 'FK5-UTC-VEL',
1370
+ :time => TimeCoordinate.new(:name => 'Time2'),
1371
+ :position => Position1D.new(:name => 'FK5Cart2', :unit => PosUnit.new('m')),
1372
+ :velocity => Velocity1D.new(:name => 'Vel2', :unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('h')),
1373
+ :spectral => Spectral.new(:name => 'Spectrum2'),
1374
+ :redshift => Redshift.new(:name => 'Redshift2'),
1375
+ :coord_file => AstroCoordsFile.new(:file => Fits.new(:uri => 'http://www.noao.edu/'))
1376
+ ),
1377
+ f.time_ref_direction
1378
+ )
1379
+ end
1380
+
1381
+ def test_relationships
1382
+ f = TimeFrameType.new(
1383
+ :name => 'MyTimeFrame',
1384
+ :time_scale => TimeScale.new('UTC'),
1385
+ :reference_position => Topocenter.new,
1386
+ :time_ref_direction => AstroCoords.new(
1387
+ :coord_system_id => 'FK5-UTC-VEL',
1388
+ :time => TimeCoordinate.new(:name => 'Time'),
1389
+ :position => Position1D.new(:name => 'FK5Cart', :unit => PosUnit.new('m')),
1390
+ :velocity => Velocity1D.new(:name => 'Vel', :unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('h')),
1391
+ :spectral => Spectral.new(:name => 'Spectrum'),
1392
+ :redshift => Redshift.new(:name => 'Redshift'),
1393
+ :coord_file => AstroCoordsFile.new(:file => Fits.new(:uri => 'http://www.noao.edu/'))
1394
+ )
1395
+ )
1396
+
1397
+ assert_kind_of CoordFrameType, f
1398
+ end
1399
+
1400
+ def test_xml
1401
+ f1 = TimeFrameType.new(
1402
+ :name => 'MyTimeFrame',
1403
+ :time_scale => TimeScale.new('UTC'),
1404
+ :reference_position => Topocenter.new,
1405
+ :time_ref_direction => AstroCoords.new(
1406
+ :coord_system_id => 'FK5-UTC-VEL',
1407
+ :time => TimeCoordinate.new(:name => 'Time'),
1408
+ :position => Position1D.new(:name => 'FK5Cart', :unit => PosUnit.new('m')),
1409
+ :velocity => Velocity1D.new(:name => 'Vel', :unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('h')),
1410
+ :spectral => Spectral.new(:name => 'Spectrum'),
1411
+ :redshift => Redshift.new(:name => 'Redshift'),
1412
+ :coord_file => AstroCoordsFile.new(:file => Fits.new(:uri => 'http://www.noao.edu/'))
1413
+ )
1414
+ )
1415
+
1416
+ f2 = TimeFrameType.from_xml(f1.to_xml)
1417
+ assert_equal f1, f2
1418
+ end
1419
+ end
1420
+
1421
+ class SpectralFrameTypeTest < ::Test::Unit::TestCase
1422
+ def test_construction
1423
+ assert_nothing_raised {
1424
+ SpectralFrameType.new(:reference_position => Topocenter.new)
1425
+ }
1426
+
1427
+ assert_raises ArgumentError do
1428
+ SpectralFrameType.new
1429
+ end
1430
+ assert_raises TypeError do
1431
+ SpectralFrameType.new(:reference_position => 'blah')
1432
+ end
1433
+ end
1434
+
1435
+ def test_accessors
1436
+ f = SpectralFrameType.new(:reference_position => Topocenter.new)
1437
+ assert_equal Topocenter.new, f.reference_position
1438
+
1439
+ f.reference_position = Heliocenter.new
1440
+ assert_equal Heliocenter.new, f.reference_position
1441
+ end
1442
+
1443
+ def test_relationships
1444
+ assert_kind_of CoordFrameType, SpectralFrameType.new(:reference_position => Topocenter.new)
1445
+ end
1446
+
1447
+ def test_xml
1448
+ f1 = SpectralFrameType.new(:reference_position => Topocenter.new)
1449
+
1450
+ f2 = SpectralFrameType.from_xml(f1.to_xml)
1451
+ assert_equal f1, f2
1452
+ end
1453
+ end
1454
+
1455
+ class DopplerDefinitionTest < ::Test::Unit::TestCase
1456
+ def test_construction
1457
+ assert_nothing_raised {
1458
+ DopplerDefinition.new('OPTICAL')
1459
+ DopplerDefinition.new('RADIO')
1460
+ DopplerDefinition.new('RELATIVISTIC')
1461
+ }
1462
+
1463
+ assert_raises ArgumentError do
1464
+ DopplerDefinition.new
1465
+ end
1466
+ assert_raises ArgumentError do
1467
+ DopplerDefinition.new('blah')
1468
+ end
1469
+ end
1470
+
1471
+ def test_accessors
1472
+ d = DopplerDefinition.new('RADIO')
1473
+ assert_equal 'RADIO', d.value
1474
+
1475
+ d.value = 'OPTICAL'
1476
+ assert_equal 'OPTICAL', d.value
1477
+ end
1478
+ end
1479
+
1480
+ class RedshiftFrameTypeTest < ::Test::Unit::TestCase
1481
+ def test_construction
1482
+ assert_nothing_raised {
1483
+ RedshiftFrameType.new(
1484
+ :doppler_definition => 'OPTICAL',
1485
+ :reference_position => Topocenter.new,
1486
+ :value_type => 'REDSHIFT'
1487
+ )
1488
+ RedshiftFrameType.new(
1489
+ :reference_position => Topocenter.new,
1490
+ :value_type => 'REDSHIFT'
1491
+ )
1492
+ RedshiftFrameType.new(
1493
+ :reference_position => Topocenter.new
1494
+ )
1495
+ }
1496
+
1497
+ assert_raises ArgumentError do
1498
+ RedshiftFrameType.new(
1499
+ :doppler_definition => 'OPTICAL',
1500
+ :value_type => 'REDSHIFT'
1501
+ )
1502
+ end
1503
+ assert_raises TypeError do
1504
+ RedshiftFrameType.new(
1505
+ :reference_position => 'blah'
1506
+ )
1507
+ end
1508
+ end
1509
+
1510
+ def test_accessors
1511
+ f = RedshiftFrameType.new(
1512
+ :doppler_definition => 'OPTICAL',
1513
+ :reference_position => Topocenter.new,
1514
+ :value_type => 'REDSHIFT'
1515
+ )
1516
+
1517
+ assert_equal DopplerDefinition.new('OPTICAL'), f.doppler_definition
1518
+ assert_equal Topocenter.new, f.reference_position
1519
+ assert_equal 'REDSHIFT', f.value_type
1520
+
1521
+ f.doppler_definition = DopplerDefinition.new('RELATIVISTIC')
1522
+ assert_equal DopplerDefinition.new('RELATIVISTIC'), f.doppler_definition
1523
+ f.reference_position = Heliocenter.new
1524
+ assert_equal Heliocenter.new, f.reference_position
1525
+ f.value_type = 'VELOCITY'
1526
+ assert_equal 'VELOCITY', f.value_type
1527
+ end
1528
+
1529
+ def test_relationships
1530
+ f = RedshiftFrameType.new(
1531
+ :doppler_definition => 'OPTICAL',
1532
+ :reference_position => Topocenter.new,
1533
+ :value_type => 'REDSHIFT'
1534
+ )
1535
+
1536
+ assert_kind_of CoordFrameType, f
1537
+ end
1538
+
1539
+ def test_xml
1540
+ f1 = RedshiftFrameType.new(
1541
+ :doppler_definition => 'OPTICAL',
1542
+ :reference_position => Topocenter.new,
1543
+ :value_type => 'REDSHIFT'
1544
+ )
1545
+
1546
+ f2 = RedshiftFrameType.from_xml(f1.to_xml)
1547
+ assert_equal f1, f2
1548
+ end
1549
+ end
1550
+
1551
+ class CoordSysTypeTest < ::Test::Unit::TestCase
1552
+ def test_construction
1553
+ assert_nothing_raised {
1554
+ CoordSysType.new(
1555
+ :id => 'MyCoordSys',
1556
+ :coord_frames => [
1557
+ RedshiftFrame.new(
1558
+ :doppler_definition => 'OPTICAL',
1559
+ :reference_position => Topocenter.new,
1560
+ :value_type => 'REDSHIFT'
1561
+ )
1562
+ ]
1563
+ )
1564
+ }
1565
+
1566
+ assert_raises ArgumentError do
1567
+ CoordSysType.new(:id => 'MyCoordSys')
1568
+ end
1569
+ assert_raises ArgumentError do
1570
+ CoordSysType.new(
1571
+ :coord_frames => [
1572
+ RedshiftFrame.new(
1573
+ :doppler_definition => 'OPTICAL',
1574
+ :reference_position => Topocenter.new,
1575
+ :value_type => 'REDSHIFT'
1576
+ )
1577
+ ]
1578
+ )
1579
+ end
1580
+ assert_raises TypeError do
1581
+ CoordSysType.new(
1582
+ :id => 'MyCoordSys',
1583
+ :coord_frames => 'blah'
1584
+ )
1585
+ end
1586
+ end
1587
+
1588
+ def test_accessors
1589
+ t = CoordSysType.new(
1590
+ :id => 'MyCoordSys',
1591
+ :coord_frames => [
1592
+ RedshiftFrame.new(
1593
+ :doppler_definition => 'OPTICAL',
1594
+ :reference_position => Topocenter.new,
1595
+ :value_type => 'REDSHIFT'
1596
+ ),
1597
+ SpectralFrame.new(:reference_position => Topocenter.new)
1598
+ ]
1599
+ )
1600
+
1601
+ assert_equal Id.new('MyCoordSys'), t.id
1602
+ assert_equal(
1603
+ [
1604
+ RedshiftFrame.new(
1605
+ :doppler_definition => 'OPTICAL',
1606
+ :reference_position => Topocenter.new,
1607
+ :value_type => 'REDSHIFT'
1608
+ ),
1609
+ SpectralFrame.new(:reference_position => Topocenter.new)
1610
+ ],
1611
+ t.coord_frames
1612
+ )
1613
+
1614
+ t.id = Id.new('MyCoordSys2')
1615
+ assert_equal Id.new('MyCoordSys2'), t.id
1616
+ t.coord_frames = [
1617
+ RedshiftFrame.new(
1618
+ :doppler_definition => 'OPTICAL',
1619
+ :reference_position => Topocenter.new,
1620
+ :value_type => 'REDSHIFT'
1621
+ )
1622
+ ]
1623
+ assert_equal(
1624
+ [RedshiftFrame.new(
1625
+ :doppler_definition => 'OPTICAL',
1626
+ :reference_position => Topocenter.new,
1627
+ :value_type => 'REDSHIFT'
1628
+ )],
1629
+ t.coord_frames
1630
+ )
1631
+ end
1632
+
1633
+ def test_xml
1634
+ t1 = CoordSysType.new(
1635
+ :id => 'MyCoordSys',
1636
+ :coord_frames => [
1637
+ RedshiftFrame.new(
1638
+ :doppler_definition => 'OPTICAL',
1639
+ :reference_position => Topocenter.new,
1640
+ :value_type => 'REDSHIFT'
1641
+ ),
1642
+ SpectralFrame.new(:reference_position => Topocenter.new)
1643
+ ]
1644
+ )
1645
+
1646
+ t2 = CoordSysType.from_xml(t1.to_xml)
1647
+ assert_equal t1, t2
1648
+ end
1649
+ end
1650
+
1651
+ class AstroCoordSystemTypeTest < ::Test::Unit::TestCase
1652
+ def test_construction
1653
+ assert_nothing_raised {
1654
+ AstroCoordSystemType.new(
1655
+ :id => Id.new('ICRS-TT-CXO'),
1656
+ :time_frame => TimeFrame.new(:name => 'Time', :time_scale => TimeScale.new('TT'), :reference_position => Topocenter.new),
1657
+ :space_frame => SpaceFrame.new(
1658
+ :name => 'Space', :space_ref_frame => Icrs.new,
1659
+ :reference_position => Topocenter.new, :coord_flavor => Spherical.new
1660
+ ),
1661
+ :spectral_frame => SpectralFrame.new(:name => 'Energy', :reference_position => Topocenter.new),
1662
+ :redshift_frame => RedshiftFrame.new(
1663
+ :name => 'DopplerVelocity', :doppler_definition => DopplerDefinition.new('OPTICAL'),
1664
+ :reference_position => Barycenter.new
1665
+ ),
1666
+ :generic_coord_frames => [
1667
+ GenericCoordFrame.new(:name => 'Generic1'), GenericCoordFrame.new(:name => 'Generic2')
1668
+ ]
1669
+ )
1670
+
1671
+ AstroCoordSystemType.new(
1672
+ :id => Id.new('ICRS-TT-CXO'),
1673
+ :time_frame => TimeFrame.new(:name => 'Time', :time_scale => TimeScale.new('TT'), :reference_position => Topocenter.new),
1674
+ :space_frame => SpaceFrame.new(
1675
+ :name => 'Space', :space_ref_frame => Icrs.new,
1676
+ :reference_position => Topocenter.new, :coord_flavor => Spherical.new
1677
+ ),
1678
+ :spectral_frame => SpectralFrame.new(:name => 'Energy', :reference_position => Topocenter.new),
1679
+ :redshift_frame => RedshiftFrame.new(
1680
+ :name => 'DopplerVelocity', :doppler_definition => DopplerDefinition.new('OPTICAL'),
1681
+ :reference_position => Barycenter.new
1682
+ )
1683
+ )
1684
+
1685
+ AstroCoordSystemType.new(
1686
+ :id => Id.new('ICRS-TT-CXO'),
1687
+ :time_frame => TimeFrame.new(:name => 'Time', :time_scale => TimeScale.new('TT'), :reference_position => Topocenter.new),
1688
+ :space_frame => SpaceFrame.new(
1689
+ :name => 'Space', :space_ref_frame => Icrs.new,
1690
+ :reference_position => Topocenter.new, :coord_flavor => Spherical.new
1691
+ ),
1692
+ :spectral_frame => SpectralFrame.new(:name => 'Energy', :reference_position => Topocenter.new)
1693
+ )
1694
+
1695
+ AstroCoordSystemType.new(
1696
+ :id => Id.new('ICRS-TT-CXO'),
1697
+ :time_frame => TimeFrame.new(:name => 'Time', :time_scale => TimeScale.new('TT'), :reference_position => Topocenter.new),
1698
+ :space_frame => SpaceFrame.new(
1699
+ :name => 'Space', :space_ref_frame => Icrs.new,
1700
+ :reference_position => Topocenter.new, :coord_flavor => Spherical.new
1701
+ )
1702
+ )
1703
+ }
1704
+
1705
+ assert_raises ArgumentError do
1706
+ AstroCoordSystemType.new(
1707
+ :id => Id.new('ICRS-TT-CXO'),
1708
+ :time_frame => TimeFrame.new(:name => 'Time', :time_scale => TimeScale.new('TT'), :reference_position => Topocenter.new)
1709
+ )
1710
+ end
1711
+ assert_raises ArgumentError do
1712
+ AstroCoordSystemType.new(
1713
+ :id => Id.new('ICRS-TT-CXO'),
1714
+ :space_frame => SpaceFrame.new(
1715
+ :name => 'Space', :space_ref_frame => Icrs.new,
1716
+ :reference_position => Topocenter.new, :coord_flavor => Spherical.new
1717
+ )
1718
+ )
1719
+ end
1720
+ assert_raises ArgumentError do
1721
+ AstroCoordSystemType.new(
1722
+ :time_frame => TimeFrame.new(:name => 'Time', :time_scale => TimeScale.new('TT'), :reference_position => Topocenter.new),
1723
+ :space_frame => SpaceFrame.new(
1724
+ :name => 'Space', :space_ref_frame => Icrs.new,
1725
+ :reference_position => Topocenter.new, :coord_flavor => Spherical.new
1726
+ )
1727
+ )
1728
+ end
1729
+
1730
+ assert_raises TypeError do
1731
+ AstroCoordSystemType.new(
1732
+ :id => Id.new('ICRS-TT-CXO'),
1733
+ :time_frame => 'blah',
1734
+ :space_frame => SpaceFrame.new(
1735
+ :name => 'Space', :space_ref_frame => Icrs.new,
1736
+ :reference_position => Topocenter.new, :coord_flavor => Spherical.new
1737
+ ),
1738
+ :spectral_frame => SpectralFrame.new(:name => 'Energy', :reference_position => Topocenter.new),
1739
+ :redshift_frame => RedshiftFrame.new(
1740
+ :name => 'DopplerVelocity', :doppler_definition => DopplerDefinition.new('OPTICAL'),
1741
+ :reference_position => Barycenter.new
1742
+ ),
1743
+ :generic_coord_frames => [
1744
+ GenericCoordFrame.new(:name => 'Generic1'), GenericCoordFrame.new(:name => 'Generic2')
1745
+ ]
1746
+ )
1747
+ end
1748
+ assert_raises TypeError do
1749
+ AstroCoordSystemType.new(
1750
+ :id => Id.new('ICRS-TT-CXO'),
1751
+ :time_frame => TimeFrame.new(:name => 'Time', :time_scale => TimeScale.new('TT'), :reference_position => Topocenter.new),
1752
+ :space_frame => 'blah',
1753
+ :spectral_frame => SpectralFrame.new(:name => 'Energy', :reference_position => Topocenter.new),
1754
+ :redshift_frame => RedshiftFrame.new(
1755
+ :name => 'DopplerVelocity', :doppler_definition => DopplerDefinition.new('OPTICAL'),
1756
+ :reference_position => Barycenter.new
1757
+ ),
1758
+ :generic_coord_frames => [
1759
+ GenericCoordFrame.new(:name => 'Generic1'), GenericCoordFrame.new(:name => 'Generic2')
1760
+ ]
1761
+ )
1762
+ end
1763
+ assert_raises TypeError do
1764
+ AstroCoordSystemType.new(
1765
+ :id => Id.new('ICRS-TT-CXO'),
1766
+ :time_frame => TimeFrame.new(:name => 'Time', :time_scale => TimeScale.new('TT'), :reference_position => Topocenter.new),
1767
+ :space_frame => SpaceFrame.new(
1768
+ :name => 'Space', :space_ref_frame => Icrs.new,
1769
+ :reference_position => Topocenter.new, :coord_flavor => Spherical.new
1770
+ ),
1771
+ :spectral_frame => 'blah',
1772
+ :redshift_frame => RedshiftFrame.new(
1773
+ :name => 'DopplerVelocity', :doppler_definition => DopplerDefinition.new('OPTICAL'),
1774
+ :reference_position => Barycenter.new
1775
+ ),
1776
+ :generic_coord_frames => [
1777
+ GenericCoordFrame.new(:name => 'Generic1'), GenericCoordFrame.new(:name => 'Generic2')
1778
+ ]
1779
+ )
1780
+ end
1781
+ assert_raises TypeError do
1782
+ AstroCoordSystemType.new(
1783
+ :id => Id.new('ICRS-TT-CXO'),
1784
+ :time_frame => TimeFrame.new(:name => 'Time', :time_scale => TimeScale.new('TT'), :reference_position => Topocenter.new),
1785
+ :space_frame => SpaceFrame.new(
1786
+ :name => 'Space', :space_ref_frame => Icrs.new,
1787
+ :reference_position => Topocenter.new, :coord_flavor => Spherical.new
1788
+ ),
1789
+ :spectral_frame => SpectralFrame.new(:name => 'Energy', :reference_position => Topocenter.new),
1790
+ :redshift_frame => 'blah',
1791
+ :generic_coord_frames => [
1792
+ GenericCoordFrame.new(:name => 'Generic1'), GenericCoordFrame.new(:name => 'Generic2')
1793
+ ]
1794
+ )
1795
+ end
1796
+ assert_raises TypeError do
1797
+ AstroCoordSystemType.new(
1798
+ :id => Id.new('ICRS-TT-CXO'),
1799
+ :time_frame => TimeFrame.new(:name => 'Time', :time_scale => TimeScale.new('TT'), :reference_position => Topocenter.new),
1800
+ :space_frame => SpaceFrame.new(
1801
+ :name => 'Space', :space_ref_frame => Icrs.new,
1802
+ :reference_position => Topocenter.new, :coord_flavor => Spherical.new
1803
+ ),
1804
+ :spectral_frame => SpectralFrame.new(:name => 'Energy', :reference_position => Topocenter.new),
1805
+ :redshift_frame => RedshiftFrame.new(
1806
+ :name => 'DopplerVelocity', :doppler_definition => DopplerDefinition.new('OPTICAL'),
1807
+ :reference_position => Barycenter.new
1808
+ ),
1809
+ :generic_coord_frames => [
1810
+ 'blah', GenericCoordFrame.new(:name => 'Generic2')
1811
+ ]
1812
+ )
1813
+ end
1814
+ end
1815
+
1816
+ def test_accessors
1817
+ s = AstroCoordSystemType.new(
1818
+ :id => Id.new('ICRS-TT-CXO'),
1819
+ :time_frame => TimeFrame.new(:name => 'Time', :time_scale => TimeScale.new('TT'), :reference_position => Topocenter.new),
1820
+ :space_frame => SpaceFrame.new(
1821
+ :name => 'Space', :space_ref_frame => Icrs.new,
1822
+ :reference_position => Topocenter.new, :coord_flavor => Spherical.new
1823
+ ),
1824
+ :spectral_frame => SpectralFrame.new(:name => 'Energy', :reference_position => Topocenter.new),
1825
+ :redshift_frame => RedshiftFrame.new(
1826
+ :name => 'DopplerVelocity', :doppler_definition => DopplerDefinition.new('OPTICAL'),
1827
+ :reference_position => Barycenter.new
1828
+ ),
1829
+ :generic_coord_frames => [
1830
+ GenericCoordFrame.new(:name => 'Generic1'), GenericCoordFrame.new(:name => 'Generic2')
1831
+ ]
1832
+ )
1833
+
1834
+ assert_equal Id.new('ICRS-TT-CXO'), s.id
1835
+ assert_equal(
1836
+ TimeFrame.new(:name => 'Time', :time_scale => TimeScale.new('TT'), :reference_position => Topocenter.new),
1837
+ s.time_frame
1838
+ )
1839
+ assert_equal(
1840
+ SpaceFrame.new(
1841
+ :name => 'Space', :space_ref_frame => Icrs.new,
1842
+ :reference_position => Topocenter.new, :coord_flavor => Spherical.new
1843
+ ),
1844
+ s.space_frame
1845
+ )
1846
+ assert_equal SpectralFrame.new(:name => 'Energy', :reference_position => Topocenter.new), s.spectral_frame
1847
+ assert_equal(
1848
+ RedshiftFrame.new(
1849
+ :name => 'DopplerVelocity', :doppler_definition => DopplerDefinition.new('OPTICAL'),
1850
+ :reference_position => Barycenter.new
1851
+ ),
1852
+ s.redshift_frame
1853
+ )
1854
+ assert_equal(
1855
+ GenericCoordFrameList.new([GenericCoordFrame.new(:name => 'Generic1'), GenericCoordFrame.new(:name => 'Generic2')]),
1856
+ s.generic_coord_frames
1857
+ )
1858
+
1859
+ assert_equal s.time_frame, s.coord_frames[0]
1860
+ assert_equal s.space_frame, s.coord_frames[1]
1861
+ assert_equal s.spectral_frame, s.coord_frames[2]
1862
+ assert_equal s.redshift_frame, s.coord_frames[3]
1863
+ assert_equal s.generic_coord_frames, GenericCoordFrameList.new(s.coord_frames[4..-1])
1864
+
1865
+ s.id = Id.new('ICRS-TT-CX1')
1866
+ assert_equal Id.new('ICRS-TT-CX1'), s.id
1867
+ s.time_frame = TimeFrame.new(:name => 'Time2', :time_scale => TimeScale.new('TT'), :reference_position => Topocenter.new)
1868
+ assert_equal TimeFrame.new(:name => 'Time2', :time_scale => TimeScale.new('TT'), :reference_position => Topocenter.new), s.time_frame
1869
+ s.space_frame = SpaceFrame.new(
1870
+ :name => 'Space2', :space_ref_frame => Icrs.new,
1871
+ :reference_position => Topocenter.new, :coord_flavor => Spherical.new
1872
+ )
1873
+ assert_equal(
1874
+ SpaceFrame.new(
1875
+ :name => 'Space2', :space_ref_frame => Icrs.new,
1876
+ :reference_position => Topocenter.new, :coord_flavor => Spherical.new
1877
+ ),
1878
+ s.space_frame
1879
+ )
1880
+ s.spectral_frame = SpectralFrame.new(:name => 'Energy2', :reference_position => Topocenter.new)
1881
+ assert_equal SpectralFrame.new(:name => 'Energy2', :reference_position => Topocenter.new), s.spectral_frame
1882
+ s.redshift_frame = RedshiftFrame.new(
1883
+ :name => 'DopplerVelocity2', :doppler_definition => DopplerDefinition.new('OPTICAL'),
1884
+ :reference_position => Barycenter.new
1885
+ )
1886
+ assert_equal(
1887
+ RedshiftFrame.new(
1888
+ :name => 'DopplerVelocity2', :doppler_definition => DopplerDefinition.new('OPTICAL'),
1889
+ :reference_position => Barycenter.new
1890
+ ),
1891
+ s.redshift_frame
1892
+ )
1893
+ s.generic_coord_frames = GenericCoordFrameList.new([GenericCoordFrame.new(:name => 'Generic2'), GenericCoordFrame.new(:name => 'Generic3')])
1894
+ assert_equal(
1895
+ GenericCoordFrameList.new([GenericCoordFrame.new(:name => 'Generic2'), GenericCoordFrame.new(:name => 'Generic3')]),
1896
+ s.generic_coord_frames
1897
+ )
1898
+ end
1899
+
1900
+ def test_relationships
1901
+ s = AstroCoordSystemType.new(
1902
+ :id => Id.new('ICRS-TT-CXO'),
1903
+ :time_frame => TimeFrame.new(:name => 'Time', :time_scale => TimeScale.new('TT'), :reference_position => Topocenter.new),
1904
+ :space_frame => SpaceFrame.new(
1905
+ :name => 'Space', :space_ref_frame => Icrs.new,
1906
+ :reference_position => Topocenter.new, :coord_flavor => Spherical.new
1907
+ ),
1908
+ :spectral_frame => SpectralFrame.new(:name => 'Energy', :reference_position => Topocenter.new),
1909
+ :redshift_frame => RedshiftFrame.new(
1910
+ :name => 'DopplerVelocity', :doppler_definition => DopplerDefinition.new('OPTICAL'),
1911
+ :reference_position => Barycenter.new
1912
+ ),
1913
+ :generic_coord_frames => [
1914
+ GenericCoordFrame.new(:name => 'Generic1'), GenericCoordFrame.new(:name => 'Generic2')
1915
+ ]
1916
+ )
1917
+
1918
+ assert_kind_of CoordSysType, s
1919
+ end
1920
+
1921
+ def test_xml
1922
+ s1 = AstroCoordSystemType.new(
1923
+ :id => Id.new('ICRS-TT-CXO'),
1924
+ :time_frame => TimeFrame.new(:name => 'Time', :time_scale => TimeScale.new('TT'), :reference_position => Topocenter.new),
1925
+ :space_frame => SpaceFrame.new(
1926
+ :name => 'Space', :space_ref_frame => Icrs.new,
1927
+ :reference_position => Topocenter.new, :coord_flavor => Spherical.new
1928
+ ),
1929
+ :spectral_frame => SpectralFrame.new(:name => 'Energy', :reference_position => Topocenter.new),
1930
+ :redshift_frame => RedshiftFrame.new(
1931
+ :name => 'DopplerVelocity', :doppler_definition => DopplerDefinition.new('OPTICAL'),
1932
+ :reference_position => Barycenter.new
1933
+ ),
1934
+ :generic_coord_frames => [
1935
+ GenericCoordFrame.new(:name => 'Generic1'), GenericCoordFrame.new(:name => 'Generic2')
1936
+ ]
1937
+ )
1938
+
1939
+ s2 = AstroCoordSystemType.from_xml(s1.to_xml)
1940
+ assert_equal s1, s2
1941
+ end
1942
+ end
1943
+
1944
+ class PixelCoordSystemTypeTest < ::Test::Unit::TestCase
1945
+ def test_construction
1946
+ assert_nothing_raised {
1947
+ PixelCoordSystemType.new(:id => 'System1', :pixel_coord_frames => [PixelCoordFrame.new(:name => 'CoordSystem1')])
1948
+ }
1949
+
1950
+ assert_raises ArgumentError do
1951
+ PixelCoordSystemType.new(:id => 'System1')
1952
+ end
1953
+ assert_raises ArgumentError do
1954
+ PixelCoordSystemType.new(:pixel_coord_frames => [PixelCoordFrame.new(:name => 'CoordSystem1')])
1955
+ end
1956
+ assert_raises ArgumentError do
1957
+ PixelCoordSystemType.new
1958
+ end
1959
+
1960
+ assert_raises TypeError do
1961
+ PixelCoordSystemType.new(:id => 'System1', :pixel_coord_frames => 'blah')
1962
+ end
1963
+ end
1964
+
1965
+ def test_accessors
1966
+ s = PixelCoordSystemType.new(:id => 'System1', :pixel_coord_frames => [PixelCoordFrame.new(:name => 'CoordSystem1')])
1967
+
1968
+ assert_equal Id.new('System1'), s.id
1969
+ assert_equal PixelCoordFrameList.new([PixelCoordFrame.new(:name => 'CoordSystem1')]), s.pixel_coord_frames
1970
+ s.id = Id.new('System2')
1971
+ assert_equal Id.new('System2'), s.id
1972
+ s.pixel_coord_frames = [PixelCoordFrame.new(:name => 'CoordSystem2'), PixelCoordFrame.new(:name => 'CoordSystem3')]
1973
+ assert_equal(
1974
+ PixelCoordFrameList.new([PixelCoordFrame.new(:name => 'CoordSystem2'), PixelCoordFrame.new(:name => 'CoordSystem3')]),
1975
+ s.pixel_coord_frames
1976
+ )
1977
+ end
1978
+
1979
+ def test_relationships
1980
+ s = PixelCoordSystemType.new(:id => 'System1', :pixel_coord_frames => [PixelCoordFrame.new(:name => 'CoordSystem1')])
1981
+ assert_kind_of CoordSysType, s
1982
+ end
1983
+
1984
+ def test_xml
1985
+ s1 = PixelCoordSystemType.new(:id => 'System1', :pixel_coord_frames => [PixelCoordFrame.new(:name => 'CoordSystem1')])
1986
+ s2 = PixelCoordSystemType.from_xml(s1.to_xml)
1987
+ assert_equal s1, s2
1988
+ end
1989
+ end
1990
+
1991
+ class TimeIntervalTypeTest < ::Test::Unit::TestCase
1992
+ def test_construction
1993
+ assert_nothing_raised {
1994
+ TimeIntervalType.new(
1995
+ :lo_include => true, :hi_include => false, :fill_factor => 0.5,
1996
+ :start_time => AstronTime.new('UTC', ISOTime.new(DateTime.now)),
1997
+ :stop_time => AstronTime.new('LOCAL', ISOTime.new(DateTime.now))
1998
+ )
1999
+ TimeIntervalType.new(
2000
+ :lo_include => true, :hi_include => false, :fill_factor => 0.5,
2001
+ :start_time => AstronTime.new('UTC', ISOTime.new(DateTime.now))
2002
+ )
2003
+ TimeIntervalType.new(
2004
+ :lo_include => true, :hi_include => false, :fill_factor => 0.5
2005
+ )
2006
+ TimeIntervalType.new
2007
+ }
2008
+
2009
+ assert_raises TypeError do
2010
+ TimeIntervalType.new(:start_time => 'blah')
2011
+ end
2012
+ assert_raises TypeError do
2013
+ TimeIntervalType.new(:stop_time => 'blah')
2014
+ end
2015
+ end
2016
+
2017
+ def test_accessors
2018
+ i = TimeIntervalType.new(
2019
+ :lo_include => true, :hi_include => false, :fill_factor => 0.5,
2020
+ :start_time => AstronTime.new('UTC', ISOTime.new(DateTime.parse('2008-01-01'))),
2021
+ :stop_time => AstronTime.new('LOCAL', ISOTime.new(DateTime.parse('2008-01-01')))
2022
+ )
2023
+
2024
+ assert_equal true, i.lo_include
2025
+ assert_equal false, i.hi_include
2026
+ assert_equal 0.5, i.fill_factor
2027
+ assert_equal AstronTime.new('UTC', ISOTime.new(DateTime.parse('2008-01-01'))), i.start_time
2028
+ assert_equal AstronTime.new('LOCAL', ISOTime.new(DateTime.parse('2008-01-01'))), i.stop_time
2029
+
2030
+ i.lo_include = false
2031
+ assert_equal false, i.lo_include
2032
+ i.hi_include = true
2033
+ assert_equal true, i.hi_include
2034
+ i.fill_factor = nil
2035
+ assert_equal 1.0, i.fill_factor
2036
+ i.start_time = AstronTime.new('LOCAL', ISOTime.new(DateTime.parse('2008-05-01')))
2037
+ assert_equal AstronTime.new('LOCAL', ISOTime.new(DateTime.parse('2008-05-01'))), i.start_time
2038
+ i.stop_time = AstronTime.new('UTC', ISOTime.new(DateTime.parse('2008-03-01')))
2039
+ assert_equal AstronTime.new('UTC', ISOTime.new(DateTime.parse('2008-03-01'))), i.stop_time
2040
+ end
2041
+
2042
+ def test_relationships
2043
+ assert_kind_of CoordIntervalType, TimeIntervalType.new
2044
+ end
2045
+
2046
+ def test_xml
2047
+ i1 = TimeIntervalType.new(
2048
+ :lo_include => true, :hi_include => false, :fill_factor => 0.5,
2049
+ :start_time => AstronTime.new('UTC', ISOTime.new(DateTime.parse('2008-01-01'))),
2050
+ :stop_time => AstronTime.new('LOCAL', ISOTime.new(DateTime.parse('2008-01-01')))
2051
+ )
2052
+
2053
+ i2 = TimeIntervalType.from_xml(i1.to_xml)
2054
+ assert_equal i1, i2
2055
+ end
2056
+ end
2057
+
2058
+ class CoordScalarIntervalTypeTest < ::Test::Unit::TestCase
2059
+ def test_construction
2060
+ assert_nothing_raised {
2061
+ CoordScalarIntervalType.new(
2062
+ :lo_include => true, :hi_include => false, :fill_factor => 0.5,
2063
+ :lo_limit => 10.1, :hi_limit => 21.2
2064
+ )
2065
+ CoordScalarIntervalType.new(
2066
+ :lo_include => true, :hi_include => false, :fill_factor => 0.5,
2067
+ :lo_limit => 10.1
2068
+ )
2069
+ CoordScalarIntervalType.new(
2070
+ :lo_include => true, :hi_include => false, :fill_factor => 0.5,
2071
+ :hi_limit => 21.2
2072
+ )
2073
+ CoordScalarIntervalType.new(
2074
+ :lo_include => true, :hi_include => false, :fill_factor => 0.5
2075
+ )
2076
+ CoordScalarIntervalType.new
2077
+ }
2078
+
2079
+ assert_raises ArgumentError do
2080
+ CoordScalarIntervalType.new(:lo_limit => 'blah')
2081
+ end
2082
+ assert_raises ArgumentError do
2083
+ CoordScalarIntervalType.new(:hi_limit => 'blah')
2084
+ end
2085
+ end
2086
+
2087
+ def test_accessors
2088
+ i = CoordScalarIntervalType.new(
2089
+ :lo_include => true, :hi_include => false, :fill_factor => 0.5,
2090
+ :lo_limit => 10.1, :hi_limit => 21.2
2091
+ )
2092
+
2093
+ assert_equal true, i.lo_include
2094
+ assert_equal false, i.hi_include
2095
+ assert_equal 0.5, i.fill_factor
2096
+ assert_equal 10.1, i.lo_limit
2097
+ assert_equal 21.2, i.hi_limit
2098
+
2099
+ i.lo_include = false
2100
+ assert_equal false, i.lo_include
2101
+ i.hi_include = true
2102
+ assert_equal true, i.hi_include
2103
+ i.fill_factor = 0.8
2104
+ assert_equal 0.8, i.fill_factor
2105
+ i.lo_limit = 0.1
2106
+ assert_equal 0.1, i.lo_limit
2107
+ i.hi_limit = nil
2108
+ assert_equal nil, i.hi_limit
2109
+ end
2110
+
2111
+ def test_relationships
2112
+ assert_kind_of CoordIntervalType, CoordScalarIntervalType.new
2113
+ end
2114
+
2115
+ def test_xml
2116
+ i1 = CoordScalarIntervalType.new(
2117
+ :lo_include => true, :hi_include => false, :fill_factor => 0.5,
2118
+ :lo_limit => 10.1, :hi_limit => 21.2
2119
+ )
2120
+
2121
+ i2 = CoordScalarIntervalType.from_xml(i1.to_xml)
2122
+ assert_equal i1, i2
2123
+ end
2124
+ end
2125
+
2126
+ class Coord2VecIntervalTypeTest < ::Test::Unit::TestCase
2127
+ def test_construction
2128
+ assert_nothing_raised {
2129
+ Coord2VecIntervalType.new(
2130
+ :lo_include => true, :hi_include => false, :fill_factor => 0.5,
2131
+ :lo_limit => [10.1, 2.4], :hi_limit => [21.2, 9.1]
2132
+ )
2133
+ Coord2VecIntervalType.new(
2134
+ :lo_include => true, :hi_include => false, :fill_factor => 0.5,
2135
+ :lo_limit => [10.1, 2.4]
2136
+ )
2137
+ Coord2VecIntervalType.new(
2138
+ :lo_include => true, :hi_include => false, :fill_factor => 0.5,
2139
+ :hi_limit => [21.2, 9.1]
2140
+ )
2141
+ Coord2VecIntervalType.new(
2142
+ :lo_include => true, :hi_include => false, :fill_factor => 0.5
2143
+ )
2144
+ Coord2VecIntervalType.new
2145
+ }
2146
+
2147
+ assert_raises TypeError do
2148
+ Coord2VecIntervalType.new(:lo_limit => 'blah')
2149
+ end
2150
+ assert_raises TypeError do
2151
+ Coord2VecIntervalType.new(:hi_limit => 'blah')
2152
+ end
2153
+ end
2154
+
2155
+ def test_accessors
2156
+ i = Coord2VecIntervalType.new(
2157
+ :lo_include => true, :hi_include => false, :fill_factor => 0.5,
2158
+ :lo_limit => [10.1, 2.4], :hi_limit => [21.2, 9.1]
2159
+ )
2160
+
2161
+ assert_equal true, i.lo_include
2162
+ assert_equal false, i.hi_include
2163
+ assert_equal 0.5, i.fill_factor
2164
+ assert_equal Double2.new([10.1, 2.4]), i.lo_limit
2165
+ assert_equal Double2.new([21.2, 9.1]), i.hi_limit
2166
+
2167
+ i.lo_include = false
2168
+ assert_equal false, i.lo_include
2169
+ i.hi_include = true
2170
+ assert_equal true, i.hi_include
2171
+ i.fill_factor = 0.8
2172
+ assert_equal 0.8, i.fill_factor
2173
+ i.lo_limit = [0.1, 0.5]
2174
+ assert_equal Double2.new([0.1, 0.5]), i.lo_limit
2175
+ i.hi_limit = nil
2176
+ assert_equal nil, i.hi_limit
2177
+ end
2178
+
2179
+ def test_relationships
2180
+ assert_kind_of CoordIntervalType, Coord2VecIntervalType.new
2181
+ end
2182
+
2183
+ def test_xml
2184
+ i1 = Coord2VecIntervalType.new(
2185
+ :lo_include => true, :hi_include => false, :fill_factor => 0.5,
2186
+ :lo_limit => [10.1, 2.4], :hi_limit => [21.2, 9.1]
2187
+ )
2188
+
2189
+ i2 = Coord2VecIntervalType.from_xml(i1.to_xml)
2190
+ assert_equal i1, i2
2191
+ end
2192
+ end
2193
+
2194
+ class Coord3VecIntervalTypeTest < ::Test::Unit::TestCase
2195
+ def test_construction
2196
+ assert_nothing_raised {
2197
+ Coord3VecIntervalType.new(
2198
+ :lo_include => true, :hi_include => false, :fill_factor => 0.5,
2199
+ :lo_limit => [10.1, 2.4, 5.1], :hi_limit => [21.2, 9.1, 8.2]
2200
+ )
2201
+ Coord3VecIntervalType.new(
2202
+ :lo_include => true, :hi_include => false, :fill_factor => 0.5,
2203
+ :lo_limit => [10.1, 2.4, 5.1]
2204
+ )
2205
+ Coord3VecIntervalType.new(
2206
+ :lo_include => true, :hi_include => false, :fill_factor => 0.5,
2207
+ :hi_limit => [21.2, 9.1, 8.2]
2208
+ )
2209
+ Coord3VecIntervalType.new(
2210
+ :lo_include => true, :hi_include => false, :fill_factor => 0.5
2211
+ )
2212
+ Coord3VecIntervalType.new
2213
+ }
2214
+
2215
+ assert_raises TypeError do
2216
+ Coord3VecIntervalType.new(:lo_limit => 'blah')
2217
+ end
2218
+ assert_raises TypeError do
2219
+ Coord3VecIntervalType.new(:hi_limit => 'blah')
2220
+ end
2221
+ end
2222
+
2223
+ def test_accessors
2224
+ i = Coord3VecIntervalType.new(
2225
+ :lo_include => true, :hi_include => false, :fill_factor => 0.5,
2226
+ :lo_limit => [10.1, 2.4, 5.1], :hi_limit => [21.2, 9.1, 8.2]
2227
+ )
2228
+
2229
+ assert_equal true, i.lo_include
2230
+ assert_equal false, i.hi_include
2231
+ assert_equal 0.5, i.fill_factor
2232
+ assert_equal Double3.new([10.1, 2.4, 5.1]), i.lo_limit
2233
+ assert_equal Double3.new([21.2, 9.1, 8.2]), i.hi_limit
2234
+
2235
+ i.lo_include = false
2236
+ assert_equal false, i.lo_include
2237
+ i.hi_include = true
2238
+ assert_equal true, i.hi_include
2239
+ i.fill_factor = 0.8
2240
+ assert_equal 0.8, i.fill_factor
2241
+ i.lo_limit = [0.1, 0.5, 0.8]
2242
+ assert_equal Double3.new([0.1, 0.5, 0.8]), i.lo_limit
2243
+ i.hi_limit = nil
2244
+ assert_equal nil, i.hi_limit
2245
+ end
2246
+
2247
+ def test_relationships
2248
+ assert_kind_of CoordIntervalType, Coord3VecIntervalType.new
2249
+ end
2250
+
2251
+ def test_xml
2252
+ i1 = Coord3VecIntervalType.new(
2253
+ :lo_include => true, :hi_include => false, :fill_factor => 0.5,
2254
+ :lo_limit => [10.1, 2.4, 1.1], :hi_limit => [21.2, 9.1, 8.7]
2255
+ )
2256
+
2257
+ i2 = Coord3VecIntervalType.from_xml(i1.to_xml)
2258
+ assert_equal i1, i2
2259
+ end
2260
+ end
2261
+
2262
+ class SphereTypeTest < ::Test::Unit::TestCase
2263
+ def test_construction
2264
+ assert_nothing_raised {
2265
+ SphereType.new(
2266
+ :radius => 10.2,
2267
+ :center => [1.1, 2.3, 3.3],
2268
+ :unit => PosUnit.new('m'),
2269
+ :radius_unit => PosUnit.new('deg'),
2270
+ :fill_factor => 0.4
2271
+ )
2272
+ SphereType.new(
2273
+ :radius => 10.2,
2274
+ :center => [1.1, 2.3, 3.3],
2275
+ :unit => PosUnit.new('m'),
2276
+ :radius_unit => PosUnit.new('deg')
2277
+ )
2278
+ SphereType.new(
2279
+ :radius => 10.2,
2280
+ :center => [1.1, 2.3, 3.3],
2281
+ :unit => PosUnit.new('m')
2282
+ )
2283
+ }
2284
+
2285
+ assert_raises ArgumentError do
2286
+ SphereType.new(
2287
+ :radius => 10.2,
2288
+ :center => [1.1, 2.3, 3.3]
2289
+ )
2290
+ end
2291
+ assert_raises ArgumentError do
2292
+ SphereType.new(
2293
+ :radius => 10.2,
2294
+ :unit => PosUnit.new('m')
2295
+ )
2296
+ end
2297
+ assert_raises ArgumentError do
2298
+ SphereType.new(
2299
+ :center => [1.1, 2.3, 3.3],
2300
+ :unit => PosUnit.new('m')
2301
+ )
2302
+ end
2303
+
2304
+ assert_raises TypeError do
2305
+ SphereType.new(
2306
+ :radius => 10.2,
2307
+ :center => 'blah',
2308
+ :unit => PosUnit.new('m')
2309
+ )
2310
+ end
2311
+ end
2312
+
2313
+ def test_accessors
2314
+ s = SphereType.new(
2315
+ :radius => 10.2,
2316
+ :center => [1.1, 2.3, 3.3],
2317
+ :unit => PosUnit.new('m'),
2318
+ :radius_unit => PosUnit.new('deg'),
2319
+ :fill_factor => 0.4
2320
+ )
2321
+
2322
+ assert_equal 10.2, s.radius
2323
+ assert_equal Double3.new([1.1, 2.3, 3.3]), s.center
2324
+ assert_equal PosUnit.new('m'), s.unit
2325
+ assert_equal PosUnit.new('deg'), s.radius_unit
2326
+ assert_equal 0.4, s.fill_factor
2327
+
2328
+ s.radius = 5.2
2329
+ assert_equal 5.2, s.radius
2330
+ s.center = [2.2, 3.3, 4.4]
2331
+ assert_equal Double3.new([2.2, 3.3, 4.4]), s.center
2332
+ s.unit = 'kpc'
2333
+ assert_equal PosUnit.new('kpc'), s.unit
2334
+ s.radius_unit = 'arcmin'
2335
+ assert_equal PosUnit.new('arcmin'), s.radius_unit
2336
+ s.fill_factor = 0.2
2337
+ assert_equal 0.2, s.fill_factor
2338
+ end
2339
+
2340
+ def test_relationships
2341
+ assert_kind_of SpatialIntervalType, SphereType.new(:radius => 10.2, :center => [1.1, 2.3, 3.3], :unit => PosUnit.new('m'))
2342
+ end
2343
+
2344
+ def test_xml
2345
+ s1 = SphereType.new(
2346
+ :radius => 10.2,
2347
+ :center => [1.1, 2.3, 3.3],
2348
+ :unit => PosUnit.new('m'),
2349
+ :radius_unit => PosUnit.new('deg'),
2350
+ :fill_factor => 0.4
2351
+ )
2352
+
2353
+ s2 = SphereType.from_xml(s1.to_xml)
2354
+ assert_equal s1, s2
2355
+ end
2356
+ end
2357
+
2358
+ class VelocitySphereTypeTest < ::Test::Unit::TestCase
2359
+ def test_construction
2360
+ assert_nothing_raised {
2361
+ VelocitySphereType.new(
2362
+ :radius => 10.2,
2363
+ :center => [1.1, 2.3, 3.3],
2364
+ :unit => PosUnit.new('m'),
2365
+ :radius_unit => PosUnit.new('deg'),
2366
+ :fill_factor => 0.4,
2367
+ :vel_time_unit => VelTimeUnit.new('s')
2368
+ )
2369
+ VelocitySphereType.new(
2370
+ :radius => 10.2,
2371
+ :center => [1.1, 2.3, 3.3],
2372
+ :unit => PosUnit.new('m'),
2373
+ :radius_unit => PosUnit.new('deg'),
2374
+ :vel_time_unit => VelTimeUnit.new('s')
2375
+ )
2376
+ VelocitySphereType.new(
2377
+ :radius => 10.2,
2378
+ :center => [1.1, 2.3, 3.3],
2379
+ :unit => PosUnit.new('m'),
2380
+ :vel_time_unit => VelTimeUnit.new('s')
2381
+ )
2382
+ }
2383
+
2384
+ assert_raises ArgumentError do
2385
+ VelocitySphereType.new(
2386
+ :radius => 10.2,
2387
+ :center => [1.1, 2.3, 3.3]
2388
+ )
2389
+ end
2390
+ assert_raises ArgumentError do
2391
+ VelocitySphereType.new(
2392
+ :radius => 10.2,
2393
+ :unit => PosUnit.new('m')
2394
+ )
2395
+ end
2396
+ assert_raises ArgumentError do
2397
+ VelocitySphereType.new(
2398
+ :center => [1.1, 2.3, 3.3],
2399
+ :unit => PosUnit.new('m')
2400
+ )
2401
+ end
2402
+
2403
+ assert_raises TypeError do
2404
+ VelocitySphereType.new(
2405
+ :radius => 10.2,
2406
+ :center => 'blah',
2407
+ :unit => PosUnit.new('m'),
2408
+ :vel_time_unit => VelTimeUnit.new('s')
2409
+ )
2410
+ end
2411
+ end
2412
+
2413
+ def test_accessors
2414
+ s = VelocitySphereType.new(
2415
+ :radius => 10.2,
2416
+ :center => [1.1, 2.3, 3.3],
2417
+ :unit => PosUnit.new('m'),
2418
+ :radius_unit => PosUnit.new('deg'),
2419
+ :fill_factor => 0.4,
2420
+ :vel_time_unit => VelTimeUnit.new('s')
2421
+ )
2422
+
2423
+ assert_equal 10.2, s.radius
2424
+ assert_equal Double3.new([1.1, 2.3, 3.3]), s.center
2425
+ assert_equal PosUnit.new('m'), s.unit
2426
+ assert_equal PosUnit.new('deg'), s.radius_unit
2427
+ assert_equal 0.4, s.fill_factor
2428
+ assert_equal VelTimeUnit.new('s'), s.vel_time_unit
2429
+
2430
+ s.radius = 5.2
2431
+ assert_equal 5.2, s.radius
2432
+ s.center = [2.2, 3.3, 4.4]
2433
+ assert_equal Double3.new([2.2, 3.3, 4.4]), s.center
2434
+ s.unit = 'kpc'
2435
+ assert_equal PosUnit.new('kpc'), s.unit
2436
+ s.radius_unit = 'arcmin'
2437
+ assert_equal PosUnit.new('arcmin'), s.radius_unit
2438
+ s.fill_factor = 0.2
2439
+ assert_equal 0.2, s.fill_factor
2440
+ s.vel_time_unit = VelTimeUnit.new('h')
2441
+ assert_equal VelTimeUnit.new('h'), s.vel_time_unit
2442
+ end
2443
+
2444
+ def test_relationships
2445
+ assert_kind_of(
2446
+ SphereType,
2447
+ VelocitySphereType.new(
2448
+ :radius => 10.2,
2449
+ :center => [1.1, 2.3, 3.3],
2450
+ :unit => PosUnit.new('m'),
2451
+ :radius_unit => PosUnit.new('deg'),
2452
+ :fill_factor => 0.4,
2453
+ :vel_time_unit => VelTimeUnit.new('s')
2454
+ )
2455
+ )
2456
+ end
2457
+
2458
+ def test_xml
2459
+ s1 = VelocitySphereType.new(
2460
+ :radius => 10.2,
2461
+ :center => [1.1, 2.3, 3.3],
2462
+ :unit => PosUnit.new('m'),
2463
+ :radius_unit => PosUnit.new('deg'),
2464
+ :fill_factor => 0.4,
2465
+ :vel_time_unit => VelTimeUnit.new('s')
2466
+ )
2467
+
2468
+ s2 = VelocitySphereType.from_xml(s1.to_xml)
2469
+ assert_equal s1, s2
2470
+ end
2471
+ end
2472
+
2473
+ class PositionIntervalTypeTest < ::Test::Unit::TestCase
2474
+ def test_construction
2475
+ assert_nothing_raised {
2476
+ PositionIntervalType.new(:unit => PosUnit.new('m'), :coord_interval => CoordScalarInterval.new(:lo_include => true, :hi_include => true))
2477
+ }
2478
+
2479
+ assert_raises ArgumentError do
2480
+ PositionIntervalType.new(:unit => PosUnit.new('m'))
2481
+ end
2482
+ assert_raises ArgumentError do
2483
+ PositionIntervalType.new(:coord_interval => CoordScalarInterval.new(:lo_include => true, :hi_include => true))
2484
+ end
2485
+
2486
+ assert_raises TypeError do
2487
+ PositionIntervalType.new(:unit => PosUnit.new('m'), :coord_interval => 'blah')
2488
+ end
2489
+ end
2490
+
2491
+ def test_accessors
2492
+ i = PositionIntervalType.new(:unit => PosUnit.new('m'), :coord_interval => CoordScalarInterval.new(:lo_include => true, :hi_include => true))
2493
+
2494
+ assert_equal PosUnit.new('m'), i.unit
2495
+ assert_equal CoordScalarInterval.new(:lo_include => true, :hi_include => true), i.coord_interval
2496
+
2497
+ i.unit = PosUnit.new('arcmin')
2498
+ assert_equal PosUnit.new('arcmin'), i.unit
2499
+ i.coord_interval = CoordScalarInterval.new(:lo_include => false, :hi_include => false)
2500
+ assert_equal CoordScalarInterval.new(:lo_include => false, :hi_include => false), i.coord_interval
2501
+ end
2502
+
2503
+ def test_relationships
2504
+ assert_kind_of(
2505
+ SpatialIntervalType,
2506
+ PositionIntervalType.new(:unit => PosUnit.new('m'), :coord_interval => CoordScalarInterval.new(:lo_include => true, :hi_include => true))
2507
+ )
2508
+ end
2509
+
2510
+ def test_xml
2511
+ i1 = PositionIntervalType.new(
2512
+ :unit => PosUnit.new('m'),
2513
+ :coord_interval => CoordScalarInterval.new(:lo_include => true, :hi_include => true)
2514
+ )
2515
+
2516
+ i2 = PositionIntervalType.from_xml(i1.to_xml)
2517
+ assert_equal i1, i2
2518
+ end
2519
+ end
2520
+
2521
+ class VelocityIntervalTypeTest < ::Test::Unit::TestCase
2522
+ def test_construction
2523
+ assert_nothing_raised {
2524
+ VelocityIntervalType.new(
2525
+ :unit => PosUnit.new('m'),
2526
+ :vel_time_unit => VelTimeUnit.new('s'),
2527
+ :coord_interval => CoordScalarInterval.new(:lo_include => true, :hi_include => true)
2528
+ )
2529
+ }
2530
+
2531
+ assert_raises ArgumentError do
2532
+ VelocityIntervalType.new(:unit => PosUnit.new('m'))
2533
+ end
2534
+ assert_raises ArgumentError do
2535
+ VelocityIntervalType.new(:vel_time_unit => VelTimeUnit.new('s'))
2536
+ end
2537
+ assert_raises ArgumentError do
2538
+ VelocityIntervalType.new(:coord_interval => CoordScalarInterval.new(:lo_include => true, :hi_include => true))
2539
+ end
2540
+
2541
+ assert_raises TypeError do
2542
+ VelocityIntervalType.new(:unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('s'), :coord_interval => 'blah')
2543
+ end
2544
+ end
2545
+
2546
+ def test_accessors
2547
+ i = VelocityIntervalType.new(
2548
+ :unit => PosUnit.new('m'),
2549
+ :vel_time_unit => VelTimeUnit.new('s'),
2550
+ :coord_interval => CoordScalarInterval.new(:lo_include => true, :hi_include => true)
2551
+ )
2552
+
2553
+ assert_equal PosUnit.new('m'), i.unit
2554
+ assert_equal VelTimeUnit.new('s'), i.vel_time_unit
2555
+ assert_equal CoordScalarInterval.new(:lo_include => true, :hi_include => true), i.coord_interval
2556
+
2557
+ i.unit = PosUnit.new('arcmin')
2558
+ assert_equal PosUnit.new('arcmin'), i.unit
2559
+ i.vel_time_unit = VelTimeUnit.new('h')
2560
+ assert_equal VelTimeUnit.new('h'), i.vel_time_unit
2561
+ i.coord_interval = CoordScalarInterval.new(:lo_include => false, :hi_include => false)
2562
+ assert_equal CoordScalarInterval.new(:lo_include => false, :hi_include => false), i.coord_interval
2563
+ end
2564
+
2565
+ def test_relationships
2566
+ assert_kind_of(
2567
+ PositionIntervalType,
2568
+ VelocityIntervalType.new(
2569
+ :unit => PosUnit.new('m'),
2570
+ :vel_time_unit => VelTimeUnit.new('s'),
2571
+ :coord_interval => CoordScalarInterval.new(:lo_include => true, :hi_include => true)
2572
+ )
2573
+ )
2574
+ end
2575
+
2576
+ def test_xml
2577
+ i1 = VelocityIntervalType.new(
2578
+ :unit => PosUnit.new('m'),
2579
+ :vel_time_unit => VelTimeUnit.new('s'),
2580
+ :coord_interval => CoordScalarInterval.new(:lo_include => true, :hi_include => true)
2581
+ )
2582
+
2583
+ i2 = VelocityIntervalType.from_xml(i1.to_xml)
2584
+ assert_equal i1, i2
2585
+ end
2586
+ end
2587
+
2588
+ class RegionFileTypeTest < ::Test::Unit::TestCase
2589
+ def test_construction
2590
+ assert_nothing_raised { RegionFileType.new(:file => 'http://www.noao.edu/region.xml') }
2591
+ assert_raises ArgumentError do
2592
+ RegionFileType.new
2593
+ end
2594
+ end
2595
+
2596
+ def test_accessors
2597
+ f = RegionFileType.new(:file => 'http://www.noao.edu/region.xml')
2598
+ assert_equal URI.parse('http://www.noao.edu/region.xml'), f.file
2599
+
2600
+ f.file = 'http://www.stsci.edu/region.xml'
2601
+ assert_equal URI.parse('http://www.stsci.edu/region.xml'), f.file
2602
+ end
2603
+
2604
+ def test_relationships
2605
+ assert_kind_of SpatialIntervalType, RegionFileType.new(:file => 'http://www.noao.edu/region.xml')
2606
+ end
2607
+
2608
+ def test_xml
2609
+ f1 = RegionFileType.new(:file => 'http://www.noao.edu/region.xml')
2610
+ f2 = RegionFileType.from_xml(f1.to_xml)
2611
+ assert_equal f1, f2
2612
+ end
2613
+ end
2614
+
2615
+ class RegionTypeTest < ::Test::Unit::TestCase
2616
+ def test_construction
2617
+ assert_nothing_raised {
2618
+ RegionType.new(
2619
+ :region => Circle.new(
2620
+ :center => Double2.new([112.2, 223.3]),
2621
+ :radius => 100.0,
2622
+ :coord_system_id => Id.new('MyCircle')
2623
+ )
2624
+ )
2625
+ }
2626
+
2627
+ assert_raises ArgumentError do
2628
+ RegionType.new
2629
+ end
2630
+ assert_raises TypeError do
2631
+ RegionType.new(:region => 'blah')
2632
+ end
2633
+ end
2634
+
2635
+ def test_accessors
2636
+ r = RegionType.new(
2637
+ :region => Circle.new(
2638
+ :center => Double2.new([112.2, 223.3]),
2639
+ :radius => 100.0,
2640
+ :coord_system_id => Id.new('MyCircle')
2641
+ )
2642
+ )
2643
+
2644
+ assert_equal(
2645
+ Circle.new(
2646
+ :center => Double2.new([112.2, 223.3]),
2647
+ :radius => 100.0,
2648
+ :coord_system_id => Id.new('MyCircle')
2649
+ ),
2650
+ r.region
2651
+ )
2652
+
2653
+ r.region = Circle.new(
2654
+ :center => Double2.new([222.2, 333.3]),
2655
+ :radius => 50.0,
2656
+ :coord_system_id => Id.new('MyCircle')
2657
+ )
2658
+ assert_equal(
2659
+ Circle.new(
2660
+ :center => Double2.new([222.2, 333.3]),
2661
+ :radius => 50.0,
2662
+ :coord_system_id => Id.new('MyCircle')
2663
+ ),
2664
+ r.region
2665
+ )
2666
+ end
2667
+
2668
+ def test_relationships
2669
+ assert_kind_of(
2670
+ SpatialIntervalType,
2671
+ RegionType.new(
2672
+ :region => Circle.new(
2673
+ :center => Double2.new([112.2, 223.3]),
2674
+ :radius => 100.0,
2675
+ :coord_system_id => Id.new('MyCircle')
2676
+ )
2677
+ )
2678
+ )
2679
+ end
2680
+
2681
+ def test_xml
2682
+ r1 = RegionType.new(
2683
+ :region => Circle.new(
2684
+ :center => Double2.new([112.2, 223.3]),
2685
+ :radius => 100.0,
2686
+ :coord_system_id => Id.new('MyCircle')
2687
+ )
2688
+ )
2689
+
2690
+ r2 = RegionType.from_xml(r1.to_xml)
2691
+ assert_equal r1, r2
2692
+ end
2693
+ end
2694
+
2695
+ class SpectralIntervalTest < ::Test::Unit::TestCase
2696
+ def test_construction
2697
+ assert_nothing_raised {
2698
+ SpectralInterval.new(
2699
+ :lo_include => true, :hi_include => false, :fill_factor => 0.5,
2700
+ :lo_limit => 10.1, :hi_limit => 21.2, :unit => SpectralUnit.new('GHz')
2701
+ )
2702
+ SpectralInterval.new(
2703
+ :lo_include => true, :hi_include => false, :fill_factor => 0.5,
2704
+ :lo_limit => 10.1, :unit => SpectralUnit.new('GHz')
2705
+ )
2706
+ SpectralInterval.new(
2707
+ :lo_include => true, :hi_include => false, :fill_factor => 0.5,
2708
+ :hi_limit => 21.2, :unit => SpectralUnit.new('GHz')
2709
+ )
2710
+ SpectralInterval.new(
2711
+ :lo_include => true, :hi_include => false, :fill_factor => 0.5,
2712
+ :unit => SpectralUnit.new('GHz')
2713
+ )
2714
+ SpectralInterval.new(:unit => SpectralUnit.new('GHz'))
2715
+ }
2716
+
2717
+ assert_raises ArgumentError do
2718
+ SpectralInterval.new(:lo_limit => 'blah', :unit => SpectralUnit.new('GHz'))
2719
+ end
2720
+ assert_raises ArgumentError do
2721
+ SpectralInterval.new(:hi_limit => 'blah', :unit => SpectralUnit.new('GHz'))
2722
+ end
2723
+ end
2724
+
2725
+ def test_accessors
2726
+ i = SpectralInterval.new(
2727
+ :lo_include => true, :hi_include => false, :fill_factor => 0.5,
2728
+ :lo_limit => 10.1, :hi_limit => 21.2, :unit => SpectralUnit.new('GHz')
2729
+ )
2730
+
2731
+ assert_equal true, i.lo_include
2732
+ assert_equal false, i.hi_include
2733
+ assert_equal 0.5, i.fill_factor
2734
+ assert_equal 10.1, i.lo_limit
2735
+ assert_equal 21.2, i.hi_limit
2736
+ assert_equal SpectralUnit.new('GHz'), i.unit
2737
+
2738
+ i.lo_include = false
2739
+ assert_equal false, i.lo_include
2740
+ i.hi_include = true
2741
+ assert_equal true, i.hi_include
2742
+ i.fill_factor = 0.8
2743
+ assert_equal 0.8, i.fill_factor
2744
+ i.lo_limit = 0.1
2745
+ assert_equal 0.1, i.lo_limit
2746
+ i.hi_limit = nil
2747
+ assert_equal nil, i.hi_limit
2748
+ i.unit = SpectralUnit.new('A')
2749
+ assert_equal SpectralUnit.new('A'), i.unit
2750
+ end
2751
+
2752
+ def test_relationships
2753
+ assert_kind_of CoordScalarIntervalType, SpectralInterval.new(:unit => SpectralUnit.new('GHz'))
2754
+ end
2755
+
2756
+ def test_xml
2757
+ i1 = SpectralInterval.new(
2758
+ :lo_include => true, :hi_include => false, :fill_factor => 0.5,
2759
+ :lo_limit => 10.1, :hi_limit => 21.2, :unit => SpectralUnit.new('GHz')
2760
+ )
2761
+
2762
+ i2 = SpectralInterval.from_xml(i1.to_xml)
2763
+ assert_equal i1, i2
2764
+ end
2765
+ end
2766
+
2767
+ class RedshiftIntervalTest < ::Test::Unit::TestCase
2768
+ def test_construction
2769
+ assert_nothing_raised {
2770
+ RedshiftInterval.new(
2771
+ :lo_include => true, :hi_include => false, :fill_factor => 0.5,
2772
+ :lo_limit => 10.1, :hi_limit => 21.2, :unit => PosUnit.new('m'),
2773
+ :vel_time_unit => VelTimeUnit.new('yr')
2774
+ )
2775
+ RedshiftInterval.new(
2776
+ :lo_include => true, :hi_include => false, :fill_factor => 0.5,
2777
+ :lo_limit => 10.1, :unit => PosUnit.new('m'),
2778
+ :vel_time_unit => VelTimeUnit.new('yr')
2779
+ )
2780
+ RedshiftInterval.new(
2781
+ :lo_include => true, :hi_include => false, :fill_factor => 0.5,
2782
+ :hi_limit => 21.2, :unit => PosUnit.new('m'),
2783
+ :vel_time_unit => VelTimeUnit.new('yr')
2784
+ )
2785
+ RedshiftInterval.new(
2786
+ :lo_include => true, :hi_include => false, :fill_factor => 0.5,
2787
+ :unit => PosUnit.new('m')
2788
+ )
2789
+ RedshiftInterval.new
2790
+ }
2791
+
2792
+ assert_raises ArgumentError do
2793
+ RedshiftInterval.new(:lo_limit => 'blah')
2794
+ end
2795
+ assert_raises ArgumentError do
2796
+ RedshiftInterval.new(:hi_limit => 'blah')
2797
+ end
2798
+ end
2799
+
2800
+ def test_accessors
2801
+ i = RedshiftInterval.new(
2802
+ :lo_include => true, :hi_include => false, :fill_factor => 0.5,
2803
+ :lo_limit => 10.1, :hi_limit => 21.2, :unit => PosUnit.new('m'),
2804
+ :vel_time_unit => VelTimeUnit.new('yr')
2805
+ )
2806
+
2807
+ assert_equal true, i.lo_include
2808
+ assert_equal false, i.hi_include
2809
+ assert_equal 0.5, i.fill_factor
2810
+ assert_equal 10.1, i.lo_limit
2811
+ assert_equal 21.2, i.hi_limit
2812
+ assert_equal PosUnit.new('m'), i.unit
2813
+ assert_equal VelTimeUnit.new('yr'), i.vel_time_unit
2814
+
2815
+ i.lo_include = false
2816
+ assert_equal false, i.lo_include
2817
+ i.hi_include = true
2818
+ assert_equal true, i.hi_include
2819
+ i.fill_factor = 0.8
2820
+ assert_equal 0.8, i.fill_factor
2821
+ i.lo_limit = 0.1
2822
+ assert_equal 0.1, i.lo_limit
2823
+ i.hi_limit = nil
2824
+ assert_equal nil, i.hi_limit
2825
+ i.unit = PosUnit.new('m')
2826
+ assert_equal PosUnit.new('m'), i.unit
2827
+ i.vel_time_unit = VelTimeUnit.new('s')
2828
+ assert_equal VelTimeUnit.new('s'), i.vel_time_unit
2829
+ end
2830
+
2831
+ def test_relationships
2832
+ assert_kind_of CoordScalarIntervalType, RedshiftInterval.new
2833
+ end
2834
+
2835
+ def test_xml
2836
+ i1 = RedshiftInterval.new(
2837
+ :lo_include => true, :hi_include => false, :fill_factor => 0.5,
2838
+ :lo_limit => 10.1, :hi_limit => 21.2, :unit => PosUnit.new('m'),
2839
+ :vel_time_unit => VelTimeUnit.new('yr')
2840
+ )
2841
+
2842
+ i2 = RedshiftInterval.from_xml(i1.to_xml)
2843
+ assert_equal i1, i2
2844
+ end
2845
+ end
2846
+
2847
+ class CoordAreaTypeTest < ::Test::Unit::TestCase
2848
+ def test_construction
2849
+ assert_nothing_raised {
2850
+ CoordAreaType.new(
2851
+ :id => Id.new('MyArea'),
2852
+ :coord_system_id => 'MyCoordSystemId',
2853
+ :time_intervals => [TimeIntervalType.new],
2854
+ :spatial_interval => Sphere.new(:radius => 10.1, :center => Double3.new([1.1, 2.2, 3.3]), :unit => PosUnit.new('m')),
2855
+ :vel_intervals => [
2856
+ VelocitySphere.new(
2857
+ :radius => 10.1, :center => Double3.new([1.1, 2.2, 3.3]),
2858
+ :unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('s')
2859
+ )
2860
+ ],
2861
+ :spectral_intervals => [SpectralInterval.new(:unit => SpectralUnit.new('GHz'))],
2862
+ :redshift_intervals => [RedshiftInterval.new],
2863
+ :coord_intervals => [CoordScalarInterval.new]
2864
+ )
2865
+
2866
+ CoordAreaType.new(
2867
+ :id => Id.new('MyArea'),
2868
+ :coord_system_id => 'MyCoordSystemId',
2869
+ :time_intervals => [TimeIntervalType.new],
2870
+ :spatial_interval => Sphere.new(:radius => 10.1, :center => Double3.new([1.1, 2.2, 3.3]), :unit => PosUnit.new('m')),
2871
+ :vel_intervals => [
2872
+ VelocitySphere.new(
2873
+ :radius => 10.1, :center => Double3.new([1.1, 2.2, 3.3]),
2874
+ :unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('s')
2875
+ )
2876
+ ],
2877
+ :spectral_intervals => [SpectralInterval.new(:unit => SpectralUnit.new('GHz'))],
2878
+ :redshift_intervals => [RedshiftInterval.new]
2879
+ )
2880
+
2881
+ CoordAreaType.new(
2882
+ :id => Id.new('MyArea'),
2883
+ :coord_system_id => 'MyCoordSystemId',
2884
+ :time_intervals => [TimeIntervalType.new],
2885
+ :spatial_interval => Sphere.new(:radius => 10.1, :center => Double3.new([1.1, 2.2, 3.3]), :unit => PosUnit.new('m')),
2886
+ :vel_intervals => [
2887
+ VelocitySphere.new(
2888
+ :radius => 10.1, :center => Double3.new([1.1, 2.2, 3.3]),
2889
+ :unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('s')
2890
+ )
2891
+ ],
2892
+ :spectral_intervals => [SpectralInterval.new(:unit => SpectralUnit.new('GHz'))]
2893
+ )
2894
+
2895
+ CoordAreaType.new(
2896
+ :id => Id.new('MyArea'),
2897
+ :coord_system_id => 'MyCoordSystemId',
2898
+ :time_intervals => [TimeIntervalType.new],
2899
+ :spatial_interval => Sphere.new(:radius => 10.1, :center => Double3.new([1.1, 2.2, 3.3]), :unit => PosUnit.new('m')),
2900
+ :vel_intervals => [
2901
+ VelocitySphere.new(
2902
+ :radius => 10.1, :center => Double3.new([1.1, 2.2, 3.3]),
2903
+ :unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('s')
2904
+ )
2905
+ ]
2906
+ )
2907
+
2908
+ CoordAreaType.new(
2909
+ :id => Id.new('MyArea'),
2910
+ :coord_system_id => 'MyCoordSystemId',
2911
+ :time_intervals => [TimeIntervalType.new],
2912
+ :spatial_interval => Sphere.new(:radius => 10.1, :center => Double3.new([1.1, 2.2, 3.3]), :unit => PosUnit.new('m'))
2913
+ )
2914
+
2915
+ CoordAreaType.new(
2916
+ :id => Id.new('MyArea'),
2917
+ :coord_system_id => 'MyCoordSystemId',
2918
+ :time_intervals => [TimeIntervalType.new]
2919
+ )
2920
+
2921
+ CoordAreaType.new(
2922
+ :id => Id.new('MyArea'),
2923
+ :coord_system_id => 'MyCoordSystemId'
2924
+ )
2925
+ }
2926
+
2927
+ assert_raises ArgumentError do
2928
+ CoordAreaType.new(:id => Id.new('MyArea'))
2929
+ end
2930
+ assert_raises ArgumentError do
2931
+ CoordAreaType.new(:coord_system_id => 'MyCoordSystemId')
2932
+ end
2933
+
2934
+ assert_raises TypeError do
2935
+ CoordAreaType.new(:id => Id.new('MyArea'), :coord_system_id => 'MyCoordSystemId', :time_intervals => 'blah')
2936
+ end
2937
+ assert_raises TypeError do
2938
+ CoordAreaType.new(:id => Id.new('MyArea'), :coord_system_id => 'MyCoordSystemId', :spatial_interval => 'blah')
2939
+ end
2940
+ assert_raises TypeError do
2941
+ CoordAreaType.new(:id => Id.new('MyArea'), :coord_system_id => 'MyCoordSystemId', :vel_intervals => 'blah')
2942
+ end
2943
+ assert_raises TypeError do
2944
+ CoordAreaType.new(:id => Id.new('MyArea'), :coord_system_id => 'MyCoordSystemId', :spectral_intervals => 'blah')
2945
+ end
2946
+ assert_raises TypeError do
2947
+ CoordAreaType.new(:id => Id.new('MyArea'), :coord_system_id => 'MyCoordSystemId', :redshift_intervals => 'blah')
2948
+ end
2949
+ assert_raises TypeError do
2950
+ CoordAreaType.new(:id => Id.new('MyArea'), :coord_system_id => 'MyCoordSystemId', :coord_intervals => 'blah')
2951
+ end
2952
+ end
2953
+
2954
+ def test_accessors
2955
+ a = CoordAreaType.new(
2956
+ :id => Id.new('MyArea'),
2957
+ :coord_system_id => 'MyCoordSystemId',
2958
+ :time_intervals => [TimeIntervalType.new],
2959
+ :spatial_interval => Sphere.new(:radius => 10.1, :center => Double3.new([1.1, 2.2, 3.3]), :unit => PosUnit.new('m')),
2960
+ :vel_intervals => [
2961
+ VelocitySphere.new(
2962
+ :radius => 10.1, :center => Double3.new([1.1, 2.2, 3.3]),
2963
+ :unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('s')
2964
+ )
2965
+ ],
2966
+ :spectral_intervals => [SpectralInterval.new(:unit => SpectralUnit.new('GHz'))],
2967
+ :redshift_intervals => [RedshiftInterval.new],
2968
+ :coord_intervals => [CoordScalarInterval.new]
2969
+ )
2970
+
2971
+ assert_equal Id.new('MyArea'), a.id
2972
+ assert_equal IdRef.new('MyCoordSystemId'), a.coord_system_id
2973
+ assert_equal TimeIntervalList.new([TimeIntervalType.new]), a.time_intervals
2974
+ assert_equal Sphere.new(:radius => 10.1, :center => Double3.new([1.1, 2.2, 3.3]), :unit => PosUnit.new('m')), a.spatial_interval
2975
+ assert_equal(
2976
+ VelIntervalList.new([
2977
+ VelocitySphere.new(
2978
+ :radius => 10.1, :center => Double3.new([1.1, 2.2, 3.3]),
2979
+ :unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('s')
2980
+ )
2981
+ ]),
2982
+ a.vel_intervals
2983
+ )
2984
+ assert_equal SpectralIntervalList.new([SpectralInterval.new(:unit => SpectralUnit.new('GHz'))]), a.spectral_intervals
2985
+ assert_equal RedshiftIntervalList.new([RedshiftInterval.new]), a.redshift_intervals
2986
+ assert_equal CoordIntervalList.new([CoordScalarInterval.new]), a.coord_intervals
2987
+
2988
+ a.id = Id.new('MyArea2')
2989
+ assert_equal Id.new('MyArea2'), a.id
2990
+ a.coord_system_id = IdRef.new('MyCoordSystemId2')
2991
+ assert_equal IdRef.new('MyCoordSystemId2'), a.coord_system_id
2992
+ a.time_intervals = [TimeIntervalType.new, TimeIntervalType.new]
2993
+ assert_equal TimeIntervalList.new([TimeIntervalType.new, TimeIntervalType.new]), a.time_intervals
2994
+ a.spatial_interval = Sphere.new(:radius => 0.4, :center => Double3.new([0.1, 0.1, 0.1]), :unit => PosUnit.new('mm'))
2995
+ assert_equal Sphere.new(:radius => 0.4, :center => Double3.new([0.1, 0.1, 0.1]), :unit => PosUnit.new('mm')), a.spatial_interval
2996
+ a.vel_intervals = [
2997
+ VelocitySphere.new(
2998
+ :radius => 12.1, :center => Double3.new([9.0, 8.0, 7.0]),
2999
+ :unit => PosUnit.new('mm'), :vel_time_unit => VelTimeUnit.new('h')
3000
+ )
3001
+ ]
3002
+ assert_equal(
3003
+ VelIntervalList.new([
3004
+ VelocitySphere.new(
3005
+ :radius => 12.1, :center => Double3.new([9.0, 8.0, 7.0]),
3006
+ :unit => PosUnit.new('mm'), :vel_time_unit => VelTimeUnit.new('h')
3007
+ )
3008
+ ]),
3009
+ a.vel_intervals
3010
+ )
3011
+ a.spectral_intervals = [SpectralInterval.new(:unit => SpectralUnit.new('MHz'))]
3012
+ assert_equal SpectralIntervalList.new([SpectralInterval.new(:unit => SpectralUnit.new('MHz'))]), a.spectral_intervals
3013
+ a.redshift_intervals = [RedshiftInterval.new, RedshiftInterval.new]
3014
+ assert_equal RedshiftIntervalList.new([RedshiftInterval.new, RedshiftInterval.new]), a.redshift_intervals
3015
+ a.coord_intervals = [CoordScalarInterval.new, CoordScalarInterval.new]
3016
+ assert_equal CoordIntervalList.new([CoordScalarInterval.new, CoordScalarInterval.new]), a.coord_intervals
3017
+ end
3018
+
3019
+ def test_xml
3020
+ a1 = CoordAreaType.new(
3021
+ :id => Id.new('MyArea'),
3022
+ :coord_system_id => 'MyCoordSystemId',
3023
+ :time_intervals => [TimeIntervalType.new],
3024
+ :spatial_interval => Sphere.new(:radius => 10.1, :center => Double3.new([1.1, 2.2, 3.3]), :unit => PosUnit.new('m')),
3025
+ :vel_intervals => [
3026
+ VelocitySphere.new(
3027
+ :radius => 10.1, :center => Double3.new([1.1, 2.2, 3.3]),
3028
+ :unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('s')
3029
+ )
3030
+ ],
3031
+ :spectral_intervals => [SpectralInterval.new(:unit => SpectralUnit.new('GHz'))],
3032
+ :redshift_intervals => [RedshiftInterval.new],
3033
+ :coord_intervals => [CoordScalarInterval.new]
3034
+ )
3035
+
3036
+ a2 = CoordAreaType.from_xml(a1.to_xml)
3037
+ assert_equal a1, a2
3038
+ end
3039
+ end
3040
+
3041
+ class AstroCoordAreaTypeTest < ::Test::Unit::TestCase
3042
+ def test_construction
3043
+ assert_nothing_raised {
3044
+ AstroCoordAreaType.new(
3045
+ :id => Id.new('MyArea'),
3046
+ :coord_system_id => 'MyCoordSystemId',
3047
+ :time_intervals => [TimeIntervalType.new],
3048
+ :spatial_interval => Sphere.new(:radius => 10.1, :center => Double3.new([1.1, 2.2, 3.3]), :unit => PosUnit.new('m')),
3049
+ :vel_intervals => [
3050
+ VelocitySphere.new(
3051
+ :radius => 10.1, :center => Double3.new([1.1, 2.2, 3.3]),
3052
+ :unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('s')
3053
+ )
3054
+ ],
3055
+ :spectral_intervals => [SpectralInterval.new(:unit => SpectralUnit.new('GHz'))],
3056
+ :redshift_intervals => [RedshiftInterval.new],
3057
+ :coord_intervals => [CoordScalarInterval.new]
3058
+ )
3059
+
3060
+ AstroCoordAreaType.new(
3061
+ :id => Id.new('MyArea'),
3062
+ :coord_system_id => 'MyCoordSystemId',
3063
+ :time_intervals => [TimeIntervalType.new],
3064
+ :spatial_interval => Sphere.new(:radius => 10.1, :center => Double3.new([1.1, 2.2, 3.3]), :unit => PosUnit.new('m')),
3065
+ :vel_intervals => [
3066
+ VelocitySphere.new(
3067
+ :radius => 10.1, :center => Double3.new([1.1, 2.2, 3.3]),
3068
+ :unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('s')
3069
+ )
3070
+ ],
3071
+ :spectral_intervals => [SpectralInterval.new(:unit => SpectralUnit.new('GHz'))],
3072
+ :redshift_intervals => [RedshiftInterval.new]
3073
+ )
3074
+
3075
+ AstroCoordAreaType.new(
3076
+ :id => Id.new('MyArea'),
3077
+ :coord_system_id => 'MyCoordSystemId',
3078
+ :time_intervals => [TimeIntervalType.new],
3079
+ :spatial_interval => Sphere.new(:radius => 10.1, :center => Double3.new([1.1, 2.2, 3.3]), :unit => PosUnit.new('m')),
3080
+ :vel_intervals => [
3081
+ VelocitySphere.new(
3082
+ :radius => 10.1, :center => Double3.new([1.1, 2.2, 3.3]),
3083
+ :unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('s')
3084
+ )
3085
+ ],
3086
+ :spectral_intervals => [SpectralInterval.new(:unit => SpectralUnit.new('GHz'))]
3087
+ )
3088
+
3089
+ AstroCoordAreaType.new(
3090
+ :id => Id.new('MyArea'),
3091
+ :coord_system_id => 'MyCoordSystemId',
3092
+ :time_intervals => [TimeIntervalType.new],
3093
+ :spatial_interval => Sphere.new(:radius => 10.1, :center => Double3.new([1.1, 2.2, 3.3]), :unit => PosUnit.new('m')),
3094
+ :vel_intervals => [
3095
+ VelocitySphere.new(
3096
+ :radius => 10.1, :center => Double3.new([1.1, 2.2, 3.3]),
3097
+ :unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('s')
3098
+ )
3099
+ ]
3100
+ )
3101
+
3102
+ AstroCoordAreaType.new(
3103
+ :id => Id.new('MyArea'),
3104
+ :coord_system_id => 'MyCoordSystemId',
3105
+ :time_intervals => [TimeIntervalType.new],
3106
+ :spatial_interval => Sphere.new(:radius => 10.1, :center => Double3.new([1.1, 2.2, 3.3]), :unit => PosUnit.new('m'))
3107
+ )
3108
+
3109
+ AstroCoordAreaType.new(
3110
+ :id => Id.new('MyArea'),
3111
+ :coord_system_id => 'MyCoordSystemId',
3112
+ :time_intervals => [TimeIntervalType.new]
3113
+ )
3114
+
3115
+ AstroCoordAreaType.new(
3116
+ :id => Id.new('MyArea'),
3117
+ :coord_system_id => 'MyCoordSystemId'
3118
+ )
3119
+ }
3120
+
3121
+ assert_raises ArgumentError do
3122
+ AstroCoordAreaType.new(:id => Id.new('MyArea'))
3123
+ end
3124
+ assert_raises ArgumentError do
3125
+ AstroCoordAreaType.new(:coord_system_id => 'MyCoordSystemId')
3126
+ end
3127
+
3128
+ assert_raises TypeError do
3129
+ AstroCoordAreaType.new(:id => Id.new('MyArea'), :coord_system_id => 'MyCoordSystemId', :time_intervals => 'blah')
3130
+ end
3131
+ assert_raises TypeError do
3132
+ AstroCoordAreaType.new(:id => Id.new('MyArea'), :coord_system_id => 'MyCoordSystemId', :spatial_interval => 'blah')
3133
+ end
3134
+ assert_raises TypeError do
3135
+ AstroCoordAreaType.new(:id => Id.new('MyArea'), :coord_system_id => 'MyCoordSystemId', :vel_intervals => 'blah')
3136
+ end
3137
+ assert_raises TypeError do
3138
+ AstroCoordAreaType.new(:id => Id.new('MyArea'), :coord_system_id => 'MyCoordSystemId', :spectral_intervals => 'blah')
3139
+ end
3140
+ assert_raises TypeError do
3141
+ AstroCoordAreaType.new(:id => Id.new('MyArea'), :coord_system_id => 'MyCoordSystemId', :redshift_intervals => 'blah')
3142
+ end
3143
+ assert_raises TypeError do
3144
+ AstroCoordAreaType.new(:id => Id.new('MyArea'), :coord_system_id => 'MyCoordSystemId', :coord_intervals => 'blah')
3145
+ end
3146
+ end
3147
+
3148
+ def test_accessors
3149
+ a = AstroCoordAreaType.new(
3150
+ :id => Id.new('MyArea'),
3151
+ :coord_system_id => 'MyCoordSystemId',
3152
+ :time_intervals => [TimeIntervalType.new],
3153
+ :spatial_interval => Sphere.new(:radius => 10.1, :center => Double3.new([1.1, 2.2, 3.3]), :unit => PosUnit.new('m')),
3154
+ :vel_intervals => [
3155
+ VelocitySphere.new(
3156
+ :radius => 10.1, :center => Double3.new([1.1, 2.2, 3.3]),
3157
+ :unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('s')
3158
+ )
3159
+ ],
3160
+ :spectral_intervals => [SpectralInterval.new(:unit => SpectralUnit.new('GHz'))],
3161
+ :redshift_intervals => [RedshiftInterval.new],
3162
+ :coord_intervals => [CoordScalarInterval.new]
3163
+ )
3164
+
3165
+ assert_equal Id.new('MyArea'), a.id
3166
+ assert_equal IdRef.new('MyCoordSystemId'), a.coord_system_id
3167
+ assert_equal TimeIntervalList.new([TimeIntervalType.new]), a.time_intervals
3168
+ assert_equal Sphere.new(:radius => 10.1, :center => Double3.new([1.1, 2.2, 3.3]), :unit => PosUnit.new('m')), a.spatial_interval
3169
+ assert_equal(
3170
+ VelIntervalList.new([
3171
+ VelocitySphere.new(
3172
+ :radius => 10.1, :center => Double3.new([1.1, 2.2, 3.3]),
3173
+ :unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('s')
3174
+ )
3175
+ ]),
3176
+ a.vel_intervals
3177
+ )
3178
+ assert_equal SpectralIntervalList.new([SpectralInterval.new(:unit => SpectralUnit.new('GHz'))]), a.spectral_intervals
3179
+ assert_equal RedshiftIntervalList.new([RedshiftInterval.new]), a.redshift_intervals
3180
+ assert_equal CoordScalarIntervalList.new([CoordScalarInterval.new]), a.coord_intervals
3181
+
3182
+ a.id = Id.new('MyArea2')
3183
+ assert_equal Id.new('MyArea2'), a.id
3184
+ a.coord_system_id = IdRef.new('MyCoordSystemId2')
3185
+ assert_equal IdRef.new('MyCoordSystemId2'), a.coord_system_id
3186
+ a.time_intervals = [TimeIntervalType.new, TimeIntervalType.new]
3187
+ assert_equal TimeIntervalList.new([TimeIntervalType.new, TimeIntervalType.new]), a.time_intervals
3188
+ a.spatial_interval = Sphere.new(:radius => 0.4, :center => Double3.new([0.1, 0.1, 0.1]), :unit => PosUnit.new('mm'))
3189
+ assert_equal Sphere.new(:radius => 0.4, :center => Double3.new([0.1, 0.1, 0.1]), :unit => PosUnit.new('mm')), a.spatial_interval
3190
+ a.vel_intervals = [
3191
+ VelocitySphere.new(
3192
+ :radius => 12.1, :center => Double3.new([9.0, 8.0, 7.0]),
3193
+ :unit => PosUnit.new('mm'), :vel_time_unit => VelTimeUnit.new('h')
3194
+ )
3195
+ ]
3196
+ assert_equal(
3197
+ VelIntervalList.new([
3198
+ VelocitySphere.new(
3199
+ :radius => 12.1, :center => Double3.new([9.0, 8.0, 7.0]),
3200
+ :unit => PosUnit.new('mm'), :vel_time_unit => VelTimeUnit.new('h')
3201
+ )
3202
+ ]),
3203
+ a.vel_intervals
3204
+ )
3205
+ a.spectral_intervals = [SpectralInterval.new(:unit => SpectralUnit.new('MHz'))]
3206
+ assert_equal SpectralIntervalList.new([SpectralInterval.new(:unit => SpectralUnit.new('MHz'))]), a.spectral_intervals
3207
+ a.redshift_intervals = [RedshiftInterval.new, RedshiftInterval.new]
3208
+ assert_equal RedshiftIntervalList.new([RedshiftInterval.new, RedshiftInterval.new]), a.redshift_intervals
3209
+ a.coord_intervals = [CoordScalarInterval.new, CoordScalarInterval.new]
3210
+ assert_equal CoordScalarIntervalList.new([CoordScalarInterval.new, CoordScalarInterval.new]), a.coord_intervals
3211
+ end
3212
+
3213
+ def test_xml
3214
+ a1 = AstroCoordAreaType.new(
3215
+ :id => Id.new('MyArea'),
3216
+ :coord_system_id => 'MyCoordSystemId',
3217
+ :time_intervals => [TimeIntervalType.new],
3218
+ :spatial_interval => Sphere.new(:radius => 10.1, :center => Double3.new([1.1, 2.2, 3.3]), :unit => PosUnit.new('m')),
3219
+ :vel_intervals => [
3220
+ VelocitySphere.new(
3221
+ :radius => 10.1, :center => Double3.new([1.1, 2.2, 3.3]),
3222
+ :unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('s')
3223
+ )
3224
+ ],
3225
+ :spectral_intervals => [SpectralInterval.new(:unit => SpectralUnit.new('GHz'))],
3226
+ :redshift_intervals => [RedshiftInterval.new],
3227
+ :coord_intervals => [CoordScalarInterval.new]
3228
+ )
3229
+
3230
+ a2 = AstroCoordAreaType.from_xml(a1.to_xml)
3231
+ assert_equal a1, a2
3232
+ end
3233
+ end
3234
+
3235
+ class PixelCoordAreaTypeTest < ::Test::Unit::TestCase
3236
+ def test_construction
3237
+ assert_nothing_raised {
3238
+ PixelCoordAreaType.new(
3239
+ :id => Id.new('MyArea'),
3240
+ :coord_system_id => 'MyCoordSystemId',
3241
+ :time_intervals => [TimeIntervalType.new],
3242
+ :spatial_interval => Sphere.new(:radius => 10.1, :center => Double3.new([1.1, 2.2, 3.3]), :unit => PosUnit.new('m')),
3243
+ :vel_intervals => [
3244
+ VelocitySphere.new(
3245
+ :radius => 10.1, :center => Double3.new([1.1, 2.2, 3.3]),
3246
+ :unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('s')
3247
+ )
3248
+ ],
3249
+ :spectral_intervals => [SpectralInterval.new(:unit => SpectralUnit.new('GHz'))],
3250
+ :redshift_intervals => [RedshiftInterval.new],
3251
+ :coord_intervals => [CoordScalarInterval.new]
3252
+ )
3253
+
3254
+ PixelCoordAreaType.new(
3255
+ :id => Id.new('MyArea'),
3256
+ :coord_system_id => 'MyCoordSystemId',
3257
+ :time_intervals => [TimeIntervalType.new],
3258
+ :spatial_interval => Sphere.new(:radius => 10.1, :center => Double3.new([1.1, 2.2, 3.3]), :unit => PosUnit.new('m')),
3259
+ :vel_intervals => [
3260
+ VelocitySphere.new(
3261
+ :radius => 10.1, :center => Double3.new([1.1, 2.2, 3.3]),
3262
+ :unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('s')
3263
+ )
3264
+ ],
3265
+ :spectral_intervals => [SpectralInterval.new(:unit => SpectralUnit.new('GHz'))],
3266
+ :coord_intervals => [CoordScalarInterval.new]
3267
+ )
3268
+
3269
+ PixelCoordAreaType.new(
3270
+ :id => Id.new('MyArea'),
3271
+ :coord_system_id => 'MyCoordSystemId',
3272
+ :time_intervals => [TimeIntervalType.new],
3273
+ :spatial_interval => Sphere.new(:radius => 10.1, :center => Double3.new([1.1, 2.2, 3.3]), :unit => PosUnit.new('m')),
3274
+ :vel_intervals => [
3275
+ VelocitySphere.new(
3276
+ :radius => 10.1, :center => Double3.new([1.1, 2.2, 3.3]),
3277
+ :unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('s')
3278
+ )
3279
+ ],
3280
+ :coord_intervals => [CoordScalarInterval.new]
3281
+ )
3282
+
3283
+ PixelCoordAreaType.new(
3284
+ :id => Id.new('MyArea'),
3285
+ :coord_system_id => 'MyCoordSystemId',
3286
+ :time_intervals => [TimeIntervalType.new],
3287
+ :spatial_interval => Sphere.new(:radius => 10.1, :center => Double3.new([1.1, 2.2, 3.3]), :unit => PosUnit.new('m')),
3288
+ :vel_intervals => [
3289
+ VelocitySphere.new(
3290
+ :radius => 10.1, :center => Double3.new([1.1, 2.2, 3.3]),
3291
+ :unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('s')
3292
+ )
3293
+ ],
3294
+ :coord_intervals => [CoordScalarInterval.new]
3295
+ )
3296
+
3297
+ PixelCoordAreaType.new(
3298
+ :id => Id.new('MyArea'),
3299
+ :coord_system_id => 'MyCoordSystemId',
3300
+ :time_intervals => [TimeIntervalType.new],
3301
+ :spatial_interval => Sphere.new(:radius => 10.1, :center => Double3.new([1.1, 2.2, 3.3]), :unit => PosUnit.new('m')),
3302
+ :coord_intervals => [CoordScalarInterval.new]
3303
+ )
3304
+
3305
+ PixelCoordAreaType.new(
3306
+ :id => Id.new('MyArea'),
3307
+ :coord_system_id => 'MyCoordSystemId',
3308
+ :time_intervals => [TimeIntervalType.new],
3309
+ :coord_intervals => [CoordScalarInterval.new]
3310
+ )
3311
+
3312
+ PixelCoordAreaType.new(
3313
+ :id => Id.new('MyArea'),
3314
+ :coord_system_id => 'MyCoordSystemId',
3315
+ :coord_intervals => [CoordScalarInterval.new]
3316
+ )
3317
+ }
3318
+
3319
+ assert_raises ArgumentError do
3320
+ PixelCoordAreaType.new(:id => Id.new('MyArea'), :coord_intervals => [CoordScalarInterval.new])
3321
+ end
3322
+ assert_raises ArgumentError do
3323
+ PixelCoordAreaType.new(:coord_system_id => 'MyCoordSystemId', :coord_intervals => [CoordScalarInterval.new])
3324
+ end
3325
+ assert_raises ArgumentError do
3326
+ PixelCoordAreaType.new(:id => Id.new('MyArea'), :coord_system_id => 'MyCoordSystemId')
3327
+ end
3328
+
3329
+ assert_raises RuntimeError do
3330
+ PixelCoordAreaType.new(
3331
+ :id => Id.new('MyArea'),
3332
+ :coord_system_id => 'MyCoordSystemId',
3333
+ :coord_intervals => []
3334
+ )
3335
+ end
3336
+
3337
+ assert_raises TypeError do
3338
+ PixelCoordAreaType.new(
3339
+ :id => Id.new('MyArea'), :coord_system_id => 'MyCoordSystemId', :coord_intervals => [CoordScalarInterval.new], :time_intervals => 'blah'
3340
+ )
3341
+ end
3342
+ assert_raises TypeError do
3343
+ PixelCoordAreaType.new(
3344
+ :id => Id.new('MyArea'), :coord_system_id => 'MyCoordSystemId', :coord_intervals => [CoordScalarInterval.new], :spatial_interval => 'blah'
3345
+ )
3346
+ end
3347
+ assert_raises TypeError do
3348
+ PixelCoordAreaType.new(
3349
+ :id => Id.new('MyArea'), :coord_system_id => 'MyCoordSystemId', :coord_intervals => [CoordScalarInterval.new], :vel_intervals => 'blah'
3350
+ )
3351
+ end
3352
+ assert_raises TypeError do
3353
+ PixelCoordAreaType.new(
3354
+ :id => Id.new('MyArea'), :coord_system_id => 'MyCoordSystemId', :coord_intervals => [CoordScalarInterval.new], :spectral_intervals => 'blah'
3355
+ )
3356
+ end
3357
+ assert_raises TypeError do
3358
+ PixelCoordAreaType.new(
3359
+ :id => Id.new('MyArea'), :coord_system_id => 'MyCoordSystemId', :coord_intervals => [CoordScalarInterval.new], :redshift_intervals => 'blah'
3360
+ )
3361
+ end
3362
+ assert_raises TypeError do
3363
+ PixelCoordAreaType.new(
3364
+ :id => Id.new('MyArea'), :coord_system_id => 'MyCoordSystemId', :coord_intervals => [CoordScalarInterval.new], :coord_intervals => 'blah'
3365
+ )
3366
+ end
3367
+ end
3368
+
3369
+ def test_accessors
3370
+ a = PixelCoordAreaType.new(
3371
+ :id => Id.new('MyArea'),
3372
+ :coord_system_id => 'MyCoordSystemId',
3373
+ :time_intervals => [TimeIntervalType.new],
3374
+ :spatial_interval => Sphere.new(:radius => 10.1, :center => Double3.new([1.1, 2.2, 3.3]), :unit => PosUnit.new('m')),
3375
+ :vel_intervals => [
3376
+ VelocitySphere.new(
3377
+ :radius => 10.1, :center => Double3.new([1.1, 2.2, 3.3]),
3378
+ :unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('s')
3379
+ )
3380
+ ],
3381
+ :spectral_intervals => [SpectralInterval.new(:unit => SpectralUnit.new('GHz'))],
3382
+ :redshift_intervals => [RedshiftInterval.new],
3383
+ :coord_intervals => [CoordScalarInterval.new]
3384
+ )
3385
+
3386
+ assert_equal Id.new('MyArea'), a.id
3387
+ assert_equal IdRef.new('MyCoordSystemId'), a.coord_system_id
3388
+ assert_equal TimeIntervalList.new([TimeIntervalType.new]), a.time_intervals
3389
+ assert_equal Sphere.new(:radius => 10.1, :center => Double3.new([1.1, 2.2, 3.3]), :unit => PosUnit.new('m')), a.spatial_interval
3390
+ assert_equal(
3391
+ VelIntervalList.new([
3392
+ VelocitySphere.new(
3393
+ :radius => 10.1, :center => Double3.new([1.1, 2.2, 3.3]),
3394
+ :unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('s')
3395
+ )
3396
+ ]),
3397
+ a.vel_intervals
3398
+ )
3399
+ assert_equal SpectralIntervalList.new([SpectralInterval.new(:unit => SpectralUnit.new('GHz'))]), a.spectral_intervals
3400
+ assert_equal RedshiftIntervalList.new([RedshiftInterval.new]), a.redshift_intervals
3401
+ assert_equal PixelCoordAreaType::CoordScalarIntervalList.new([CoordScalarInterval.new]), a.coord_intervals
3402
+
3403
+ a.id = Id.new('MyArea2')
3404
+ assert_equal Id.new('MyArea2'), a.id
3405
+ a.coord_system_id = IdRef.new('MyCoordSystemId2')
3406
+ assert_equal IdRef.new('MyCoordSystemId2'), a.coord_system_id
3407
+ a.time_intervals = [TimeIntervalType.new, TimeIntervalType.new]
3408
+ assert_equal TimeIntervalList.new([TimeIntervalType.new, TimeIntervalType.new]), a.time_intervals
3409
+ a.spatial_interval = Sphere.new(:radius => 0.4, :center => Double3.new([0.1, 0.1, 0.1]), :unit => PosUnit.new('mm'))
3410
+ assert_equal Sphere.new(:radius => 0.4, :center => Double3.new([0.1, 0.1, 0.1]), :unit => PosUnit.new('mm')), a.spatial_interval
3411
+ a.vel_intervals = [
3412
+ VelocitySphere.new(
3413
+ :radius => 12.1, :center => Double3.new([9.0, 8.0, 7.0]),
3414
+ :unit => PosUnit.new('mm'), :vel_time_unit => VelTimeUnit.new('h')
3415
+ )
3416
+ ]
3417
+ assert_equal(
3418
+ VelIntervalList.new([
3419
+ VelocitySphere.new(
3420
+ :radius => 12.1, :center => Double3.new([9.0, 8.0, 7.0]),
3421
+ :unit => PosUnit.new('mm'), :vel_time_unit => VelTimeUnit.new('h')
3422
+ )
3423
+ ]),
3424
+ a.vel_intervals
3425
+ )
3426
+ a.spectral_intervals = [SpectralInterval.new(:unit => SpectralUnit.new('MHz'))]
3427
+ assert_equal SpectralIntervalList.new([SpectralInterval.new(:unit => SpectralUnit.new('MHz'))]), a.spectral_intervals
3428
+ a.redshift_intervals = [RedshiftInterval.new, RedshiftInterval.new]
3429
+ assert_equal RedshiftIntervalList.new([RedshiftInterval.new, RedshiftInterval.new]), a.redshift_intervals
3430
+ a.coord_intervals = [CoordScalarInterval.new, CoordScalarInterval.new]
3431
+ assert_equal PixelCoordAreaType::CoordScalarIntervalList.new([CoordScalarInterval.new, CoordScalarInterval.new]), a.coord_intervals
3432
+ end
3433
+
3434
+ def test_xml
3435
+ a1 = PixelCoordAreaType.new(
3436
+ :id => Id.new('MyArea'),
3437
+ :coord_system_id => 'MyCoordSystemId',
3438
+ :time_intervals => [TimeIntervalType.new],
3439
+ :spatial_interval => Sphere.new(:radius => 10.1, :center => Double3.new([1.1, 2.2, 3.3]), :unit => PosUnit.new('m')),
3440
+ :vel_intervals => [
3441
+ VelocitySphere.new(
3442
+ :radius => 10.1, :center => Double3.new([1.1, 2.2, 3.3]),
3443
+ :unit => PosUnit.new('m'), :vel_time_unit => VelTimeUnit.new('s')
3444
+ )
3445
+ ],
3446
+ :spectral_intervals => [SpectralInterval.new(:unit => SpectralUnit.new('GHz'))],
3447
+ :redshift_intervals => [RedshiftInterval.new],
3448
+ :coord_intervals => [CoordScalarInterval.new]
3449
+ )
3450
+
3451
+ a2 = PixelCoordAreaType.from_xml(a1.to_xml)
3452
+ assert_equal a1, a2
3453
+ end
3454
+ end
3455
+
3456
+ class StcResourceProfileTypeTest < ::Test::Unit::TestCase
3457
+ def setup
3458
+ @astro_coord_systems = [AstroCoordSystem.new(
3459
+ :id => 'ICRS-TT-CXO',
3460
+ :time_frame => TimeFrame.new(
3461
+ :name => 'Time',
3462
+ :time_scale => TimeScale.new('TT'),
3463
+ :reference_position => Topocenter.new
3464
+ ),
3465
+ :space_frame => SpaceFrame.new(
3466
+ :name => 'Space',
3467
+ :space_ref_frame => Icrs.new,
3468
+ :reference_position => Topocenter.new,
3469
+ :coord_flavor => Spherical.new(2)
3470
+ ),
3471
+ :spectral_frame => SpectralFrame.new(
3472
+ :name => 'Energy',
3473
+ :reference_position => Topocenter.new
3474
+ )
3475
+ )]
3476
+
3477
+ @astro_coords = AstroCoords.new(
3478
+ :coord_system_id => 'ICRS-TT-CXO',
3479
+ :time => TimeCoordinate.new(
3480
+ :name => 'Time',
3481
+ :error => [Error.new(0.0001)],
3482
+ :resolution => [Resolution.new(0.000016), Resolution.new(3.0)],
3483
+ :size => [Size.new(1000.0), Size.new(170000.0)]
3484
+ ),
3485
+ :position => Position2D.new(
3486
+ :name => 'Position',
3487
+ :unit => PosUnit.new('arcsec'),
3488
+ :error => [Error2.new([1.0, 1.0])],
3489
+ :resolution => [Resolution2.new([0.5, 0.5])],
3490
+ :size => [Size2.new([1000.0, 1000.0]), Size2.new([4000.0, 4000.0])]
3491
+ ),
3492
+ :spectral => Spectral.new(
3493
+ :name => 'Energy',
3494
+ :unit => SpectralUnit.new('keV'),
3495
+ :error => [Error.new(0.1)],
3496
+ :resolution => [Resolution.new(0.02), Resolution.new(2.0)],
3497
+ :size => [Size.new(2.0), Size.new(10.0)]
3498
+ )
3499
+ )
3500
+
3501
+ @astro_coord_areas = AstroCoordArea.new(
3502
+ :id => 'AllSky-CXO',
3503
+ :coord_system_id => 'ICRS-TT-CXO',
3504
+ :time_intervals => [
3505
+ TimeIntervalType.new(
3506
+ :start_time => AstronTime.new('TT', ISOTime.new('1999-07-23T16:00:00'))
3507
+ )
3508
+ ],
3509
+ :spatial_interval => Region.new(:region => AllSky.new(:fill_factor => 0.02)),
3510
+ :spectral_intervals => [
3511
+ SpectralInterval.new(:unit => SpectralUnit.new('keV'), :lo_limit => 0.12, :hi_limit => 10.0)
3512
+ ]
3513
+ )
3514
+ end
3515
+
3516
+ def test_construction
3517
+ assert_nothing_raised {
3518
+ StcResourceProfileType.new(
3519
+ :id => 'MyResourceProfile',
3520
+ :coord_sys => @astro_coord_systems,
3521
+ :coords => @astro_coords,
3522
+ :coord_areas => @astro_coord_areas
3523
+ )
3524
+
3525
+ StcResourceProfileType.new(
3526
+ :coord_sys => @astro_coord_systems,
3527
+ :coords => @astro_coords,
3528
+ :coord_areas => @astro_coord_areas
3529
+ )
3530
+ }
3531
+
3532
+ assert_raises ArgumentError do
3533
+ StcResourceProfileType.new(
3534
+ :id => 'MyResourceProfile',
3535
+ :coord_sys => @astro_coord_systems,
3536
+ :coords => @astro_coords
3537
+ )
3538
+ end
3539
+ assert_raises ArgumentError do
3540
+ StcResourceProfileType.new(
3541
+ :id => 'MyResourceProfile',
3542
+ :coord_sys => @astro_coord_systems,
3543
+ :coord_areas => @astro_coord_areas
3544
+ )
3545
+ end
3546
+ assert_raises ArgumentError do
3547
+ StcResourceProfileType.new(
3548
+ :id => 'MyResourceProfile',
3549
+ :coords => @astro_coords,
3550
+ :coord_areas => @astro_coord_areas
3551
+ )
3552
+ end
3553
+
3554
+ assert_raises TypeError do
3555
+ StcResourceProfileType.new(
3556
+ :id => 'MyResourceProfile',
3557
+ :coord_sys => 'blah',
3558
+ :coords => @astro_coords,
3559
+ :coord_areas => @astro_coord_areas
3560
+ )
3561
+ end
3562
+ assert_raises TypeError do
3563
+ StcResourceProfileType.new(
3564
+ :id => 'MyResourceProfile',
3565
+ :coord_sys => @astro_coord_systems,
3566
+ :coords => 'blah',
3567
+ :coord_areas => @astro_coord_areas
3568
+ )
3569
+ end
3570
+ assert_raises TypeError do
3571
+ StcResourceProfileType.new(
3572
+ :id => 'MyResourceProfile',
3573
+ :coord_sys => 'blah',
3574
+ :coords => @astro_coords,
3575
+ :coord_areas => @astro_coord_areas
3576
+ )
3577
+ end
3578
+ end
3579
+
3580
+ def test_accessors
3581
+ p = StcResourceProfileType.new(
3582
+ :id => 'MyResourceProfile',
3583
+ :coord_sys => @astro_coord_systems,
3584
+ :coords => @astro_coords,
3585
+ :coord_areas => @astro_coord_areas
3586
+ )
3587
+
3588
+ assert_equal Id.new('MyResourceProfile'), p.id
3589
+ assert_equal @astro_coord_systems, p.coord_sys
3590
+ assert_equal @astro_coords, p.coords
3591
+ assert_equal @astro_coord_areas, p.coord_areas
3592
+ end
3593
+
3594
+ def test_relationships
3595
+ p = StcResourceProfileType.new(
3596
+ :id => 'MyResourceProfile',
3597
+ :coord_sys => @astro_coord_systems,
3598
+ :coords => @astro_coords,
3599
+ :coord_areas => @astro_coord_areas
3600
+ )
3601
+
3602
+ assert_kind_of StcDescription, p
3603
+ end
3604
+
3605
+ def test_xml
3606
+ p1 = StcResourceProfileType.new(
3607
+ :id => 'MyResourceProfile',
3608
+ :coord_sys => @astro_coord_systems,
3609
+ :coords => @astro_coords,
3610
+ :coord_areas => @astro_coord_areas
3611
+ )
3612
+
3613
+ p2 = StcResourceProfileType.from_xml(p1.to_xml)
3614
+ assert_equal p1, p2
3615
+ end
3616
+
3617
+ def test_real_world
3618
+ p1 = StcResourceProfileType.new(
3619
+ :coord_sys => @astro_coord_systems,
3620
+ :coords => @astro_coords,
3621
+ :coord_areas => @astro_coord_areas
3622
+ )
3623
+
3624
+ p2 = StcResourceProfileType.from_xml(File.new('test/voruby/stc/1.10/stc-resource-profile.xml'))
3625
+ assert_equal p1, p2
3626
+ end
3627
+ end
3628
+
3629
+ class SearchLocationTypeTest < ::Test::Unit::TestCase
3630
+ def setup
3631
+ @astro_coord_systems = [AstroCoordSystem.new(
3632
+ :id => 'ICRS-TT-BARY',
3633
+ :time_frame => TimeFrame.new(
3634
+ :name => 'Time',
3635
+ :time_scale => TimeScale.new('TT'),
3636
+ :reference_position => Barycenter.new
3637
+ ),
3638
+ :space_frame => SpaceFrame.new(
3639
+ :name => 'Equatorial',
3640
+ :space_ref_frame => Icrs.new,
3641
+ :reference_position => Barycenter.new,
3642
+ :coord_flavor => Spherical.new(2)
3643
+ ),
3644
+ :spectral_frame => SpectralFrame.new(
3645
+ :name => 'Wavelength',
3646
+ :reference_position => Barycenter.new
3647
+ )
3648
+ )]
3649
+
3650
+ @astro_coords = AstroCoords.new(
3651
+ :coord_system_id => 'ICRS-TT-BARY',
3652
+ :position => Position2D.new(
3653
+ :name => 'RA,Dec',
3654
+ :unit => PosUnit.new('deg'),
3655
+ :resolution => [Resolution2.new([0.0001, 0.0001]), Resolution2.new([0.0003, 0.0003])],
3656
+ :size => [Size2.new([0.5, 0.5]), Size2.new([0.67, 0.67])],
3657
+ :pix_size => [PixSize2.new([0.00005, 0.00005]), PixSize2.new([0.00015, 0.00015])]
3658
+ ),
3659
+ :spectral => Spectral.new(
3660
+ :name => 'Lambda',
3661
+ :unit => SpectralUnit.new('A'),
3662
+ :resolution => [Resolution.new(300.0), Resolution.new(600.0)]
3663
+ )
3664
+ )
3665
+
3666
+ @astro_coord_areas = AstroCoordArea.new(
3667
+ :id => 'M81',
3668
+ :coord_system_id => 'ICRS-TT-BARY',
3669
+ :time_intervals => [
3670
+ TimeIntervalType.new(
3671
+ :start_time => AstronTime.new('TT', ISOTime.new('1900-01-01T00:00:00'))
3672
+ )
3673
+ ],
3674
+ :spatial_interval => Region.new(
3675
+ :region => Circle.new(
3676
+ :coord_system_id => 'ICRS-TT-BARY',
3677
+ :unit => PosUnit.new('deg'),
3678
+ :center => [148.9, 69.1],
3679
+ :radius => 2.0
3680
+ )
3681
+ ),
3682
+ :spectral_intervals => [
3683
+ SpectralInterval.new(:unit => SpectralUnit.new('A'), :lo_limit => 4000.0, :hi_limit => 7000.0)
3684
+ ]
3685
+ )
3686
+ end
3687
+
3688
+ def test_construction
3689
+ assert_nothing_raised {
3690
+ SearchLocationType.new(
3691
+ :id => 'MySearchLocation',
3692
+ :coord_sys => @astro_coord_systems,
3693
+ :coords => @astro_coords,
3694
+ :coord_areas => @astro_coord_areas
3695
+ )
3696
+
3697
+ SearchLocationType.new(
3698
+ :id => 'MySearchLocation',
3699
+ :coord_sys => @astro_coord_systems,
3700
+ :coord_areas => @astro_coord_areas
3701
+ )
3702
+
3703
+ SearchLocationType.new(
3704
+ :coord_sys => @astro_coord_systems,
3705
+ :coords => @astro_coords,
3706
+ :coord_areas => @astro_coord_areas
3707
+ )
3708
+ }
3709
+
3710
+ assert_raises ArgumentError do
3711
+ SearchLocationType.new(
3712
+ :id => 'MySearchLocation',
3713
+ :coords => @astro_coords,
3714
+ :coord_areas => @astro_coord_areas
3715
+ )
3716
+ end
3717
+ assert_raises ArgumentError do
3718
+ SearchLocationType.new(
3719
+ :id => 'MySearchLocation',
3720
+ :coord_sys => @astro_coord_systems,
3721
+ :coords => @astro_coords
3722
+ )
3723
+ end
3724
+
3725
+ assert_raises TypeError do
3726
+ SearchLocationType.new(
3727
+ :id => 'MySearchLocation',
3728
+ :coord_sys => @astro_coord_systems,
3729
+ :coords => @astro_coords,
3730
+ :coord_areas => 'blah'
3731
+ )
3732
+ end
3733
+ assert_raises TypeError do
3734
+ SearchLocationType.new(
3735
+ :id => 'MySearchLocation',
3736
+ :coord_sys => @astro_coord_systems,
3737
+ :coords => 'blah',
3738
+ :coord_areas => @astro_coord_areas
3739
+ )
3740
+ end
3741
+ assert_raises TypeError do
3742
+ SearchLocationType.new(
3743
+ :id => 'MySearchLocation',
3744
+ :coord_sys => 'blah',
3745
+ :coords => @astro_coords,
3746
+ :coord_areas => @astro_coord_areas
3747
+ )
3748
+ end
3749
+ end
3750
+
3751
+ def test_accessors
3752
+ l = SearchLocationType.new(
3753
+ :id => 'MySearchLocation',
3754
+ :coord_sys => @astro_coord_systems,
3755
+ :coords => @astro_coords,
3756
+ :coord_areas => @astro_coord_areas
3757
+ )
3758
+
3759
+ assert_equal Id.new('MySearchLocation'), l.id
3760
+ assert_equal @astro_coord_systems, l.coord_sys
3761
+ assert_equal @astro_coords, l.coords
3762
+ assert_equal @astro_coord_areas, l.coord_areas
3763
+ end
3764
+
3765
+ def test_relationships
3766
+ l = SearchLocationType.new(
3767
+ :id => 'MySearchLocation',
3768
+ :coord_sys => @astro_coord_systems,
3769
+ :coords => @astro_coords,
3770
+ :coord_areas => @astro_coord_areas
3771
+ )
3772
+
3773
+ assert_kind_of StcDescription, l
3774
+ end
3775
+
3776
+ def test_xml
3777
+ l1 = SearchLocationType.new(
3778
+ :id => 'MySearchLocation',
3779
+ :coord_sys => @astro_coord_systems,
3780
+ :coords => @astro_coords,
3781
+ :coord_areas => @astro_coord_areas
3782
+ )
3783
+
3784
+ l2 = SearchLocationType.from_xml(l1.to_xml)
3785
+ assert_equal l1, l2
3786
+ end
3787
+
3788
+ def test_real_world
3789
+ l1 = SearchLocationType.new(
3790
+ :coord_sys => @astro_coord_systems,
3791
+ :coords => @astro_coords,
3792
+ :coord_areas => @astro_coord_areas
3793
+ )
3794
+
3795
+ l2 = StcResourceProfileType.from_xml(File.new('test/voruby/stc/1.10/stc-search-location.xml'))
3796
+ assert_equal l1, l2
3797
+ end
3798
+ end
3799
+
3800
+ class CatalogEntryLocationTypeTest < ::Test::Unit::TestCase
3801
+ def setup
3802
+ @astro_coord_systems = [
3803
+ AstroCoordSystem.new(
3804
+ :id => 'B1950-OPTICAL-ET',
3805
+ :time_frame => TimeFrame.new(
3806
+ :name => 'Time',
3807
+ :time_scale => TimeScale.new('ET'),
3808
+ :reference_position => Topocenter.new
3809
+ ),
3810
+ :space_frame => SpaceFrame.new(
3811
+ :name => 'PosEq',
3812
+ :space_ref_frame => Fk4.new(CoordEquinox.new('B1950.0')),
3813
+ :reference_position => Barycenter.new,
3814
+ :coord_flavor => Spherical.new(2, true)
3815
+ ),
3816
+ :spectral_frame => SpectralFrame.new(
3817
+ :name => 'Optical',
3818
+ :reference_position => Topocenter.new
3819
+ ),
3820
+ :redshift_frame => RedshiftFrame.new(
3821
+ :name => 'DopplerVelocity',
3822
+ :doppler_definition => 'OPTICAL',
3823
+ :reference_position => Barycenter.new
3824
+ )
3825
+ ),
3826
+ AstroCoordSystem.new(
3827
+ :id => 'SGC-OPTICAL-ET',
3828
+ :time_frame => TimeFrame.new(
3829
+ :name => 'Time',
3830
+ :time_scale => TimeScale.new('ET'),
3831
+ :reference_position => Topocenter.new
3832
+ ),
3833
+ :space_frame => SpaceFrame.new(
3834
+ :name => 'SGC',
3835
+ :space_ref_frame => SuperGalactic.new,
3836
+ :reference_position => Barycenter.new,
3837
+ :coord_flavor => Spherical.new(2, true)
3838
+ ),
3839
+ :spectral_frame => SpectralFrame.new(
3840
+ :name => 'Optical',
3841
+ :reference_position => Topocenter.new
3842
+ ),
3843
+ :redshift_frame => RedshiftFrame.new(
3844
+ :name => 'DopplerVelocity',
3845
+ :doppler_definition => 'OPTICAL',
3846
+ :reference_position => GalacticCenter.new
3847
+ )
3848
+ )
3849
+ ]
3850
+
3851
+ @astro_coords = [
3852
+ AstroCoords.new(
3853
+ :coord_system_id => 'B1950-OPTICAL-ET',
3854
+ :position => Position2D.new(
3855
+ :name => 'RA,Dec',
3856
+ :unit => PosUnit.new('deg'),
3857
+ :value => Value2Ref.new('Column3'),
3858
+ :error => Error2Ref.new('Column4'),
3859
+ :size => Size2Ref.new('Column5')
3860
+ ),
3861
+ :redshift => Redshift.new(
3862
+ :unit => PosUnit.new('km'),
3863
+ :vel_time_unit => VelTimeUnit.new('s'),
3864
+ :name => 'Vrad(barycenter)',
3865
+ :value => ValueRef.new('Column6'),
3866
+ :error => ErrorRef.new('Column7')
3867
+ )
3868
+ ),
3869
+ AstroCoords.new(
3870
+ :coord_system_id => 'SGC-OPTICAL-ET',
3871
+ :position => Position2D.new(
3872
+ :name => 'SGLong,SGLat',
3873
+ :unit => PosUnit.new('deg'),
3874
+ :value => Value2Ref.new('Column8'),
3875
+ :error => Error2Ref.new('Column9'),
3876
+ :size => Size2Ref.new('Column10')
3877
+ ),
3878
+ :redshift => Redshift.new(
3879
+ :unit => PosUnit.new('km'),
3880
+ :vel_time_unit => VelTimeUnit.new('s'),
3881
+ :name => 'Vrad(Galcenter)',
3882
+ :value => ValueRef.new('Column11'),
3883
+ :error => ErrorRef.new('Column12')
3884
+ )
3885
+ )
3886
+ ]
3887
+
3888
+ @astro_coord_areas = [
3889
+ AstroCoordArea.new(
3890
+ :coord_system_id => 'B1950-OPTICAL-ET',
3891
+ :id => 'RA6-18hDec20-70deg',
3892
+ :time_intervals => [
3893
+ TimeIntervalType.new(
3894
+ :start_time => AstronTime.new('ET', JDTime.new(2440000)),
3895
+ :stop_time => AstronTime.new('ET', JDTime.new(2441000))
3896
+ )
3897
+ ],
3898
+ :spatial_interval => Region.new(
3899
+ :region => Polygon.new(
3900
+ :coord_system_id => 'B1950-OPTICAL-ET',
3901
+ :unit => PosUnit.new('deg'),
3902
+ :vertices => [
3903
+ Vertex.new(:position => Double2.new([270.0, 20.0])),
3904
+ Vertex.new(:position => Double2.new([90.0, 20.0]), :small_circle => SmallCircle.new),
3905
+ Vertex.new(:position => Double2.new([90.0, 70.0])),
3906
+ Vertex.new(:position => Double2.new([270.0, 70.0]))
3907
+ ]
3908
+ )
3909
+ ),
3910
+ :spectral_intervals => [
3911
+ SpectralInterval.new(:unit => SpectralUnit.new('A'), :lo_limit => 5000.0, :hi_limit => 6500.0)
3912
+ ],
3913
+ :redshift_intervals => [
3914
+ RedshiftInterval.new(:unit => PosUnit.new('km'), :vel_time_unit => VelTimeUnit.new('s'), :hi_limit => 10000.0)
3915
+ ]
3916
+ )
3917
+ ]
3918
+ end
3919
+
3920
+ def test_construction
3921
+ assert_nothing_raised {
3922
+ CatalogEntryLocationType.new(
3923
+ :id => 'MyCatalogEntry',
3924
+ :coord_sys => @astro_coord_systems,
3925
+ :coords => @astro_coords,
3926
+ :coord_areas => @astro_coord_areas
3927
+ )
3928
+
3929
+ CatalogEntryLocationType.new(
3930
+ :id => 'MyCatalogEntry',
3931
+ :coord_sys => @astro_coord_systems,
3932
+ :coords => @astro_coords
3933
+ )
3934
+ }
3935
+
3936
+ assert_raises ArgumentError do
3937
+ CatalogEntryLocationType.new(
3938
+ :id => 'MyCatalogEntry',
3939
+ :coords => @astro_coords,
3940
+ :coord_areas => @astro_coord_areas
3941
+ )
3942
+ end
3943
+ assert_raises ArgumentError do
3944
+ CatalogEntryLocationType.new(
3945
+ :id => 'MyCatalogEntry',
3946
+ :coord_sys => @astro_coord_systems,
3947
+ :coord_areas => @astro_coord_areas
3948
+ )
3949
+ end
3950
+
3951
+ assert_raises TypeError do
3952
+ CatalogEntryLocationType.new(
3953
+ :id => 'MyCatalogEntry',
3954
+ :coord_sys => 'blah',
3955
+ :coords => @astro_coords,
3956
+ :coord_areas => @astro_coord_areas
3957
+ )
3958
+ end
3959
+ assert_raises TypeError do
3960
+ CatalogEntryLocationType.new(
3961
+ :id => 'MyCatalogEntry',
3962
+ :coord_sys => @astro_coord_systems,
3963
+ :coords => 'blah',
3964
+ :coord_areas => @astro_coord_areas
3965
+ )
3966
+ end
3967
+ assert_raises TypeError do
3968
+ CatalogEntryLocationType.new(
3969
+ :id => 'MyCatalogEntry',
3970
+ :coord_sys => @astro_coord_systems,
3971
+ :coords => @astro_coords,
3972
+ :coord_areas => 'blah'
3973
+ )
3974
+ end
3975
+ end
3976
+
3977
+ def test_construction
3978
+ l = CatalogEntryLocationType.new(
3979
+ :id => 'MyCatalogEntry',
3980
+ :coord_sys => @astro_coord_systems,
3981
+ :coords => @astro_coords,
3982
+ :coord_areas => @astro_coord_areas
3983
+ )
3984
+
3985
+ assert_equal Id.new('MyCatalogEntry'), l.id
3986
+ assert_equal @astro_coord_systems, l.coord_sys
3987
+ assert_equal @astro_coords, l.coords
3988
+ assert_equal @astro_coord_areas, l.coord_areas
3989
+ end
3990
+
3991
+ def test_relationships
3992
+ l = CatalogEntryLocationType.new(
3993
+ :id => 'MyCatalogEntry',
3994
+ :coord_sys => @astro_coord_systems,
3995
+ :coords => @astro_coords,
3996
+ :coord_areas => @astro_coord_areas
3997
+ )
3998
+
3999
+ assert_kind_of StcDescription, l
4000
+ end
4001
+
4002
+ def test_xml
4003
+ l1 = CatalogEntryLocationType.new(
4004
+ :id => 'MyCatalogEntry',
4005
+ :coord_sys => @astro_coord_systems,
4006
+ :coords => @astro_coords,
4007
+ :coord_areas => @astro_coord_areas
4008
+ )
4009
+
4010
+ l2 = CatalogEntryLocationType.from_xml(l1.to_xml)
4011
+ assert_equal l1, l2
4012
+ end
4013
+
4014
+ def test_real_world
4015
+ l1 = CatalogEntryLocationType.new(
4016
+ :coord_sys => @astro_coord_systems,
4017
+ :coords => @astro_coords,
4018
+ :coord_areas => @astro_coord_areas
4019
+ )
4020
+
4021
+ l2 = CatalogEntryLocationType.from_xml(File.new('test/voruby/stc/1.10/stc-catalog-entry-location.xml'))
4022
+ assert_equal l1, l2
4023
+ end
4024
+ end
4025
+
4026
+ class ObservatoryLocationTest < ::Test::Unit::TestCase
4027
+ def setup
4028
+ @astro_coord_systems = [AstroCoordSystem.new(
4029
+ :id => 'FK5-UTC-VEL',
4030
+ :time_frame => TimeFrame.new(
4031
+ :name => 'Time',
4032
+ :time_scale => TimeScale.new('UTC'),
4033
+ :reference_position => Topocenter.new
4034
+ ),
4035
+ :space_frame => SpaceFrame.new(
4036
+ :name => 'FK5Cart+Vel',
4037
+ :space_ref_frame => Fk5.new(CoordEquinox.new('J2000.0')),
4038
+ :reference_position => Topocenter.new,
4039
+ :coord_flavor => Cartesian.new(3, true)
4040
+ )
4041
+ )]
4042
+
4043
+ @astro_coords = AstroCoords.new(
4044
+ :coord_system_id => 'FK5-UTC-VEL',
4045
+ :coord_file => AstroCoordsFile.new(
4046
+ :file => Fits.new(:hdu_num => 1, :uri => 'http://MySpace.edu/OrbitEphemeris.fits'),
4047
+ :time => CoordFitsColumns.new(:name => 'Time', :value => 'VALUE'),
4048
+ :position => CoordFitsColumns.new(:name => 'Position', :value => 'X,Y,Z'),
4049
+ :velocity => CoordFitsColumns.new(:name => 'Velocity', :value => 'VX,VY,VZ')
4050
+ )
4051
+ )
4052
+ end
4053
+
4054
+ def test_construction
4055
+ assert_nothing_raised {
4056
+ ObservatoryLocation.new(
4057
+ :id => 'MyObservatoryLocation',
4058
+ :coord_sys => @astro_coord_systems,
4059
+ :coords => @astro_coords
4060
+ )
4061
+ }
4062
+
4063
+ assert_raises ArgumentError do
4064
+ ObservatoryLocation.new(
4065
+ :id => 'MyObservatoryLocation',
4066
+ :coords => @astro_coords
4067
+ )
4068
+ end
4069
+ assert_raises ArgumentError do
4070
+ ObservatoryLocation.new(
4071
+ :id => 'MyObservatoryLocation',
4072
+ :coord_sys => @astro_coord_systems
4073
+ )
4074
+ end
4075
+ assert_raises ArgumentError do
4076
+ ObservatoryLocation.new(
4077
+ :id => 'MyObservatoryLocation',
4078
+ :coord_sys => @astro_coord_systems,
4079
+ :coords => @astro_coords,
4080
+ :coord_areas => 'blah'
4081
+ )
4082
+ end
4083
+
4084
+ assert_raises TypeError do
4085
+ ObservatoryLocation.new(
4086
+ :id => 'MyObservatoryLocation',
4087
+ :coord_sys => 'blah',
4088
+ :coords => @astro_coords
4089
+ )
4090
+ end
4091
+ assert_raises TypeError do
4092
+ ObservatoryLocation.new(
4093
+ :id => 'MyObservatoryLocation',
4094
+ :coord_sys => @astro_coord_systems,
4095
+ :coords => 'blah'
4096
+ )
4097
+ end
4098
+ end
4099
+
4100
+ def test_accessors
4101
+ l = ObservatoryLocation.new(
4102
+ :id => 'MyObservatoryLocation',
4103
+ :coord_sys => @astro_coord_systems,
4104
+ :coords => @astro_coords
4105
+ )
4106
+
4107
+ assert_equal Id.new('MyObservatoryLocation'), l.id
4108
+ assert_equal @astro_coord_systems, l.coord_sys
4109
+ assert_equal @astro_coords, l.coords
4110
+ end
4111
+
4112
+ def test_relationships
4113
+ l = ObservatoryLocation.new(
4114
+ :id => 'MyObservatoryLocation',
4115
+ :coord_sys => @astro_coord_systems,
4116
+ :coords => @astro_coords
4117
+ )
4118
+
4119
+ assert_kind_of StcDescription, l
4120
+ end
4121
+
4122
+ def test_xml
4123
+ l1 = ObservatoryLocation.new(
4124
+ :id => 'ROSAT',
4125
+ :coord_sys => @astro_coord_systems,
4126
+ :coords => @astro_coords
4127
+ )
4128
+
4129
+ l2 = ObservatoryLocation.from_xml(l1.to_xml)
4130
+ assert_equal l1, l2
4131
+ end
4132
+ end
4133
+
4134
+ class ObservationLocationTest < ::Test::Unit::TestCase
4135
+ def setup
4136
+ @astro_coord_systems = [AstroCoordSystem.new(
4137
+ :id => 'FK5-UTC-Energy',
4138
+ :time_frame => TimeFrame.new(
4139
+ :name => 'TimeUTC',
4140
+ :time_scale => TimeScale.new('UTC'),
4141
+ :reference_position => Topocenter.new
4142
+ ),
4143
+ :space_frame => SpaceFrame.new(
4144
+ :name => 'FK5Spher',
4145
+ :space_ref_frame => Fk5.new(CoordEquinox.new('J2000.0')),
4146
+ :reference_position => Topocenter.new,
4147
+ :coord_flavor => Spherical.new(2)
4148
+ )
4149
+ )]
4150
+
4151
+ @astro_coords = AstroCoords.new(
4152
+ :coord_system_id => 'FK5-UTC-Energy',
4153
+ :time => TimeCoordinate.new(
4154
+ :unit => TimeUnit.new('s'),
4155
+ :time_instant => AstronTime.new(
4156
+ TimeScale.new('UTC'),
4157
+ MJDTime.new(49192.57)
4158
+ ),
4159
+ :error => Error.new(0.1),
4160
+ :resolution => Resolution.new(22955),
4161
+ :pix_size => PixSize.new(22955)
4162
+ ),
4163
+ :position => Position2D.new(
4164
+ :name => 'RA,Dec',
4165
+ :unit => PosUnit.new('deg'),
4166
+ :value => Value2.new([233.73, 23.49]),
4167
+ :error => Error2.new([0.005, 0.005]),
4168
+ :resolution => Resolution2.new([0.01, 0.01]),
4169
+ :pix_size => PixSize2.new([0.0041667, 0.0041667])
4170
+ ),
4171
+ :spectral => Spectral.new(
4172
+ :name => 'Energy',
4173
+ :unit => SpectralUnit.new('keV'),
4174
+ :value => Value.new(1.0),
4175
+ :error => Error.new(0.1),
4176
+ :resolution => Resolution.new(2.3),
4177
+ :pix_size => PixSize.new(2.3)
4178
+ )
4179
+ )
4180
+
4181
+ @astro_coord_areas = AstroCoordArea.new(
4182
+ :coord_system_id => 'FK5-UTC-Energy',
4183
+ :id => 'ROSATFIELD',
4184
+ :time_intervals => [
4185
+ TimeIntervalType.new(
4186
+ :fill_factor => 0.025,
4187
+ :start_time => AstronTime.new('UTC', ISOTime.new('1993-07-24T13:47:39')),
4188
+ :stop_time => AstronTime.new('UTC', ISOTime.new('1993-08-03T21:17:42'))
4189
+ )
4190
+ ],
4191
+ :spatial_interval => Region.new(
4192
+ :region => Circle.new(
4193
+ :coord_system_id => 'FK5-UTC-Energy',
4194
+ :unit => PosUnit.new('deg'),
4195
+ :center => Double2.new([233.73, 23.49]),
4196
+ :radius => 1.0
4197
+ )
4198
+ ),
4199
+ :spectral_intervals => [
4200
+ SpectralInterval.new(:unit => SpectralUnit.new('keV'), :lo_limit => 0.1, :hi_limit => 2.4)
4201
+ ]
4202
+ )
4203
+ end
4204
+
4205
+ def test_construction
4206
+ assert_nothing_raised {
4207
+ ObservationLocation.new(
4208
+ :coord_sys => @astro_coord_systems,
4209
+ :coords => @astro_coords,
4210
+ :coord_areas => @astro_coord_areas
4211
+ )
4212
+ }
4213
+
4214
+ assert_raises ArgumentError do
4215
+ ObservationLocation.new(
4216
+ :coord_sys => @astro_coord_systems,
4217
+ :coords => @astro_coords
4218
+ )
4219
+ end
4220
+ assert_raises ArgumentError do
4221
+ ObservationLocation.new(
4222
+ :coord_sys => @astro_coord_systems,
4223
+ :coord_areas => @astro_coord_areas
4224
+ )
4225
+ end
4226
+ assert_raises ArgumentError do
4227
+ ObservationLocation.new(
4228
+ :coords => @astro_coords,
4229
+ :coord_areas => @astro_coord_areas
4230
+ )
4231
+ end
4232
+
4233
+ assert_raises TypeError do
4234
+ ObservationLocation.new(
4235
+ :coord_sys => 'blah',
4236
+ :coords => @astro_coords,
4237
+ :coord_areas => @astro_coord_areas
4238
+ )
4239
+ end
4240
+ assert_raises TypeError do
4241
+ ObservationLocation.new(
4242
+ :coord_sys => @astro_coord_systems,
4243
+ :coords => 'blah',
4244
+ :coord_areas => @astro_coord_areas
4245
+ )
4246
+ end
4247
+ assert_raises TypeError do
4248
+ ObservationLocation.new(
4249
+ :coord_sys => @astro_coord_systems,
4250
+ :coords => @astro_coords,
4251
+ :coord_areas => 'blah'
4252
+ )
4253
+ end
4254
+ end
4255
+
4256
+ def test_accessors
4257
+ l = ObservationLocation.new(
4258
+ :coord_sys => @astro_coord_systems,
4259
+ :coords => @astro_coords,
4260
+ :coord_areas => @astro_coord_areas
4261
+ )
4262
+
4263
+ assert_equal @astro_coord_systems, l.coord_sys
4264
+ assert_equal @astro_coords, l.coords
4265
+ assert_equal @astro_coord_areas, l.coord_areas
4266
+ end
4267
+
4268
+ def test_relationships
4269
+ l = ObservationLocation.new(
4270
+ :coord_sys => @astro_coord_systems,
4271
+ :coords => @astro_coords,
4272
+ :coord_areas => @astro_coord_areas
4273
+ )
4274
+
4275
+ assert_kind_of StcDescription, l
4276
+ end
4277
+
4278
+ def test_xml
4279
+ l1 = ObservationLocation.new(
4280
+ :id => 'US701411P.N1',
4281
+ :coord_sys => @astro_coord_systems,
4282
+ :coords => @astro_coords,
4283
+ :coord_areas => @astro_coord_areas
4284
+ )
4285
+
4286
+ l2 = ObservationLocation.from_xml(l1.to_xml)
4287
+ assert_equal l1, l2
4288
+ end
4289
+ end
4290
+
4291
+ class PixelSpaceTest < ::Test::Unit::TestCase
4292
+ def setup
4293
+ @pixel_coord_systems = PixelCoordSystem.new(
4294
+ :id => 'US701411P.N1Pix',
4295
+ :pixel_coord_frames => [
4296
+ PixelCoordFrame.new(:name => 'X'),
4297
+ PixelCoordFrame.new(:name => 'Y')
4298
+ ]
4299
+ )
4300
+
4301
+ @pixel_coords = [
4302
+ PixelCoords.new(
4303
+ :coordinates => [PixelCoordinate.new(:value => 2.3)],
4304
+ :coord_system_id => IdRef.new('ref')
4305
+ )
4306
+ ]
4307
+
4308
+ @pixel_coord_areas = PixelCoordArea.new(
4309
+ :coord_system_id => 'US701411P.N1Pix',
4310
+ :id => 'US701411P.N1PixImage',
4311
+ :coord_intervals => [
4312
+ CoordScalarInterval.new(:fill_factor => 0.9, :lo_limit => 1.0, :hi_limit => 1024.0),
4313
+ CoordScalarInterval.new(:fill_factor => 0.9, :lo_limit => 1.0, :hi_limit => 1024.0)
4314
+ ]
4315
+ )
4316
+ end
4317
+
4318
+ def test_construction
4319
+ assert_nothing_raised {
4320
+ PixelSpace.new(
4321
+ :id => 'MyPixelSpace',
4322
+ :coord_sys => @pixel_coord_systems,
4323
+ :coords => @pixel_coords,
4324
+ :coord_areas => @pixel_coord_areas
4325
+ )
4326
+
4327
+ PixelSpace.new(
4328
+ :id => 'MyPixelSpace',
4329
+ :coord_sys => @pixel_coord_systems,
4330
+ :coord_areas => @pixel_coord_areas
4331
+ )
4332
+ }
4333
+
4334
+ assert_raises ArgumentError do
4335
+ PixelSpace.new(
4336
+ :id => 'MyPixelSpace',
4337
+ :coords => @pixel_coords,
4338
+ :coord_areas => @pixel_coord_areas
4339
+ )
4340
+ end
4341
+ assert_raises ArgumentError do
4342
+ PixelSpace.new(
4343
+ :id => 'MyPixelSpace',
4344
+ :coord_sys => @pixel_coord_systems,
4345
+ :coords => @pixel_coords
4346
+ )
4347
+ end
4348
+
4349
+ assert_raises TypeError do
4350
+ PixelSpace.new(
4351
+ :id => 'MyPixelSpace',
4352
+ :coord_sys => 'blah',
4353
+ :coords => @pixel_coords,
4354
+ :coord_areas => @pixel_coord_areas
4355
+ )
4356
+ end
4357
+ assert_raises TypeError do
4358
+ PixelSpace.new(
4359
+ :id => 'MyPixelSpace',
4360
+ :coord_sys => @pixel_coord_systems,
4361
+ :coords => 'blah',
4362
+ :coord_areas => @pixel_coord_areas
4363
+ )
4364
+ end
4365
+ assert_raises TypeError do
4366
+ PixelSpace.new(
4367
+ :id => 'MyPixelSpace',
4368
+ :coord_sys => @pixel_coord_systems,
4369
+ :coords => @pixel_coords,
4370
+ :coord_areas => 'blah'
4371
+ )
4372
+ end
4373
+ end
4374
+
4375
+ def test_accessors
4376
+ s = PixelSpace.new(
4377
+ :id => 'MyPixelSpace',
4378
+ :coord_sys => @pixel_coord_systems,
4379
+ :coords => @pixel_coords,
4380
+ :coord_areas => @pixel_coord_areas
4381
+ )
4382
+
4383
+ assert_equal Id.new('MyPixelSpace'), s.id
4384
+ assert_equal @pixel_coord_systems, s.coord_sys
4385
+ assert_equal @pixel_coords, s.coords
4386
+ assert_equal @pixel_coord_areas, s.coord_areas
4387
+ end
4388
+
4389
+ def test_relationships
4390
+ s = PixelSpace.new(
4391
+ :id => 'MyPixelSpace',
4392
+ :coord_sys => @pixel_coord_systems,
4393
+ :coords => @pixel_coords,
4394
+ :coord_areas => @pixel_coord_areas
4395
+ )
4396
+
4397
+ assert_kind_of StcDescription, s
4398
+ end
4399
+
4400
+ def test_xml
4401
+ s1 = PixelSpace.new(
4402
+ :id => 'MyPixelSpace',
4403
+ :coord_sys => @pixel_coord_systems,
4404
+ :coords => @pixel_coords,
4405
+ :coord_areas => @pixel_coord_areas
4406
+ )
4407
+
4408
+ s2 = PixelSpace.from_xml(s1.to_xml)
4409
+ assert_equal s1, s2
4410
+ end
4411
+ end
4412
+
4413
+ class ObsDataLocationTypeTest < ::Test::Unit::TestCase
4414
+ def setup
4415
+ @observatory_location = ObservatoryLocation.new(
4416
+ :id => 'ROSAT',
4417
+ :coord_sys => [AstroCoordSystem.new(
4418
+ :id => 'FK5-UTC-VEL',
4419
+ :time_frame => TimeFrame.new(
4420
+ :name => 'Time',
4421
+ :time_scale => TimeScale.new('UTC'),
4422
+ :reference_position => Topocenter.new
4423
+ ),
4424
+ :space_frame => SpaceFrame.new(
4425
+ :name => 'FK5Cart+Vel',
4426
+ :space_ref_frame => Fk5.new(CoordEquinox.new('J2000.0')),
4427
+ :reference_position => Topocenter.new,
4428
+ :coord_flavor => Cartesian.new(3, true)
4429
+ )
4430
+ )],
4431
+ :coords => AstroCoords.new(
4432
+ :coord_system_id => 'FK5-UTC-VEL',
4433
+ :coord_file => AstroCoordsFile.new(
4434
+ :file => Fits.new(:hdu_num => 1, :uri => 'http://MySpace.edu/OrbitEphemeris.fits'),
4435
+ :time => CoordFitsColumns.new(:name => 'Time', :value => 'VALUE'),
4436
+ :position => CoordFitsColumns.new(:name => 'Position', :value => 'X,Y,Z'),
4437
+ :velocity => CoordFitsColumns.new(:name => 'Velocity', :value => 'VX,VY,VZ')
4438
+ )
4439
+ )
4440
+ )
4441
+
4442
+ @observation_location = ObservationLocation.new(
4443
+ :coord_sys => [AstroCoordSystem.new(
4444
+ :id => 'FK5-UTC-Energy',
4445
+ :time_frame => TimeFrame.new(
4446
+ :name => 'TimeUTC',
4447
+ :time_scale => TimeScale.new('UTC'),
4448
+ :reference_position => Topocenter.new
4449
+ ),
4450
+ :space_frame => SpaceFrame.new(
4451
+ :name => 'FK5Spher',
4452
+ :space_ref_frame => Fk5.new(CoordEquinox.new('J2000.0')),
4453
+ :reference_position => Topocenter.new,
4454
+ :coord_flavor => Spherical.new(2)
4455
+ )
4456
+ )],
4457
+ :coords => AstroCoords.new(
4458
+ :coord_system_id => 'FK5-UTC-Energy',
4459
+ :time => TimeCoordinate.new(
4460
+ :unit => TimeUnit.new('s'),
4461
+ :time_instant => AstronTime.new(
4462
+ TimeScale.new('UTC'),
4463
+ MJDTime.new(49192.57)
4464
+ ),
4465
+ :error => Error.new(0.1),
4466
+ :resolution => Resolution.new(22955),
4467
+ :pix_size => PixSize.new(22955)
4468
+ ),
4469
+ :position => Position2D.new(
4470
+ :name => 'RA,Dec',
4471
+ :unit => PosUnit.new('deg'),
4472
+ :value => Value2.new([233.73, 23.49]),
4473
+ :error => Error2.new([0.005, 0.005]),
4474
+ :resolution => Resolution2.new([0.01, 0.01]),
4475
+ :pix_size => PixSize2.new([0.0041667, 0.0041667])
4476
+ ),
4477
+ :spectral => Spectral.new(
4478
+ :name => 'Energy',
4479
+ :unit => SpectralUnit.new('keV'),
4480
+ :value => Value.new(1.0),
4481
+ :error => Error.new(0.1),
4482
+ :resolution => Resolution.new(2.3),
4483
+ :pix_size => PixSize.new(2.3)
4484
+ )
4485
+ ),
4486
+ :coord_areas => AstroCoordArea.new(
4487
+ :coord_system_id => 'FK5-UTC-Energy',
4488
+ :id => 'ROSATFIELD',
4489
+ :time_intervals => [
4490
+ TimeIntervalType.new(
4491
+ :fill_factor => 0.025,
4492
+ :start_time => AstronTime.new('UTC', ISOTime.new('1993-07-24T13:47:39')),
4493
+ :stop_time => AstronTime.new('UTC', ISOTime.new('1993-08-03T21:17:42'))
4494
+ )
4495
+ ],
4496
+ :spatial_interval => Region.new(
4497
+ :region => Circle.new(
4498
+ :coord_system_id => 'FK5-UTC-Energy',
4499
+ :unit => PosUnit.new('deg'),
4500
+ :center => Double2.new([233.73, 23.49]),
4501
+ :radius => 1.0
4502
+ )
4503
+ ),
4504
+ :spectral_intervals => [
4505
+ SpectralInterval.new(:unit => SpectralUnit.new('keV'), :lo_limit => 0.1, :hi_limit => 2.4)
4506
+ ]
4507
+ )
4508
+ )
4509
+
4510
+ @pixel_space = PixelSpace.new(
4511
+ :coord_sys => PixelCoordSystem.new(
4512
+ :id => 'US701411P.N1Pix',
4513
+ :pixel_coord_frames => [
4514
+ PixelCoordFrame.new(:name => 'X'),
4515
+ PixelCoordFrame.new(:name => 'Y')
4516
+ ]
4517
+ ),
4518
+ :coord_areas => PixelCoordArea.new(
4519
+ :coord_system_id => 'US701411P.N1Pix',
4520
+ :id => 'US701411P.N1PixImage',
4521
+ :coord_intervals => [
4522
+ CoordScalarInterval.new(:fill_factor => 0.9, :lo_limit => 1.0, :hi_limit => 1024.0),
4523
+ CoordScalarInterval.new(:fill_factor => 0.9, :lo_limit => 1.0, :hi_limit => 1024.0)
4524
+ ]
4525
+ )
4526
+ )
4527
+ end
4528
+
4529
+ def test_construction
4530
+ assert_nothing_raised {
4531
+ ObsDataLocationType.new(
4532
+ :observatory_location => @observatory_location,
4533
+ :observation_location => @observation_location,
4534
+ :pixel_space => @pixel_space
4535
+ )
4536
+
4537
+ ObsDataLocationType.new(
4538
+ :observatory_location => @observatory_location,
4539
+ :observation_location => @observation_location
4540
+ )
4541
+ }
4542
+
4543
+ assert_raises ArgumentError do
4544
+ ObsDataLocationType.new(
4545
+ :observatory_location => @observatory_location
4546
+ )
4547
+ end
4548
+ assert_raises ArgumentError do
4549
+ ObsDataLocationType.new(
4550
+ :observation_location => @observation_location
4551
+ )
4552
+ end
4553
+
4554
+ assert_raises TypeError do
4555
+ ObsDataLocationType.new(
4556
+ :observatory_location => 'blah',
4557
+ :observation_location => @observation_location,
4558
+ :pixel_space => @pixel_space
4559
+ )
4560
+ end
4561
+ assert_raises TypeError do
4562
+ ObsDataLocationType.new(
4563
+ :observatory_location => @observatory_location,
4564
+ :observation_location => 'blah',
4565
+ :pixel_space => @pixel_space
4566
+ )
4567
+ end
4568
+ assert_raises TypeError do
4569
+ ObsDataLocationType.new(
4570
+ :observatory_location => @observatory_location,
4571
+ :observation_location => @observation_location,
4572
+ :pixel_space => 'blah'
4573
+ )
4574
+ end
4575
+ end
4576
+
4577
+ def test_accessors
4578
+ l = ObsDataLocationType.new(
4579
+ :observatory_location => @observatory_location,
4580
+ :observation_location => @observation_location,
4581
+ :pixel_space => @pixel_space
4582
+ )
4583
+
4584
+ assert_equal @observatory_location, l.observatory_location
4585
+ assert_equal @observation_location, l.observation_location
4586
+ assert_equal @pixel_space, l.pixel_space
4587
+ end
4588
+
4589
+ def test_relationships
4590
+ l = ObsDataLocationType.new(
4591
+ :observatory_location => @observatory_location,
4592
+ :observation_location => @observation_location,
4593
+ :pixel_space => @pixel_space
4594
+ )
4595
+
4596
+ assert_kind_of StcMetadataType, l
4597
+ end
4598
+
4599
+ def test_xml
4600
+ l1 = ObsDataLocationType.new(
4601
+ :observatory_location => @observatory_location,
4602
+ :observation_location => @observation_location,
4603
+ :pixel_space => @pixel_space
4604
+ )
4605
+
4606
+ l2 = ObsDataLocationType.from_xml(l1.to_xml)
4607
+ assert_equal l1, l2
4608
+ end
4609
+
4610
+ def test_real_world
4611
+ l1 = ObsDataLocationType.new(
4612
+ :observatory_location => @observatory_location,
4613
+ :observation_location => @observation_location,
4614
+ :pixel_space => @pixel_space
4615
+ )
4616
+
4617
+ l2 = ObsDataLocationType.from_xml(File.new('test/voruby/stc/1.10/stc-obs-data-location.xml'))
4618
+ assert_equal l1, l2
4619
+ end
4620
+ end
4621
+
4622
+ end
4623
+ end
4624
+ end
4625
+ end
4626
+ end