cds.astro
Class Astrocoo

java.lang.Object
  extended by cds.astro.Coo
      extended by cds.astro.Astrocoo
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
Astropos

public class Astrocoo
extends Coo
implements java.io.Serializable

This class defines the spherical coordinates used in Astronomy. It associates the coordinates on the sphere (defined in the Coo class) with the system (Astroframe) in which they are expressed. It also includes the accuracy (number of digits) in which the coordinates are expressed, and the epoch of the position.

The typical usage of the Astrocoo class consists in:

  1. Define an astronomical coordinate frame by means of one of the constructors;
  2. Assign a position in this frame via one of the set methods
  3. Convert to another frame via the convertTo method
  4. The angles (in degrees) are best extracted via getLon and getLat methods
The edition of the position in an Astrocoo can be done in a StringBuffer (edit methods) with options like sexagesimal or decimal edition, or as a String with one of the available toString methods.

See Also:
Astroframe, Astroformat, Serialized Form

Field Summary
static byte ARCMIN
          Definitions of Precisions for the angles
static byte ARCSEC
          Definitions of Precisions for the angles
static boolean DEBUG
           
static byte DEG
          Definitions of Precisions for the angles
protected  byte dlat
          The precision (number of decimals+1) of the latitude
protected  byte dlon
          The precision (number of decimals+1) of the longitude
static short EDIT_2NUMBERS
          Editing option to separate the 2 components by a blank
static short EDIT_DEFAULT
          The default edition options
static short EDIT_EPOCH
          Editing option to write the Epoch
static short EDIT_FRAME
          Editing option to insert the name of the frame
static short EDIT_FULL
          Editing option to show all decimals
static short EDIT_MEAN_EPOCH
          Editing option to write the MeanEpoch
protected  short editing
          The editing option includes basic options described in Astroformat, plus the EDIT_FRAME, EDIT_FULL and EDIT_2 options.
 double epoch
          Epoch (Jyr) of the position
protected  byte formRA
          How RA was entered, see Astroformat
 Astroframe frame
          The associated frame
static byte MAS
          Definitions of Precisions for the angles
static byte NONE
          Definitions of Precisions for the angles
protected  byte precision
          The precision is 0=unknown, 1=DEG, 3=ARCMIN, 5=ARCSEC, 8=MAS, etc .
 
Fields inherited from class cds.astro.Coo
decimals, ed, lat, lon, Umatrix3, x, y, z
 
Constructor Summary
Astrocoo()
          Create the default ICRS Astrocoo
Astrocoo(Astroframe frame)
          Create an Astrocoo object: specify just frame, equinox, precision.
Astrocoo(Astroframe frame, double lon, double lat)
          Create an Astrocoo object with a known position.
Astrocoo(Astroframe frame, double lon, double lat, double epoch)
          Create an Astrocoo object with a known position at given epoch.
Astrocoo(Astroframe frame, java.lang.String text)
          Create an Astrocoo object from a position (Epoch)
Astrocoo(java.lang.String text)
          Create an Astrocoo object from just a string.
 
Method Summary
 java.lang.Object clone()
          Clone the Coo object
static void convert(Astrocoo source, Astrocoo target)
          Transform the celestial position.
 void convertTo(Astroframe new_frame)
          Transform the position into another frame.
 void dump(java.lang.String title)
          Dump the contents of an Astrocoo.
 java.lang.StringBuffer edit(java.lang.StringBuffer buf, int opt)
          Method to edit the Coordinates in a StringBuffer
protected  java.lang.StringBuffer editEpoch(java.lang.StringBuffer buf, double Jyr)
          Function to edit one number representing an apoch in Jyr
static int editingOptions(java.lang.String text)
          Convert the String of editing options into an integer
 boolean equals(java.lang.Object o)
          Compare 2 coordinates.
static java.lang.String explain(int editing)
          Explain the editing option of the coordinate
 int getEditing()
          Get the defaut editing option.
static double getEpoch(Parsing txt)
          Interpret an epoch, eventually within ( ).
 Astroframe getFrame()
          Get an explicit designation of the frame
 byte getLatPrec()
          Get the precision on the longitude
 byte getLonPrec()
          Get the precision on the latitude
 int getPrecision()
          Get the precision of the current value
 int parse(java.lang.String txt, int offset)
          Parsing method: interpret a String.
 boolean parseIAU(Parsing txt)
          Interpret the string representing a position in IAU-style.
 boolean parsing(Parsing txt)
          Interpret the string and convert to Coo + Epoch.
 void set(Astrocoo coo)
          Set a position from an existing one (copy).
 void set(Coo coo, double epoch)
          Set position + epoch.
 void set(java.lang.String text)
          Set a position from a text which may contain position and Epoch.
 void setEditing(int edit_option)
          Change the default way of edition
 void setEditing(java.lang.String options)
          Change the default way of edition
 boolean setEpoch(double epoch)
          Change the Epoch of the data
 void setIAU(java.lang.String text)
          Set a position from a text -- accept IAU-format (HHMM...+DDMM...).
 void setPrecision(int precision)
          Change the precision of the data
 void setPrecision(int dlon, int dlat)
          Change the precision of the data
 java.lang.String toIAU(java.lang.String IAUtemplate)
          Edition with IAU-style.
 java.lang.String toString()
          Default edition: use what's stored
 java.lang.String toString(int edit_option)
          Customized edition of Coordinates to a String
 java.lang.String toString(java.lang.String options)
          Customized edition of Coordinates to a String
 
Methods inherited from class cds.astro.Coo
add, add, angle, copyAngles, copyUvector, dist2, dist2, dist2, distance, distance, distc, dotprod, dotprod, dotprod, editCoo, eulerMatrix, getLat, getLon, localMatrix, localMatrix, localMatrix, moveMatrix, norm2, normalize, normalize, perpendicular, posAngle, rotate_1, rotate, rotateVector_1, rotateVector, set, set, set, set, setDecimals, setUvec, sub, sub, toString, toString, toString, vecprod, vecprod, vecprod
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEBUG

public static boolean DEBUG

frame

public Astroframe frame
The associated frame


epoch

public double epoch
Epoch (Jyr) of the position


dlon

protected byte dlon
The precision (number of decimals+1) of the longitude


dlat

protected byte dlat
The precision (number of decimals+1) of the latitude


precision

protected byte precision
The precision is 0=unknown, 1=DEG, 3=ARCMIN, 5=ARCSEC, 8=MAS, etc . There is also an intrinsic precision associated to the frame.


formRA

protected byte formRA
How RA was entered, see Astroformat


editing

protected short editing
The editing option includes basic options described in Astroformat, plus the EDIT_FRAME, EDIT_FULL and EDIT_2 options. It can be changed via the setEditing(int) method.


NONE

public static final byte NONE
Definitions of Precisions for the angles

See Also:
Constant Field Values

DEG

public static final byte DEG
Definitions of Precisions for the angles

See Also:
Constant Field Values

ARCMIN

public static final byte ARCMIN
Definitions of Precisions for the angles

See Also:
Constant Field Values

ARCSEC

public static final byte ARCSEC
Definitions of Precisions for the angles

See Also:
Constant Field Values

MAS

public static final byte MAS
Definitions of Precisions for the angles

See Also:
Constant Field Values

EDIT_FRAME

public static final short EDIT_FRAME
Editing option to insert the name of the frame

See Also:
Constant Field Values

EDIT_2NUMBERS

public static final short EDIT_2NUMBERS
Editing option to separate the 2 components by a blank

See Also:
Constant Field Values

EDIT_EPOCH

public static final short EDIT_EPOCH
Editing option to write the Epoch

See Also:
Constant Field Values

EDIT_MEAN_EPOCH

public static final short EDIT_MEAN_EPOCH
Editing option to write the MeanEpoch

See Also:
Constant Field Values

EDIT_FULL

public static final short EDIT_FULL
Editing option to show all decimals

See Also:
Constant Field Values

EDIT_DEFAULT

public static final short EDIT_DEFAULT
The default edition options

See Also:
Constant Field Values
Constructor Detail

Astrocoo

public Astrocoo()
Create the default ICRS Astrocoo


Astrocoo

public Astrocoo(Astroframe frame)
Create an Astrocoo object: specify just frame, equinox, precision. Actual positions are normally specified by the set method.

Parameters:
frame - one of the possible Astroframes

Astrocoo

public Astrocoo(Astroframe frame,
                double lon,
                double lat)
Create an Astrocoo object with a known position.

Parameters:
frame - one of the possible Astroframes
lon - Longitude of the position (degrees)
lat - Latitude of the position (degrees)

