Package nom.tam.fits

Class BasicHDU<DataClass extends Data>

    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected BasicHDU​(Header myHeader, DataClass myData)  
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      void addValue​(java.lang.String key, boolean val, java.lang.String comment)
      Add information to the header.
      void addValue​(java.lang.String key, double val, java.lang.String comment)  
      void addValue​(java.lang.String key, int val, java.lang.String comment)  
      void addValue​(java.lang.String key, java.lang.String val, java.lang.String comment)  
      void addValue​(IFitsHeader key, boolean val)  
      void addValue​(IFitsHeader key, double val)  
      void addValue​(IFitsHeader key, int val)  
      void addValue​(IFitsHeader key, java.lang.String val)  
      HeaderCardBuilder card​(IFitsHeader key)
      get a builder for filling the header cards using the builder pattern.
      java.lang.String getAuthor()
      Return the name of the person who compiled the information in the data associated with this header.
      int[] getAxes()
      In FITS files the index represented by NAXIS1 is the index that changes most rapidly.
      int getBitPix()  
      long getBlankValue()  
      double getBScale()  
      java.lang.String getBUnit()  
      double getBZero()  
      java.util.Date getCreationDate()
      Get the FITS file creation date as a Date object.
      DataClass getData()  
      static BasicHDU<?> getDummyHDU()  
      double getEpoch()
      Deprecated.
      use getEquinox() instead
      double getEquinox()
      Get the equinox in years for the celestial coordinate system in which positions given in either the header or data are expressed.
      long getFileOffset()
      Get the starting offset of the HDU
      int getGroupCount()  
      Header getHeader()  
      java.lang.String getInstrument()
      Get the name of the instrument which was used to acquire the data in this FITS file.
      java.lang.Object getKernel()  
      double getMaximumValue()
      Return the minimum valid value in the array.
      double getMinimumValue()
      Return the minimum valid value in the array.
      java.lang.String getObject()
      Get the name of the observed object in this FITS file.
      java.util.Date getObservationDate()
      Get the FITS file observation date as a Date object.
      java.lang.String getObserver()
      Get the name of the person who acquired the data in this FITS file.
      java.lang.String getOrigin()
      Get the name of the organization which created this FITS file.
      int getParameterCount()  
      java.lang.String getReference()
      Return the citation of a reference where the data associated with this header are published.
      long getSize()  
      java.lang.String getTelescope()
      Get the name of the telescope which was used to acquire the data in this FITS file.
      java.lang.String getTrimmedString​(java.lang.String keyword)
      Get the String value associated with keyword.
      java.lang.String getTrimmedString​(IFitsHeader keyword)
      Get the String value associated with keyword.
      abstract void info​(java.io.PrintStream stream)
      Print out some information about this HDU.
      static boolean isData​(java.lang.Object o)  
      static boolean isHeader​(Header header)
      Check that this is a valid header for the HDU.
      void read​(ArrayDataInput stream)
      Read a data array into the current object and if needed position to the beginning of the next FITS block.
      boolean reset()
      Reset the input stream to point to the beginning of this element
      void rewrite()
      Rewrite the contents of the element in place.
      boolean rewriteable()  
      protected void saveReplaceCard​(java.lang.String key, boolean isString, java.lang.String value)
      Safely replace a card in the header, knowing that no exception will occur.
      void write​(ArrayDataOutput stream)
      Write the contents of the element to a data sink.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • 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​(java.lang.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​(java.lang.String key,
                                       boolean isString,
                                       java.lang.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​(java.lang.String key,
                             boolean val,
                             java.lang.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
      • getAuthor

        public java.lang.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.
      • getBScale

        public double getBScale()
      • getBUnit

        public java.lang.String getBUnit()
      • getBZero

        public double getBZero()
      • getCreationDate

        public java.util.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 java.lang.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 java.lang.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 java.lang.String getObject()
        Get the name of the observed object in this FITS file.
        Returns:
        either null or a String object
      • getObservationDate

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

        public java.lang.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 java.lang.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 java.lang.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 java.lang.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 java.lang.String getTrimmedString​(java.lang.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 java.lang.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​(java.io.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,
                         java.io.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.
        java.io.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,
                            java.io.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.
        java.io.IOException - if the rewrite was unsuccessful.
      • rewriteable

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