Package nom.tam.fits

Class BasicHDU<DataClass extends Data>

java.lang.Object
nom.tam.fits.BasicHDU<DataClass>
All Implemented Interfaces:
FitsElement
Direct Known Subclasses:
ImageHDU, RandomGroupsHDU, TableHDU, UndefinedHDU

public abstract class BasicHDU<DataClass extends Data> extends Object implements FitsElement
This abstract class is the parent of all HDU types. It provides basic functionality for an HDU.
  • Field Details

  • Constructor Details

  • Method Details

    • getDummyHDU

      public static BasicHDU<?> getDummyHDU()
      Returns:
      an HDU without content
    • isHeader

      public static boolean isHeader(Header header)
      Check that this is a valid header for the HDU. This method is static but should be implemented by all subclasses. TODO: refactor this to be in a meta object so it can inherit normally also see isData(Object)
      Parameters:
      header - to validate.
      Returns:
      true if this is a valid header.
    • isData

      public static boolean isData(Object o)
      Parameters:
      o - The Object being tested.
      Returns:
      if this object can be described as a FITS image. This method is static but should be implemented by all subclasses. TODO: refactor this to be in a meta object so it can inherit normally also see isHeader(Header)
    • saveReplaceCard

      protected void saveReplaceCard(String key, boolean isString, String value)
      Safely replace a card in the header, knowing that no exception will occur. Only for internal use!
      Parameters:
      key - the key of the card
      isString - is the value a String
      value - the String representation of the value
    • addValue

      public void addValue(IFitsHeader key, boolean val) throws HeaderCardException
      Throws:
      HeaderCardException
    • addValue

      public void addValue(IFitsHeader key, double val) throws HeaderCardException
      Throws:
      HeaderCardException
    • addValue

      public void addValue(IFitsHeader key, int val) throws HeaderCardException
      Throws:
      HeaderCardException
    • addValue

      public void addValue(IFitsHeader key, String val) throws HeaderCardException
      Throws:
      HeaderCardException
    • addValue

      public void addValue(String key, boolean val, String comment) throws HeaderCardException
      Add information to the header.
      Parameters:
      key - key to add to the header
      val - value for the key to add
      comment - comment for the key/value pair
      Throws:
      HeaderCardException - if the card does not follow the specification
    • addValue

      public void addValue(String key, double val, String comment) throws HeaderCardException
      Throws:
      HeaderCardException
    • addValue

      public void addValue(String key, int val, String comment) throws HeaderCardException
      Throws:
      HeaderCardException
    • addValue

      public void addValue(String key, String val, String comment) throws HeaderCardException
      Throws:
      HeaderCardException
    • getAuthor

      public String getAuthor()
      Return the name of the person who compiled the information in the data associated with this header.
      Returns:
      either null or a String object
    • getAxes

      public int[] getAxes() throws FitsException
      In FITS files the index represented by NAXIS1 is the index that changes most rapidly. This reflects the behavior of Fortran where there are true multidimensional arrays. In Java in a multidimensional array is an array of arrays and the first index is the index that changes slowest. So at some point a client of the library is going to have to invert the order. E.g., if I have a FITS file will
       BITPIX=16
       NAXIS1=10
       NAXIS2=20
       NAXIS3=30
       
      this will be read into a Java array short[30][20][10] so it makes sense to me at least that the returned dimensions are 30,20,10
      Returns:
      the dimensions of the axis.
      Throws:
      FitsException - if the axis are configured wrong.
    • getBitPix

      public int getBitPix() throws FitsException
      Throws:
      FitsException
    • getBlankValue

      public long getBlankValue() throws FitsException
      Throws:
      FitsException
    • getBScale

      public double getBScale()
    • getBUnit

      public String getBUnit()
    • getBZero

      public double getBZero()
    • getCreationDate

      public Date getCreationDate()
      Get the FITS file creation date as a Date object.
      Returns:
      either null or a Date object
    • getData

      public DataClass getData()
      Returns:
      the associated Data object
    • getEpoch

      @Deprecated public double getEpoch()
      Deprecated.
      use getEquinox() instead
      Get the equinox in years for the celestial coordinate system in which positions given in either the header or data are expressed.
      Returns:
      either null or a String object
    • getEquinox

      public double getEquinox()
      Get the equinox in years for the celestial coordinate system in which positions given in either the header or data are expressed.
      Returns:
      either null or a String object
    • getFileOffset

      public long getFileOffset()
      Get the starting offset of the HDU
      Specified by:
      getFileOffset in interface FitsElement
      Returns:
      the byte at which this element begins. This is only available if the data is originally read from a random access medium.
    • getGroupCount

      public int getGroupCount()
    • getHeader

      public Header getHeader()
      Returns:
      the associated header
    • card

      public HeaderCardBuilder card(IFitsHeader key)
      get a builder for filling the header cards using the builder pattern.
      Parameters:
      key - the key for the first card.
      Returns:
      the builder for header cards.
    • getInstrument

      public String getInstrument()
      Get the name of the instrument which was used to acquire the data in this FITS file.
      Returns:
      either null or a String object
    • getKernel

      public Object getKernel()
      Returns:
      the non-FITS data object
    • getMaximumValue

      public double getMaximumValue()
      Return the minimum valid value in the array.
      Returns:
      minimum value.
    • getMinimumValue

      public double getMinimumValue()
      Return the minimum valid value in the array.
      Returns:
      minimum value.
    • getObject

      public String getObject()
      Get the name of the observed object in this FITS file.
      Returns:
      either null or a String object
    • getObservationDate

      public Date getObservationDate()
      Get the FITS file observation date as a Date object.
      Returns:
      either null or a Date object
    • getObserver

      public String getObserver()
      Get the name of the person who acquired the data in this FITS file.
      Returns:
      either null or a String object
    • getOrigin

      public String getOrigin()
      Get the name of the organization which created this FITS file.
      Returns:
      either null or a String object
    • getParameterCount

      public int getParameterCount()
    • getReference

      public String getReference()
      Return the citation of a reference where the data associated with this header are published.
      Returns:
      either null or a String object
    • getSize

      public long getSize()
      Specified by:
      getSize in interface FitsElement
      Returns:
      The size of this element in bytes
    • getTelescope

      public String getTelescope()
      Get the name of the telescope which was used to acquire the data in this FITS file.
      Returns:
      either null or a String object
    • getTrimmedString

      public String getTrimmedString(String keyword)
      Get the String value associated with keyword.
      Parameters:
      keyword - the FITS keyword
      Returns:
      either null or a String with leading/trailing blanks stripped.
    • getTrimmedString

      public String getTrimmedString(IFitsHeader keyword)
      Get the String value associated with keyword.
      Parameters:
      keyword - the FITS keyword
      Returns:
      either null or a String with leading/trailing blanks stripped.
    • info

      public abstract void info(PrintStream stream)
      Print out some information about this HDU.
      Parameters:
      stream - the printstream to write the info on
    • read

      public void read(ArrayDataInput stream) throws FitsException, IOException
      Description copied from interface: FitsElement
      Read a data array into the current object and if needed position to the beginning of the next FITS block.
      Specified by:
      read in interface FitsElement
      Parameters:
      stream - The input data stream
      Throws:
      FitsException - if the read was unsuccessful.
      IOException - if the read was unsuccessful.
    • reset

      public boolean reset()
      Description copied from interface: FitsElement
      Reset the input stream to point to the beginning of this element
      Specified by:
      reset in interface FitsElement
      Returns:
      True if the reset succeeded.
    • rewrite

      public void rewrite() throws FitsException, IOException
      Description copied from interface: FitsElement
      Rewrite the contents of the element in place. The data must have been originally read from a random access device, and the size of the element may not have changed.
      Specified by:
      rewrite in interface FitsElement
      Throws:
      FitsException - if the rewrite was unsuccessful.
      IOException - if the rewrite was unsuccessful.
    • rewriteable

      public boolean rewriteable()
      Specified by:
      rewriteable in interface FitsElement
      Returns:
      true if this element can be rewritten?
    • write

      public void write(ArrayDataOutput stream) throws FitsException
      Description copied from interface: FitsElement
      Write the contents of the element to a data sink.
      Specified by:
      write in interface FitsElement
      Parameters:
      stream - The data sink.
      Throws:
      FitsException - if the write was unsuccessful.