miriad 4.1.0.12 → 4.1.0.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/Rakefile +2 -2
  2. data/ext/miriad_ruby.i +22 -6
  3. data/ext/miriad_wrap.c +25 -9
  4. data/lib/miriad.rb +188 -40
  5. metadata +2 -2
data/Rakefile CHANGED
@@ -1,4 +1,4 @@
1
- # $Id: Rakefile 30 2008-05-16 20:10:42Z davidm $
1
+ # $Id: Rakefile 33 2009-03-17 21:30:46Z 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.12'
17
+ s.version = '4.1.0.14'
18
18
  s.summary = 'Ruby interface to MIRIAD'
19
19
  s.description = <<-EOS
20
20
  The MIRIAD-Ruby package...
data/ext/miriad_ruby.i CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- * $Id: miriad_ruby.i 23 2008-04-30 21:42:24Z davidm $
2
+ * $Id: miriad_ruby.i 33 2009-03-17 21:30:46Z davidm $
3
3
  *
4
4
  * Ruby specific typemaps for MIRIAD Swig wrapper
5
5
  */
@@ -7,6 +7,22 @@
7
7
  #if defined SWIGRUBY
8
8
 
9
9
  %{
10
+ #ifndef RARRAY_LEN
11
+ #define RARRAY_LEN(a) (RARRAY(a)->len)
12
+ #endif
13
+
14
+ #ifndef RARRAY_PTR
15
+ #define RARRAY_PTR(a) (RARRAY(a)->ptr)
16
+ #endif
17
+
18
+ #ifndef RSTRING_LEN
19
+ #define RSTRING_LEN(s) (RSTRING(s)->len)
20
+ #endif
21
+
22
+ #ifndef RSTRING_PTR
23
+ #define RSTRING_PTR(s) (RSTRING(s)->ptr)
24
+ #endif
25
+
10
26
  VALUE mirlib_eWrappedMirlibError;
11
27
  %}
12
28
 
@@ -53,7 +69,7 @@ VALUE mirlib_eWrappedMirlibError;
53
69
  // Store or convert doubles to Ruby Objects
54
70
  if(TYPE(ptr[i]) == T_FLOAT) {
55
71
  // TODO Is this legit?
56
- RFLOAT(ptr[i])->value = $1[i];
72
+ RFLOAT_VALUE(ptr[i]) = $1[i];
57
73
  } else {
58
74
  ptr[i] = rb_float_new($1[i]);
59
75
  }
@@ -99,7 +115,7 @@ VALUE mirlib_eWrappedMirlibError;
99
115
  // Store or convert doubles to Ruby Objects
100
116
  if(TYPE(ptr[i]) == T_FLOAT) {
101
117
  // TODO Is this legit?
102
- RFLOAT(ptr[i])->value = $1[i];
118
+ RFLOAT_VALUE(ptr[i]) = $1[i];
103
119
  } else {
104
120
  ptr[i] = rb_float_new($1[i]);
105
121
  }
@@ -242,7 +258,7 @@ PUTVRX_TYPEMAP(NA_DFLOAT,double,NUM2DBL);
242
258
  // putvr typemap.
243
259
  %typemap(in) (int type) {
244
260
  if(TYPE($input) == T_STRING) {
245
- $1 = (int)((RSTRING($input)->ptr)[0]);
261
+ $1 = (int)((RSTRING_PTR($input))[0]);
246
262
  } else {
247
263
  $1 = NUM2INT($input);
248
264
  }
@@ -288,8 +304,8 @@ PUTVRX_TYPEMAP(NA_DFLOAT,double,NUM2DBL);
288
304
  // Make sure we have a string!
289
305
  VALUE val = rb_ary_entry(vinput3,0);
290
306
  Check_Type(val, T_STRING);
291
- $1 = RSTRING(val)->ptr;
292
- $2 = RSTRING(val)->len;
307
+ $1 = RSTRING_PTR(val);
308
+ $2 = RSTRING_LEN(val);
293
309
  }
294
310
  break;
295
311
  default:
data/ext/miriad_wrap.c CHANGED
@@ -1791,6 +1791,22 @@ typedef struct {
1791
1791
  } uvio;
1792
1792
 
1793
1793
 
1794
+ #ifndef RARRAY_LEN
1795
+ #define RARRAY_LEN(a) (RARRAY(a)->len)
1796
+ #endif
1797
+
1798
+ #ifndef RARRAY_PTR
1799
+ #define RARRAY_PTR(a) (RARRAY(a)->ptr)
1800
+ #endif
1801
+
1802
+ #ifndef RSTRING_LEN
1803
+ #define RSTRING_LEN(s) (RSTRING(s)->len)
1804
+ #endif
1805
+
1806
+ #ifndef RSTRING_PTR
1807
+ #define RSTRING_PTR(s) (RSTRING(s)->ptr)
1808
+ #endif
1809
+
1794
1810
  VALUE mirlib_eWrappedMirlibError;
1795
1811
 
1796
1812
 
@@ -2518,7 +2534,7 @@ _wrap_Uvio_putvr(int argc, VALUE *argv, VALUE self) {
2518
2534
  if (argc > 2) {
2519
2535
  {
2520
2536
  if(TYPE(argv[2]) == T_STRING) {
2521
- arg5 = (int)((RSTRING(argv[2])->ptr)[0]);
2537
+ arg5 = (int)((RSTRING_PTR(argv[2]))[0]);
2522
2538
  } else {
2523
2539
  arg5 = NUM2INT(argv[2]);
2524
2540
  }
@@ -2562,8 +2578,8 @@ _wrap_Uvio_putvr(int argc, VALUE *argv, VALUE self) {
2562
2578
  // Make sure we have a string!
2563
2579
  VALUE val = rb_ary_entry(vinput3,0);
2564
2580
  Check_Type(val, T_STRING);
2565
- arg3 = RSTRING(val)->ptr;
2566
- arg4 = RSTRING(val)->len;
2581
+ arg3 = RSTRING_PTR(val);
2582
+ arg4 = RSTRING_LEN(val);
2567
2583
  }
2568
2584
  break;
2569
2585
  default:
@@ -2717,7 +2733,7 @@ _wrap_Uvio_write(int argc, VALUE *argv, VALUE self) {
2717
2733
  // Store or convert doubles to Ruby Objects
2718
2734
  if(TYPE(ptr[i]) == T_FLOAT) {
2719
2735
  // TODO Is this legit?
2720
- RFLOAT(ptr[i])->value = arg2[i];
2736
+ RFLOAT_VALUE(ptr[i]) = arg2[i];
2721
2737
  } else {
2722
2738
  ptr[i] = rb_float_new(arg2[i]);
2723
2739
  }
@@ -2736,7 +2752,7 @@ _wrap_Uvio_write(int argc, VALUE *argv, VALUE self) {
2736
2752
  // Store or convert doubles to Ruby Objects
2737
2753
  if(TYPE(ptr[i]) == T_FLOAT) {
2738
2754
  // TODO Is this legit?
2739
- RFLOAT(ptr[i])->value = arg3[i];
2755
+ RFLOAT_VALUE(ptr[i]) = arg3[i];
2740
2756
  } else {
2741
2757
  ptr[i] = rb_float_new(arg3[i]);
2742
2758
  }
@@ -2838,7 +2854,7 @@ _wrap_Uvio_wwrite(int argc, VALUE *argv, VALUE self) {
2838
2854
  // Store or convert doubles to Ruby Objects
2839
2855
  if(TYPE(ptr[i]) == T_FLOAT) {
2840
2856
  // TODO Is this legit?
2841
- RFLOAT(ptr[i])->value = arg2[i];
2857
+ RFLOAT_VALUE(ptr[i]) = arg2[i];
2842
2858
  } else {
2843
2859
  ptr[i] = rb_float_new(arg2[i]);
2844
2860
  }
@@ -3057,7 +3073,7 @@ _wrap_Uvio_uvread(int argc, VALUE *argv, VALUE self) {
3057
3073
  // Store or convert doubles to Ruby Objects
3058
3074
  if(TYPE(ptr[i]) == T_FLOAT) {
3059
3075
  // TODO Is this legit?
3060
- RFLOAT(ptr[i])->value = arg2[i];
3076
+ RFLOAT_VALUE(ptr[i]) = arg2[i];
3061
3077
  } else {
3062
3078
  ptr[i] = rb_float_new(arg2[i]);
3063
3079
  }
@@ -3076,7 +3092,7 @@ _wrap_Uvio_uvread(int argc, VALUE *argv, VALUE self) {
3076
3092
  // Store or convert doubles to Ruby Objects
3077
3093
  if(TYPE(ptr[i]) == T_FLOAT) {
3078
3094
  // TODO Is this legit?
3079
- RFLOAT(ptr[i])->value = arg3[i];
3095
+ RFLOAT_VALUE(ptr[i]) = arg3[i];
3080
3096
  } else {
3081
3097
  ptr[i] = rb_float_new(arg3[i]);
3082
3098
  }
@@ -3186,7 +3202,7 @@ _wrap_Uvio_uvwread(int argc, VALUE *argv, VALUE self) {
3186
3202
  // Store or convert doubles to Ruby Objects
3187
3203
  if(TYPE(ptr[i]) == T_FLOAT) {
3188
3204
  // TODO Is this legit?
3189
- RFLOAT(ptr[i])->value = arg2[i];
3205
+ RFLOAT_VALUE(ptr[i]) = arg2[i];
3190
3206
  } else {
3191
3207
  ptr[i] = rb_float_new(arg2[i]);
3192
3208
  }
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 32 2008-12-31 00:23:24Z davidm $
10
+ # $Id: miriad.rb 33 2009-03-17 21:30:46Z davidm $
11
11
  #++
12
12
 
13
13
  require 'rbconfig'
@@ -27,45 +27,47 @@ Math::const_set :CKMS, 299792.458 unless Math::const_defined? :CKMS
27
27
  module Math
28
28
  # Convert possibly non-integer degrees +fr+ to [degrees, minutes, seconds]
29
29
  # where degrees and minutes are integers.
30
- def self.d_to_dms(fr)
30
+ def d_to_dms(fr)
31
31
  sign = fr <=> 0
32
32
  fr *= sign
33
33
  d = fr.to_i; fr %= 1; fr *= 60
34
34
  m = fr.to_i; fr %= 1; fr *= 60
35
35
  return d*sign, m, fr
36
36
  end
37
+ module_function :d_to_dms
37
38
 
38
39
  # Convert possibly non-integer hours +fr+ to [hours, minutes, seconds]
39
40
  # where hours and minutes are integers.
40
- def self.h_to_hms(fr); d_to_dms(fr); end
41
+ def h_to_hms(fr); d_to_dms(fr); end; module_function :h_to_hms
41
42
 
42
43
  # Convert degrees, minutes, seconds to possibly non-integer degrees.
43
44
  # Missing arguments are assumed to be 0.
44
- def self.dms_to_d(*args)
45
+ def dms_to_d(*args)
45
46
  d = 0.to_r
46
47
  d += args.shift unless args.empty?
47
- sign = d <=> 0
48
+ sign = d < 0 ? -1 : 1
48
49
  d += args.shift * Rational(sign,60) unless args.empty?
49
50
  d += args.shift * Rational(sign,3600) unless args.empty?
50
51
  return d
51
52
  end
53
+ module_function :dms_to_d
52
54
 
53
55
  # Convert hours, minutes, seconds to possibly non-integer hours.
54
56
  # Missing arguments are assumed to be 0.
55
- def self.hms_to_h(*args); dms_to_d(*args); end
57
+ def hms_to_h(*args); dms_to_d(*args); end
56
58
 
57
59
  # Convert degrees to radians
58
- def self.d2r(d) d*PI/180; end
60
+ def d2r(d) d*PI/180; end; module_function :d2r
59
61
  # Convert radians to degrees
60
- def self.r2d(r) r*180/PI; end
62
+ def r2d(r) r*180/PI; end; module_function :r2d
61
63
  # Convert hours to radians
62
- def self.h2r(h) h*PI/12; end
64
+ def h2r(h) h*PI/12; end; module_function :h2r
63
65
  # Convert radians to hours
64
- def self.r2h(r) r*12/PI; end
66
+ def r2h(r) r*12/PI; end; module_function :r2h
65
67
  # Convert degrees to hours
66
- def self.d2h(d) d/15.0; end
68
+ def d2h(d) d/15.0; end; module_function :d2h
67
69
  # Convert hours to degrees
68
- def self.h2d(h) h*15.0; end
70
+ def h2d(h) h*15.0; end; module_function :h2d
69
71
  end
70
72
 
71
73
  # The MIRIAD package adds angle conversion and angle formatting methods to
@@ -329,26 +331,75 @@ module Miriad
329
331
  # -8:: 'YX' (Linear YX)
330
332
  POLMAP = a_lookup_table
331
333
 
332
- # call-seq: Miriad.xyz2uvw(xyz1, xyz2, obsra, obsdec, lst) -> [u, v, w]
334
+ # call-seq:
335
+ # Miriad.dir2hadec(obsra, obsdec, lst) -> [ha, obsdec]
336
+ # Miriad.dir2hadec(obsra, obsdec, lst, <tt>:radec</tt>) -> [ha, obsdec]
337
+ # Miriad.dir2hadec(az, el, latitude, <tt>:azel</tt>) -> [ha, obsdec]
338
+ #
339
+ # Compute the hour angle +ha+ and apparent declination +obsdec+ of the
340
+ # direction given by +obsra+ and +obsdec+ at local apparent sidereal time
341
+ # +lst+ or +az+ and +el+ at the given +latitude+.
342
+ #
343
+ # +obsra+, +obsdec+, +lst+ (i.e. right ascension and declination in the
344
+ # current epoch) at the local apparent sidereal time +lst+) if type is
345
+ # <tt>:radec</tt> (or not specified).
346
+ #
347
+ # +az+, +el+, +latitude+ (i.e. azimuth and elevation at latitude) if
348
+ # type is <tt>:azel</tt>.
349
+ #
350
+ # +obsra+, +obsdec+, +lst+, +az+, +el+, +latitude+ should be given in
351
+ # radians.
352
+ def dir2hadec(azra, eldec, latlst, type=:radec)
353
+ if type == :azel
354
+ latlst = String(ENV['LATITUDE']).dms_to_d.d2r unless latlst
355
+ n, e, u = azel2neu(azra, eldec) # az, el
356
+ x, y, z = neu2xyz(n, e, u, latlst) # n, e, u, lat
357
+ ha = Math.atan2(-y, x)
358
+ dec = Math.atan2(z, Math.hypot(x, y))
359
+ elsif type == :radec
360
+ ha = latlst - azra # lst - ra
361
+ dec = eldec
362
+ else
363
+ raise ArgumentError, "invalid type (#{type.inspect})"
364
+ end
365
+ [ha, dec]
366
+ end
367
+ module_function :dir2hadec
368
+
369
+ # call-seq:
370
+ # Miriad.xyz2uvw(xyz1, xyz2, obsra, obsdec, lst) -> [u, v, w]
371
+ # Miriad.xyz2uvw(xyz1, xyz2, obsra, obsdec, lst, <tt>:radec</tt>) -> [u, v, w]
372
+ # Miriad.xyz2uvw(xyz1, xyz2, az, el, latitude, <tt>:azel</tt>) -> [u, v, w]
333
373
  #
334
374
  # Compute the [u,v,w] projection of a baseline with endpoints <tt>xyz1</tt>
335
- # and <tt>xyz2</tt> in the direction of +obsra+, +obsdec+ (i.e. right
336
- # ascension and declination in the current epoch) at the local apparent
337
- # sidereal time +lst+. <tt>xyz1</tt> and <tt>xyz2</tt> are three element
375
+ # and <tt>xyz2</tt>
376
+ # <tt>xyz1</tt> and <tt>xyz2</tt> are three element
338
377
  # arrays containing equitorial coordinates of the baseline endpoints, and
339
- # +obsra+, +obsdec+, and +lst+ are all in radians
378
+ # +obsra+, +obsdec+, and +lst+ are all in radians in the direction of:
379
+ #
380
+ #
381
+ # +obsra+, +obsdec+, +lst+ (i.e. right ascension and declination in the
382
+ # current epoch) at the local apparent sidereal time +lst+) if
383
+ # type is <tt>:radec</tt> (or not specified).
384
+ #
385
+ # +az+, +el+, +latitude+ (i.e. azimuth and elevation at latitude) if
386
+ # +type+ is <tt>:azel</tt>.
387
+ #
388
+ # +obsra+, +obsdec+, +lst+, +az+, +el+, +latitude+ should be given in
389
+ # radians.
340
390
  #
341
- # The body of this method was transcribed from the MIRIAD source file
391
+ # Much of the body of this method was transcribed from the MIRIAD source file
342
392
  # <tt>uvcal.for</tt>.
343
- def self.xyz2uvw(xyz1,xyz2,obsra,obsdec,lst)
393
+ def xyz2uvw(xyz1, xyz2, azra, eldec, latlst, type=:radec)
344
394
  x1,y1,z1 = xyz1
345
395
  x2,y2,z2 = xyz2
346
396
 
347
- ha = lst - obsra
397
+ ha, dec = dir2hadec(azra, eldec, latlst, type)
398
+
348
399
  sinha = Math.sin(ha)
349
400
  cosha = Math.cos(ha)
350
- sind = Math.sin(obsdec)
351
- cosd = Math.cos(obsdec)
401
+ sind = Math.sin(dec)
402
+ cosd = Math.cos(dec)
352
403
 
353
404
  bxx = x2 - x1
354
405
  byy = y2 - y1
@@ -360,6 +411,7 @@ module Miriad
360
411
 
361
412
  [u,v,w]
362
413
  end
414
+ module_function :xyz2uvw
363
415
 
364
416
  # call-seq:
365
417
  # Miriad.neu2xyz(n, e, u, latitude) -> [x, y, z]
@@ -372,8 +424,8 @@ module Miriad
372
424
  # Output coordinates will be in the same units as the input coordinates.
373
425
  #
374
426
  # See also Miriad.xyz2neu
375
- def self.neu2xyz(*args)
376
- n, e, u, latitude, extra = args.flatten!
427
+ def neu2xyz(*args)
428
+ n, e, u, latitude, extra = args.flatten
377
429
  latitude ||= ENV.fetch('LATITUDE','0.0').dms_to_d.d2r
378
430
 
379
431
  sinlat = Math.sin(latitude)
@@ -384,11 +436,14 @@ module Miriad
384
436
  n * coslat + u * sinlat
385
437
  ]
386
438
  end
439
+ module_function :neu2xyz
387
440
 
388
441
  # :stopdoc:
442
+ alias :xyz2neu :neu2xyz
389
443
  class << self
390
444
  alias :xyz2neu :neu2xyz
391
445
  end
446
+
392
447
  # :startdoc:
393
448
  # RDoc xyz2neu as a method rather than an alias
394
449
  if false
@@ -412,9 +467,50 @@ module Miriad
412
467
  n * coslat + u * sinlat
413
468
  ]
414
469
  end
470
+ end # RDoc hack
471
+
472
+ # call-seq: Miriad.azel2neu(azimuth, elevation) -> [n, e, u]
473
+ #
474
+ # Compute northing +n+, easting +e+, and up +u+ from +azimuth+ and
475
+ # +elevation+ at a unit distance (i.e. the length of the returned [n, e, u]
476
+ # vector will be 1). +azimuth+ and +elevation+ should be in radians.
477
+ def azel2neu(az, el)
478
+ cosel = Math.cos(el)
479
+ n = cosel*Math.cos(az)
480
+ e = cosel*Math.sin(az)
481
+ u = Math.sin(el)
482
+ [n, e, u]
483
+ end
484
+ module_function :azel2neu
485
+
486
+ # call-seq: Miriad.neu2azel(n, e, u) -> [azimuth, elevation]
487
+ #
488
+ # Compute the +azimuth+ and +elevation+ for the given northing +n+, easting
489
+ # +e+, and up +u+. The returned +azimuth+ and +elevation+ will be in
490
+ # radians.
491
+ def neu2azel(n, e, u)
492
+ az = Math.atan2(e,n)
493
+ ne = Math.hypot(n,e)
494
+ el = Math.atan2(u,ne)
495
+ [az, el]
415
496
  end
497
+ module_function :neu2azel
416
498
 
417
- # call-seq: Miriad.azel(obsra, obsdec, lst, latitude) -> [azimuth, elevation]
499
+ # call-seq:
500
+ # Miriad.azeldelay(+neu+, +az+, +el+) -> +delay+
501
+ # Miriad.azeldelay(+n+, +e+, +u+, +az+, +el+) -> +delay+
502
+ #
503
+ # Computes the delay in the direction given by +az+ and +el+ seen by a
504
+ # baseline given in N, E, U topocentric coordinates (either as a three
505
+ # element +neu+ array or as individual parameters).
506
+ def azeldelay(*args)
507
+ bn, be, bu, az, el = args.flatten
508
+ sn, se, su = azel2neu(az, el)
509
+ bn*sn + be*se + bu*su
510
+ end
511
+ module_function :azeldelay
512
+
513
+ # call-seq: Miriad.radec2azel(obsra, obsdec, lst, latitude) -> [azimuth, elevation]
418
514
  #
419
515
  # Compute +azimuth+ and +elevation+ from +obsra+, +obsdec+, +lst+,
420
516
  # +latitude+.
@@ -439,7 +535,7 @@ module Miriad
439
535
  #
440
536
  # The body of this method was transcribed from the miriad source file
441
537
  # <tt>ephem.for</tt> originally created by Bob Sault.
442
- def self.azel(obsra, obsdec, lst, latitude=String(ENV['LATITUDE']).dms_to_d.d2r)
538
+ def radec2azel(obsra, obsdec, lst, latitude=String(ENV['LATITUDE']).dms_to_d.d2r)
443
539
  ha = lst - obsra
444
540
  cosha = Math.cos(ha)
445
541
  sinha = Math.sin(ha)
@@ -454,26 +550,71 @@ module Miriad
454
550
 
455
551
  [az, el]
456
552
  end
553
+ module_function :radec2azel
554
+
555
+ alias :azel :radec2azel
556
+ class << self
557
+ alias :azel :radec2azel
558
+ end
559
+
560
+ # call-seq: Miriad.azel2radec(azimuth, elevation, lst, latitude) -> [ra, dec]
561
+ #
562
+ # Compute the apparent +ra+ and +dec+ (in current epoch) from +azimuth+,
563
+ # +elevation+, +lst+, and +latitude+.
564
+ #
565
+ # NOTE: This calculation is based on a spherical model for the earth, and
566
+ # does not include any atmospheric effects (e.g. refraction).
567
+ #
568
+ # Input:
569
+ #
570
+ # +azimuth+:: Azimuth from north (radians).
571
+ # +elevation+:: Elevation from horizon (radians).
572
+ # +lst+:: Local sidereal time (radians).
573
+ # +latitude+:: Observatory geodetic latitude (radians). If not given, the
574
+ # value from <tt>ENV['LATITUDE']</tt> (which should be in
575
+ # degrees in <tt>dd:mm:ss.sss</tt> or <tt>dd.ddd</tt> format)
576
+ # will be used.
577
+ #
578
+ # Output:
579
+ #
580
+ # +ra+:: Apparent RA of the source of interest (radians).
581
+ # +dec+:: Apparent DEC of the source of interest (radians).
582
+ def azel2radec(az, el, lst, latitude=String(ENV['LATITUDE']).dms_to_d.d2r)
583
+ x, y, z = Miriad.neu2xyz(azel2neu(az, el), latitude)
584
+ ha = Math.atan2(-y, x)
585
+ ra = (lst - ha) % (2*Math::PI)
586
+ dec = Math.atan2(z, Math.hypot(x, y))
587
+ [ra, dec]
588
+ end
589
+ module_function :azel2radec
457
590
 
458
- # call-seq: Miriad.fringe_rate(bx, by, obsra, obsdec, lst, freq)
591
+ # call-seq:
592
+ # Miriad.fringe_rate(bx, by, freq, obsra, obsdec, lst)
593
+ # Miriad.fringe_rate(bx, by, freq, obsra, obsdec, lst, <tt>:radec</tt>)
594
+ # Miriad.fringe_rate(bx, by, freq, az, el, latitude, <tt>:azel</tt>)
595
+ #
596
+ # Computes the Earth rotation synthesis fringe rate at sky frequency +freq+
597
+ # for a source in the direction given by either +obsra+ and +obsdec+ at local
598
+ # sidereal time +lst+ or +az+ and +el+ at +latitude+ as seen by a baseline
599
+ # with X and Y equitorial components +bx+ and +by+.
459
600
  #
460
- # Computes the Earth rotation synthesis fringe rate for a source at +obsra+
461
- # and +obsdec+ at local sidereal time +lst+ and sky frequency +freq+ as seen
462
- # by a baseline with X and Y equitorial components +bx+ and +by+.
601
+ # +obsra+, +obsdec+, +lst+, +az+, +el+, +latitude+ should be given in
602
+ # radians.
463
603
  #
464
604
  # The units of the result depends on the the units of the inputs. To get
465
605
  # turns per second (i.e. Hz), +bx+ and +by+ should be in nanoseconds and
466
606
  # +freq+ should be in GHz (alternatively, +bx+ and +by+ in seconds and +freq+
467
607
  # in Hz). To get radians per second, multiply +freq+ by 2*Math::PI. To get
468
608
  # degrees per second, multiply +freq+ by 360.
469
- def self.fringe_rate(bx, by, obsra, obsdec, lst, freq)
470
- ha = lst - obsra
609
+ def fringe_rate(bx, by, freq, azra, eldec, latlst, type=:radec)
610
+ ha, obsdec = dir2hadec(azra, eldec, latlst, type)
471
611
  cosha = Math.cos(ha)
472
612
  sinha = Math.sin(ha)
473
613
  cosd = Math.cos(obsdec)
474
614
 
475
615
  -freq * DateTime::OMEGA * (bx*sinha + by*cosha) * cosd
476
616
  end
617
+ module_function :fringe_rate
477
618
 
478
619
  # call-seq: Miriad.parang(obsra, obsdec, lst, latitude) -> parallactic_angle
479
620
  #
@@ -496,13 +637,14 @@ module Miriad
496
637
  #
497
638
  # The body of this method was transcribed from the miriad source file
498
639
  # <tt>ephem.for</tt> originally created by Bob Sault.
499
- def self.parang(obsra, obsdec, lst, latitude=String(ENV['LATITUDE']).dms_to_d.d2r)
640
+ def parang(obsra, obsdec, lst, latitude=String(ENV['LATITUDE']).dms_to_d.d2r)
500
641
  ha = lst - obsra
501
642
  sinq = Math.cos(latitude) * Math.sin(ha)
502
643
  cosq = Math.sin(latitude) * Math.cos(obsdec) -
503
644
  Math.cos(latitude) * Math.sin(obsdec) * Math.cos(ha)
504
645
  Math.atan2(sinq, cosq)
505
646
  end
647
+ module_function :parang
506
648
 
507
649
  # call-seq: Miriad.precess(ra, dec, to_jd, from_jd) -> [ra, dec]
508
650
  #
@@ -532,7 +674,7 @@ module Miriad
532
674
  #
533
675
  # The body of this method was transcribed from the miriad source file
534
676
  # <tt>ephem.for</tt> originally created by Bob Sault.
535
- def self.precess(ra, dec, to_jd=DateTime.now.ajd, from_jd=DateTime::J2000.ajd)
677
+ def precess(ra, dec, to_jd=DateTime.now.ajd, from_jd=DateTime::J2000.ajd)
536
678
  t = (from_jd - 2451545)/36525
537
679
  m = Math::PI/180 * (1.2812323 + (0.0003879 + 0.0000101*t)*t)*t
538
680
  n = Math::PI/180 * (0.5567530 - (0.0001185 + 0.0000116*t)*t)*t
@@ -557,46 +699,51 @@ module Miriad
557
699
 
558
700
  [ra, dec]
559
701
  end
702
+ module_function :precess
560
703
 
561
704
  # call-seq: Miriad.basstr(baseline, format='%d-%d') -> "A1-A2"
562
705
  #
563
706
  # Format a MIRIAD baseline number as a String according to +format+.
564
- def self.basstr(baseline, format='%d-%d')
707
+ def basstr(baseline, format='%d-%d')
565
708
  baseline = baseline.to_i
566
709
  format % basant(baseline)
567
710
  end
711
+ module_function :basstr
568
712
 
569
713
  # call-seq: Miriad.basant(baseline) -> [a1, a2]
570
714
  #
571
715
  # Convert a MIRIAD baseline number into two antenna numbers.
572
- def self.basant(baseline)
716
+ def basant(baseline)
573
717
  baseline = baseline.to_i
574
718
  [baseline/256, baseline%256]
575
719
  end
720
+ module_function :basant
576
721
 
577
722
  # call-seq: Miriad.antbas(a1, a2) -> baseline_number
578
723
  #
579
724
  # Convert two antenna numbers into a MIRIAD baseline number
580
- def self.antbas(a1,a2)
725
+ def antbas(a1,a2)
581
726
  a1, a2 = a2, a1 if a2 < a1
582
727
  a1.to_i*256 + a2.to_i
583
728
  end
729
+ module_function :antbas
584
730
 
585
731
  # call-seq: Miriad.basidx(a1, a2, n) -> baseline_index
586
732
  #
587
733
  # Convert two antenna numbers, <tt>a1</tt> and <tt>a2</tt>, into a baseline
588
734
  # index (NOT a MIRIAD baseline number) using +n+ as the maximum antenna
589
735
  # number.
590
- def self.basidx(a1,a2,n)
736
+ def basidx(a1,a2,n)
591
737
  a1, a2 = a2, a1 if a2 < a1
592
738
  return a1 + ((2*n+1)*(a2-a1) - (a2-a1)**2) / 2
593
739
  end
740
+ module_function :basidx
594
741
 
595
742
  # call-seq: Miriad.idxbas(baseline_index, n) -> [a1, a2]
596
743
  #
597
744
  # Convert a baseline index (NOT a MIRIAD baseline number) +i+ into two
598
745
  # antenna numbers using +n+ as the maximum antenna number.
599
- def self.idxbas(i,n)
746
+ def idxbas(i,n)
600
747
  b = -(2*n+1)
601
748
  ac = 2*i
602
749
  r = Math.sqrt(b**2-4*ac)
@@ -605,6 +752,7 @@ module Miriad
605
752
  a2 = a1 + d
606
753
  [a1, a2]
607
754
  end
755
+ module_function :idxbas
608
756
 
609
757
  # The Visibility class holds preamble, visdata, and flags for one integration
610
758
  # on one baseline. It also provides convenience methods to query and access
@@ -893,7 +1041,7 @@ module Miriad
893
1041
  # Format the current value of the _baseline_ uv variable as a String
894
1042
  # according to +format+.
895
1043
  def basstr(format='%d-%d')
896
- format % basant(getvr('baseline'))
1044
+ format % basant
897
1045
  end
898
1046
 
899
1047
  # call-seq: basant -> [ant1, ant2]
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.12
4
+ version: 4.1.0.14
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-12-30 00:00:00 -08:00
12
+ date: 2009-03-18 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency