Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD

Class ncsa.horizon.coordinates.FITSCoordMetadata

java.lang.Object
  |
  +--java.util.Dictionary
        |
        +--java.util.Hashtable
              |
              +--ncsa.horizon.util.Metadata
                    |
                    +--ncsa.horizon.coordinates.CoordMetadata
                          |
                          +--ncsa.horizon.coordinates.FITSCoordMetadata

public class FITSCoordMetadata
extends CoordMetadata
a Metadata class for loading coordinate metadata from a FITS image file.

This class provides a variety of methods that makes it easy load FITS metadata with the correct type. As the are loaded, they are converted values and types defined by the horizon schema so that they can be used by the horizon coordinate classes.

One should note that the FITS metadata format/schema uses the convention of numbering axes beginning with 1, in contrast to the horizon schema which numbers axes beginning with 0. Methods in this class that take an axis number as an argument assume the FITS convention (subtracting 1 from the input value when converting to the horizon schema).

The majority of methods provided by this class give the user a way of saving individual metadata values; these are methods like setNAXIS() and setCTYPE(). It also provides a few methods for parsing out FITS headers for coordinate-related data. These include scanHeaderLine() which parses a single line from the header, and scanHeader for parsing an entire header from an input stream. The modernize() method is used for converting depricated FITS keywords into their current alternatives. Finally, after the metadata list is fully loaded, one can use the createCoordSys() method to create the CoordinateSystem object the metadata describe.

See Also:
Serialized Form

Field Summary
static AxisPosFormatter defaultDecFormatter
           
static AxisPosFormatter defaultLinearFormatter
           
static AxisPosFormatter defaultRAFormatter
           
 
Fields inherited from class ncsa.horizon.coordinates.CoordMetadata
Axes, axisSchema, formatter, horizonSchema, label, name, naxes, refoffset, refposition, refvalue, stepsize, type, version
 
Fields inherited from class ncsa.horizon.util.Metadata
defaults, executeRunners, METARUNNER_TAG, schema, schemaVersion
 
Constructor Summary
FITSCoordMetadata()
          Construct a CoordMetadata list for a FITS image
FITSCoordMetadata(int naxes, Metadata defaults)
          Creates an metadatum list for a coordinate system with naxes axes
FITSCoordMetadata(int naxes)
          Creates an empty metadatum list with specified defaults.
FITSCoordMetadata(Metadata defaults)
          Creates an empty metadatum list with specified defaults.
 
Method Summary
static CoordinateSystem createCoordSys(Metadata md)
          create the coordinate system described by a metadata set.
CoordinateSystem createCoordSys()
          create the coordinate system described by this metadata set.
static java.lang.String FITSkeyval(java.lang.String line)
          return the value portion of a key-value pair from FITS header line.
static Metavector getIdentityPCMatrix(int n)
          return a Metavector object containing a PCMatrix whose values are equal to 1 on the diagonal and 0 otherwise.
static java.lang.String getLONLATName(char c)
          return the name horizon gives to various kinds of longitude and latitude based on the first letter of the CTYPE string.
static int getNAXIS(Metadata md)
          return the value of FITS keyword NAXIS, the number of axes in the dataset
int getNAXIS()
          return the value of FITS keyword NAXIS, the number of axes in the dataset
static void main(java.lang.String[] args)
           
static void modernize(Metadata md)
          convert deprecated metadata into their modern alternatives.
void modernize()
          convert deprecated metadata into their modern alternatives.
static java.lang.String parseAfterDash(java.lang.String ctype)
          return the string appearing after one or more dashes in a string
static java.lang.String scanHeaderCard(Metadata md, java.lang.String line)
          scan an 80-character line of a FITS header and load the data in the metadata list if it is recognized as pertaining to the coordinate system.
java.lang.String scanHeaderCard(java.lang.String card)
          scan an 80-character line of a FITS header and load the data in this metadata list if it is recognized as pertaining to the coordinate system.
static int scanHeader(Metadata md, java.io.InputStream header)
          scan FITS header and loads all the data recognized as pertaining to the coordinate system.
