miriad 4.1.0.2 → 4.1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +2 -2
- data/ext/miriad_ruby.c +6 -19
- data/ext/miriad_ruby.i +1 -27
- data/ext/miriad_wrap.c +0 -88
- data/lib/miriad.rb +26 -23
- metadata +2 -2
data/Rakefile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# $Id: Rakefile
|
1
|
+
# $Id: Rakefile 18 2008-04-23 17:31:29Z davidm $
|
2
2
|
|
3
3
|
require 'rubygems'
|
4
4
|
require 'rake/gempackagetask'
|
@@ -14,7 +14,7 @@ run_swig unless test ?e, 'ext/miriad_wrap.c'
|
|
14
14
|
spec = Gem::Specification.new do |s|
|
15
15
|
# Basics
|
16
16
|
s.name = 'miriad'
|
17
|
-
s.version = '4.1.0.
|
17
|
+
s.version = '4.1.0.4'
|
18
18
|
s.summary = 'Ruby interface to MIRIAD'
|
19
19
|
s.description = <<-EOS
|
20
20
|
The MIRIAD-Ruby package...
|
data/ext/miriad_ruby.c
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
* $Id: miriad_ruby.c
|
2
|
+
* $Id: miriad_ruby.c 18 2008-04-23 17:31:29Z davidm $
|
3
3
|
*
|
4
4
|
* This file is just to document the classes/methods from the SWIG wrappers
|
5
5
|
* that we want to document. It is for rdoc, not gcc. At least for now.
|
@@ -322,10 +322,7 @@ static VALUE uvio_set;
|
|
322
322
|
* preamble will populate _w_ with 0.0 if the dataset was written with only a
|
323
323
|
* 4 element preamble.
|
324
324
|
*
|
325
|
-
* *
|
326
|
-
* NArray::DFLOAT is created and returned with the preamble data.
|
327
|
-
*
|
328
|
-
* * Otherwise +preamble+ must be passed in as an Array or NArray (of type
|
325
|
+
* * +preamble+ must be passed in as an Array or NArray (of type
|
329
326
|
* NArray::DFLOAT) of suitable length (i.e. either 4 or 5). Its contents
|
330
327
|
* will be overwritten with new premable data.
|
331
328
|
*
|
@@ -333,19 +330,14 @@ static VALUE uvio_set;
|
|
333
330
|
*
|
334
331
|
* The complex valued correlation data are returned in +data+.
|
335
332
|
*
|
336
|
-
* *
|
337
|
-
* type NArray::SCOMPLEX is created, populated with +nread+ complex data
|
338
|
-
* values, and returned.
|
339
|
-
*
|
340
|
-
* * Otherwise, +data+ must be passed in as an Array or Narray (of type
|
333
|
+
* * +data+ must be passed in as an Array or Narray (of type
|
341
334
|
* NArray::SCOMPLEX). Its contents will be overwritten with +nread+ data
|
342
335
|
* values. Note that an Array will be filled with real and imaginary
|
343
336
|
* components in consecutive elements and must therefore contain twice as
|
344
337
|
* many elements as the number of complex valued data points. In general,
|
345
338
|
* NArray +data+ will be preferred.
|
346
339
|
*
|
347
|
-
* *
|
348
|
-
* (either +data+ or <tt>data.length</tt>) must be the same as the number
|
340
|
+
* * The number of complex valued data points must be the same as the number
|
349
341
|
* of flag values, otherwise an exception will be raised. Note that the
|
350
342
|
* length of an Array is twice the number of complex valued data points
|
351
343
|
* that will fit in it.
|
@@ -355,16 +347,11 @@ static VALUE uvio_set;
|
|
355
347
|
* The +flags+ indicate whether the corresponding data value has been deemed
|
356
348
|
* good or bad. A <tt>1</tt> means good; a <tt>0</tt> means bad.
|
357
349
|
*
|
358
|
-
* *
|
359
|
-
* type NArray::LINT is created, populated with +nread+ flag values, and
|
360
|
-
* returned.
|
361
|
-
*
|
362
|
-
* * Otherwise, +flags+ must be passed in as an Array or Narray (of type
|
350
|
+
* * +flags+ must be passed in as an Array or Narray (of type
|
363
351
|
* NArray::LINT). Its contents will be overwritten with +nread+ flag
|
364
352
|
* values.
|
365
353
|
*
|
366
|
-
* *
|
367
|
-
* (either +data+ or <tt>data.length</tt>) must be the same as the number
|
354
|
+
* * The number of complex valued data points must be the same as the number
|
368
355
|
* of flag values, otherwise an exception will be raised.
|
369
356
|
*
|
370
357
|
* * +nread+
|
data/ext/miriad_ruby.i
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
/*
|
2
|
-
* $Id: miriad_ruby.i
|
2
|
+
* $Id: miriad_ruby.i 18 2008-04-23 17:31:29Z davidm $
|
3
3
|
*
|
4
4
|
* Ruby specific typemaps for MIRIAD Swig wrapper
|
5
5
|
*/
|
@@ -20,14 +20,6 @@ VALUE mirlib_eWrappedMirlibError;
|
|
20
20
|
|
21
21
|
// Typemaps for preamble
|
22
22
|
%typemap(in) (double *preamble) {
|
23
|
-
// If FIXNUM allocate NA_DFLOAT array that many
|
24
|
-
// This only makes sense for reads (or writing zeros)
|
25
|
-
if(TYPE($input) == T_FIXNUM) {
|
26
|
-
int rank = 1;
|
27
|
-
int shape = FIX2INT($input);
|
28
|
-
VALUE naclass = rb_const_get(rb_cObject,rb_intern("NArray"));
|
29
|
-
$input = na_make_object(NA_DFLOAT,rank,&shape,naclass);
|
30
|
-
}
|
31
23
|
// If NArray
|
32
24
|
if(NA_IsNArray($input)) {
|
33
25
|
Check_NArrayType($input,NA_DFLOAT);
|
@@ -74,15 +66,6 @@ VALUE mirlib_eWrappedMirlibError;
|
|
74
66
|
// Length of complex data must be twice the length of flags
|
75
67
|
%typemap(in) (float * data) (int ndata) {
|
76
68
|
int i;
|
77
|
-
// If FIXNUM or BIGNUM, allocate NA_SCOMPLEX array that many
|
78
|
-
// This only makes sense for reads (or writing zeros)
|
79
|
-
if(TYPE($input) == T_FIXNUM || TYPE($input) == T_BIGNUM) {
|
80
|
-
ndata = NUM2INT($input);
|
81
|
-
int rank = 1;
|
82
|
-
int shape = ndata;
|
83
|
-
VALUE naclass = rb_const_get(rb_cObject,rb_intern("NArray"));
|
84
|
-
$input = na_make_object(NA_SCOMPLEX,rank,&shape,naclass);
|
85
|
-
}
|
86
69
|
// If NArray
|
87
70
|
if(NA_IsNArray($input)) {
|
88
71
|
Check_NArrayType2($input,NA_SFLOAT,NA_SCOMPLEX);
|
@@ -130,15 +113,6 @@ VALUE mirlib_eWrappedMirlibError;
|
|
130
113
|
// Length of complex data must be twice the length of flags
|
131
114
|
%typemap(in) (int * flags, int n) (int nflag) {
|
132
115
|
int i;
|
133
|
-
// If FIXNUM or BIGNUM, allocate NA_LINT array that many
|
134
|
-
// This only makes sense for reads (or writing zeros)
|
135
|
-
if(TYPE($input) == T_FIXNUM || TYPE($input) == T_BIGNUM) {
|
136
|
-
nflag = NUM2INT($input);
|
137
|
-
int rank = 1;
|
138
|
-
int shape = nflag;
|
139
|
-
VALUE naclass = rb_const_get(rb_cObject,rb_intern("NArray"));
|
140
|
-
$input = na_make_object(NA_LINT,rank,&shape,naclass);
|
141
|
-
}
|
142
116
|
// If NArray
|
143
117
|
if(NA_IsNArray($input)) {
|
144
118
|
Check_NArrayType($input,NA_LINT);
|
data/ext/miriad_wrap.c
CHANGED
@@ -2631,14 +2631,6 @@ _wrap_Uvio_write(int argc, VALUE *argv, VALUE self) {
|
|
2631
2631
|
}
|
2632
2632
|
arg1 = (uvio *)(argp1);
|
2633
2633
|
{
|
2634
|
-
// If FIXNUM allocate NA_DFLOAT array that many
|
2635
|
-
// This only makes sense for reads (or writing zeros)
|
2636
|
-
if(TYPE(argv[0]) == T_FIXNUM) {
|
2637
|
-
int rank = 1;
|
2638
|
-
int shape = FIX2INT(argv[0]);
|
2639
|
-
VALUE naclass = rb_const_get(rb_cObject,rb_intern("NArray"));
|
2640
|
-
argv[0] = na_make_object(NA_DFLOAT,rank,&shape,naclass);
|
2641
|
-
}
|
2642
2634
|
// If NArray
|
2643
2635
|
if(NA_IsNArray(argv[0])) {
|
2644
2636
|
Check_NArrayType(argv[0],NA_DFLOAT);
|
@@ -2660,15 +2652,6 @@ _wrap_Uvio_write(int argc, VALUE *argv, VALUE self) {
|
|
2660
2652
|
}
|
2661
2653
|
{
|
2662
2654
|
int i;
|
2663
|
-
// If FIXNUM or BIGNUM, allocate NA_SCOMPLEX array that many
|
2664
|
-
// This only makes sense for reads (or writing zeros)
|
2665
|
-
if(TYPE(argv[1]) == T_FIXNUM || TYPE(argv[1]) == T_BIGNUM) {
|
2666
|
-
ndata3 = NUM2INT(argv[1]);
|
2667
|
-
int rank = 1;
|
2668
|
-
int shape = ndata3;
|
2669
|
-
VALUE naclass = rb_const_get(rb_cObject,rb_intern("NArray"));
|
2670
|
-
argv[1] = na_make_object(NA_SCOMPLEX,rank,&shape,naclass);
|
2671
|
-
}
|
2672
2655
|
// If NArray
|
2673
2656
|
if(NA_IsNArray(argv[1])) {
|
2674
2657
|
Check_NArrayType2(argv[1],NA_SFLOAT,NA_SCOMPLEX);
|
@@ -2692,15 +2675,6 @@ _wrap_Uvio_write(int argc, VALUE *argv, VALUE self) {
|
|
2692
2675
|
}
|
2693
2676
|
{
|
2694
2677
|
int i;
|
2695
|
-
// If FIXNUM or BIGNUM, allocate NA_LINT array that many
|
2696
|
-
// This only makes sense for reads (or writing zeros)
|
2697
|
-
if(TYPE(argv[2]) == T_FIXNUM || TYPE(argv[2]) == T_BIGNUM) {
|
2698
|
-
nflag4 = NUM2INT(argv[2]);
|
2699
|
-
int rank = 1;
|
2700
|
-
int shape = nflag4;
|
2701
|
-
VALUE naclass = rb_const_get(rb_cObject,rb_intern("NArray"));
|
2702
|
-
argv[2] = na_make_object(NA_LINT,rank,&shape,naclass);
|
2703
|
-
}
|
2704
2678
|
// If NArray
|
2705
2679
|
if(NA_IsNArray(argv[2])) {
|
2706
2680
|
Check_NArrayType(argv[2],NA_LINT);
|
@@ -2807,15 +2781,6 @@ _wrap_Uvio_wwrite(int argc, VALUE *argv, VALUE self) {
|
|
2807
2781
|
arg1 = (uvio *)(argp1);
|
2808
2782
|
{
|
2809
2783
|
int i;
|
2810
|
-
// If FIXNUM or BIGNUM, allocate NA_SCOMPLEX array that many
|
2811
|
-
// This only makes sense for reads (or writing zeros)
|
2812
|
-
if(TYPE(argv[0]) == T_FIXNUM || TYPE(argv[0]) == T_BIGNUM) {
|
2813
|
-
ndata2 = NUM2INT(argv[0]);
|
2814
|
-
int rank = 1;
|
2815
|
-
int shape = ndata2;
|
2816
|
-
VALUE naclass = rb_const_get(rb_cObject,rb_intern("NArray"));
|
2817
|
-
argv[0] = na_make_object(NA_SCOMPLEX,rank,&shape,naclass);
|
2818
|
-
}
|
2819
2784
|
// If NArray
|
2820
2785
|
if(NA_IsNArray(argv[0])) {
|
2821
2786
|
Check_NArrayType2(argv[0],NA_SFLOAT,NA_SCOMPLEX);
|
@@ -2839,15 +2804,6 @@ _wrap_Uvio_wwrite(int argc, VALUE *argv, VALUE self) {
|
|
2839
2804
|
}
|
2840
2805
|
{
|
2841
2806
|
int i;
|
2842
|
-
// If FIXNUM or BIGNUM, allocate NA_LINT array that many
|
2843
|
-
// This only makes sense for reads (or writing zeros)
|
2844
|
-
if(TYPE(argv[1]) == T_FIXNUM || TYPE(argv[1]) == T_BIGNUM) {
|
2845
|
-
nflag3 = NUM2INT(argv[1]);
|
2846
|
-
int rank = 1;
|
2847
|
-
int shape = nflag3;
|
2848
|
-
VALUE naclass = rb_const_get(rb_cObject,rb_intern("NArray"));
|
2849
|
-
argv[1] = na_make_object(NA_LINT,rank,&shape,naclass);
|
2850
|
-
}
|
2851
2807
|
// If NArray
|
2852
2808
|
if(NA_IsNArray(argv[1])) {
|
2853
2809
|
Check_NArrayType(argv[1],NA_LINT);
|
@@ -3015,14 +2971,6 @@ _wrap_Uvio_uvread(int argc, VALUE *argv, VALUE self) {
|
|
3015
2971
|
}
|
3016
2972
|
arg1 = (uvio *)(argp1);
|
3017
2973
|
{
|
3018
|
-
// If FIXNUM allocate NA_DFLOAT array that many
|
3019
|
-
// This only makes sense for reads (or writing zeros)
|
3020
|
-
if(TYPE(argv[0]) == T_FIXNUM) {
|
3021
|
-
int rank = 1;
|
3022
|
-
int shape = FIX2INT(argv[0]);
|
3023
|
-
VALUE naclass = rb_const_get(rb_cObject,rb_intern("NArray"));
|
3024
|
-
argv[0] = na_make_object(NA_DFLOAT,rank,&shape,naclass);
|
3025
|
-
}
|
3026
2974
|
// If NArray
|
3027
2975
|
if(NA_IsNArray(argv[0])) {
|
3028
2976
|
Check_NArrayType(argv[0],NA_DFLOAT);
|
@@ -3044,15 +2992,6 @@ _wrap_Uvio_uvread(int argc, VALUE *argv, VALUE self) {
|
|
3044
2992
|
}
|
3045
2993
|
{
|
3046
2994
|
int i;
|
3047
|
-
// If FIXNUM or BIGNUM, allocate NA_SCOMPLEX array that many
|
3048
|
-
// This only makes sense for reads (or writing zeros)
|
3049
|
-
if(TYPE(argv[1]) == T_FIXNUM || TYPE(argv[1]) == T_BIGNUM) {
|
3050
|
-
ndata3 = NUM2INT(argv[1]);
|
3051
|
-
int rank = 1;
|
3052
|
-
int shape = ndata3;
|
3053
|
-
VALUE naclass = rb_const_get(rb_cObject,rb_intern("NArray"));
|
3054
|
-
argv[1] = na_make_object(NA_SCOMPLEX,rank,&shape,naclass);
|
3055
|
-
}
|
3056
2995
|
// If NArray
|
3057
2996
|
if(NA_IsNArray(argv[1])) {
|
3058
2997
|
Check_NArrayType2(argv[1],NA_SFLOAT,NA_SCOMPLEX);
|
@@ -3076,15 +3015,6 @@ _wrap_Uvio_uvread(int argc, VALUE *argv, VALUE self) {
|
|
3076
3015
|
}
|
3077
3016
|
{
|
3078
3017
|
int i;
|
3079
|
-
// If FIXNUM or BIGNUM, allocate NA_LINT array that many
|
3080
|
-
// This only makes sense for reads (or writing zeros)
|
3081
|
-
if(TYPE(argv[2]) == T_FIXNUM || TYPE(argv[2]) == T_BIGNUM) {
|
3082
|
-
nflag4 = NUM2INT(argv[2]);
|
3083
|
-
int rank = 1;
|
3084
|
-
int shape = nflag4;
|
3085
|
-
VALUE naclass = rb_const_get(rb_cObject,rb_intern("NArray"));
|
3086
|
-
argv[2] = na_make_object(NA_LINT,rank,&shape,naclass);
|
3087
|
-
}
|
3088
3018
|
// If NArray
|
3089
3019
|
if(NA_IsNArray(argv[2])) {
|
3090
3020
|
Check_NArrayType(argv[2],NA_LINT);
|
@@ -3199,15 +3129,6 @@ _wrap_Uvio_uvwread(int argc, VALUE *argv, VALUE self) {
|
|
3199
3129
|
arg1 = (uvio *)(argp1);
|
3200
3130
|
{
|
3201
3131
|
int i;
|
3202
|
-
// If FIXNUM or BIGNUM, allocate NA_SCOMPLEX array that many
|
3203
|
-
// This only makes sense for reads (or writing zeros)
|
3204
|
-
if(TYPE(argv[0]) == T_FIXNUM || TYPE(argv[0]) == T_BIGNUM) {
|
3205
|
-
ndata2 = NUM2INT(argv[0]);
|
3206
|
-
int rank = 1;
|
3207
|
-
int shape = ndata2;
|
3208
|
-
VALUE naclass = rb_const_get(rb_cObject,rb_intern("NArray"));
|
3209
|
-
argv[0] = na_make_object(NA_SCOMPLEX,rank,&shape,naclass);
|
3210
|
-
}
|
3211
3132
|
// If NArray
|
3212
3133
|
if(NA_IsNArray(argv[0])) {
|
3213
3134
|
Check_NArrayType2(argv[0],NA_SFLOAT,NA_SCOMPLEX);
|
@@ -3231,15 +3152,6 @@ _wrap_Uvio_uvwread(int argc, VALUE *argv, VALUE self) {
|
|
3231
3152
|
}
|
3232
3153
|
{
|
3233
3154
|
int i;
|
3234
|
-
// If FIXNUM or BIGNUM, allocate NA_LINT array that many
|
3235
|
-
// This only makes sense for reads (or writing zeros)
|
3236
|
-
if(TYPE(argv[1]) == T_FIXNUM || TYPE(argv[1]) == T_BIGNUM) {
|
3237
|
-
nflag3 = NUM2INT(argv[1]);
|
3238
|
-
int rank = 1;
|
3239
|
-
int shape = nflag3;
|
3240
|
-
VALUE naclass = rb_const_get(rb_cObject,rb_intern("NArray"));
|
3241
|
-
argv[1] = na_make_object(NA_LINT,rank,&shape,naclass);
|
3242
|
-
}
|
3243
3155
|
// If NArray
|
3244
3156
|
if(NA_IsNArray(argv[1])) {
|
3245
3157
|
Check_NArrayType(argv[1],NA_LINT);
|
data/lib/miriad.rb
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
# astronomy related methods to Ruby classes.
|
8
8
|
#
|
9
9
|
#--
|
10
|
-
# $Id: miriad.rb
|
10
|
+
# $Id: miriad.rb 18 2008-04-23 17:31:29Z davidm $
|
11
11
|
#++
|
12
12
|
|
13
13
|
require 'rbconfig'
|
@@ -588,18 +588,22 @@ module Miriad
|
|
588
588
|
# The MIRIAD flags
|
589
589
|
attr_accessor :flags
|
590
590
|
# Constructs a new Visibility object containing the given +preamble+,
|
591
|
-
# +data+, and +flags+ objects. Not used
|
592
|
-
# are obtained from Uvio#read.
|
591
|
+
# +data+, and +flags+ objects. Not often used directly. Usually
|
592
|
+
# Visibility objects are obtained from Uvio#read.
|
593
593
|
def initialize(preamble, data, flags)
|
594
594
|
@preamble = preamble
|
595
595
|
@data = data
|
596
596
|
@flags = flags
|
597
597
|
end
|
598
|
-
# call-seq: Visibility[
|
598
|
+
# call-seq: Visibility[nchan]
|
599
599
|
#
|
600
|
-
#
|
601
|
-
def self.[](
|
602
|
-
self.new(
|
600
|
+
# Contruct a Visibility object capable of holding +nchan+ channels of data.
|
601
|
+
def self.[](nchan)
|
602
|
+
self.new(
|
603
|
+
NArray.dfloat(5),
|
604
|
+
NArray.scomplex(nchan),
|
605
|
+
NArray.int(nchan)
|
606
|
+
)
|
603
607
|
end
|
604
608
|
# call-seq: coord() -> [u, v, w]
|
605
609
|
#
|
@@ -697,28 +701,21 @@ module Miriad
|
|
697
701
|
end
|
698
702
|
|
699
703
|
# call-seq:
|
700
|
-
# read() ->
|
701
|
-
# read(nil) -> uvread(5, nchan, nchan) -> Visibility
|
702
|
-
# read(vis) -> uvread(vis.preamble, vis.data, vis.flags) -> Visibility
|
703
|
-
# read(*args) -> uvread(*args) -> Visibility
|
704
|
+
# read(vis=nil) -> vis or Visibility[nchan] or nil
|
704
705
|
#
|
705
706
|
# Convenience wrapper around uvread. Shortens data and flags if they were
|
706
707
|
# passed in longer than necessary. Always returns a Visibility, except at
|
707
|
-
# end of file in which case it returns +nil+.
|
708
|
+
# end of file in which case it returns +nil+. If passed +nil+ (or no
|
709
|
+
# argument), a new Visibility object will be created, populated, and
|
710
|
+
# returned. Otherwise, +vis+ will be modified in place and returned.
|
708
711
|
#
|
709
712
|
# See uvread for details.
|
710
713
|
#
|
711
714
|
# <b>This method should be preferred over uvread. uvread may disappear in
|
712
715
|
# future versions!</b>
|
713
|
-
def read(
|
714
|
-
|
715
|
-
|
716
|
-
n, p, d, f = uvread(5,nchan,nchan)
|
717
|
-
elsif args.length == 1 && Visibility === args[0]
|
718
|
-
n, p, d, f = uvread(args[0].preamble,args[0].data,args[0].flags)
|
719
|
-
else
|
720
|
-
n, p, d, f = uvread(*args)
|
721
|
-
end
|
716
|
+
def read(vis=nil)
|
717
|
+
vis = Visibility[nchan] if vis.nil?
|
718
|
+
n, p, d, f = uvread(vis.preamble,vis.data,vis.flags)
|
722
719
|
|
723
720
|
# Return nil on EOF
|
724
721
|
return nil if n == 0
|
@@ -731,8 +728,14 @@ module Miriad
|
|
731
728
|
f = f[0...flen] if flen != f.length
|
732
729
|
|
733
730
|
# Return Visibility
|
734
|
-
|
735
|
-
|
731
|
+
vis
|
732
|
+
end
|
733
|
+
|
734
|
+
# call-seq: nchan -> Integer
|
735
|
+
#
|
736
|
+
# Returns the current value of the _nchan_ uv variable or zero if it is not (yet) present.
|
737
|
+
def nchan
|
738
|
+
getvr('nchan') || 0
|
736
739
|
end
|
737
740
|
|
738
741
|
# call-seq: polstr -> String
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: miriad
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.1.0.
|
4
|
+
version: 4.1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David MacMahon
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-04-
|
12
|
+
date: 2008-04-23 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|