Class: Miriad::Uvio

Inherits:
Object
  • Object
show all
Defined in:
lib/miriad.rb,
ext/miriad_ruby.c,
ext/miriad_ruby.c

Overview

The Uvio class is mostly a SWIG wrapper around the UVIO C routines from MIRIAD. Some convenience methods are added in miriad.rb.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.open(name, mode = 'r') ⇒ Object

call-seq:

Uvio.open(name, mode='r') -> uvio
Uvio.open(name, mode='r') {|uvio| ...}

Opens a uv dataset and readies it for access.

name

The dataset’s name

mode

Specifies how to open the dataset. Valid values are:

  • 'r' for reading an existing dataset,

  • 'w' for writing a new dataset, or

  • 'a' for appending to an existing dataset.

Note that datsets opened for reading may still be modified in some ways (e.g. writing new flags).

If a block is given, dataset name is opened according to mode and the resulting Uvio object is passed into the block. The dataset will be automatically closed when the block terminates. In this case, the return value of Uvio.open is the return value of the block.

If no block is given, the new Uvio object is returned.



863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
# File 'lib/miriad.rb', line 863

def self.open(name, mode='r')
  raise 'invalid dataset name' if name.nil? or name.empty?
  case mode[0]
  when ?r then
    raise 'invalid dataset given' unless test ?d, name
  when ?w then
    raise 'dataset exists' if test ?d, name
  when ?a then
    raise 'invalid dataset given' unless test ?d, name
  end

  uvio = self.new(name,mode)

  return uvio unless block_given?

  begin
    return yield(uvio)
  ensure
    uvio.close() rescue nil
  end
end

Instance Method Details

#[](name) ⇒ Object

call-seq:

uvio['name'] -> value or nil
uvio[:name] -> value or nil

Returns the current value of the uv variable named name or nil if the named variable does not (yet) exist.

This provides a Hash-like interface to the uv variables.

It is implemented as getvr(name.to_s).



1177
1178
1179
# File 'lib/miriad.rb', line 1177

def [](name)
  getvr(name.to_s)
end

#[]=(*args) ⇒ Object

call-seq:

uvio['name'] = value -> value
uvio[:name] = value -> value
uvio['name', type] = value -> value
uvio[:name, type] = value  -> value

Sets the uv variable name to value. If type is not given, the MIRIAD type will be autodetected from value. Generally, this works well only for Strings and NArrays, but not for Numeric types. For full control, specify type as one of…

  • 'a' (or ?a) - ASCII data

  • 'i' (or ?i) - Integer data

  • 'r' (or ?r) - Single precision real data

  • 'd' (or ?d) - Double precision real data

  • 'c' (or ?c) - Single precision complex data [NOT YET SUPPORTED!]



1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
# File 'lib/miriad.rb', line 1198

def []=(*args)
  n, t, v = case args.length
            when 2; [args[0], -1, args[1]]
            when 3; [args[0], args[1], args[2]]
            else
              raise ArgumentError.new(
                "wrong number of arguments (#{args.length} for 3)")
            end
  putvr(n.to_s, v, t)
  v
end

#antpos(*args) ⇒ Object

call-seq:

antpos -> [[0,0,0], [Xa1,Ya1,Za1], ..., [Xan, Yan, Zan]]
antpos(a1, a2) -> [[Xa1,Ya1,Za1], [Xa2, Ya2, Za2]]
antpos([a1, a2]) -> [[Xa1,Ya1,Za1], [Xa2, Ya2, Za2]]
antpos(a) -> [Xa,Ya,Za]

If called without a parameter (other than the optional Hash, see below), returns the current value of the antpos uv variable array arranged for convenient indexing by a 1-based antenna number (e.g. as retuned by basant). The 0th position in the array contains a [0,0,0] place holder position.

If called with multiple integer parameters or an Array of Integers, returns an array of positions of the specified antennas. In this case, the returned array will not contain a [0,0,0] placeholder in the 0th position.

If called with a single Integer parameter, returns the position of the specified antenna.

An optional Hash can be passed in as the last parameter to specify units and coordinates. The following key/value entries are recognized:

:coord => :xyz

Position(s) in equitorial coordinates (default)

:coord => :neu

Position(s) in topocentric coordinates (uses the latitude uv variable for conversion from XYZ to NEU)

:coord => :uvw

Projection of position in the direction of obsra and obsdec at the local apparent sidereal time lst

:units => :ns

Position(s) in nanoseconds (default)

:units => :meter

Position(s) in meters

:units => :lamda

Position(s) in wavelengths

:units => :klamda

Position(s) in kilo-wavelengths

The following are some examples of common usage:

a1xyz_ns, a2xyz_ns = uvio.antpos(uvio.basant)

ant5neu_m = uvio.antpos(5, :coord => :neu, :units => :meter)


965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
# File 'lib/miriad.rb', line 965

def antpos(*args)
  opts = {:coord => :xyz, :units => :ns}
  opts.merge!(args.pop) if Hash === args[-1]
  return nil unless ap = getvr('antpos')
  args.flatten!
  n = ap.length/3
  ap = [ap[0*n...1*n], ap[1*n...2*n], ap[2*n...3*n]].transpose.unshift([0,0,0])
  ap = ap.values_at(*args.flatten) if args.length > 0

  # Do units scaling, if requested
  scale = case opts[:units]
          when :ns; nil
          when :meter; Math::CKMS / 1e6
          when :lambda; getvr('freq') || 1.0
          when :klambda; (getvr('freq') || 1.0) / 1000
          else raise "Unrecognized units '#{opts[:units]}'"
          end
  ap.map!{|p| p.map!{|c| c*scale}} if scale

  # Do coordinate conversion, if requested
  if opts[:coord] == :neu
    latitude = getvr('latitud') || 0.0
    ap.map!{|p| Miriad.xyz2neu(p,latitude)}
  elsif opts[:coord] == :uvw
    obsra = getvr('obsra') || 0.0
    obsdec = getvr('obsdec') || 0.0
    lst = getvr('lst') || 0.0
    ap.map!{|p| Miriad.xyz2uvw([0.0, 0.0, 0.0], p, obsra, obsdec, lst)}
  elsif opts[:coord] != :xyz
    raise "Unrecognized coordinate system '#{opts[:coord]}'"
  end

  # Return single position if only one was asked for
  args.length == 1 ? ap[0] : ap
end

#azelObject

Computes the azimuth and elevation from the current values of lst, obsra, obsdec, and latitude. Missing components are assumed to be 0.0.

See Miriad.azel for more details.



1085
1086
1087
1088
1089
1090
1091
# File 'lib/miriad.rb', line 1085

def azel
  obsra = getvr('obsra') || 0.0
  obsdec = getvr('obsdec') || 0.0
  lst = getvr('lst') || 0.0
  latitude = getvr('latitud') || 0.0
  Miriad.azel(obsra, obsdec, lst, latitude)
end

#basantObject

call-seq: basant -> [ant1, ant2]

Decodes the value of the baseline uv variable and returns a two element array containing the two antenna numbers.



1054
1055
1056
1057
# File 'lib/miriad.rb', line 1054

def basant
  bl = getvr('baseline')
  bl = [bl.to_i/256, bl.to_i%256] if bl
end

#baseline(*args) ⇒ Object

call-seq:

baseline -> [bx, by, bz]
baseline(a1, a2) -> [Xa2-Xa1, Ya2-Ya1, Za2-Za1]

If called without a parameter (other than the optional Hash, see below), returns the dimensions of the current baseline.

If called with two antenna numbers, returns the dimension of their baseline. The two antenna numbers will be swapped if a1 > a2.

In either case, an optional Hash can be passed in. This hash is passed to antpos, so see antpos for a decription of what options are available.



1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
# File 'lib/miriad.rb', line 1013

def baseline(*args)
  opts = (Hash === args[-1]) ? args.pop : {}
  a1, a2 = case args.length
           when 0; basant
           when 2; args
           else raise ArgumentError(
             "wrong number of arguments (#{args.length} for 0 or 2)")
           end
  a1, a2 = a2, a1 if a1 > a2
  p1, p2 = antpos(a1, a2, opts)
  [p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2]]
end

#basstr(format = '%d-%d') ⇒ Object

call-seq: basstr(format=‘%d-%d’) -> “A1-A2”

Format the current value of the baseline uv variable as a String according to format.



1046
1047
1048
# File 'lib/miriad.rb', line 1046

def basstr(format='%d-%d')
  format % basant
end

#chiObject

Returns the value of the uv variable chi. If chi is not defined, return parang() plus the value of the evector uv variable if it is defined.



1138
1139
1140
# File 'lib/miriad.rb', line 1138

def chi
  getvr('chi') || (parang + (getvr('evector') || 0.0))
end

#closeObject

call-seq: close() -> nil

Closes the uv dataset.

#flagwrObject

call-seq: flagwr(flags) -> nil

Write uv flags after a read. This causes the flags associated with correlation data to be rewritten. It is typically used by a flagging program to overwrite old flagging information. It will typically be called soon after uvread (which is used to get the old flags, and position the file), thus overwriting the old flags.

flags is either an Array or NArray (of type NArray::LINT) and will typically have been returned by uvread and subsequently modified. The flags indicate whether the corresponding data value has been deemed good or bad:

  • 1 means good

  • 0 means bad

#flushObject

call-seq: flush() -> nil

Flush buffers of the uv dataset to disk.

#fringe_hz(freq_ghz = getvr('freq')) ⇒ Object

Computes the Earth rotation synthesis fringe rate in Hz using the current value of the obsdec uv variable and u from the coord us variable.

freq_ghz is the sky frequency, in GHz, for which the fringe rate will be determined. If it is not given, the value of the freq uv variable will be used.



1099
1100
1101
1102
1103
1104
# File 'lib/miriad.rb', line 1099

def fringe_hz(freq_ghz = getvr('freq'))
  u = getvr('coord')[0] rescue 0.0
  obsdec = getvr('obsdec') || 0.0
  freq_ghz ||= 0.0
  -freq_ghz * DateTime::OMEGA * u * Math.cos(obsdec)
end

#fringe_sec(freq_ghz = getvr('freq')) ⇒ Object

Computes the Earth rotation synthesis fringe period in seconds using the current value of the obsdec uv variable and u from the coord us variable.

freq_ghz is the sky frequency, in GHz, for which the fringe rate will be determined. If it is not given, the value of the freq uv variable will be used.



1113
1114
1115
# File 'lib/miriad.rb', line 1113

def fringe_sec(freq_ghz = getvr('freq'))
  1.0 / fringe_hz(freq_ghz)
end

#getvrObject

call-seq: getvr(name) -> value or nil

Returns the current value of uv variable named name or nil if the named variable does not (yet) exist.

Note that complex uv variables are not [yet] supported.

#haObject

Computes hour angle (in radians) as lst - obsra. Returns 0.0 if either one (or both) is undefined.



1061
1062
1063
# File 'lib/miriad.rb', line 1061

def ha
  getvr('lst') - getvr('obsra') rescue 0.0
end

#hiswriteObject

call-seq: hiswrite(text) -> nil

Write a line of text to the history file. This writes a text string to the history file associated with the underlying dataset.

#nantsObject

call-seq: nants -> Integer

Returns the current value of the nants uv variable or zero if it is not (yet) present.



920
921
922
# File 'lib/miriad.rb', line 920

def nants
  getvr('nants') || 0
end

#nchanObject

call-seq: nchan -> Integer

Returns the current value of the nchan uv variable or zero if it is not (yet) present.



1030
1031
1032
# File 'lib/miriad.rb', line 1030

def nchan
  getvr('nchan') || 0
end

#parangObject

Computes the current parallactic angle from the current values of lst, obsra, obsdec, and latitude. Missing components are assumed to be 0.0.

See Miriad.parang for more details.



1127
1128
1129
1130
1131
1132
1133
# File 'lib/miriad.rb', line 1127

def parang
  obsra = getvr('obsra') || 0.0
  obsdec = getvr('obsdec') || 0.0
  lst = getvr('lst') || 0.0
  latitude = getvr('latitud') || 0.0
  Miriad.parang(obsra, obsdec, lst, latitude)
end

#polstrObject

call-seq: polstr -> String

Format the current value of the pol uv variable as a String according to Miriad::POLMAP.



1038
1039
1040
# File 'lib/miriad.rb', line 1038

def polstr
  Miriad::POLMAP[getvr('pol')]
end

#probvrObject

call-seq: probvr(var) -> [type, length, updated] or nil

Checks whether a the uv variable var exists. If it does, returns a three element array indicating the variable’s type, (current) length, and whether it was updated on the last call to read or scan. If it doesn’t exist, it returns nil.

type can be one of…

  • 'a' - ASCII data

  • 'i' - Integer data

  • 'r' - Single precision real data

  • 'd' - Double precision real data

  • 'c' - Single precision complex data

#putvrObject

call-seq: putvr(var, data, type=-1) -> nil

Writes data as the value of a uv variable var. data can be a Ruby object, an Array of Ruby objects, or an NArray.

If type is -1, the default, the MIRIAD type will be autodetected from data. Generally, this works well only for Strings and NArrays, but not for Numeric types. For full control, specify type as one of…

  • 'a' (or ?a) - ASCII data

  • 'i' (or ?i) - Integer data

  • 'r' (or ?r) - Single precision real data

  • 'd' (or ?d) - Double precision real data

  • 'c' (or ?c) - Single precision complex data [NOT YET SUPPORTED!]

#putvra(var, data) ⇒ Object

Calls putvr(var, data, ?a)



829
# File 'lib/miriad.rb', line 829

def putvra(var,data) putvr(var, data, ?a); end

#putvrd(var, data) ⇒ Object

Calls putvr(var, data, ?d)



835
# File 'lib/miriad.rb', line 835

def putvrd(var,data) putvr(var, data, ?d); end

#putvri(var, data) ⇒ Object

Calls putvr(var, data, ?i)



831
# File 'lib/miriad.rb', line 831

def putvri(var,data) putvr(var, data, ?i); end

#putvrr(var, data) ⇒ Object

Calls putvr(var, data, ?r)



833
# File 'lib/miriad.rb', line 833

def putvrr(var,data) putvr(var, data, ?r); end

#read(vis = nil) ⇒ Object

call-seq:

read(vis=nil) -> vis or Visibility[nchan] or nil

Convenience wrapper around uvread. Shortens data and flags if they were passed in longer than necessary. Always returns a Visibility, except at end of file in which case it returns nil. If passed nil (or no argument), a new Visibility object will be created, populated, and returned. Otherwise, vis will be modified in place and returned.

See uvread for details.

This method should be preferred over uvread. uvread may disappear in future versions!



898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
# File 'lib/miriad.rb', line 898

def read(vis=nil)
  vis = Visibility[nchan] if vis.nil?
  n, p, d, f = uvread(vis.preamble,vis.data,vis.flags)

  # Return nil on EOF
  return nil if n == 0

  # If nread is different than what was passed in
  dlen = flen = n
  dlen *= 2 if Array === d
  # Shorten data and flags
  vis.data  = d[0...dlen] if dlen != d.length
  vis.flags = f[0...flen] if flen != f.length

  # Return Visibility
  vis
end

#rewindObject

call-seq: rewind() -> nil

Rewind a uv file, readying it to be read from the begining again.

#scanObject

call-seq: scan(var) -> nil

Scan through the uv file until variable var changes. This always reads to the end of the record in which var was encountered (i.e. until all variables that change simultaneously are read).

#selaObject

call-seq: sela(object, datasel, value) -> nil

Select or reject uv data based on a String. This specifies the portion of the data to be selected by calls to uvread.

object can be either 'source' or 'purpose'.

datasel is either true or 1 to select; false or 0 to reject.

value is a String that will be used as the search critereon.

See also select().

#selectObject

call-seq: select(object, datasel, p1=0.0, p2=0.0) -> nil

Select or reject uv data based on numeric values. This specifies the portion of the data to be selected by calls to uvread. Generally uvselect will be called many times, each call giving a different selection or discard criterion.

Normally data that are not selected, are not returned. Exceptions are the “window” and “amplitude” objects, which cause the corresponding visibilities to be flagged as bad, but returned anyway.

object is a String giving the parameter on which a select/discard criterion is based. See the list below for permissible values for object.

datasel is either true or 1 to select; false or 0 to reject.

p1 and p2, both Floats, give added numerical parameters. Generally p1 and p2 give a range of parameter values to select or discard. Note that the units of the values are consistent with the units of the underlying uv variables. These are not necessarily the most convenient units for the user.

Here is a list of permissible values for object along with the applicability of p1 and </tt>p2</tt> and their units (in parentheses). Only applicable parameters are shown; parameters not shown are ignored.

time