int scanHeader(java.io.InputStream header)
          scan FITS header and loads all the data recognized as pertaining to the coordinate system.
static void setCDELT(Metadata md, int axis, double in)
          insert a voxel width into a metadata list
void setCDELT(int axis, double in)
          insert a voxel width into this metadata list
static void setCROTA(Metadata md, int axis, double in)
          insert an axis rotation into a metadata list; since the CROTA keyword is being phased out in favor of a PC Matrix, one should run modernize() on the metadata list after all metadata are loaded if this method was called.
void setCROTA(int axis, double in)
          insert an axis rotation into this metadata list; since the CROTA keyword is being phased out in favor of a PC Matrix, one should run modernize() on the metadata list after all metadata are loaded if this method was called.
static void setCRPIX(Metadata md, int axis, double in)
          insert an axis reference data position into a metadata list
void setCRPIX(int axis, double in)
          insert an axis reference data position into this metadata list
static void setCRVAL(Metadata md, int axis, double in)
          insert an axis reference value into a metadata list
void setCRVAL(int axis, double in)
          insert an axis reference value into this metadata list
static void setCTYPE(Metadata md, int axis, java.lang.String value)
          insert the name and type information into a metadata list
void setCTYPE(int axis, java.lang.String in)
          insert the name and type information into this metadata list
static void setEPOCH(Metadata md, double in)
          insert the value of the EPOCH keyword into a metadata list
void setEPOCH(double in)
          insert the value of the EPOCH keyword into this metadata list
static void setEQUINOX(Metadata md, double in)
          insert the value of the EQUINOX keyword into a metadata list
void setEQUINOX(double in)
          insert the value of the EQUINOX keyword into this metadata list
static void setLATPOLE(Metadata md, double latpole)
          a the value of FITS keyword LATPOLE into a metadata list
void setLATPOLE(double latpole)
          insert the value of FITS keyword LATPOLE into this metadata list
static void setLONGPOLE(Metadata md, double longpole)
          a the value of FITS keyword LONGPOLE into a metadata list
void setLONGPOLE(double longpole)
          insert the value of FITS keyword LONGPOLE into this metadata list
static void setNAXIS(Metadata md, int nax)
          insert the number of axes into a metadata list
void setNAXIS(int nax)
          insert the number of axes into this metadata list
static void setPCMatrix(Metadata md, double[] in)
          insert a PC matrix into a metadata list
void setPCMatrix(double[] in)
          insert a PC matrix into this metadata list
static void setPCMatrix(Metadata md, int i, int j, double in)
          insert an element of the PC matrix into a metadata list.
void setPCMatrix(int i, int j, double in)
          insert an element of the PC matrix into a metadata list.
static void setPROJP(Metadata md, double[] in)
          insert an array of projection parameters in a metadata list
void setPROJP(double[] in)
          insert an array of projection parameters in this metadata list
static void setPROJP(Metadata md, int i, double in)
          insert an element of the array of projection parameters
void setPROJP(int i, double in)
          insert an element of the array of projection parameters
static void setRADECSYS(Metadata md, java.lang.String in)
          insert the value of the RADECSYS keyword into a metadata list
void setRADECSYS(java.lang.String in)
          insert the value of the RADECSYS keyword into this metadata list
static void setVeloStandard(Metadata md, int axis, java.lang.String in)
          set the value of the velocity standard in use for specific axis
void setVeloStandard(int axis, java.lang.String in)
          set the value of the velocity standard in use for specific axis
static void setVeloStandard(Metadata md, java.lang.String in)
          set the value of the default velocity standard for the entire coordinate system
void setVeloStandard(java.lang.String in)
          set the value of the default velocity standard for the entire coordinate system
 
