edu.wisc.ssec.mcidas
Class AreaFile
- java.lang.Object
-
- edu.wisc.ssec.mcidas.AreaFile
-
- All Implemented Interfaces:
- java.io.Serializable
public class AreaFile extends java.lang.Object implements java.io.SerializableAreaFile interface with McIDAS 'area' file format image data.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
Calibratorinterface.This implementation does not check the 'valcode' on each line.
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field and Description static intAD_AUXOFFSETAD_AUXOFFSET - byte offset to start of auxilliary data sectionstatic intAD_AVGSMPFLAGAD_AVGSMPFLAG - data is averaged (1), or sampled (0)static intAD_BANDMAPAD_BANDMAP - spectral band map, bit set for each of 32 bands presentstatic intAD_CALLENGTHAD_CALLENGTH - length in bytes of line prefix calibration informationstatic intAD_CALOFFSETAD_CALOFFSET - byte offset to start of calibration sectionstatic intAD_CALTYPEAD_CALTYPE - McIDAS calibration type (ascii, satellite specific)static intAD_CALTYPESCALEAD_CALTYPESCALE - calibration scaling factorstatic intAD_CALTYPEUNITAD_CALTYPEUNIT - calibration unitstatic intAD_CRDATEAD_CRDATE - year and day image was created, CCYYDDD formatstatic intAD_CRTIMEAD_CRTIME - time image was created, HHMMSS formatstatic intAD_DATAOFFSETAD_DATAOFFSET - byte offset to start of data blockstatic intAD_DATAWIDTHAD_DATAWIDTH - number of bytes per data pointstatic intAD_DIRSIZEAD_DIRSIZE - size in 4 byte words of an image directory blockstatic intAD_DOCLENGTHAD_DOCLENGTH - length in bytes of line prefix documentationstatic intAD_ELEMRESAD_ELEMRES - data resolution in element directionstatic intAD_IMGDATEAD_IMGDATE - nominal year and day of the image, YYYDDD formatstatic intAD_IMGTIMEAD_IMGTIME - nominal time of the image, HHMMSS formatstatic intAD_LEVLENGTHAD_LEVLENGTH - length in bytes of line prefix level sectionstatic intAD_LINERESAD_LINERES - data resolution in line directionstatic intAD_NAVOFFSETAD_NAVOFFSET - byte offset to start of navigation blockstatic intAD_NUMBANDSAD_NUMBANDS - number of spectral bands, or channels, in imagestatic intAD_NUMCOMMENTSAD_NUMCOMMENTS - number of 80 character comment cardsstatic intAD_NUMELEMSAD_NUMELEMS - number of data points per linestatic intAD_NUMLINESAD_NUMLINES - number of lines in the imagestatic intAD_PFXSIZEAD_PFXSIZE - length in bytes of line prefix sectionstatic intAD_PROJNUMAD_PROJNUM - SSEC project number used in creating imagestatic intAD_SENSORIDAD_SENSORID - McIDAS sensor identifierstatic intAD_SRCTYPEAD_SRCTYPE - McIDAS source type (ascii, satellite specific)static intAD_SRCTYPEORIGAD_SRCTYPEORIG - original source type (ascii, satellite specific)static intAD_STARTDATEAD_STARTDATE - actual image start year and Julian day, yyyddd formatstatic intAD_STARTSCANAD_STARTSCAN - starting scan number (sensor based) of imagestatic intAD_STARTTIMEAD_STARTTIME - actual image start time, hhmmss; in milliseconds for POES datastatic intAD_STATUSAD_STATUS - old status field, now used as position num in ADDEstatic intAD_STELEMAD_STELEM - upper left image element coordinatestatic intAD_STLINEAD_STLINE - upper left image line coordinatestatic intAD_VALCODEAD_VALCODE - validity codestatic intAD_VERSIONAD_VERSION - McIDAS area file format version numberstatic intVERSION_NUMBERVERSION_NUMBER - version number for a valid AREA file (since 1985)
-
Constructor Summary
Constructors Constructor and Description AreaFile(java.lang.String source)Creates an AreaFile object that allows reading of McIDAS 'area' file format image data.AreaFile(java.lang.String filename, java.applet.Applet parent)creates an AreaFile object that allows reading of McIDAS 'area' file format image data from an appletAreaFile(java.lang.String source, int startLine, int numLines, int lineMag, int startElem, int numEles, int eleMag, int band)Create a subsetted instance.AreaFile(java.net.URL url)create anAreaFilethat allows reading of McIDAS 'area' file format image data from aURLwith a protocol of eitherfileorADDE.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method and Description voidclose()Close this instance.AreaDirectorygetAreaDirectory()Returns the AreaDirectory object for this AreaFileint[]getAux()Returns AUX blockint[]getCal()Returns calibration blockintgetCalType()Get the calibration type that will be used on data returned formgetCalibratedData().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 fromAreaFileFactorywith the appropriate subsetting parameters.int[][]getData(int lineNumber, int eleNumber, int numLines, int numEles, int bandNumber)Deprecated.Use one of the factory methods fromAreaFileFactorywith the appropriate subsetting parameters.int[]getDir()Returns the directory blockfloat[][][]getFloatData()Read the AREA file and return the contents as floats.java.lang.StringgetImageSource()returns the string of the image source locationint[]getNav()Returns the navigation blockAREAnavgetNavigation()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).booleanisRemote()Was this instance create with a remote data source.booleanisSubsetted()Is thisAreaFileinstance subseted.static booleanisURLHandlerLoaded()static voidmain(java.lang.String[] args)Test Method.voidsave(java.lang.String outputFile)Save this AreaFile to the output locationvoidsave(java.lang.String outputFile, boolean verbose)Save this AreaFile to the output locationvoidsetCalType(int cal)Set the calibration type that will be used on data returned fromgetCalibratedData().java.lang.StringtoString()Get a String representation of this image metadata/information
-
-
-
Field Detail
-
AD_STATUS
public static final int AD_STATUS
AD_STATUS - old status field, now used as position num in ADDE- See Also:
- Constant Field Values
-
AD_VERSION
public static final int AD_VERSION
AD_VERSION - McIDAS area file format version number- See Also:
- Constant Field Values
-
AD_SENSORID
public static final int AD_SENSORID
AD_SENSORID - McIDAS sensor identifier- See Also:
- Constant Field Values
-
AD_IMGDATE
public static final int AD_IMGDATE
AD_IMGDATE - nominal year and day of the image, YYYDDD format- See Also:
- Constant Field Values
-
AD_IMGTIME
public static final int AD_IMGTIME
AD_IMGTIME - nominal time of the image, HHMMSS format- See Also:
- Constant Field Values
-
AD_STLINE
public static final int AD_STLINE
AD_STLINE - upper left image line coordinate- See Also:
- Constant Field Values
-
AD_STELEM
public static final int AD_STELEM
AD_STELEM - upper left image element coordinate- See Also:
- Constant Field Values
-
AD_NUMLINES
public static final int AD_NUMLINES
AD_NUMLINES - number of lines in the image- See Also:
- Constant Field Values
-
AD_NUMELEMS
public static final int AD_NUMELEMS
AD_NUMELEMS - number of data points per line- See Also:
- Constant Field Values
-
AD_DATAWIDTH
public static final int AD_DATAWIDTH
AD_DATAWIDTH - number of bytes per data point- See Also:
- Constant Field Values
-
AD_LINERES
public static final int AD_LINERES
AD_LINERES - data resolution in line direction- See Also:
- Constant Field Values
-
AD_ELEMRES
public static final int AD_ELEMRES
AD_ELEMRES - data resolution in element direction- See Also:
- Constant Field Values
-
AD_NUMBANDS
public static final int AD_NUMBANDS
AD_NUMBANDS - number of spectral bands, or channels, in image- See Also:
- Constant Field Values
-
AD_PFXSIZE
public static final int AD_PFXSIZE
AD_PFXSIZE - length in bytes of line prefix section- See Also:
- Constant Field Values
-
AD_PROJNUM
public static final int AD_PROJNUM
AD_PROJNUM - SSEC project number used in creating image- See Also:
- Constant Field Values
-
AD_CRDATE
public static final int AD_CRDATE
AD_CRDATE - year and day image was created, CCYYDDD format- See Also:
- Constant Field Values
-
AD_CRTIME
public static final int AD_CRTIME
AD_CRTIME - time image was created, HHMMSS format- See Also:
- Constant Field Values
-
AD_BANDMAP
public static final int AD_BANDMAP
AD_BANDMAP - spectral band map, bit set for each of 32 bands present- See Also:
- Constant Field Values
-
AD_DATAOFFSET
public static final int AD_DATAOFFSET
AD_DATAOFFSET - byte offset to start of data block- See Also:
- Constant Field Values
-
AD_NAVOFFSET
public static final int AD_NAVOFFSET
AD_NAVOFFSET - byte offset to start of navigation block- See Also:
- Constant Field Values
-
AD_VALCODE
public static final int AD_VALCODE
AD_VALCODE - validity code- See Also:
- Constant Field Values
-
AD_STARTDATE
public static final int AD_STARTDATE
AD_STARTDATE - actual image start year and Julian day, yyyddd format- See Also:
- Constant Field Values
-
AD_STARTTIME
public static final int AD_STARTTIME
AD_STARTTIME - actual image start time, hhmmss; in milliseconds for POES data- See Also:
- Constant Field Values
-
AD_STARTSCAN
public static final int AD_STARTSCAN
AD_STARTSCAN - starting scan number (sensor based) of image- See Also:
- Constant Field Values
-
AD_DOCLENGTH
public static final int AD_DOCLENGTH
AD_DOCLENGTH - length in bytes of line prefix documentation- See Also:
- Constant Field Values
-
AD_CALLENGTH
public static final int AD_CALLENGTH
AD_CALLENGTH - length in bytes of line prefix calibration information- See Also:
- Constant Field Values
-
AD_LEVLENGTH
public static final int AD_LEVLENGTH
AD_LEVLENGTH - length in bytes of line prefix level section- See Also:
- Constant Field Values
-
AD_SRCTYPE
public static final int AD_SRCTYPE
AD_SRCTYPE - McIDAS source type (ascii, satellite specific)- See Also:
- Constant Field Values
-
AD_CALTYPE
public static final int AD_CALTYPE
AD_CALTYPE - McIDAS calibration type (ascii, satellite specific)- See Also:
- Constant Field Values
-
AD_AVGSMPFLAG
public static final int AD_AVGSMPFLAG
AD_AVGSMPFLAG - data is averaged (1), or sampled (0)- See Also:
- Constant Field Values
-
AD_SRCTYPEORIG
public static final int AD_SRCTYPEORIG
AD_SRCTYPEORIG - original source type (ascii, satellite specific)- See Also:
- Constant Field Values
-
AD_CALTYPEUNIT
public static final int AD_CALTYPEUNIT
AD_CALTYPEUNIT - calibration unit- See Also:
- Constant Field Values
-
AD_CALTYPESCALE
public static final int AD_CALTYPESCALE
AD_CALTYPESCALE - calibration scaling factor- See Also:
- Constant Field Values
-
AD_AUXOFFSET
public static final int AD_AUXOFFSET
AD_AUXOFFSET - byte offset to start of auxilliary data section- See Also:
- Constant Field Values
-
AD_CALOFFSET
public static final int AD_CALOFFSET
AD_CALOFFSET - byte offset to start of calibration section- See Also:
- Constant Field Values
-
AD_NUMCOMMENTS
public static final int AD_NUMCOMMENTS
AD_NUMCOMMENTS - number of 80 character comment cards- See Also:
- Constant Field Values
-
AD_DIRSIZE
public static final int AD_DIRSIZE
AD_DIRSIZE - size in 4 byte words of an image directory block- See Also:
- Constant Field Values
-
VERSION_NUMBER
public static final int VERSION_NUMBER
VERSION_NUMBER - version number for a valid AREA file (since 1985)- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AreaFile
public AreaFile(java.lang.String source) throws AreaFileExceptionCreates an AreaFile object that allows reading of McIDAS 'area' file format image data. allows reading either from a disk file, or a server via ADDE.- Parameters:
source- the file name, ADDE URL, or local file URL to read from- Throws:
AreaFileException- if file cannot be opened
-
AreaFile
public AreaFile(java.lang.String filename, java.applet.Applet parent) throws AreaFileExceptioncreates an AreaFile object that allows reading of McIDAS 'area' file format image data from an applet- Parameters:
filename- the disk filename (incl path) to read fromparent- the parent applet- Throws:
AreaFileException- if file cannot be opened
-
AreaFile
public AreaFile(java.net.URL url) throws AreaFileExceptioncreate anAreaFilethat allows reading of McIDAS 'area' file format image data from aURLwith a protocol of eitherfileorADDE. SeeAddeURLConnectionfor more information on constructing ADDE urls.- Parameters:
url-- Throws:
AreaFileException- if file cannot be opened
-
AreaFile
public AreaFile(java.lang.String source, int startLine, int numLines, int lineMag, int startElem, int numEles, int eleMag, int band) throws AreaFileExceptionCreate a subsetted instance. When subsetted, the data not included in the subset is no longer available to this instance due to the directory block being updated with the subsetting parameters.- Parameters:
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 band- Throws:
AreaFileException- if file cannot be openedjava.lang.IllegalArgumentException- 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
-
-
Method Detail
-
isURLHandlerLoaded
public static boolean isURLHandlerLoaded()
- Returns:
- status
-
isSubsetted
public boolean isSubsetted()
Is thisAreaFileinstance subseted.- Returns:
- True if this instance represents a subset of the total data available.
-
isRemote
public boolean isRemote()
Was this instance create with a remote data source.- Returns:
- True if created with an ADDE url
-
getImageSource
public java.lang.String getImageSource()
returns the string of the image source location- Returns:
- name of image source
-
getDir
public int[] getDir()
Returns the directory block- Returns:
- an integer array containing the area directory
-
getAreaDirectory
public AreaDirectory getAreaDirectory()
Returns the AreaDirectory object for this AreaFile- Returns:
- AreaDirectory
-
getNav
public int[] getNav()
Returns the navigation block- Returns:
- an integer array containing the nav block data
-
getNavigation
public AREAnav getNavigation() throws AreaFileException
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).- Returns:
- AREAnav for this image (may be null)
- Throws:
AreaFileException
-
getCal
public int[] getCal()
Returns calibration block- Returns:
- an integer array containing the nav block data
-
getAux
public int[] getAux()
Returns AUX block- Returns:
- an integer array containing the aux block data
-
getData
public int[][][] getData() throws AreaFileExceptionRead the AREA data.- Returns:
- int array[band][lines][element] - If the
AreaFilewas created as a subset only the band and subset indicated are returned, otherwise all bands are returned. - Throws:
AreaFileException- if there is a problem
-
getData
public int[][][] getData(int[][][] target) throws AreaFileExceptionRead AREA file data by reference. After reading the internal data array is will be a reference to the target array, so any changes made to the target array will be reflected in the internal data array.- Parameters:
target- Array to use as the destination of the data read. This array must be appropriately dimensioned as [#bands][#lines][#elems].- Returns:
- int array[band][lines][element] - If the
AreaFilewas created as a subset only the band and subset indicated are returned, otherwise all bands are returned. - Throws:
java.lang.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.
-
setCalType
public void setCalType(int cal)
Set the calibration type that will be used on data returned fromgetCalibratedData(). This must be called beforegetCalibratedData()to get calibrated data, otherwise it will just return the data in the format specified in the directory.- Parameters:
cal- calibration type fromCalibrator.
-
getCalType
public int getCalType()
Get the calibration type that will be used on data returned formgetCalibratedData().- Returns:
- calibration type from
Calibrator.
-
getFloatData
public float[][][] getFloatData() throws AreaFileExceptionRead the AREA file and return the contents as floats. If the calibration type has been set viasetCalType(),isRemote()is false, and aCalibratoris available data is calibrated before returning, otherwise the calibration type is ignored. The original data is alway preserved.- Returns:
- data[band][lines][elements] as described above
- Throws:
AreaFileException- on error reading data.- See Also:
Calibrator
-
getData
public int[][] getData(int lineNumber, int eleNumber, int numLines, int numEles) throws AreaFileExceptionDeprecated. Use one of the factory methods fromAreaFileFactorywith the appropriate subsetting parameters.Read the specified 2-dimensional array of data values from the AREA file. Values will always be returned as int regardless of whether they are 1, 2, or 4 byte values.- 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 line- Returns:
- int array[lines][elements] with data values.
- Throws:
AreaFileException- if the is a problem reading the file
-
getData
public int[][] getData(int lineNumber, int eleNumber, int numLines, int numEles, int bandNumber) throws AreaFileExceptionDeprecated. Use one of the factory methods fromAreaFileFactorywith the appropriate subsetting parameters.Read the specified 2-dimensional array of data values from the AREA file. Values will always be returned as int regardless of whether they are 1, 2, or 4 byte values.- 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 return- Returns:
- int array[lines][elements] with data values.
- Throws:
AreaFileException- if the is a problem reading the file
-
toString
public java.lang.String toString()
Get a String representation of this image metadata/information- Overrides:
toStringin classjava.lang.Object- Returns:
- string of metadata
-
main
public static void main(java.lang.String[] args) throws java.lang.ExceptionTest Method.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.
- Parameters:
args-- Throws:
java.lang.Exception
-
close
public void close()
Close this instance.
-
save
public void save(java.lang.String outputFile) throws AreaFileExceptionSave this AreaFile to the output location- Parameters:
outputFile- path to the output file- Throws:
AreaFileException- problem saving to the file
-
save
public void save(java.lang.String outputFile, boolean verbose) throws AreaFileExceptionSave this AreaFile to the output location- Parameters:
outputFile- path to the output fileverbose- true to print out status messages- Throws:
AreaFileException- on any error writing the file
-
-
DMelt 3.0 © DataMelt by jWork.ORG