Class FileFits


  • public class FileFits
    extends FileBase
    Some of this code is derived from FITS.java in ImageJ. In A User's Guide for the Flexible Image Transport System (FITS) Version 4.0, Section 4.1 Indexes and Physical Coordinates, the text says, "Historically, astronomers have generally assumed that the index point in a FITS file represents the center of a pixel. This interpretation is endorsed by GC. It differs from the common practice in computer graphics of treating the center of a pixel as a half-integral point." For CRPIXn in FITS: The center of the first pixel is 1 and the center of the last pixel is NAXISn. In MIPAV the center of the first pixel is 0.5 and the center of the last pixel is NAXISn - 0.5. So subtract 0.5 to go from FITS to MIPAV. " ...recommend that FITS writers order pixels starting in the lower left hand corner of the image, with the first axis increasing to the right, as in the rectangular coordinate x-axis, and the second increasing upward (the y-axis)." MIPAV uses the upper left hand corner as the origin and has the y axis going downward. Therefore, the image is flipped after reading and flipped before writing.

    ImageJ disclaimer:

    ImageJ is being developed at the National Institutes of Health by an employee of the Federal Government in the course of his official duties. Pursuant to Title 17, Section 105 of the United States Code, this software is not subject to copyright protection and is in the public domain. ImageJ is an experimental system. NIH assumes no responsibility whatsoever for its use by other parties, and makes no guarantees, expressed or implied, about its quality, reliability, or any other characteristic.

    • Field Detail

      • imgExtents

        int[] imgExtents
        DOCUMENT ME!
      • nDimensions

        int nDimensions
        DOCUMENT ME!
      • sourceType

        int sourceType
        DOCUMENT ME!
      • BLANK

        private int BLANK
        DOCUMENT ME!
      • endianess

        private boolean endianess
        DOCUMENT ME!
      • file

        private java.io.File file
        DOCUMENT ME!
      • fileDir

        private java.lang.String fileDir
        DOCUMENT ME!
      • fileName

        private java.lang.String fileName
        DOCUMENT ME!
      • haveBlank

        private boolean haveBlank
        DOCUMENT ME!
      • LUT

        private ModelLUT LUT
        DOCUMENT ME!
      • numberSlices

        private int numberSlices
        DOCUMENT ME!
      • isColorPlanar2D

        private boolean isColorPlanar2D
    • Constructor Detail

      • FileFits

        public FileFits​(java.lang.String fileName,
                        java.lang.String fileDir)
                 throws java.io.IOException
        FITS reader/writer constructor.
        Parameters:
        fileName - file name
        fileDir - file directory
        Throws:
        java.io.IOException - if there is an error making the file
    • Method Detail

      • finalize

        public void finalize()
        Prepares this class for cleanup. Calls the finalize method for existing elements, closes any open files and sets other elements to null.
        Overrides:
        finalize in class FileBase
      • getModelLUT

        public ModelLUT getModelLUT()
        returns LUT if defined.
        Returns:
        the LUT if defined else it is null
      • readImage

        public ModelImage readImage​(boolean one)
                             throws java.io.IOException
        reads the FITS file header and data.
        Parameters:
        one - DOCUMENT ME!
        Returns:
        DOCUMENT ME!
        Throws:
        java.io.IOException - if there is an error reading the file
      • writeImage

        public void writeImage​(ModelImage image,
                               FileWriteOptions options)
                        throws java.io.IOException
        Writes a FITS format type image.
        Parameters:
        image - Image model of data to write.
        options - options such as starting and ending slices and times
        Throws:
        java.io.IOException - if there is an error writing the file
      • readBuffer

        private void readBuffer​(int slice,
                                float[] buffer,
                                float scaleFact,
                                float scaleOffset)
                         throws java.io.IOException
        Reads a slice of data at a time and stores the results in the buffer.
        Parameters:
        slice - offset into the file stored in the dataOffset array
        buffer - buffer where the info is stored
        scaleFact - if 1 data is unscaled
        scaleOffset - if 0 don't add offset
        Throws:
        java.io.IOException - if there is an error reading the file
      • readDBuffer

        private void readDBuffer​(int slice,
                                 double[] buffer,
                                 double scaleFact,
                                 double scaleOffset)
                          throws java.io.IOException
        Reads a slice of data at a time and stores the results in the buffer.
        Parameters:
        slice - offset into the file stored in the dataOffset array
        buffer - buffer where the info is stored
        scaleFact - if 1 data is unscaled
        scaleOffset - if 0 don't add offset
        Throws:
        java.io.IOException - if there is an error reading the file