org.esa.beam.framework.datamodel
Class AbstractBand

java.lang.Object
  extended by com.bc.ceres.core.ExtensibleObject
      extended by org.esa.beam.framework.datamodel.ProductNode
          extended by org.esa.beam.framework.datamodel.DataNode
              extended by org.esa.beam.framework.datamodel.RasterDataNode
                  extended by org.esa.beam.framework.datamodel.AbstractBand
All Implemented Interfaces:
com.bc.ceres.core.Extensible, Scaling
Direct Known Subclasses:
Band

public abstract class AbstractBand
extends RasterDataNode

The AbstractBand class provides a set of pixel access methods but does not provide an implementation of the actual reading and writing of pixel data from or into a raster.

Version:
$Revision$ $Date$
Author:
Norman Fomferra, Sabine Embacher

Nested Class Summary
 
Nested classes/interfaces inherited from class org.esa.beam.framework.datamodel.RasterDataNode
RasterDataNode.RasterDataDoubleList, RasterDataNode.RasterDataProcessor
 
Field Summary
static String VIEW_MODE_FORWARD
           
static String VIEW_MODE_NADIR
           
static String VIEW_MODE_ORTHO
           
 
Fields inherited from class org.esa.beam.framework.datamodel.RasterDataNode
INVALID_POS_TEXT, IO_ERROR_TEXT, NO_DATA_TEXT, NOT_LOADED_TEXT, PROPERTY_NAME_GEOCODING, PROPERTY_NAME_IMAGE_INFO, PROPERTY_NAME_LOG_10_SCALED, PROPERTY_NAME_NO_DATA_VALUE, PROPERTY_NAME_NO_DATA_VALUE_USED, PROPERTY_NAME_ROI_DEFINITION, PROPERTY_NAME_SCALING_FACTOR, PROPERTY_NAME_SCALING_OFFSET, PROPERTY_NAME_STX, PROPERTY_NAME_VALID_PIXEL_EXPRESSION
 
Fields inherited from class org.esa.beam.framework.datamodel.DataNode
PROPERTY_NAME_DATA, PROPERTY_NAME_READ_ONLY, PROPERTY_NAME_SYNTHETIC, PROPERTY_NAME_UNIT
 
Fields inherited from class org.esa.beam.framework.datamodel.ProductNode
PROPERTY_NAME_DESCRIPTION, PROPERTY_NAME_NAME
 
Fields inherited from interface org.esa.beam.framework.datamodel.Scaling
IDENTITY
 
Constructor Summary
AbstractBand(String name, int dataType, int width, int height)
           
 
Method Summary
 int computeBand(String expression, String validMaskExpression, Product[] sourceProducts, int defaultProductIndex, boolean checkInvalids, boolean useInvalidValue, double noDataValue, com.bc.ceres.core.ProgressMonitor pm)
          Deprecated. Since BEAM 4.10. Use VirtualBand or VirtualBandOpImage.
protected static double[] ensureMinLengthArray(double[] array, int length)
           
protected static float[] ensureMinLengthArray(float[] array, int length)
           
protected static int[] ensureMinLengthArray(int[] array, int length)
           
 void ensureRasterData()
          Ensures that raster data exists
 double getPixelDouble(int x, int y)
          Gets the sample for the pixel located at (x,y) as a double value.
 float getPixelFloat(int x, int y)
          Gets the sample for the pixel located at (x,y) as a float value.
 int getPixelInt(int x, int y)
          Gets the sample for the pixel located at (x,y) as an integer value.
 double[] getPixels(int x, int y, int w, int h, double[] pixels, com.bc.ceres.core.ProgressMonitor pm)
          Retrieves the range of pixels specified by the coordinates as double array.
 float[] getPixels(int x, int y, int w, int h, float[] pixels, com.bc.ceres.core.ProgressMonitor pm)
          Retrieves the range of pixels specified by the coordinates as float array.
 int[] getPixels(int x, int y, int w, int h, int[] pixels, com.bc.ceres.core.ProgressMonitor pm)
          Retrieves the range of pixels specified by the coordinates as integer array.
abstract  long getRawStorageSize(ProductSubsetDef subsetDef)
          Gets an estimated raw storage size in bytes of this product node.
 ProductData getSceneRasterData()
          Gets a raster data holding this band's pixel data for an entire product scene.
 String getViewModeId(String bandName)
           
 void loadRasterData(com.bc.ceres.core.ProgressMonitor pm)
          Loads the complete underlying raster data.
 double[] readPixels(int x, int y, int w, int h, double[] pixels, com.bc.ceres.core.ProgressMonitor pm)
          Retrieves the band data at the given offset (x, y), width and height as double data.
 float[] readPixels(int x, int y, int w, int h, float[] pixels, com.bc.ceres.core.ProgressMonitor pm)
          Retrieves the band data at the given offset (x, y), width and height as float data.
 int[] readPixels(int x, int y, int w, int h, int[] pixels, com.bc.ceres.core.ProgressMonitor pm)
          Retrieves the band data at the given offset (x, y), width and height as integer data.
 void setPixelDouble(int x, int y, double pixelValue)
          Sets the pixel value at the given pixel coordinate to the given pixel value.
 void setPixelFloat(int x, int y, float pixelValue)
          Sets the pixel at the given pixel coordinate to the given pixel value.
 void setPixelInt(int x, int y, int pixelValue)
          Sets the pixel at the given pixel co-ordinate to the given pixel value.
 void setPixels(int x, int y, int w, int h, double[] pixels)
          Sets a range of pixels specified by the coordinates as double array.
 void setPixels(int x, int y, int w, int h, float[] pixels)
          Sets a range of pixels specified by the coordinates as float array.
 void setPixels(int x, int y, int w, int h, int[] pixels)
          Sets a range of pixels specified by the coordinates as integer array.
 void unloadRasterData()
          Un-loads the raster data for this band.
 void writePixels(int x, int y, int w, int h, double[] pixels, com.bc.ceres.core.ProgressMonitor pm)
          Retrieves the range of pixels specified by the coordinates as double array.
 void writePixels(int x, int y, int w, int h, float[] pixels, com.bc.ceres.core.ProgressMonitor pm)
          Retrieves the range of pixels specified by the coordinates as float array.
 void writePixels(int x, int y, int w, int h, int[] pixels, com.bc.ceres.core.ProgressMonitor pm)
          Retrieves the range of pixels specified by the coordinates as integer array.
 
Methods inherited from class org.esa.beam.framework.datamodel.RasterDataNode
acceptVisitor, canBeOrthorectified, checkCompatibleRasterData, clearNoDataValue, computeStxImpl, createColorIndexedImage, createCompatibleRasterData, createCompatibleRasterData, createCompatibleSceneRasterData, createDefaultImageInfo, createDefaultImageInfo, createPixelValidator, createPointing, createRgbImage, createSourceImage, createTransectProfileData, dispose, fireImageInfoChanged, getBitmaskDefs, getGeoCoding, getGeophysicalDataType, getGeophysicalImage, getGeophysicalNoDataValue, getImageInfo, getImageInfo, getImageInfo, getNoDataValue, getOverlayMaskGroup, getPixels, getPixels, getPixels, getPixelString, getPointing, getRasterData, getRasterHeight, getRasterWidth, getRoiMaskGroup, getSampleFloat, getSampleInt, getScalingFactor, getScalingOffset, getSceneRasterHeight, getSceneRasterWidth, getSourceImage, getStx, getStx, getValidMaskExpression, getValidMaskImage, getValidPixelExpression, getValidShape, hasIntPixels, hasRasterData, isCompatibleRasterData, isFloatingPointType, isGeophysicalImageSet, isLog10Scaled, isNoDataValueSet, isNoDataValueUsed, isPixelValid, isPixelValid, isPixelValid, isScalingApplied, isSourceImageSet, isStxSet, isValidMaskImageSet, isValidMaskProperty, isValidMaskUsed, loadRasterData, processRasterData, quantizeRasterData, quantizeRasterData, readPixels, readPixels, readPixels, readRasterData, readRasterData, readRasterDataFully, readRasterDataFully, readValidMask, resetValidMask, scale, scaleInverse, setGeoCoding, setGeophysicalNoDataValue, setImageInfo, setImageInfo, setLog10Scaled, setModified, setNoDataValue, setNoDataValueUsed, setRasterData, setScalingFactor, setScalingOffset, setSourceImage, setSourceImage, setStx, setValidPixelExpression, updateExpression, writePixels, writePixels, writePixels, writeRasterData, writeRasterData, writeRasterDataFully, writeRasterDataFully
 
