Class NOAA1bReader

java.lang.Object
noaa.coastwatch.io.EarthDataReader
noaa.coastwatch.io.NOAA1bReader
Direct Known Subclasses:
NOAA1bV1Reader, NOAA1bV2Reader

public abstract class NOAA1bReader extends EarthDataReader
A NOAA 1b reader is an earth data reader that reads NOAA 1b format GAC/LAC/HRPT data files available from the NOAA/NESDIS Satellite Active Archive. For file format details, see:
http://www.saa.noaa.gov
The class may be used in a general way as an earth data reader to retrieve calibrated AVHRR variable data and dataset information, or in a more specific way to retrieve raw scan line and header information. A selected subset of scan line and header attributes are available as needed to implement the interface of an Earth data reader. Where no access to the underlying data is supplied, the raw data may be used.
Since:
3.1.3
Author:
Peter Hollemans
  • Field Details

    • SWATH_POLY_SIZE

      public static final double SWATH_POLY_SIZE
      The swath polynomial size in kilometers.
      See Also:
    • LAC_NAVIGATION_START

      public static final int LAC_NAVIGATION_START
      The starting sample for LAC navigation.
      See Also:
    • LAC_NAVIGATION_END

      public static final int LAC_NAVIGATION_END
      The ending sample for LAC navigation.
      See Also:
    • LAC_NAVIGATION_STEP

      public static final int LAC_NAVIGATION_STEP
      The navigation step size for LAC navigation.
      See Also:
    • GAC_NAVIGATION_START

      public static final int GAC_NAVIGATION_START
      The starting sample for GAC navigation.
      See Also:
    • GAC_NAVIGATION_END

      public static final int GAC_NAVIGATION_END
      The ending sample for GAC navigation.
      See Also:
    • GAC_NAVIGATION_STEP

      public static final int GAC_NAVIGATION_STEP
      The navigation step size for GAC navigation.
      See Also:
    • LAC_SAMPLES

      public static final int LAC_SAMPLES
      The number of samples per line for LAC data.
      See Also:
    • GAC_SAMPLES

      public static final int GAC_SAMPLES
      The number of samples per line for GAC data.
      See Also:
    • LOOKUP_TABLE_SIZE

      public static final int LOOKUP_TABLE_SIZE
      The size of each calibration lookup table.
      See Also:
    • MAX_LOOKUP_TABLES

      public static final int MAX_LOOKUP_TABLES
      The maximum number of calibration lookup tables per channel.
      See Also:
    • MAX_SCAN_LINES

      public static final int MAX_SCAN_LINES
      The maximum number of scan lines in the cache.
      See Also:
    • inputChannel

      protected FileChannel inputChannel
      The input channel.
    • lines

      protected int lines
      The number of scan lines in this dataset.
    • records

      protected int records
      The number of records in this dataset. This is the number of actual scan lines minus the number of missing lines.
    • scanLineMap

      protected int[] scanLineMap
      The scan line map array mapping scan line number to record number.
    • samples

      protected int samples
      The number of samples in this dataset.
    • archive

      protected boolean archive
      The archive header flag, true if we have an archive header.
    • dataHeaders

      protected int dataHeaders
      The number of data headers for this dataset.
    • archiveHeaderSize

      protected int archiveHeaderSize
      The size of the archive header for this dataset in bytes.
    • recordSize

      protected int recordSize
      The size of the data header and records for this dataset in bytes.
    • attributeDataSize

      protected int attributeDataSize
      The size of the scan line attributes section in bytes.
    • sensorWordSize

      protected int sensorWordSize
      The sensor word size in bits.
    • scanLineCache

      protected Map<Integer,NOAA1bReader.ScanLine> scanLineCache
      The scan line cache.
  • Constructor Details

    • NOAA1bReader

      protected NOAA1bReader(String file) throws IOException
      Constructs a NOAA 1b reader from the specified file.
      Parameters:
      file - the file name to read.
      Throws:
      IOException - if an error occurred reading the file data.
  • Method Details

    • getRecordStart

      protected int getRecordStart(int record)
      Gets the start of the record as a byte offset.
    • getVariableNames

      protected abstract String[] getVariableNames()
      Gets the variable names in this dataset.
    • getArchiveFlag

      protected abstract boolean getArchiveFlag() throws IOException
      Checks for an archive header and returns true if so.
      Throws:
      IOException
    • getLines

      public int getLines()
      Gets the number of scan lines in this dataset.
    • getSamples

      public int getSamples()
      Gets the number of samples per scan line in this dataset.
    • isArchive

      public boolean isArchive()
      Gets the archive header flag, true if the dataset has an archive header.
    • getArchiveHeader

      public abstract NOAA1bReader.ArchiveHeader getArchiveHeader() throws IOException
      Gets the archive header if it exists.
      Returns:
      the archive header.
      Throws:
      IOException - if an error occurred reading the file data.
    • getDataHeader

      public abstract NOAA1bReader.DataHeader getDataHeader() throws IOException
      Gets the data header.
      Returns:
      the data header.
      Throws:
      IOException - if an error occurred reading the file data.
    • getScanLine

      public abstract NOAA1bReader.ScanLine getScanLine(int line, int start, int count) throws IOException
      Gets the scan line at the specified index.
      Parameters:
      line - the scan line index in the range [0..lines-1].
      start - the starting sensor data sample.
      count - the total number of sensor data samples. If the count is 0, no sensor data is read.
      Returns:
      the requested scan line.
      Throws:
      IOException - if an error occurred reading the file data or the scan line is marked as missing.
      See Also:
    • checkFormat

      protected abstract void checkFormat() throws IOException
      Checks the dataset format and throws an error if it is incompatible with this reader.
      Throws:
      IOException
    • isByteSwapped

      public boolean isByteSwapped()
      Determines if the data is byte swapped. Normally, NOAA 1b format files are not byte swapped, so this method returns false but may be overridden in a subclass for handling strange formats.
      Returns:
      true if byte swapped, or false if not.
    • isNavigationUsable

      protected abstract boolean isNavigationUsable(int record, ByteBuffer buffer) throws IOException
      Gets the navigation data usability flag. This method is used to determine if navigation data is usable for a certain scan line without reading all the scan line data.
      Parameters:
      record - the record to check for navigation (note this is not the same as the line number used in the scan line constructor).
      buffer - the buffer to use for reading data.
      Returns:
      true if the line has usable navigation data, or false if not.
      Throws:
      IOException
    • getDataBuffer

      protected ByteBuffer getDataBuffer(int start, int length) throws IOException
      Gets a data buffer for the file with data from the specified region.
      Parameters:
      start - the starting byte offset.
      length - the length of the buffer.
      Returns:
      the buffer of byte values.
      Throws:
      IOException - if an error occurred reading the file.
    • isPrint

      public static boolean isPrint(byte b)
      Determines if a byte is a valid printable ASCII character.
    • getBytes

      public static byte[] getBytes(ByteBuffer data, int offset, int length)
      Gets a byte array from the specified byte buffer.
    • getUByte

      public static short getUByte(ByteBuffer data, int offset)
      Gets an unsigned 8-bit value from the specified byte buffer.
    • getUShort

      public static int getUShort(ByteBuffer data, int offset)
      Gets an unsigned 16-bit value from the specified byte buffer.
    • getShort

      public static short getShort(ByteBuffer data, int offset)
      Gets a signed 16-bit value from the specified byte buffer.
    • getUInt

      public static long getUInt(ByteBuffer data, int offset)
      Gets an unsigned 32-bit value from the specified byte buffer.
    • getNBit

      public static long getNBit(ByteBuffer data, int startOffset, int valueOffset, int bits)
      Gets an n-bit value from the specified byte buffer.
      Parameters:
      data - the byte buffer to extract data from.
      startOffset - the starting offset into the byte buffer to count n-bit data values from.
      valueOffset - the number of n-bit values into the array to extract an integer from.
      bits - the number of bits in each value in the range [1..64].
    • getInt

      public static int getInt(ByteBuffer data, int offset)
      Gets a signed 32-bit value from the specified byte buffer.
    • interpolateNavigation

      public float[] interpolateNavigation(float[] navData, int lineIndex, int variable, int start, int count)
      Interpolates navigation data using the specified raw navigation data and sample range.
      Parameters:
      navData - the navigation data.
      lineIndex - the scan line index in the range [0..lines-1].
      variable - the navigation variable to interpolate. Special actions may be taken depending on the variable.
      start - the starting sensor data sample.
      count - the total number of sensor data samples.
      Returns:
      an array of navigation angles, interpolated so that each sample in the specified range.
      See Also:
    • interpolateRawNavigation

      public float[] interpolateRawNavigation(int line, int variable)
      Interpolates the raw navigation data values for the specified scan line. Generally, this is only required if continuous navigation data is critical in some application. The interpolation employs a 4-point Lagrange method using the closest lines with valid navigation both before and after the specified line.
      Parameters:
      line - the desired line for interpolation.
      variable - the navigation variable for interpolation.
      Returns:
      the array of interpolated raw navigation data values.
      Throws:
      RuntimeException - if not enough valid navigation lines are available close to the specified line to perform an interpolation.
      See Also:
    • getPreviewImpl

      protected DataVariable getPreviewImpl(int index) throws IOException
      Description copied from class: EarthDataReader
      Implementation for the subclass.
      Specified by:
      getPreviewImpl in class EarthDataReader
      Throws:
      IOException
      See Also:
    • getVariable

      public DataVariable getVariable(int index) throws IOException
      Description copied from class: EarthDataReader
      Creates a data variable object. The full data is read into the object.
      Specified by:
      getVariable in class EarthDataReader
      Parameters:
      index - the index of the variable to get. Indexing starts at 0.
      Returns:
      a data variable object with full data value array.
      Throws:
      IOException - if the data source had I/O errors.
      See Also:
    • close

      public void close() throws IOException
      Description copied from class: EarthDataReader
      Closes the reader and frees any resources.
      Specified by:
      close in class EarthDataReader
      Throws:
      IOException - if the data source had I/O errors.