p1=min, p2=max (Julian date)

on

p1=state

polarization

p1=polval (FITS code)

dazim

p1=min, p2=max (radians?)

delev

p1=min, p2=max (radians?)

dra

p1=min, p2=max (radians)

ddec

p1=min, p2=max (radians)

ra

p1=min, p2=max (radians)

dec

p1=min, p2=max (radians)

ha

p1=min, p2=max (radians?)

lst

p1=min, p2=max (radians?)

elevation

p1=min, p2=max (radians?)

uvrange

p1=min, p2=max (wavelengths)

uvnrange

p1=min, p2=max (nanoseconds)

frequency

p1=min, p2=max (GHz)

pointing

p1=min, p2=max (arcseconds)

seeing

p1=min, p2=max (???)

visibility

p1=min, p2=max

increment

p1=incr

shadow

p1=min, p2=max (???)

bin

p1=min, p2=max

amplitude

p1=min, p2=max

window

p1=win

antennae

p1=ant1, p2=ant2

auto

or

and

clear

Notes:

  • For “antennae”, a zero indicates “all antennae”.

  • For “shadow”, a zero indicates use “antdiam” variable.

  • The clear object causes the selection criteria to be reset to its default of selected everything.

  • NB: select treates and and or as having identical precedence, and handles these operators in the order in which they are given. Beware of this lack of precedence.

#setObject

call-seq: set(object, type, n=0, p1=0.0, p2=0.0, p3=0.0) -> nil

Modifies the behavior of the read and write methods.

How set affects read

The uvread routine can perform, at the programmer’s request, extra processing steps on the visibility data. These steps consist of averaging and resampling frequency channels, uv coordinate conversion and some corrections for planet observations. The steps are requested by calls to set. In the call to set, object (String) gives the general processing step that is being requested. The type argument (String) gives more specific details, and the arguments n (Integer) and p1, p2 and p3 (Floats) give any numerical values needed.

Note that the setup given by set only becomes correctly activated during the next call to read. Before this next call, the setup is in a somewhat nebulous state. You should not expect various other routines associated with read to work as expected until after the next call to read. Associated routines include flagwr and info [info not yet implemented].

The possible values of the arguments to set are summarized below. Not all parameters are used in every case. If a parameter is not mentioned for a particular usage, then it is ignored. While several processing steps can be performed simultaneously (several calls to set will be needed to specify them all), others are mutually inconsistent. When mutually inconsistent steps are requested, the last requested step is honored.

  • object='data' -> n=nchan, p1=start, p2=width, p3=step

    This gives operations on the spectral data.

    • type='channel' selects the channels to be returned, and possible averaging together of the channel data. If the original channels are numbers from 1 to N, then, by using type='channel', read will return nchan massaged channels, where the ith channel of the massaged channels is formed by averaging width channels of the original data, starting at channel (i-1)*step+start. If set is called with nchan being zero, all channels are selected (note that this only makes sense if start, step, and width are all 1).

    • type='wide' is similar, but uses the continuum data rather than the spectral data.

    • type='velocity' is also similar, returning a weighted sum of the spectral data. However in this case start, width and step are given in units of km/s (rather than channels). This is particularly useful if the spectrometer setup is not constant throughout the data or there is no Doppler tracking, and so the velocity of a given channel changes.

    • Note that ‘channel’, ‘wide’, and ‘velocity’ are mutually exclusive. The default is ‘channel’ (or wide if there is no spectral data in the file), with start, width, and step of 1.

    • If there are fewer than nchan channels, then dummy channels, which are flagged as bad, are added. If nchan is specified as 0, then read will return as many channels as possible.

  • object='reference' -> p1=start, p2=width

    The “reference line” is a spectral channel, or an average of spectral channels, which the main data is divided by. Typically the reference line would be a strong point source (e.g. a maser). The resultant data is essentially normalized and shifted, but it also has atmospheric-based and instrument-base calibration problems removed. The extra parameters needed to describe the reference line is the same as for object='data', except that the number of channels, and the increment is ignored (there is only ever one reference line). The default is not to have a reference line.

  • object='coord'

    This sets the units of the u, v, and w coordinates returned in the preamble. Using type='wavelength' or type='nanosec' sets the units of the returned coordinates. For 'wavelength', the sky frequency used is that of the first channel returned. The default value is 'nanosec'.

  • object='planet' -> p1=plmaj, p2=plmin, p3=plangle

    This causes the u and v coordinates to be scaled and rotated, and the correlation values to be scaled, to adjust for changes when observing planets. The parameters plmaj, plmin and plangle give the reference size (arcseconds) and position angle (degrees) of the planet. If the reference size is 0, then the size of the first selected data record is used.

  • object='selection' -> n=n

    This gives extra control over the uv selection process. Currently there is only one possible type, 'amplitude', which enables or disables the amplitude selection process. If the argument n is positive, then amplitude selection is applied (i.e. the normal action), otherwise amplitude selection is not applied.

  • object='preamble'

    • type='uv/time/baseline' - The preamble will be read as four doubles: u, v, time, and baseline. If the dataset was written with five element preambles, w will be discarded.

    • type='uvw/time/baseline' - The preamble will be read as five doubles: u, v, w, time, and baseline. If the dataset was written with four element preambles, w will be set to 0.0.

How set affects write

  • object='corr'

    The uv routines allow the correlation data to be stored on disk, either as floating point numbers, or as 16 bit integers with an associated scale factor. The 16 bit format roughly halves the disk space required, but slows the read and write operation, and can cause precision problems. On the first call to write, the uv routines decide on the format to use, using a simple rule. The set method can be used to override this rule. To be of use, it must be called before the first call to write. The type argument is a single character, being 'r' or 'j', which instructs floating point or scaled integers, respectively, to be used.

  • object='data'

    This controls whether write() writes the data to the corr or wcorr variable. The default is to write it to the corr item (i.e. it assumes that the data is spectral, rather than continuum data).

  • object='preamble'

    • type='uv/time/baseline' - The preamble will be written as four doubles: u, v, time, and baseline.

    • type='uvw/time/baseline' - The preamble will be written as five doubles: u, v, w, time, and baseline.

#tauObject

Returns getvr('inttime') or 0.0 if it is not (yet) defined.



1118
1119
1120
# File 'lib/miriad.rb', line 1118

def tau
  getvr('inttime') || 0.0
end

#trackObject

call-seq: track(name, switches)

Allows the programmer to set switches associated with uv variable name.

There appears to be no way to “untrack” a variable.

swicthes is a String containing one or both of the following characters:

u

Remember if variable name gets updated. When it gets updated, updated? returns true the next time it is called.

c

Remember if variable name gets updated. When it gets updated, cause it to be copied during the next call to copyvr. [copyvr not yet supported.]

#updated?Boolean

call-seq: updated?() -> true or false

This checks whether any “important variables” has been updated in the last call to uvread() or scan(). Important variables are those flagged with the ‘u’ flag in a call to track().

Returns:

  • (Boolean)

#uvangleObject

Computes the uv position angle (in radians, clockwise from the v axis) from the current value of the coord uv variable using atan2(u,v). Returns 0.0 if coord is undefined or maldefined.



1068
1069
1070
1071
# File 'lib/miriad.rb', line 1068

def uvangle
  u, v, w = getvr('coord')
  (u && v) ? Math.atan2(u, v) : 0.0
end

#uvdistObject

Computes the uv distance from the current value of the coord uv variable. Returns 0.0 if coord is undefined or maldefined.



1075
1076
1077
1078
# File 'lib/miriad.rb', line 1075

def uvdist
  u, v, w = getvr('coord')
  (u && v) ? Math.hypot(u, v) : 0.0
end

#uvnextObject

call-seq: uvnext() -> nil

Skip to the next uv data record. When writing, this causes an end-of-record mark to be written. When reading, this causes data to be read up until the next end-of-record mark.

#uvreadObject

call-seq: uvread(preamble, data, flags) -> [nread, preamble, data, flags]

NOTE: This method provides lower-level access than the read() method. It may disappear in future versions.

This reads a single visibility from the data file. This starts by scanning the uv data stream until a correlation record is found. The correlations are then converted to complex numbers if necessary, and returned to the caller. read also performs some massaging and selection steps (see set() and select()).

  • preamble

    The preamble is either [u,v,time,baseline] or [u,v,w,time,baseline] if set('preamble','uvw/time/baseline') was called. A 5 element preamble will populate w with 0.0 if the dataset was written with only a 4 element preamble.

    • preamble must be passed in as an Array or NArray (of type NArray::DFLOAT) of suitable length (i.e. either 4 or 5). Its contents will be overwritten with new premable data.

  • data

    The complex valued correlation data are returned in data.

    • data must be passed in as an Array or Narray (of type NArray::SCOMPLEX). Its contents will be overwritten with nread data values. Note that an Array will be filled with real and imaginary components in consecutive elements and must therefore contain twice as many elements as the number of complex valued data points. In general, NArray data will be preferred.

    • The number of complex valued data points must be the same as the number of flag values, otherwise an exception will be raised. Note that the length of an Array is twice the number of complex valued data points that will fit in it.

  • flags

    The flags indicate whether the corresponding data value has been deemed good or bad. A 1 means good; a 0 means bad.

    • flags must be passed in as an Array or Narray (of type NArray::LINT). Its contents will be overwritten with nread flag values.

    • The number of complex valued data points must be the same as the number of flag values, otherwise an exception will be raised.

  • nread

    The number of complex data values and flag values actually read is returned in the first element of the return Array.

#uvwreadObject

call-seq: uvwread(data, flags) -> [nread, data, flags]

NOTE: This method provides lower-level access than the wread() method. It may disappear in future versions.

This reads a single wideband visibility record from the data file. This should generally be called after uvread(). It performs no scanning before returning the data. Thus it always returns any wideband data (even if uvread() has detected end-of-file). Although uvwread() is independent of the linetype set with set(), it otherwise generally performs the same massaging steps as uvread() (e.g. data selection, amplitude flagging and planet scaling).

The parameters and return values are the same as for uvread(), minus the preamble parameter and return value.

#vartableObject

Returns a Hash whose keys are the names of all uv variables present in this dataset, with corresponding values indicating the type code (suitable for passing to getvr()) of the uv variable.

This reads the vartable item, thus when using this method on a dataset opened in ‘write’ mode, you must call flush() before calling this method, otherwise the vartable item will be up to date.



1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
# File 'lib/miriad.rb', line 1149

def vartable
  v = {}
  begin
    item = haccess('vartable','r')
  rescue
    return nil
  end
  begin
    while (line = hreadln(item))
      type, name = line.split
      v[name] = type[0,1]
    end
  ensure
    hdaccess(item)
  end
  v
end

#visnoObject

call-seq: visno(name) -> Integer

Returns the number of the last visibility read. Note that MIRIAD currently increments the visibiliity number on every read, including reads at (or beyond) the end of file. This means that after looping through a dataset with while vis = uvio.read(vis), visno will return one more than the visibility number of the last visibility.

#wflagwrObject

call-seq: wflagwr(flags) -> nil

Write wideband flags after a uvwread. This rewrites the flags associated with the last call to uvwread. It will typically be called soon after uvwread, thus overwriting the old flags.

flags is either an Array or NArray (of type NArray::LINT) and will typically have been returned by uvread and subsequently modified.

#writeObject

call-seq: write(preamble, data, flags) -> [preamble, data, flags]

Write a visibility record to the uv dataset. Please note write closes the record. Any wideband data should have been written with wwrite before this call.

preamble can be an Array or NArray of 4 or 5 elements giving u, v, optionally w (see uvset()), time, and baseline (in that order). If preamble is an NArray, it must be of type NArray::DFLOAT.

data is the complex correlation data. It can be an Array or NArray. If it is an Array, it must have the real and imaginary components in consecutive elemtents (specifically, Complex Array elements are not [yet] supported). If it is an NArray, it must be of type NArray::SFLOAT (with real and imaginary components in consecutive elements) or NArray::SCOMPLEX (with complex elements).

flags can be an Array or NArray. If it is an NArray, it must be of type NArray::LINT. Note that flags must have as many elements as data has complex data points. This will be either half as many elements as data (if data has real and imaginary components in consecutive elements) or the same number of elements as data (if data is NArray::SCOMPLEX).

The flags indicate whether the corresponding data value has been deemed good or bad:

  • 1 means good

  • 0 means bad

#wwriteObject

call-seq: wwrite(preamble, data, flags) -> [preamble, data, flags]

Write a wide-band visibility record to the data file. Make sure this routine is called before write(), since that closes the record.

See write() for a discussion of preamble, data, and flags.