edu.nrao.sss.model.source
Class SourceVelocity

java.lang.Object
  extended by edu.nrao.sss.model.source.SourceVelocity
All Implemented Interfaces:
Cloneable, Comparable<SourceVelocity>

public class SourceVelocity
extends Object
implements Cloneable, Comparable<SourceVelocity>

The velocity of an astronomical source.

Version Info:

$Revision: 1710 $
$Date: 2008-11-14 11:54:07 -0700 (Fri, 14 Nov 2008) $
$Author: dharland $

Since:
2006-03-24
Author:
David M. Harland

Constructor Summary
SourceVelocity()
          Creates a new instance.
 
Method Summary
 Frequency calcShiftedFrequency(Frequency restFreq)
          Returns an observed frequency based on a rest frequency and the convention and magnitude of this source velocity.
 SourceVelocity clone()
          Returns a source velocity that is equal to this one.
 int compareTo(SourceVelocity other)
          Compares this velocity to other for order.
 boolean equals(Object o)
          Returns true if o is equal to this source velocity.
 VelocityConvention getConvention()
          Returns the convention used for this velocity.
 LinearVelocity getRadialVelocity()
          Returns the speed of this source velocity.
 VelocityFrame getRestFrame()
          Returns the frame of rest used for this velocity.
 FrequencyRange getValidFrequency()
          Returns the frequency range for which this source velocity is valid.
 int hashCode()
          Returns a hash code value for this source velocity.
 void reset()
          Returns this velocity to its initial state.
 void setConvention(VelocityConvention newConvention)
          Sets the convention used for this velocity.
 void setRadialVelocity(LinearVelocity newSpeed)
          Sets the speed of this source velocity.
 void setRestFrame(VelocityFrame restFrame)
          Sets the frame of rest used for this velocity.
 void setValidFrequency(FrequencyRange newRange)
          Sets the valid frequency range for this source velocity, assuming the source is at rest.
 String toString()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SourceVelocity

public SourceVelocity()
Creates a new instance.

Method Detail

reset

public void reset()
Returns this velocity to its initial state.


setConvention

public void setConvention(VelocityConvention newConvention)
Sets the convention used for this velocity.

If newConvention is null, it will be treated as a non-null default type.

Parameters:
newConvention - the measurement convention used by this velocity.

getConvention

public VelocityConvention getConvention()
Returns the convention used for this velocity.

Returns:
the velocity convention used by this source velocity.

setRestFrame

public void setRestFrame(VelocityFrame restFrame)
Sets the frame of rest used for this velocity.

Parameters:
restFrame - the frame of rest used for this velocity.

getRestFrame

public VelocityFrame getRestFrame()
Returns the frame of rest used for this velocity.

Returns:
the frame of rest used for this velocity.

setRadialVelocity

public void setRadialVelocity(LinearVelocity newSpeed)
Sets the speed of this source velocity. Note that newSpeed will be referenced internally by this object, so any changes made to it after this call will be reflected herein.

If newSpeed is null, this velocity's speed will be set to zero, with the units set according to the current convention.

Parameters:
newSpeed - the new radial velocity for this source velocity.

getRadialVelocity

public LinearVelocity getRadialVelocity()
Returns the speed of this source velocity.

The return value is guaranteed to be non-null. It is also the speed that is held internally by this source velocity, so any changes made to the returned speed will be reflected in this object.

Returns:
the radial velocity for this source velocity.

setValidFrequency

public void setValidFrequency(FrequencyRange newRange)
Sets the valid frequency range for this source velocity, assuming the source is at rest.

If newRange is null, this velocity's frequency range will be set to all (positive) frequencies.

Parameters:
newRange - the frequency range for this source velocity.

getValidFrequency

public FrequencyRange getValidFrequency()
Returns the frequency range for which this source velocity is valid.

The return value is guaranteed to be non-null. It is also the range that is held internally by this source velocity, so any changes made to the returned range will be reflected in this object.

Returns:
the valid frequency range for this source velocity.

calcShiftedFrequency

public Frequency calcShiftedFrequency(Frequency restFreq)
Returns an observed frequency based on a rest frequency and the convention and magnitude of this source velocity.

Parameters:
restFreq - a rest frequency that is to be transformed to another value based on this velocity.
Returns:
an observed frequency based on restFreq and this velocity.

toString

public String toString()
Overrides:
toString in class Object

clone

public SourceVelocity clone()
Returns a source velocity that is equal to this one.

If anything goes wrong during the cloning procedure, a RuntimeException will be thrown.

Overrides:
clone in class Object

equals

public boolean equals(Object o)
Returns true if o is equal to this source velocity.

Overrides:
equals in class Object

hashCode

public int hashCode()
Returns a hash code value for this source velocity.

Overrides:
hashCode in class Object

compareTo

public int compareTo(SourceVelocity other)
Compares this velocity to other for order.

One velocity is deemed to be "less than" the other if it has a valid frequency range that is less than that of the other. In the case that two velocities have the same valid frequency range, the rest frame is used as a tie-breaker. If these are the same the velocity value, in km/s, is compared next. If no differences are found, the return value is zero.

Specified by:
compareTo in interface Comparable<SourceVelocity>
Parameters:
other - the velocity to which this one is compared.
Returns:
a negative integer, zero, or a positive integer as this velocity is less than, equal to, or greater than the other velocity.


Copyright © 2009. All Rights Reserved.