Methods inherited from class ncsa.horizon.coordinates.CoordMetadata
axesMatchingName, axesMatchingName, axesMatchingType, axesMatchingType, axisExactlyMatchingName, axisExactlyMatchingType, firstAxisMatchingName, firstAxisMatchingName, firstAxisMatchingType, firstAxisMatchingType, getAxisNames, getAxisStrings, getAxisTypes, getNaxes, getNaxes, indicesMatchingString, initMetadata, put, setAxes, setAxes, setAxisFormatter, setAxisFormatter, setAxisFormatter, setAxisFormatter, setAxisLabel, setAxisLabel, setAxisLabel, setAxisLabel, setAxisName, setAxisName, setAxisName, setAxisName, setAxisObject, setAxisRefoffset, setAxisRefoffset, setAxisRefoffset, setAxisRefoffset, setAxisRefposition, setAxisRefposition, setAxisRefposition, setAxisRefposition, setAxisRefvalue, setAxisRefvalue, setAxisRefvalue, setAxisRefvalue, setAxisStepsize, setAxisStepsize, setAxisStepsize, setAxisStepsize, setAxisType, setAxisType, setAxisType, setAxisType, setName, setName, setNaxes, setNaxes, usesHorizonSchema, usesReferencedAxis
 
Methods inherited from class ncsa.horizon.util.Metadata
cloneDefaults, clone, copyMetadata, copyMetadata, deepClone, detachedClone, detach, fetchDatum, fetchMetadatum, getDefaults, getMetadatum, getMetadatum, getMetadatum, getMetadatum, getRunnerNames, giveDefaults, metadatumNames, put, removeAllMetadata, setDefaults, setSchema, setSchemaVersion, toString
 
Methods inherited from class java.util.Hashtable
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keySet, keys, putAll, put, rehash, remove, size, toString, values
 
Methods inherited from class java.util.Dictionary
elements, get, isEmpty, keys, put, remove, size
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait
 

Field Detail

defaultRAFormatter

public static final AxisPosFormatter defaultRAFormatter

defaultDecFormatter

public static final AxisPosFormatter defaultDecFormatter

defaultLinearFormatter

public static final AxisPosFormatter defaultLinearFormatter
Constructor Detail

FITSCoordMetadata

public FITSCoordMetadata()
Construct a CoordMetadata list for a FITS image

FITSCoordMetadata

public FITSCoordMetadata(int naxes,
                         Metadata defaults)
                  throws java.lang.ArrayIndexOutOfBoundsException
Creates an metadatum list for a coordinate system with naxes axes
Parameters:
naxes - the number of axes in the coordinate system
defaults - the defaults (can be null)

FITSCoordMetadata

public FITSCoordMetadata(int naxes)
                  throws java.lang.ArrayIndexOutOfBoundsException
Creates an empty metadatum list with specified defaults.
Parameters:
defaults - the defaults

FITSCoordMetadata

public FITSCoordMetadata(Metadata defaults)
                  throws java.lang.ArrayIndexOutOfBoundsException
Creates an empty metadatum list with specified defaults.
Parameters:
defaults - the defaults
Method Detail

getNAXIS

public static int getNAXIS(Metadata md)
return the value of FITS keyword NAXIS, the number of axes in the dataset
Parameters:
md - the metadata list to search

getNAXIS

public int getNAXIS()
return the value of FITS keyword NAXIS, the number of axes in the dataset

setNAXIS

public static void setNAXIS(Metadata md,
                            int nax)
insert the number of axes into a metadata list
Parameters:
md - the Metadata list to insert value into
nax - the value of the NAXIS keyword

setNAXIS

public void setNAXIS(int nax)
insert the number of axes into this metadata list
Parameters:
nax - the value of the NAXIS keyword

setCTYPE

public static void setCTYPE(Metadata md,
                            int axis,
                            java.lang.String value)
insert the name and type information into a metadata list
Parameters:
md - the Metadata list to insert value into
axis - the axis number (first axis is 1)
in - the value of the CTYPE keyword

setCTYPE

public void setCTYPE(int axis,
                     java.lang.String in)
insert the name and type information into this metadata list
Parameters:
axis - the axis number (first axis is 1)
in - the value of the CTYPE keyword

getLONLATName

protected static java.lang.String getLONLATName(char c)
return the name horizon gives to various kinds of longitude and latitude based on the first letter of the CTYPE string. This method assumes that the CTYPE is of the form "xLON-..." or "xLAT-...", where x is one of { G, E, H, S }.