Astrocoo

public Astrocoo(Astroframe frame,
                double lon,
                double lat,
                double epoch)
Create an Astrocoo object with a known position at given epoch.

Parameters:
frame - one of the possible Astroframes
lon - Longitude of the position (degrees)
lat - Latitude of the position (degrees)
epoch - Epoch of the position, in Jyr (see Astrotime)

Astrocoo

public Astrocoo(Astroframe frame,
                java.lang.String text)
         throws java.text.ParseException
Create an Astrocoo object from a position (Epoch)

Parameters:
frame - one of the possible Astroframes
text - Text with position, possibly followed by an epoch. Valid texts are e.g. "12 34 12.45 -42 12 76.4 J1991.25" or "12 34 12.45 -42 12 76.4 (J1991.25)"
Throws:
java.text.ParseException

Astrocoo

public Astrocoo(java.lang.String text)
         throws java.text.ParseException
Create an Astrocoo object from just a string.

Parameters:
text - Text with frame, position, possibly followed by an epoch. Valid texts are e.g. "J2000: 12 34 12.45 -42 12 76.4 J1991.25" or "(ICRS) 12 34 12.45 -42 12 76.4 (J1991.25)" "J123456.12+781245.1" (IAU-type)
Throws:
java.text.ParseException
Method Detail

explain

public static final java.lang.String explain(int editing)
Explain the editing option of the coordinate

Returns:
A printable variant of format.

clone

public java.lang.Object clone()
Description copied from class: Coo
Clone the Coo object

Overrides:
clone in class Coo

getEpoch

public static double getEpoch(Parsing txt)
Interpret an epoch, eventually within ( ). We accept JD, MJD, J or B times.

Parameters:
txt - Text to interpret
Returns:
the epoch in Jyr, NULL if not found

parsing

public boolean parsing(Parsing txt)
Interpret the string and convert to Coo + Epoch. Called from set and parse routines.

Overrides:
parsing in class Coo
Parameters:
txt - to interpret as a Parsing object "12 34.5 -72 54 J1991.25"
Returns:
true if OK (2 coordinates found, and possibly an epoch). If false, no mouvement in txt.

parseIAU

public boolean parseIAU(Parsing txt)
Interpret the string representing a position in IAU-style.

Parameters:
txt - to interpret as a Parsing object "12 34.5 -72 54 J1991.25"
Returns:
true if OK (2 coordinates found, corresponding to frame) If false, no mouvement in txt.

parse

public int parse(java.lang.String txt,
                 int offset)
Parsing method: interpret a String.

Overrides:
parse in class Coo
Parameters:
txt - to interpret.
offset - starting position in text
Returns:
new position.

set

public void set(Astrocoo coo)
Set a position from an existing one (copy).

Parameters:
coo - the Astrocoo to copy.

set

public void set(java.lang.String text)
         throws java.text.ParseException
Set a position from a text which may contain position and Epoch. The frame is not modified. The precision is adapted to the number of significant digits existing in the input text string.

Overrides:
set in class Coo
Parameters:
text - Longitude + latitude in text
Throws:
java.text.ParseException - when the text can't br fully interpreted.

setIAU

public void setIAU(java.lang.String text)
            throws java.text.ParseException
Set a position from a text -- accept IAU-format (HHMM...+DDMM...). The frame is not modified.

Parameters:
text - HHMM..+DDMM.. or classical sexagesimal/decimal coordinates.
Throws:
java.text.ParseException - when the argument text is neither an IAU string, nor a position.

set

public void set(Coo coo,
                double epoch)
Set position + epoch. The precision is not changed.

Parameters:
coo - the lon+lat
epoch - the epoch.

setPrecision

public void setPrecision(int precision)
Change the precision of the data

Parameters:
precision - integer number, typically one of the values NONE (0), DEG (1), ARCMIN (3), ARCSEC (5), MAS (8); use ARCSEC+1 for 0.1arcsec, MAS-1 for 10mas, etc...

setPrecision

public void setPrecision(int dlon,
                         int dlat)
Change the precision of the data

Parameters:
dlon - Precision number on longitude (RA).
dlat - Precision number on latitude (Dec).

setEditing

public void setEditing(int edit_option)
Change the default way of edition

Parameters:
edit_option - A mixture of Astroformat options, and EDIT_FRAME EDIT_FULL.

setEditing

