public class AreaFile extends Object implements Serializable
This will allow 'area' format data to be read from disk; the navigation block is made available (see GVARnav for example).
Calibration is handled via classes that implement the Calibrator
interface.
This implementation does not check the 'valcode' on each line.
Modifier and Type | Field and Description |
---|---|
static int |
AD_AUXOFFSET
AD_AUXOFFSET - byte offset to start of auxilliary data section
|
static int |
AD_AVGSMPFLAG
AD_AVGSMPFLAG - data is averaged (1), or sampled (0)
|
static int |
AD_BANDMAP
AD_BANDMAP - spectral band map, bit set for each of 32 bands present
|
static int |
AD_CALLENGTH
AD_CALLENGTH - length in bytes of line prefix calibration information
|
static int |
AD_CALOFFSET
AD_CALOFFSET - byte offset to start of calibration section
|
static int |
AD_CALTYPE
AD_CALTYPE - McIDAS calibration type (ascii, satellite specific)
|
static int |
AD_CALTYPESCALE
AD_CALTYPESCALE - calibration scaling factor
|
static int |
AD_CALTYPEUNIT
AD_CALTYPEUNIT - calibration unit
|
static int |
AD_CRDATE
AD_CRDATE - year and day image was created, CCYYDDD format
|
static int |
AD_CRTIME
AD_CRTIME - time image was created, HHMMSS format
|
static int |
AD_DATAOFFSET
AD_DATAOFFSET - byte offset to start of data block
|
static int |
AD_DATAWIDTH
AD_DATAWIDTH - number of bytes per data point
|
static int |
AD_DIRSIZE
AD_DIRSIZE - size in 4 byte words of an image directory block
|
static int |
AD_DOCLENGTH
AD_DOCLENGTH - length in bytes of line prefix documentation
|
static int |
AD_ELEMRES
AD_ELEMRES - data resolution in element direction
|
static int |
AD_IMGDATE
AD_IMGDATE - nominal year and day of the image, YYYDDD format
|
static int |
AD_IMGTIME
AD_IMGTIME - nominal time of the image, HHMMSS format
|
static int |
AD_LEVLENGTH
AD_LEVLENGTH - length in bytes of line prefix level section
|
static int |
AD_LINERES
AD_LINERES - data resolution in line direction
|
static int |
AD_NAVOFFSET
AD_NAVOFFSET - byte offset to start of navigation block
|
static int |
AD_NUMBANDS
AD_NUMBANDS - number of spectral bands, or channels, in image
|
static int |
AD_NUMCOMMENTS
AD_NUMCOMMENTS - number of 80 character comment cards
|
static int |
AD_NUMELEMS
AD_NUMELEMS - number of data points per line
|
static int |
AD_NUMLINES
AD_NUMLINES - number of lines in the image
|
static int |
AD_PFXSIZE
AD_PFXSIZE - length in bytes of line prefix section
|
static int |
AD_PROJNUM
AD_PROJNUM - SSEC project number used in creating image
|
static int |
AD_SENSORID
AD_SENSORID - McIDAS sensor identifier
|
static int |
AD_SRCTYPE
AD_SRCTYPE - McIDAS source type (ascii, satellite specific)
|
static int |
AD_SRCTYPEORIG
AD_SRCTYPEORIG - original source type (ascii, satellite specific)
|
static int |
AD_STARTDATE
AD_STARTDATE - actual image start year and Julian day, yyyddd format
|
static int |
AD_STARTSCAN
AD_STARTSCAN - starting scan number (sensor based) of image
|
static int |
AD_STARTTIME
AD_STARTTIME - actual image start time, hhmmss;
in milliseconds for POES data
|
static int |
AD_STATUS
AD_STATUS - old status field, now used as position num in ADDE
|
static int |
AD_STELEM
AD_STELEM - upper left image element coordinate
|
static int |
AD_STLINE
AD_STLINE - upper left image line coordinate
|
static int |
AD_VALCODE
AD_VALCODE - validity code
|
static int |
AD_VERSION
AD_VERSION - McIDAS area file format version number
|
static int |
VERSION_NUMBER
VERSION_NUMBER - version number for a valid AREA file (since 1985)
|
Constructor and Description |
---|
AreaFile(String source)
Creates an AreaFile object that allows reading
of McIDAS 'area' file format image data.
|
AreaFile(String filename,
Applet parent)
creates an AreaFile object that allows reading
of McIDAS 'area' file format image data from an applet
|
AreaFile(String source,
int startLine,
int numLines,
int lineMag,
int startElem,
int numEles,
int eleMag,
int band)
Create a subsetted instance.
|
AreaFile(URL url)
create an
AreaFile that allows reading of McIDAS 'area'
file format image data from a URL with a protocol of either
file or ADDE . |
Modifier and Type | Method and Description |
---|---|
void |
close()
Close this instance.
|
AreaDirectory |
getAreaDirectory()
Returns the AreaDirectory object for this AreaFile
|
int[] |
getAux()
Returns AUX block
|
int[] |
getCal()
Returns calibration block
|
int |
getCalType()
Get the calibration type that will be used on data returned form
getCalibratedData() . |
int[][][] |
getData()
Read the AREA data.
|
int[][][] |
getData(int[][][] target)
Read AREA file data by reference.
|
int[][] |
getData(int lineNumber,
int eleNumber,
int numLines,
int numEles)
Deprecated.
Use one of the factory methods from
AreaFileFactory
with the appropriate subsetting parameters. |
int[][] |
getData(int lineNumber,
int eleNumber,
int numLines,
int numEles,
int bandNumber)
Deprecated.
Use one of the factory methods from
AreaFileFactory
with the appropriate subsetting parameters. |
int[] |
getDir()
Returns the directory block
|
float[][][] |
getFloatData()
Read the AREA file and return the contents as floats.
|
String |
getImageSource()
returns the string of the image source location
|
int[] |
getNav()
Returns the navigation block
|
AREAnav |
getNavigation()
Get the navigation, and pre-set it
for the ImageStart and Res (from Directory block), and
the file start (0,0), and Mag (1,1).
|
boolean |
isRemote()
Was this instance create with a remote data source.
|
boolean |
isSubsetted()
Is this
AreaFile instance subseted. |
static boolean |
isURLHandlerLoaded() |
static void |
main(String[] args)
Test Method.
|
void |
save(String outputFile)
Save this AreaFile to the output location
|
void |
save(String outputFile,
boolean verbose)
Save this AreaFile to the output location
|
void |
setCalType(int cal)
Set the calibration type that will be used on data returned from
getCalibratedData() . |
String |
toString()
Get a String representation of this image metadata/information
|
public static final int AD_STATUS
public static final int AD_VERSION
public static final int AD_SENSORID
public static final int AD_IMGDATE
public static final int AD_IMGTIME
public static final int AD_STLINE
public static final int AD_STELEM
public static final int AD_NUMLINES
public static final int AD_NUMELEMS
public static final int AD_DATAWIDTH
public static final int AD_LINERES
public static final int AD_ELEMRES
public static final int AD_NUMBANDS
public static final int AD_PFXSIZE
public static final int AD_PROJNUM
public static final int AD_CRDATE
public static final int AD_CRTIME
public static final int AD_BANDMAP
public static final int AD_DATAOFFSET
public static final int AD_NAVOFFSET
public static final int AD_VALCODE
public static final int AD_STARTDATE
public static final int AD_STARTTIME
public static final int AD_STARTSCAN
public static final int AD_DOCLENGTH
public static final int AD_CALLENGTH
public static final int AD_LEVLENGTH
public static final int AD_SRCTYPE
public static final int AD_CALTYPE
public static final int AD_AVGSMPFLAG
public static final int AD_SRCTYPEORIG
public static final int AD_CALTYPEUNIT
public static final int AD_CALTYPESCALE
public static final int AD_AUXOFFSET
public static final int AD_CALOFFSET
public static final int AD_NUMCOMMENTS
public static final int AD_DIRSIZE
public static final int VERSION_NUMBER
public AreaFile(String source) throws AreaFileException
source
- the file name, ADDE URL, or local file URL to read fromAreaFileException
- if file cannot be openedpublic AreaFile(String filename, Applet parent) throws AreaFileException
filename
- the disk filename (incl path) to read fromparent
- the parent appletAreaFileException
- if file cannot be openedpublic AreaFile(URL url) throws AreaFileException
AreaFile
that allows reading of McIDAS 'area'
file format image data from a URL
with a protocol of either
file
or ADDE
. See
AddeURLConnection
for more information on
constructing ADDE urls.url
- AreaFileException
- if file cannot be openedpublic AreaFile(String source, int startLine, int numLines, int lineMag, int startElem, int numEles, int eleMag, int band) throws AreaFileException
source
- the path to the filestartLine
- the starting image linenumLines
- the total number of lines to returnlineMag
- the line magnification. Valid values are <= -1.
-1, 0, and 1 are all taken to be full line resolution,
-2 is every other line, -3 every third, etc...startElem
- the starting image elementnumEles
- the total number of elements to returneleMag
- the element magnification. Valid values are <= -1.
-1, 0, and 1 are all taken to be full element resolution,
-2 is every other element, -3 every third, etc...band
- the 1-based band number for the subset, which must be present
in the directory blocks band map or -1 for the first bandAreaFileException
- if file cannot be openedIllegalArgumentException
- If the magnification is greater than 1,
the band number is not in the band map, or either of the following are
true:
startLine + (numLines * abs(lineMag)) > total number of lines startElem + (numEles * abs(eleMag)) > total number of elements
public static boolean isURLHandlerLoaded()
public boolean isSubsetted()
AreaFile
instance subseted.public boolean isRemote()
public String getImageSource()
public int[] getDir()
public AreaDirectory getAreaDirectory()
public int[] getNav()
public AREAnav getNavigation() throws AreaFileException
AreaFileException
public int[] getCal()
public int[] getAux()
public int[][][] getData() throws AreaFileException
AreaFile
was created as a subset only the band and subset indicated are returned,
otherwise all bands are returned.AreaFileException
- if there is a problempublic int[][][] getData(int[][][] target) throws AreaFileException
target
- Array to use as the destination of the data read. This array
must be appropriately dimensioned as [#bands][#lines][#elems].AreaFile
was created as a subset only the band and subset indicated are returned,
otherwise all bands are returned.IllegalArgumentException
- If the target array is not dimensioned
according to the subset, if subsetted, or otherwise has dimensions other than
[bands][lines][elements].AreaFileException
- If an error occurs while reading data.public void setCalType(int cal)
getCalibratedData()
. This must be called before
getCalibratedData()
to get calibrated data, otherwise it will
just return the data in the format specified in the directory.cal
- calibration type from Calibrator
.public int getCalType()
getCalibratedData()
.Calibrator
.public float[][][] getFloatData() throws AreaFileException
setCalType()
, isRemote()
is false, and a Calibrator
is available data is calibrated
before returning, otherwise the calibration type is ignored.
The original data is alway preserved.AreaFileException
- on error reading data.Calibrator
public int[][] getData(int lineNumber, int eleNumber, int numLines, int numEles) throws AreaFileException
AreaFileFactory
with the appropriate subsetting parameters.lineNumber
- the file-relative image line number that will
be put in array[0][j]eleNumber
- the file-relative image element number that will
be put into array[i][0]numLines
- the number of lines to returnnumEles
- the number of elements to return for each lineAreaFileException
- if the is a problem reading the filepublic int[][] getData(int lineNumber, int eleNumber, int numLines, int numEles, int bandNumber) throws AreaFileException
AreaFileFactory
with the appropriate subsetting parameters.lineNumber
- the file-relative image line number that will
be put in array[0][j]eleNumber
- the file-relative image element number that will
be put into array[i][0]numLines
- the number of lines to returnnumEles
- the number of elements to return for each linebandNumber
- the spectral band to returnAreaFileException
- if the is a problem reading the filepublic String toString()
public static void main(String[] args) throws Exception
USAGE: AreaFile <source> [(raw|temp|brit|rad|refl)]
If source is a file path or url without subsetting information directory information is printed. If source is a local file url with subsetting information data is printed according to the parameters.
This has not been tested with an ADDE url, but it should work ... maybe.
args
- Exception
public void close()
public void save(String outputFile) throws AreaFileException
outputFile
- path to the output fileAreaFileException
- problem saving to the filepublic void save(String outputFile, boolean verbose) throws AreaFileException
outputFile
- path to the output fileverbose
- true to print out status messagesAreaFileException
- on any error writing the fileCopyright © 1996–2023 The SSEC Visualization Project. All rights reserved.