parseAfterDash

public static java.lang.String parseAfterDash(java.lang.String ctype)
return the string appearing after one or more dashes in a string
Parameters:
ctype - the string to parse, usually the value of the CTYPE keyword

setCRVAL

public static void setCRVAL(Metadata md,
                            int axis,
                            double in)
insert an axis reference value into a metadata list
Parameters:
md - the Metadata list to insert value into
axis - the axis number (first axis is 1)
in - the value of the CRVAL keyword

setCRVAL

public void setCRVAL(int axis,
                     double in)
insert an axis reference value into this metadata list
Parameters:
axis - the axis number (first axis is 1)
in - the value of the CRVAL keyword

setCRPIX

public static void setCRPIX(Metadata md,
                            int axis,
                            double in)
insert an axis reference data position into a metadata list
Parameters:
md - the Metadata list to insert value into
axis - the axis number (first axis is 1)
in - the value of the CRPIX keyword

setCRPIX

public void setCRPIX(int axis,
                     double in)
insert an axis reference data position into this metadata list
Parameters:
axis - the axis number (first axis is 1)
in - the value of the CRPIX keyword

setCDELT

public static void setCDELT(Metadata md,
                            int axis,
                            double in)
insert a voxel width into a metadata list
Parameters:
md - the Metadata list to insert value into
axis - the axis number (first axis is 1)
in - the value of the CDELT keyword

setCDELT

public void setCDELT(int axis,
                     double in)
insert a voxel width into this metadata list
Parameters:
axis - the axis number (first axis is 1)
in - the value of the CDELT keyword

setCROTA

public static void setCROTA(Metadata md,
                            int axis,
                            double in)
insert an axis rotation into a metadata list; since the CROTA keyword is being phased out in favor of a PC Matrix, one should run modernize() on the metadata list after all metadata are loaded if this method was called.
Parameters:
md - the Metadata list to insert value into
axis - the axis the standard is associated with
in - the value of the CROTA keyword

setCROTA

public void setCROTA(int axis,
                     double in)
insert an axis rotation into this metadata list; since the CROTA keyword is being phased out in favor of a PC Matrix, one should run modernize() on the metadata list after all metadata are loaded if this method was called.
Parameters:
md - the Metadata list to insert value into
axis - the axis the standard is associated with
in - the value of the CROTA keyword

setVeloStandard

public static void setVeloStandard(Metadata md,
                                   int axis,
                                   java.lang.String in)
set the value of the velocity standard in use for specific axis
Parameters:
md - the Metadata list to insert value into
axis - the axis the standard is associated with
in - the code for the standard; e.g. "LSR", "HEL", "OBS".

setVeloStandard

public void setVeloStandard(int axis,
                            java.lang.String in)
set the value of the velocity standard in use for specific axis
Parameters:
axis - the axis the standard is associated with
in - the code for the standard; e.g. "LSR", "HEL", "OBS".

setVeloStandard

public static void setVeloStandard(Metadata md,
                                   java.lang.String in)
set the value of the default velocity standard for the entire coordinate system
Parameters:
md - the Metadata list to insert value into
in - the code for the standard; e.g. "LSR", "HEL", "OBS".

setVeloStandard

public void setVeloStandard(java.lang.String in)
set the value of the default velocity standard for the entire coordinate system
Parameters:
in - the code for the standard; e.g. "LSR", "HEL", "OBS".

setLONGPOLE

public static void setLONGPOLE(Metadata md,
                               double longpole)
a the value of FITS keyword LONGPOLE into a metadata list
Parameters:
md - the Metadata list to insert value into
in - value of the FITS keyword LONGPOLE

setLONGPOLE

public void setLONGPOLE(double longpole)
insert the value of FITS keyword LONGPOLE into this metadata list
Parameters:
in - value of the FITS keyword LONGPOLE

setLATPOLE

public static void setLATPOLE(Metadata md,
                              double latpole)
a the value of FITS keyword LATPOLE into a metadata list
Parameters:
md - the Metadata list to insert value into
in - value of the FITS keyword LATPOLE