Methods inherited from class org.esa.beam.framework.datamodel.DataNode
checkDataCompatibility, createCompatibleProductData, fireProductNodeDataChanged, getData, getDataElems, getDataElemSize, getDataType, getNumDataElems, getUnit, isReadOnly, isSynthetic, setData, setDataElems, setReadOnly, setSynthetic, setUnit
 
Methods inherited from class org.esa.beam.framework.datamodel.ProductNode
fireProductNodeChanged, fireProductNodeChanged, getDescription, getDisplayName, getName, getOwner, getProduct, getProductReader, getProductReaderSafe, getProductRefString, getProductSafe, getProductWriter, getProductWriterSafe, getRawStorageSize, isModified, isPartOfSubset, isValidNodeName, removeFromFile, setDescription, setName, setOwner, toString
 
Methods inherited from class com.bc.ceres.core.ExtensibleObject
getExtension
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

VIEW_MODE_ORTHO

public static final String VIEW_MODE_ORTHO
See Also:
Constant Field Values

VIEW_MODE_FORWARD

public static final String VIEW_MODE_FORWARD
See Also:
Constant Field Values

VIEW_MODE_NADIR

public static final String VIEW_MODE_NADIR
See Also:
Constant Field Values
Constructor Detail

AbstractBand

public AbstractBand(String name,
                    int dataType,
                    int width,
                    int height)
Method Detail

getSceneRasterData

public ProductData getSceneRasterData()
Gets a raster data holding this band's pixel data for an entire product scene. If the data has'nt been loaded so far the method returns null.

In opposite to the getRasterData method, this method returns raster data that has at least getBandOutputRasterWidth()*getBandOutputRasterHeight() elements of the given data type to store the scene's pixels.

Specified by:
getSceneRasterData in class RasterDataNode
Returns:
raster data covering the pixels for a complete scene
See Also:
RasterDataNode.getRasterData(), RasterDataNode.getSceneRasterWidth(), RasterDataNode.getSceneRasterHeight()

getPixelInt

public int getPixelInt(int x,
                       int y)
Gets the sample for the pixel located at (x,y) as an integer value.

Specified by:
getPixelInt in class RasterDataNode
Parameters:
x - The X co-ordinate of the pixel location
y - The Y co-ordinate of the pixel location
Returns:
the pixel value at (x,y)
Throws:
NullPointerException - if this band has no raster data
ArrayIndexOutOfBoundsException - if the co-ordinates are not in bounds

getPixelFloat

public float getPixelFloat(int x,
                           int y)
Gets the sample for the pixel located at (x,y) as a float value.

Specified by:
getPixelFloat in class RasterDataNode
Parameters:
x - The X co-ordinate of the pixel location
y - The Y co-ordinate of the pixel location
Returns:
the pixel value at (x,y)
Throws:
NullPointerException - if this band has no raster data
ArrayIndexOutOfBoundsException - if the co-ordinates are not in bounds

getPixelDouble

public double getPixelDouble(int x,
                             int y)
Gets the sample for the pixel located at (x,y) as a double value.

Specified by:
getPixelDouble in class RasterDataNode
Parameters:
x - The X co-ordinate of the pixel location
y - The Y co-ordinate of the pixel location
Returns:
the pixel value at (x,y)
Throws:
NullPointerException - if this band has no raster data
ArrayIndexOutOfBoundsException - if the co-ordinates are not in bounds

setPixelInt

public void setPixelInt(int x,
                        int y,
                        int pixelValue)
