Class JP2_FileDataSource

  • All Implemented Interfaces:
    IImageDataSource

    public class JP2_FileDataSource
    extends Object
    implements IImageDataSource
    This class is intended to read images from disk that are from the Helioviewer API. These are assumed to be stored in a year/month/day/wavelength directory structure.
    Author:
    Dustin Kempton, Data Mining Lab, Georgia State University
    • Constructor Summary

      Constructors 
      Constructor Description
      JP2_FileDataSource​(String baseDir, int maxCacheSize, int cadenceMin, int expireMinutes)
      Constructor builds a JP2 file reader that requires the returned image to be within as set number of minutes of the queried time.
      JP2_FileDataSource​(String baseDir, int maxCacheSize, int cadenceMin, int expireMinutes, org.slf4j.Logger logger)
      Constructor builds a JP2 file reader that requires the returned image to be within as set number of minutes of the queried time.
    • Constructor Detail

      • JP2_FileDataSource

        public JP2_FileDataSource​(String baseDir,
                                  int maxCacheSize,
                                  int cadenceMin,
                                  int expireMinutes)
        Constructor builds a JP2 file reader that requires the returned image to be within as set number of minutes of the queried time. The object uses a cache on the list of image files in a directory on disk that correspond to a particular day. If the list of files in a directory are changing on disk, say as more are added to the directory as new observations are recored, then this cache needs to be purged of that list and updated with the new set of files in that directory. To do this the cache is set to purge that list after a number of minutes of that list not being accessed. The images are expected to be relative to the passed in base directory in a year/month/day/wavelength directory structure.
        Parameters:
        baseDir - The base directory to start the search from.
        maxCacheSize - The maximum number of directories to cache the list of files for, this speeds up searching for files that match the date because the list doesn't need to be rebult each time.
        cadenceMin - The allowed number of minutes difference between the query time and the returned image time.
        expireMinutes - The number of minutes of not accessing a list of files available for a day before that list is purged from the cache and will need to be pulled from disk again.
      • JP2_FileDataSource

        public JP2_FileDataSource​(String baseDir,
                                  int maxCacheSize,
                                  int cadenceMin,
                                  int expireMinutes,
                                  org.slf4j.Logger logger)
        Constructor builds a JP2 file reader that requires the returned image to be within as set number of minutes of the queried time. The object uses a cache on the list of image files in a directory on disk that correspond to a particular day. If the list of files in a directory are changing on disk, say as more are added to the directory as new observations are recored, then this cache needs to be purged of that list and updated with the new set of files in that directory. To do this the cache is set to purge that list after a number of minutes of that list not being accessed. The images are expected to be relative to the passed in base directory in a year/month/day/wavelength directory structure.
        Parameters:
        baseDir - The base directory to start the search from.
        maxCacheSize - The maximum number of directories to cache the list of files for, this speeds up searching for files that match the date because the list doesn't need to be rebult each time.
        cadenceMin - The allowed number of minutes difference between the query time and the returned image time.
        expireMinutes - The number of minutes of not accessing a list of files available for a day before that list is purged from the cache and will need to be pulled from disk again.
        logger - A logging mechanism so we can see what is going on
    • Method Detail

      • getImage

        public BufferedImage getImage​(org.joda.time.DateTime date,
                                      Waveband wavelength)
        Description copied from interface: IImageDataSource
        Method that gets an image as a bufferedImage that corresponds to the input time and wavelength from the datasource.
        Specified by:
        getImage in interface IImageDataSource
        Parameters:
        date - The time that the image was recorded.
        wavelength - The wavelength the image was recorded in.
        Returns:
        The BufferedImage representing the results, or null if no image was found fitting the constraints desired.
      • getHeader

        public ImageDBFitsHeaderData getHeader​(org.joda.time.DateTime date,
                                               Waveband wavelength)
        Description copied from interface: IImageDataSource
        Method that gets the header information for an image that corresponds to the input time and wavelength from the datasource.
        Specified by:
        getHeader in interface IImageDataSource
        Parameters:
        date - The time that the image was recorded.
        wavelength - The wavelength the image was recorded in.
        Returns:
        The ImageDBFitsHeaderData representing the results, or null if no image was found fitting the constraints desired.
      • getImageFile

        public File getImageFile​(org.joda.time.DateTime date,
                                 Waveband wavelength)
        Description copied from interface: IImageDataSource
        Method that gets the file representation of an image that corresponds to the input time and wavelength from the datasource.
        Specified by:
        getImageFile in interface IImageDataSource
        Parameters:
        date - The time that the image was recorded.
        wavelength - The wavelength the image was recorded in.
        Returns:
        The File representing the results, or null if no image was found fitting the constraints desired.
      • readInt

        public final int readInt​(byte[] byteBuffer,
                                 int pos)
        Reads a signed int (i.e., 32 bit) from the input. Prior to reading, the input should be realigned at the byte level.
        Returns:
        The next byte-aligned signed int (32 bit) from the input.
      • readFileTypeBox

        public boolean readFileTypeBox​(byte[] byteBuffer,
                                       int pos)
        This method reads the File Type box.
        Returns:
        false if the File Type box was not found or invalid else true
        Throws:
        IOException - If an I/O error occurred.
        EOFException - If the end of file was reached