setLATPOLE

public void setLATPOLE(double latpole)
insert the value of FITS keyword LATPOLE into this metadata list
Parameters:
in - value of the FITS keyword LATPOLE

setPCMatrix

public static void setPCMatrix(Metadata md,
                               double[] in)
insert a PC matrix into a metadata list
Parameters:
md - the Metadata list to insert value into
in - an array of NAXISxNAXIS elements, in order of (PC001001, PC001002, ..., PC002001, PC002002, ...)
Throws:
java.lang.IllegalArgumentException - if in.length is not a perfect square

setPCMatrix

public void setPCMatrix(double[] in)
insert a PC matrix into this metadata list
Parameters:
in - an array of NAXISxNAXIS elements, in order of (PC001001, PC001002, ..., PC002001, PC002002, ...)
Throws:
java.lang.IllegalArgumentException - if in.length is not a perfect square

setPCMatrix

public static void setPCMatrix(Metadata md,
                               int i,
                               int j,
                               double in)
insert an element of the PC matrix into a metadata list. The proper number of axes should be set before calling this method
Parameters:
md - the Metadata list to insert value into
i - the matrix row; e.g. 3 for PC003002
j - the matrix column; e.g. 2 for PC003002
in - the PC matrix element
Throws:
java.lang.ArrayIndexOutOfBoundsException - i or j < 1 or > NAXIS

setPCMatrix

public void setPCMatrix(int i,
                        int j,
                        double in)
insert an element of the PC matrix into a metadata list. The proper number of axes should be set before calling this method
Parameters:
i - the matrix row; e.g. 3 for PC003002
j - the matrix column; e.g. 2 for PC003002
in - the PC matrix element
Throws:
java.lang.ArrayIndexOutOfBoundsException - i or j < 1 or > NAXIS

getIdentityPCMatrix

public static Metavector getIdentityPCMatrix(int n)
return a Metavector object containing a PCMatrix whose values are equal to 1 on the diagonal and 0 otherwise.
Parameters:
n - the dimensionality of the matrix; output matrix will be n x n in size.

setPROJP

public static void setPROJP(Metadata md,
                            double[] in)
insert an array of projection parameters in a metadata list
Parameters:
md - the Metadata list to insert value into
in - an array containing the projection parameters

setPROJP

public void setPROJP(double[] in)
insert an array of projection parameters in this metadata list
Parameters:
in - an array containing the projection parameters

setPROJP

public static void setPROJP(Metadata md,
                            int i,
                            double in)
                    throws java.lang.ArrayIndexOutOfBoundsException
insert an element of the array of projection parameters
Parameters:
md - the Metadata list to insert value into
i - the array element to insert; e.g. 3 for PROJP3
in - the value of the parameter
Throws:
java.lang.ArrayIndexOutOfBoundsException - i < 1

setPROJP

public void setPROJP(int i,
                     double in)
insert an element of the array of projection parameters
Parameters:
md - the Metadata list to insert value into
i - the array element to insert; e.g. 3 for PROJP3
in - the value of the parameter
Throws:
java.lang.ArrayIndexOutOfBoundsException - i < 1

setRADECSYS

public static void setRADECSYS(Metadata md,
                               java.lang.String in)
insert the value of the RADECSYS keyword into a metadata list
Parameters:
md - the Metadata list to insert value into
in - the value of the RADECSYS keyword

setRADECSYS

public void setRADECSYS(java.lang.String in)
insert the value of the RADECSYS keyword into this metadata list
Parameters:
md - the Metadata list to insert value into
in - the value of the RADECSYS keyword

setEQUINOX

public static void setEQUINOX(Metadata md,
                              double in)
insert the value of the EQUINOX keyword into a metadata list
Parameters:
md - the Metadata list to insert value into
in - the value of the EQUINOX keyword

setEQUINOX

public void setEQUINOX(double in)
insert the value of the EQUINOX keyword into this metadata list
Parameters:
md - the Metadata list to insert value into
in - the value of the EQUINOX keyword

setEPOCH