public void setEditing(java.lang.String options)
Change the default way of edition

Parameters:
options - a string with the option letters (see edit)
See Also:
editingOptions(java.lang.String)

setEpoch

public boolean setEpoch(double epoch)
Change the Epoch of the data

Parameters:
epoch - the epoch of the coordinates
Returns:
true when OK.

getFrame

public final Astroframe getFrame()
Get an explicit designation of the frame

Returns:
the explanation as a string

getPrecision

public final int getPrecision()
Get the precision of the current value

Returns:
the value.

getLonPrec

public byte getLonPrec()
Get the precision on the latitude

Returns:
the number representing the precision of the latitude

getLatPrec

public byte getLatPrec()
Get the precision on the longitude

Returns:
the number representing the longitude precision

getEditing

public final int getEditing()
Get the defaut editing option. Can be edited via e.g. Astroformat.explain()

Returns:
the value.

dump

public void dump(java.lang.String title)
Dump the contents of an Astrocoo.

Overrides:
dump in class Coo
Parameters:
title - A title to precede the dump

equals

public boolean equals(java.lang.Object o)
Compare 2 coordinates.

Overrides:
equals in class Coo
Parameters:
o - Objet a comparer.
Returns:
Vrai si o est identique a this.

editingOptions

public static int editingOptions(java.lang.String text)
                          throws java.lang.IllegalArgumentException
Convert the String of editing options into an integer

Parameters:
text - List of options:
        d = edit in Decimal
        s = edit in Sexagesimal
        : = separate sexagesimal parts with the colon
        u = separate sexagesimal parts with the relevant unit (h m s d m s)
        f = edit also the frame (system+equinox)
        F = edit in full precision (ignore the precision of the system)
        2 = edit with a blank between numbers
        E = edit the epoch
        M = edit the Mean Epoch 
        * = default edition options
Throws:
java.lang.IllegalArgumentException

editEpoch

protected final java.lang.StringBuffer editEpoch(java.lang.StringBuffer buf,
                                                 double Jyr)
Function to edit one number representing an apoch in Jyr

Parameters:
buf - Buffer where the result is appended as Jxxx or Bxxx
Jyr - The epoch, in Julian Years. A NaN value is edited as null.
Returns:
the StringBuffer

edit

public final java.lang.StringBuffer edit(java.lang.StringBuffer buf,
                                         int opt)
Method to edit the Coordinates in a StringBuffer

Overrides:
edit in class Coo
Parameters:
buf - Buffer where the result is appended
opt - A mixture of the options ED_COLON, ED_DECIMAL, EDIT_FULL, EDIT_SEXA, EDIT_FRAME, EDIT_2NUMBERS
Returns:
the StringBuffer

toString

public java.lang.String toString(int edit_option)
Customized edition of Coordinates to a String

Parameters:
edit_option - A mixture of Astroformat options, and EDIT_FRAME EDIT_FULL.
Returns:
the edited coordinates in a string

toString

public java.lang.String toString(java.lang.String options)
                          throws java.lang.IllegalArgumentException
Customized edition of Coordinates to a String

Parameters:
options - a string with the option letters (see edit)
Returns:
the edited coordinates in a string
Throws:
java.lang.IllegalArgumentException
See Also:
editingOptions(java.lang.String)

toString

public java.lang.String toString()
Default edition: use what's stored

Overrides:
toString in class Coo
Returns:
the edited string

toIAU

public java.lang.String toIAU(java.lang.String IAUtemplate)
                       throws java.text.ParseException
Edition with IAU-style.

Parameters:
IAUtemplate - a string starting by J B G (for IRCS/FK4/Galactic). A conversion is done if necessary. Examples of valid templates:
  • JHHMMSSss+DDMMSSs (as in 2MASS)
  • GLLL.llll+BB.bbbb (as in MSX)
  • JHHMM.m+DDMM (as in RX)
  • JHHMMm+DDMM (as in WDS)
  • BHHMM+DDd (as in PKS)
Returns:
the edited string.
Throws:
java.text.ParseException - when the argument text is incompatible.

convertTo

public void convertTo(Astroframe new_frame)
Transform the position into another frame.

Parameters:
new_frame - The frame of the resulting position.

convert

public static void convert(Astrocoo source,
                           Astrocoo target)
Transform the celestial position.

Parameters:
source - Source position (with its frame)
target - Target position (coordinates part replaced)