Sets the pixel at the given pixel co-ordinate to the given pixel value.

Specified by:
setPixelInt in class RasterDataNode
Parameters:
x - The X co-ordinate of the pixel location
y - The Y co-ordinate of the pixel location
pixelValue - the new pixel value
Throws:
NullPointerException - if this band has no raster data

setPixelFloat

public void setPixelFloat(int x,
                          int y,
                          float pixelValue)
Sets the pixel at the given pixel coordinate to the given pixel value.

Specified by:
setPixelFloat in class RasterDataNode
Parameters:
x - The X co-ordinate of the pixel location
y - The Y co-ordinate of the pixel location
pixelValue - the new pixel value
Throws:
NullPointerException - if this band has no raster data

setPixelDouble

public void setPixelDouble(int x,
                           int y,
                           double pixelValue)
Sets the pixel value at the given pixel coordinate to the given pixel value.

Specified by:
setPixelDouble in class RasterDataNode
Parameters:
x - The X co-ordinate of the pixel location
y - The Y co-ordinate of the pixel location
pixelValue - the new pixel value
Throws:
NullPointerException - if this band has no raster data

readPixels

public int[] readPixels(int x,
                        int y,
                        int w,
                        int h,
                        int[] pixels,
                        com.bc.ceres.core.ProgressMonitor pm)
                 throws IOException
Retrieves the band data at the given offset (x, y), width and height as integer data. If the data is already in memory, it merely copies the data to the buffer provided. If not, it calls the attached product reader to retrieve the data from the disk file. If the given buffer is null a new one was created and returned.

Specified by:
readPixels in class RasterDataNode
Parameters:
x - x offest of upper left corner
y - y offset of upper left corner
w - width of the desired data array
h - height of the desired data array
pixels - array of integer pixels to be filled with data
pm - a monitor to inform the user about progress
Returns:
the pixels read
Throws:
IllegalArgumentException - if the length of the given array is less than w*h.
IOException

readPixels

public float[] readPixels(int x,
                          int y,
                          int w,
                          int h,
                          float[] pixels,
                          com.bc.ceres.core.ProgressMonitor pm)
                   throws IOException
Retrieves the band data at the given offset (x, y), width and height as float data. If the data is already in memory, it merely copies the data to the buffer provided. If not, it calls the attached product reader to retrieve the data from the disk file. If the given buffer is null a new one was created and returned.

Specified by:
readPixels in class RasterDataNode
Parameters:
x - x offest of upper left corner
y - y offset of upper left corner
w - width of the desired data array
h - height of the desired data array
pixels - array of float pixels to be filled with data.
pm - a monitor to inform the user about progress
Returns:
the pixels read
Throws:
IllegalArgumentException - if the length of the given array is less than w*h.
IOException

readPixels

public double[] readPixels(int x,
                           int y,
                           int w,
                           int h,
                           double[] pixels,
                           com.bc.ceres.core.ProgressMonitor pm)
                    throws IOException
Retrieves the band data at the given offset (x, y), width and height as double data. If the data is already in memory, it merely copies the data to the buffer provided. If not, it calls the attached product reader to retrieve the data from the disk file. If the given buffer is null a new one was created and returned.

Specified by:
readPixels in class RasterDataNode
Parameters:
x - x offest of upper left corner
y - y offset of upper left corner
w - width of the desired data array
h - height of the desired data array
pixels - array of double pixels to be filled with data
pm - a monitor to inform the user about progress
Returns:
the pixels read
Throws:
IllegalArgumentException - if the length of the given array is less than w*h.
IOException

writePixels

public void writePixels(int x,
                        int y,
                        int w,
                        int h,
                        int[] pixels,
                        com.bc.ceres.core.ProgressMonitor pm)
                 throws IOException
Retrieves the range of pixels specified by the coordinates as integer array. Reads the data from disk if ot is not in memory yet. If the data is loaded, just copies the data..

Specified by:
writePixels in class RasterDataNode
Parameters:
x - x offset into the band
y - y offset into the band
w - width of the pixel array to be read
h - height of the pixel array to be read.
pixels - integer array to be filled with data
pm - a monitor to inform the user about progress
Throws:
IOException

writePixels

public void writePixels(int x,
                        int y,
                        int w,
                        int h,
                        float[] pixels,
                        com.bc.ceres.core.ProgressMonitor pm)
                 throws IOException
Retrieves the range of pixels specified by the coordinates as float array. Reads the data from disk if ot is not in memory yet. If the data is loaded, just copies the data..

Specified by:
writePixels in class RasterDataNode
Parameters:
x - x offset into the band
y - y offset into the band
w - width of the pixel array to be read
h - height of the pixel array to be read.
pixels - float array to be filled with data
pm - a monitor to inform the user about progress
Throws:
IOException

writePixels

public void writePixels(int x,
                        int y,
                        int w,
                        int h,
                        double[] pixels,
                        com.bc.ceres.core.ProgressMonitor pm)
                 throws IOException
Retrieves the range of pixels specified by the coordinates as double array. Reads the data from disk if ot is not in memory yet. If the data is loaded, just copies the data..

Specified by:
writePixels in class RasterDataNode
Parameters:
x - x offset into the band
y - y offset into the band
w - width of the pixel array to be read
h - height of the pixel array to be read.
pixels - double array to be filled with data
pm - a monitor to inform the user about progress
Throws:
IOException

getPixels

public int[] getPixels(int x,
                       int y,
                       int w,
                       int h,
                       int[] pixels,
                       com.bc.ceres.core.ProgressMonitor pm)
Retrieves the range of pixels specified by the coordinates as integer array. Throws exception when the data is not read from disk yet. If the given array is null a new one was created and returned.

Specified by:
getPixels in class RasterDataNode
Parameters:
x - x offset into the band
y - y offset into the band
w - width of the pixel array to be read
h - height of the pixel array to be read.
pixels - integer array to be filled with data
pm - a monitor to inform the user about progress
Throws:
NullPointerException - if this band has no raster data
IllegalArgumentException - if the length of the given array is less than w*h.

getPixels

public float[] getPixels(int x,
                         int y,
                         int w,
                         int h,
                         float[] pixels,
                         com.bc.ceres.core.ProgressMonitor pm)
Retrieves the range of pixels specified by the coordinates as float array. Throws exception when the data is not read from disk yet. If the given array is null a new one was created and returned.

Specified by:
getPixels in class RasterDataNode
Parameters:
x - x offset into the band
y - y offset into the band
w - width of the pixel array to be read
h - height of the pixel array to be read.
pixels - float array to be filled with data
pm - a monitor to inform the user about progress
Throws:
NullPointerException - if this band has no raster data
IllegalArgumentException - if the length of the given array is less than w*h.

getPixels

public double[] getPixels(int x,
                          int y,
                          int w,
                          int h,
                          double[] pixels,
                          com.bc.ceres.core.ProgressMonitor pm)
Retrieves the range of pixels specified by the coordinates as double array. Throws exception when the data is not read from disk yet. If the given array is null a new one was created and returned.

Specified by:
getPixels in class RasterDataNode
Parameters:
x - x offset into the band
y - y offset into the band
w - width of the pixel array to be read
h - height of the pixel array to be read.
pixels - double array to be filled with data
pm - a monitor to inform the user about progress
Throws:
NullPointerException - if this band has no raster data
IllegalArgumentException - if the length of the given array is less than w*h.

setPixels

public void setPixels(int x,
                      int y,
                      int w,
                      int h,
                      int[] pixels)
Sets a range of pixels specified by the coordinates as integer array. Copies the data to the memory buffer of data at the specified location. Throws exception when the target buffer is not in memory.

Specified by:
setPixels in class RasterDataNode
Parameters:
x - x offset into the band
y - y offset into the band
w - width of the pixel array to be written
h - height of the pixel array to be written.
pixels - integer array to be written
Throws:
NullPointerException - if this band has no raster data

setPixels

public void setPixels(int x,
                      int y,
                      int w,
                      int h,
                      float[] pixels)
