Package noaa.coastwatch.io
Class NOAA1bReader
java.lang.Object
noaa.coastwatch.io.EarthDataReader
noaa.coastwatch.io.NOAA1bReader
- Direct Known Subclasses:
NOAA1bV1Reader
,NOAA1bV2Reader
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.govThe 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
-
Nested Class Summary
Modifier and TypeClassDescriptionclass
The archive header class may be used to retrieve specific data from the archive header of the dataset.class
The data header class may be used to retrieve the header of the dataset.static class
TheLongitudeInterpolator
class performs longitude interpolation using polar coordinates.class
The scan line class may be used to retrieve specific data from one scan line of the dataset.protected class
TheScanLineCalibration
class holds calibration coefficients for one AVHRR scan line so that they may be used as a key in storing calibration lookup tables. -
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
The archive header flag, true if we have an archive header.protected int
The size of the archive header for this dataset in bytes.protected int
The size of the scan line attributes section in bytes.protected int
The number of data headers for this dataset.static final int
The ending sample for GAC navigation.static final int
The starting sample for GAC navigation.static final int
The navigation step size for GAC navigation.static final int
The number of samples per line for GAC data.protected NOAA1bReader.DataHeader
The dataset header record, used for calibration.protected FileChannel
The input channel.static final int
The ending sample for LAC navigation.static final int
The starting sample for LAC navigation.static final int
The navigation step size for LAC navigation.static final int
The number of samples per line for LAC data.protected int
The number of scan lines in this dataset.static final int
The size of each calibration lookup table.static final int
The maximum number of calibration lookup tables per channel.static final int
The maximum number of scan lines in the cache.protected int
The ending sample for navigation.protected int
The starting sample for navigation.protected int
The navigation step size for navigation.protected int
The number of records in this dataset.protected int
The size of the data header and records for this dataset in bytes.protected int
The number of samples in this dataset.protected Map<Integer,
NOAA1bReader.ScanLine> The scan line cache.protected int[]
The scan line map array mapping scan line number to record number.protected int
The sensor word size in bits.static final double
The swath polynomial size in kilometers.Fields inherited from class noaa.coastwatch.io.EarthDataReader
dataProjection, info, rawMetadataMap, variables
-
Constructor Summary
ModifierConstructorDescriptionprotected
NOAA1bReader
(String file) Constructs a NOAA 1b reader from the specified file. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract void
Checks the dataset format and throws an error if it is incompatible with this reader.void
close()
Closes the reader and frees any resources.protected abstract boolean
Checks for an archive header and returns true if so.abstract NOAA1bReader.ArchiveHeader
Gets the archive header if it exists.static byte[]
getBytes
(ByteBuffer data, int offset, int length) Gets a byte array from the specified byte buffer.protected ByteBuffer
getDataBuffer
(int start, int length) Gets a data buffer for the file with data from the specified region.abstract NOAA1bReader.DataHeader
Gets the data header.static int
getInt
(ByteBuffer data, int offset) Gets a signed 32-bit value from the specified byte buffer.int
getLines()
Gets the number of scan lines in this dataset.static long
getNBit
(ByteBuffer data, int startOffset, int valueOffset, int bits) Gets an n-bit value from the specified byte buffer.protected DataVariable
getPreviewImpl
(int index) Implementation for the subclass.protected int
getRecordStart
(int record) Gets the start of the record as a byte offset.int
Gets the number of samples per scan line in this dataset.abstract NOAA1bReader.ScanLine
getScanLine
(int line, int start, int count) Gets the scan line at the specified index.static short
getShort
(ByteBuffer data, int offset) Gets a signed 16-bit value from the specified byte buffer.static short
getUByte
(ByteBuffer data, int offset) Gets an unsigned 8-bit value from the specified byte buffer.static long
getUInt
(ByteBuffer data, int offset) Gets an unsigned 32-bit value from the specified byte buffer.static int
getUShort
(ByteBuffer data, int offset) Gets an unsigned 16-bit value from the specified byte buffer.getVariable
(int index) Creates a data variable object.protected abstract String[]
Gets the variable names in this dataset.float[]
interpolateNavigation
(float[] navData, int lineIndex, int variable, int start, int count) Interpolates navigation data using the specified raw navigation data and sample range.float[]
interpolateRawNavigation
(int line, int variable) Interpolates the raw navigation data values for the specified scan line.boolean
Gets the archive header flag, true if the dataset has an archive header.boolean
Determines if the data is byte swapped.protected abstract boolean
isNavigationUsable
(int record, ByteBuffer buffer) Gets the navigation data usability flag.static boolean
isPrint
(byte b) Determines if a byte is a valid printable ASCII character.Methods inherited from class noaa.coastwatch.io.EarthDataReader
canUpdateNavigation, containsVariable, finalize, findVariable, getAllGrids, getAllVariables, getChunkProducer, getCoordinateSystems, getDataFormat, getIndex, getInfo, getName, getPreview, getPreview, getRawMetadata, getRawMetadata, getSceneTime, getSource, getStatistics, getStatisticsVariables, getVariable, getVariables, getVariablesForSystem, putStatistics, setDataProjection, setUnitsMap, updateNavigation
-
Field Details
-
SWATH_POLY_SIZE
public static final double SWATH_POLY_SIZEThe swath polynomial size in kilometers.- See Also:
-
LAC_NAVIGATION_START
public static final int LAC_NAVIGATION_STARTThe starting sample for LAC navigation.- See Also:
-
LAC_NAVIGATION_END
public static final int LAC_NAVIGATION_ENDThe ending sample for LAC navigation.- See Also:
-
LAC_NAVIGATION_STEP
public static final int LAC_NAVIGATION_STEPThe navigation step size for LAC navigation.- See Also:
-
GAC_NAVIGATION_START
public static final int GAC_NAVIGATION_STARTThe starting sample for GAC navigation.- See Also:
-
GAC_NAVIGATION_END
public static final int GAC_NAVIGATION_ENDThe ending sample for GAC navigation.- See Also:
-
GAC_NAVIGATION_STEP
public static final int GAC_NAVIGATION_STEPThe navigation step size for GAC navigation.- See Also:
-
LAC_SAMPLES
public static final int LAC_SAMPLESThe number of samples per line for LAC data.- See Also:
-
GAC_SAMPLES
public static final int GAC_SAMPLESThe number of samples per line for GAC data.- See Also:
-
LOOKUP_TABLE_SIZE
public static final int LOOKUP_TABLE_SIZEThe size of each calibration lookup table.- See Also:
-
MAX_LOOKUP_TABLES
public static final int MAX_LOOKUP_TABLESThe maximum number of calibration lookup tables per channel.- See Also:
-
MAX_SCAN_LINES
public static final int MAX_SCAN_LINESThe maximum number of scan lines in the cache.- See Also:
-
inputChannel
The input channel. -
lines
protected int linesThe number of scan lines in this dataset. -
records
protected int recordsThe number of records in this dataset. This is the number of actual scan lines minus the number of missing lines. -
scanLineMap
protected int[] scanLineMapThe scan line map array mapping scan line number to record number. -
samples
protected int samplesThe number of samples in this dataset. -
archive
protected boolean archiveThe archive header flag, true if we have an archive header. -
header
The dataset header record, used for calibration. -
dataHeaders
protected int dataHeadersThe number of data headers for this dataset. -
archiveHeaderSize
protected int archiveHeaderSizeThe size of the archive header for this dataset in bytes. -
recordSize
protected int recordSizeThe size of the data header and records for this dataset in bytes. -
attributeDataSize
protected int attributeDataSizeThe size of the scan line attributes section in bytes. -
sensorWordSize
protected int sensorWordSizeThe sensor word size in bits. -
scanLineCache
The scan line cache.
-
-
Constructor Details
-
NOAA1bReader
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
Gets the variable names in this dataset. -
getArchiveFlag
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
Gets the archive header if it exists.- Returns:
- the archive header.
- Throws:
IOException
- if an error occurred reading the file data.
-
getDataHeader
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
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.
-
getDataBuffer
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
Gets a byte array from the specified byte buffer. -
getUByte
Gets an unsigned 8-bit value from the specified byte buffer. -
getUShort
Gets an unsigned 16-bit value from the specified byte buffer. -
getShort
Gets a signed 16-bit value from the specified byte buffer. -
getUInt
Gets an unsigned 32-bit value from the specified byte buffer. -
getNBit
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
Gets a signed 32-bit value from the specified byte buffer. -
getPreviewImpl
Description copied from class:EarthDataReader
Implementation for the subclass.- Specified by:
getPreviewImpl
in classEarthDataReader
- Throws:
IOException
- See Also:
-
getVariable
Description copied from class:EarthDataReader
Creates a data variable object. The full data is read into the object.- Specified by:
getVariable
in classEarthDataReader
- 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
Description copied from class:EarthDataReader
Closes the reader and frees any resources.- Specified by:
close
in classEarthDataReader
- Throws:
IOException
- if the data source had I/O errors.
-