miriad 4.1.0.14 → 4.1.0.16
Sign up to get free protection for your applications and to get access to all the features.
- data/README +1 -1
- data/Rakefile +2 -2
- data/ext/extconf.rb +1 -1
- data/ext/miriad.i +1 -1
- data/ext/miriad_ruby.c +1 -1
- data/ext/miriad_ruby.i +20 -20
- data/ext/miriad_wrap.c +172 -424
- data/ext/narray_ruby.swg +1 -1
- data/lib/miriad.rb +78 -75
- metadata +34 -13
data/ext/narray_ruby.swg
CHANGED
data/lib/miriad.rb
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
# astronomy related methods to Ruby classes.
|
8
8
|
#
|
9
9
|
#--
|
10
|
-
# $Id
|
10
|
+
# $Id$
|
11
11
|
#++
|
12
12
|
|
13
13
|
require 'rbconfig'
|
@@ -15,7 +15,7 @@ require 'rubygems'
|
|
15
15
|
require 'date'
|
16
16
|
require 'enumerator'
|
17
17
|
require 'narray'
|
18
|
-
miriad_shared_lib = 'miriad.' +
|
18
|
+
miriad_shared_lib = 'miriad.' + RbConfig::CONFIG['DLEXT']
|
19
19
|
require miriad_shared_lib
|
20
20
|
require 'miriad_gem' if false # Fake out RDoc
|
21
21
|
#require 'fftw3'
|
@@ -23,51 +23,53 @@ require 'miriad_gem' if false # Fake out RDoc
|
|
23
23
|
# Add CKMS constant to Math module
|
24
24
|
Math::const_set :CKMS, 299792.458 unless Math::const_defined? :CKMS
|
25
25
|
|
26
|
-
# The MIRIAD package
|
27
|
-
module
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
26
|
+
# The MIRIAD package provides a Miriad::AngleConversion module
|
27
|
+
module Miriad
|
28
|
+
module AngleConversion
|
29
|
+
# Convert possibly non-integer degrees +fr+ to [degrees, minutes, seconds]
|
30
|
+
# where degrees and minutes are integers.
|
31
|
+
def d_to_dms(fr)
|
32
|
+
sign = fr <=> 0
|
33
|
+
fr *= sign
|
34
|
+
d = fr.to_i; fr %= 1; fr *= 60
|
35
|
+
m = fr.to_i; fr %= 1; fr *= 60
|
36
|
+
return d*sign, m, fr
|
37
|
+
end
|
38
|
+
module_function :d_to_dms
|
39
|
+
|
40
|
+
# Convert possibly non-integer hours +fr+ to [hours, minutes, seconds]
|
41
|
+
# where hours and minutes are integers.
|
42
|
+
def h_to_hms(fr); d_to_dms(fr); end; module_function :h_to_hms
|
43
|
+
|
44
|
+
# Convert degrees, minutes, seconds to possibly non-integer degrees.
|
45
|
+
# Missing arguments are assumed to be 0.
|
46
|
+
def dms_to_d(*args)
|
47
|
+
d = 0.to_r
|
48
|
+
d += args.shift unless args.empty?
|
49
|
+
sign = d < 0 ? -1 : 1
|
50
|
+
d += args.shift * Rational(sign,60) unless args.empty?
|
51
|
+
d += args.shift * Rational(sign,3600) unless args.empty?
|
52
|
+
return d
|
53
|
+
end
|
54
|
+
module_function :dms_to_d
|
55
|
+
|
56
|
+
# Convert hours, minutes, seconds to possibly non-integer hours.
|
57
|
+
# Missing arguments are assumed to be 0.
|
58
|
+
def hms_to_h(*args); dms_to_d(*args); end
|
59
|
+
|
60
|
+
# Convert degrees to radians
|
61
|
+
def d2r(d) d*Math::PI/180; end; module_function :d2r
|
62
|
+
# Convert radians to degrees
|
63
|
+
def r2d(r) r*180/Math::PI; end; module_function :r2d
|
64
|
+
# Convert hours to radians
|
65
|
+
def h2r(h) h*Math::PI/12; end; module_function :h2r
|
66
|
+
# Convert radians to hours
|
67
|
+
def r2h(r) r*12/Math::PI; end; module_function :r2h
|
68
|
+
# Convert degrees to hours
|
69
|
+
def d2h(d) d/15.0; end; module_function :d2h
|
70
|
+
# Convert hours to degrees
|
71
|
+
def h2d(h) h*15.0; end; module_function :h2d
|
52
72
|
end
|
53
|
-
module_function :dms_to_d
|
54
|
-
|
55
|
-
# Convert hours, minutes, seconds to possibly non-integer hours.
|
56
|
-
# Missing arguments are assumed to be 0.
|
57
|
-
def hms_to_h(*args); dms_to_d(*args); end
|
58
|
-
|
59
|
-
# Convert degrees to radians
|
60
|
-
def d2r(d) d*PI/180; end; module_function :d2r
|
61
|
-
# Convert radians to degrees
|
62
|
-
def r2d(r) r*180/PI; end; module_function :r2d
|
63
|
-
# Convert hours to radians
|
64
|
-
def h2r(h) h*PI/12; end; module_function :h2r
|
65
|
-
# Convert radians to hours
|
66
|
-
def r2h(r) r*12/PI; end; module_function :r2h
|
67
|
-
# Convert degrees to hours
|
68
|
-
def d2h(d) d/15.0; end; module_function :d2h
|
69
|
-
# Convert hours to degrees
|
70
|
-
def h2d(h) h*15.0; end; module_function :h2d
|
71
73
|
end
|
72
74
|
|
73
75
|
# The MIRIAD package adds angle conversion and angle formatting methods to
|
@@ -75,7 +77,7 @@ end
|
|
75
77
|
class Numeric
|
76
78
|
# Convert +self+ to [degrees, minutes, seconds] where degrees and minutes are
|
77
79
|
# integers.
|
78
|
-
def to_dms()
|
80
|
+
def to_dms() Miriad::AngleConversion.d_to_dms(self); end
|
79
81
|
# Convert +self+ to [hours, minutes, seconds] where hours and minutes are
|
80
82
|
# integers.
|
81
83
|
alias :to_hms :to_dms
|
@@ -89,25 +91,25 @@ class Numeric
|
|
89
91
|
width = prec == 0 ? 2 : prec+3
|
90
92
|
"%02d:%02d:%0#{width}.#{prec}f" % to_dms
|
91
93
|
end
|
92
|
-
# Convert +self+ from degrees to radians (i.e. <tt>
|
93
|
-
def d2r()
|
94
|
-
# Convert +self+ from radians to degrees (i.e. <tt>
|
95
|
-
def r2d()
|
96
|
-
# Convert +self+ from hours to radians (i.e. <tt>
|
97
|
-
def h2r()
|
98
|
-
# Convert +self+ from radians to hours (i.e. <tt>
|
99
|
-
def r2h()
|
100
|
-
# Convert +self+ from degrees to hours (i.e. <tt>
|
101
|
-
def d2h()
|
102
|
-
# Convert +self+ from hours to degrees (i.e. <tt>
|
103
|
-
def h2d()
|
94
|
+
# Convert +self+ from degrees to radians (i.e. <tt>Miriad::AngleConversion.d2r(self)</tt>).
|
95
|
+
def d2r() Miriad::AngleConversion.d2r(self); end
|
96
|
+
# Convert +self+ from radians to degrees (i.e. <tt>Miriad::AngleConversion.r2d(self)</tt>).
|
97
|
+
def r2d() Miriad::AngleConversion.r2d(self); end
|
98
|
+
# Convert +self+ from hours to radians (i.e. <tt>Miriad::AngleConversion.h2r(self)</tt>).
|
99
|
+
def h2r() Miriad::AngleConversion.h2r(self); end
|
100
|
+
# Convert +self+ from radians to hours (i.e. <tt>Miriad::AngleConversion.r2h(self)</tt>).
|
101
|
+
def r2h() Miriad::AngleConversion.r2h(self); end
|
102
|
+
# Convert +self+ from degrees to hours (i.e. <tt>Miriad::AngleConversion.d2h(self)</tt>).
|
103
|
+
def d2h() Miriad::AngleConversion.d2h(self); end
|
104
|
+
# Convert +self+ from hours to degrees (i.e. <tt>Miriad::AngleConversion.h2d(self)</tt>).
|
105
|
+
def h2d() Miriad::AngleConversion.h2d(self); end
|
104
106
|
end
|
105
107
|
|
106
108
|
# The MIRIAD package adds angle conversion methods to Array class.
|
107
109
|
class Array
|
108
110
|
# Convert +self+ from [degrees, minutes, seconds] to degrees.
|
109
111
|
# Missing arguments are assumed to be 0.
|
110
|
-
def dms_to_d;
|
112
|
+
def dms_to_d; Miriad::AngleConversion::dms_to_d(*self); end
|
111
113
|
# Convert +self+ from [hours, minutes, seconds] to hours.
|
112
114
|
# Missing arguments are assumed to be 0.
|
113
115
|
alias :hms_to_h :dms_to_d
|
@@ -117,7 +119,7 @@ end
|
|
117
119
|
class String
|
118
120
|
# Parse a "dd:mm:ss.sss" String to Numeric degrees.
|
119
121
|
# <b>NOT</b> the inverse of Numeric#to_dmsstr (but may become so).
|
120
|
-
def dms_to_d;
|
122
|
+
def dms_to_d; Miriad::AngleConversion::dms_to_d(*split(':').map{|s| s.to_f}); end
|
121
123
|
# Parse a "hh:mm:ss.sss" String to Float hours.
|
122
124
|
alias :hms_to_h :dms_to_d
|
123
125
|
end
|
@@ -127,7 +129,7 @@ end
|
|
127
129
|
class DateTime
|
128
130
|
|
129
131
|
# The J2000 epoch
|
130
|
-
J2000 = civil(2000,1,1,12)
|
132
|
+
J2000 = civil(2000,1,1,12) unless const_defined? :J2000
|
131
133
|
|
132
134
|
# The sidereal rotation rate of Earth in radians per second
|
133
135
|
OMEGA = 7.29211538e-5
|
@@ -150,10 +152,10 @@ class DateTime
|
|
150
152
|
# http://www.iers.org/products/6/11136/orig/bulletina-xx-042.txt
|
151
153
|
def ut2_ut1
|
152
154
|
pi2t=Math::PI*2*(by%1)
|
153
|
-
ENV['UT2_UT1'] || 0.022 * Math
|
154
|
-
- 0.012 * Math
|
155
|
-
- 0.006 * Math
|
156
|
-
+ 0.007 * Math
|
155
|
+
ENV['UT2_UT1'] || 0.022 * Math.sin(pi2t) \
|
156
|
+
- 0.012 * Math.cos(pi2t) \
|
157
|
+
- 0.006 * Math.sin(2*pi2t) \
|
158
|
+
+ 0.007 * Math.cos(2*pi2t)
|
157
159
|
end
|
158
160
|
|
159
161
|
# UT1-UTC (unit is seconds) at the time represented by +self+
|
@@ -965,15 +967,16 @@ module Miriad
|
|
965
967
|
opts.merge!(args.pop) if Hash === args[-1]
|
966
968
|
return nil unless ap = getvr('antpos')
|
967
969
|
args.flatten!
|
968
|
-
|
970
|
+
n = ap.length/3
|
971
|
+
ap = [ap[0*n...1*n], ap[1*n...2*n], ap[2*n...3*n]].transpose.unshift([0,0,0])
|
969
972
|
ap = ap.values_at(*args.flatten) if args.length > 0
|
970
973
|
|
971
974
|
# Do units scaling, if requested
|
972
975
|
scale = case opts[:units]
|
973
|
-
when :ns
|
974
|
-
when :meter
|
975
|
-
when :lambda
|
976
|
-
when :klambda
|
976
|
+
when :ns; nil
|
977
|
+
when :meter; Math::CKMS / 1e6
|
978
|
+
when :lambda; getvr('freq') || 1.0
|
979
|
+
when :klambda; (getvr('freq') || 1.0) / 1000
|
977
980
|
else raise "Unrecognized units '#{opts[:units]}'"
|
978
981
|
end
|
979
982
|
ap.map!{|p| p.map!{|c| c*scale}} if scale
|
@@ -1010,8 +1013,8 @@ module Miriad
|
|
1010
1013
|
def baseline(*args)
|
1011
1014
|
opts = (Hash === args[-1]) ? args.pop : {}
|
1012
1015
|
a1, a2 = case args.length
|
1013
|
-
when 0
|
1014
|
-
when 2
|
1016
|
+
when 0; basant
|
1017
|
+
when 2; args
|
1015
1018
|
else raise ArgumentError(
|
1016
1019
|
"wrong number of arguments (#{args.length} for 0 or 2)")
|
1017
1020
|
end
|
@@ -1194,8 +1197,8 @@ module Miriad
|
|
1194
1197
|
# SUPPORTED!]
|
1195
1198
|
def []=(*args)
|
1196
1199
|
n, t, v = case args.length
|
1197
|
-
when 2
|
1198
|
-
when 3
|
1200
|
+
when 2; [args[0], -1, args[1]]
|
1201
|
+
when 3; [args[0], args[1], args[2]]
|
1199
1202
|
else
|
1200
1203
|
raise ArgumentError.new(
|
1201
1204
|
"wrong number of arguments (#{args.length} for 3)")
|
metadata
CHANGED
@@ -1,7 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: miriad
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 39
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 4
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
- 16
|
11
|
+
version: 4.1.0.16
|
5
12
|
platform: ruby
|
6
13
|
authors:
|
7
14
|
- David MacMahon
|
@@ -9,20 +16,25 @@ autorequire:
|
|
9
16
|
bindir: bin
|
10
17
|
cert_chain: []
|
11
18
|
|
12
|
-
date:
|
13
|
-
default_executable:
|
19
|
+
date: 2012-03-29 00:00:00 Z
|
14
20
|
dependencies:
|
15
21
|
- !ruby/object:Gem::Dependency
|
16
22
|
name: narray
|
17
|
-
|
18
|
-
|
19
|
-
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
20
26
|
requirements:
|
21
27
|
- - ">="
|
22
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 25
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
- 5
|
33
|
+
- 9
|
23
34
|
version: 0.5.9
|
24
|
-
|
25
|
-
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
description: " The MIRIAD-Ruby package...\n\n 1. Makes MIRIAD datasets accessible from Ruby by wrapping\n the MIRIAD UVIO routines.\n\n 2. Makes Ruby usable with MIRIAD datasets by adding convenience,\n utility, and astronomy related methods to Ruby classes.\n"
|
26
38
|
email: davidm@astro.berkeley.edu
|
27
39
|
executables: []
|
28
40
|
|
@@ -58,8 +70,9 @@ files:
|
|
58
70
|
- ext/maxdimc.h.in
|
59
71
|
- ext/extconf.rb
|
60
72
|
- ext/narray_ruby.swg
|
61
|
-
has_rdoc: true
|
62
73
|
homepage: http://miriad.rubyforge.org/
|
74
|
+
licenses: []
|
75
|
+
|
63
76
|
post_install_message:
|
64
77
|
rdoc_options:
|
65
78
|
- -S
|
@@ -73,23 +86,31 @@ require_paths:
|
|
73
86
|
- lib
|
74
87
|
- ext
|
75
88
|
required_ruby_version: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
76
90
|
requirements:
|
77
91
|
- - ">="
|
78
92
|
- !ruby/object:Gem::Version
|
93
|
+
hash: 63
|
94
|
+
segments:
|
95
|
+
- 1
|
96
|
+
- 8
|
97
|
+
- 4
|
79
98
|
version: 1.8.4
|
80
|
-
version:
|
81
99
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
none: false
|
82
101
|
requirements:
|
83
102
|
- - ">="
|
84
103
|
- !ruby/object:Gem::Version
|
104
|
+
hash: 3
|
105
|
+
segments:
|
106
|
+
- 0
|
85
107
|
version: "0"
|
86
|
-
version:
|
87
108
|
requirements: []
|
88
109
|
|
89
110
|
rubyforge_project: miriad
|
90
|
-
rubygems_version: 1.
|
111
|
+
rubygems_version: 1.8.12
|
91
112
|
signing_key:
|
92
|
-
specification_version:
|
113
|
+
specification_version: 3
|
93
114
|
summary: Ruby interface to MIRIAD
|
94
115
|
test_files: []
|
95
116
|
|