Sets a range of pixels specified by the coordinates as float array. Copies the data to the memory buffer of data at the specified location. Throws exception when the target buffer is not in memory.

Specified by:
setPixels in class RasterDataNode
Parameters:
x - x offset into the band
y - y offset into the band
w - width of the pixel array to be written
h - height of the pixel array to be written.
pixels - float array to be written
Throws:
NullPointerException - if this band has no raster data

setPixels

public void setPixels(int x,
                      int y,
                      int w,
                      int h,
                      double[] pixels)
Sets a range of pixels specified by the coordinates as double array. Copies the data to the memory buffer of data at the specified location. Throws exception when the target buffer is not in memory.

Specified by:
setPixels in class RasterDataNode
Parameters:
x - x offset into the band
y - y offset into the band
w - width of the pixel array to be written
h - height of the pixel array to be written.
pixels - double array to be written
Throws:
NullPointerException - if this band has no raster data

ensureRasterData

public void ensureRasterData()
Ensures that raster data exists


loadRasterData

public void loadRasterData(com.bc.ceres.core.ProgressMonitor pm)
                    throws IOException
Loads the complete underlying raster data.

After this method has been called successfully, hasRasterData() should always return true and getRasterData() should always return a valid ProductData instance with at least getRasterWidth()*getRasterHeight() elements (samples).

In opposite to the readRasterDataFully method, loadRasterData will only read data if this has not already been done.

Overrides:
loadRasterData in class RasterDataNode
Parameters:
pm - a monitor to inform the user about progress
Throws:
IOException - if an I/O error occurs
See Also:
RasterDataNode.readRasterDataFully(ProgressMonitor)

unloadRasterData

public void unloadRasterData()
Un-loads the raster data for this band.

After this method has been called successfully, the hasRasterData() method returns false and getRasterData() returns null.

Overrides:
unloadRasterData in class RasterDataNode
See Also:
RasterDataNode.loadRasterData()

getRawStorageSize

public abstract long getRawStorageSize(ProductSubsetDef subsetDef)
Gets an estimated raw storage size in bytes of this product node.

Overrides:
getRawStorageSize in class DataNode
Parameters:
subsetDef - if not null the subset may limit the size returned
Returns:
the size in bytes.

getViewModeId

public String getViewModeId(String bandName)

ensureMinLengthArray

protected static int[] ensureMinLengthArray(int[] array,
                                            int length)

ensureMinLengthArray

protected static float[] ensureMinLengthArray(float[] array,
                                              int length)

ensureMinLengthArray

protected static double[] ensureMinLengthArray(double[] array,
                                               int length)

computeBand

@Deprecated
public int computeBand(String expression,
                                  String validMaskExpression,
                                  Product[] sourceProducts,
                                  int defaultProductIndex,
                                  boolean checkInvalids,
                                  boolean useInvalidValue,
                                  double noDataValue,
                                  com.bc.ceres.core.ProgressMonitor pm)
                throws IOException,
                       ParseException
Deprecated. Since BEAM 4.10. Use VirtualBand or VirtualBandOpImage.

(Re-)Computes this band's data using the given arithmetic expression.

Parameters:
expression - the arithmetic expression string, e.g. "1 + log(radiance_5 / radiance_13)"
validMaskExpression - the arithmetic expression identifying valid source pixels, e.g. "radiance_5 > 0.0 && radiance_13 > 0.0"
sourceProducts - the list of source products possibly referenced in the expression
defaultProductIndex - the index of the product for which also symbols without the product prefix $ref-no are registered in the namespace
checkInvalids - if true, the method recognizes numerically invalid values (NaN, Infinity)
useInvalidValue - if true, numerically invalid values (NaN, Infinity) are set to invalidValue, ignored if checkInvalids = false
noDataValue - the value used in place of numerically invalid values if useInvalidValue = true, ignored if checkInvalids = false
pm - a monitor to inform the user about progress
Returns:
the number of invalid pixels, zero if checkInvalids = false
Throws:
IOException - if an I/O error occurs
ParseException - if the expression syntax is invalid


Copyright © 2002-2012 Brockmann Consult GmbH. All Rights Reserved.