public static void setEPOCH(Metadata md,
                            double in)
insert the value of the EPOCH keyword into a metadata list
Parameters:
md - the Metadata list to insert value into
in - the value of the EPOCH keyword

setEPOCH

public void setEPOCH(double in)
insert the value of the EPOCH keyword into this metadata list
Parameters:
md - the Metadata list to insert value into
in - the value of the EPOCH keyword

modernize

public static void modernize(Metadata md)
convert deprecated metadata into their modern alternatives. Currently, this includes converting CROTAi values into a PC matrix and converting the NCP projection to SIN. Note that if NCP is found to be the projection type, any previously existing projection parameters will be overriden. On the other hand, if both a PC matrix and CROTA values are found, the PC matrix will not be overriden unless it is found to be of the wrong dimensionality (i.e. != NAXIS^2).
Parameters:
md - the Metadata list to be updated

modernize

public void modernize()
convert deprecated metadata into their modern alternatives. Currently, this includes converting CROTAi values into a PC matrix and converting the NCP projection to SIN. Note that if NCP is found to be the projection type, any previously existing projection parameters will be overriden. On the other hand, if both a PC matrix and CROTA values are found, the PC matrix will not be overriden unless it is found to be of the wrong dimensionality (i.e. != NAXIS^2).
Parameters:
md - the Metadata list to be updated

scanHeaderCard

public static java.lang.String scanHeaderCard(Metadata md,
                                    java.lang.String line)
scan an 80-character line of a FITS header and load the data in the metadata list if it is recognized as pertaining to the coordinate system. The input line need not be strictly 80 characters long, as long as it contains the contents of only one FITS header card. The card is allowed to end in characters indicating the end of a line (i.e. \n, \r, \m\r). Since the line may have contained a deprecated FITS keyword, it is a good idea to run modernize on the metadata list after all metadata have been loaded.
Parameters:
md - the Metadata list to insert value into
line - the FITS header line
Returns:
String the keyword that was extracted, or null data was not saved to the metadata list

scanHeaderCard

public java.lang.String scanHeaderCard(java.lang.String card)
scan an 80-character line of a FITS header and load the data in this metadata list if it is recognized as pertaining to the coordinate system. The input line need not be strictly 80 characters long, as long as it contains the contents of only one FITS header card. The card is allowed to end in characters indicating the end of a line (i.e. \n, \r, \m\r). Since the line may have contained a deprecated FITS keyword, it is a good idea to run modernize on the metadata list after all metadata have been loaded.
Parameters:
card - the FITS header line
Returns:
String the keyword that was extracted, or null data was not saved to the metadata list

scanHeader

public static int scanHeader(Metadata md,
                             java.io.InputStream header)
                     throws java.io.IOException
scan FITS header and loads all the data recognized as pertaining to the coordinate system. Note that this method will run modernize() on the metadata list after all the data have been loaded.
Parameters:
md - the Metadata list to insert value into
header - the stream containing the header
Returns:
int the number of lines recognized as containing needed data

scanHeader

public int scanHeader(java.io.InputStream header)
              throws java.io.IOException
scan FITS header and loads all the data recognized as pertaining to the coordinate system. Note that this method will run modernize() on the metadata list after all the data have been loaded.
Parameters:
header - the stream containing the header
Returns:
int the number of lines recognized as containing needed data

FITSkeyval

public static java.lang.String FITSkeyval(java.lang.String line)
return the value portion of a key-value pair from FITS header line. If the value is a string, the quotes will be removed.

createCoordSys

public static CoordinateSystem createCoordSys(Metadata md)
                                                               throws IllegalTransformException
create the coordinate system described by a metadata set. Currently, the real type of the returned system is ncsa.horizon.coordinates.systems.SphLinCoordinateSystem.
Parameters:
md - the Metadata describing the system

createCoordSys

public CoordinateSystem createCoordSys()
                                                        throws IllegalTransformException
create the coordinate system described by this metadata set. Currently, the real type of the returned system is ncsa.horizon.coordinates.systems.SphLinCoordinateSystem.

main

public static void main(java.lang.String[] args)

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD