ensureSupportedProductTypes(); final ModisProductDescription description = new ModisProductDescription(); final String productFile = _productTypes.get(prodType); final CsvReader reader = getCsvReader(productFile); description.addBand( records[1], records[2], records[3], records[4], records[5], records[6], records[7], records[8], records[9], records[10], records[11]); } else if (records.length == ModisProductDb.EXP_NUM_SDS_DEFAULT_RECORD) { description.addBand( records[1], records[2], records[3], records[4], records[5], records[6], records[7], records[8]); description.setGeolocationDatasetNames(records[1], records[2]); } else { description.setExternalGeolocationPattern(records[1]); description.setTopDownFlip(Boolean.valueOf(records[1])); } else { logger.severe( description.addTiePointGrid(new ModisTiePointDescription( records[1], records[2], records[3], records[4])); } else {
/** * Retrieves the band description for the given product type and band name * * @param prodType * @param bandName * @return the band description */ public ModisBandDescription getBandDescription(final String prodType, final String bandName) { ModisBandDescription bandDesc = null; try { final ModisProductDescription prod = getProductDescription(prodType); bandDesc = prod.getBandDescription(bandName); } catch (IOException e) { logger.severe( "Unable to retrieve information for band '" + bandName + "' of product type '" + prodType + "'."); } return bandDesc; }
/** * Retrieves the names of the bands for the given product type. * * @param prodType the product type string * @return the names of the bands. */ public String[] getBandNames(final String prodType) { String[] bandNames = null; try { final ModisProductDescription prod = getProductDescription(prodType); bandNames = prod.getBandNames(); } catch (IOException e) { logger.severe("Unable to retrieve the band names for product of type '" + prodType + "'."); } return bandNames; }
@Test public void testDefaultConstruction() { assertEquals(0, prod.getBandNames().length); assertNull(prod.getBandDescription("no_band")); assertEquals(false, prod.mustFlipTopDown()); assertArrayEquals(null, prod.getGeolocationDatasetNames()); assertEquals(null, prod.getExternalGeolocationPattern()); assertEquals(false, prod.hasExternalGeolocation()); assertEquals(0, prod.getTiePointNames().length); }
/** * Checks the correct functionality of the geocoding accessors */ @Test public void testGeocodingAccessors() { // intially everything is null and false String[] latlon; latlon = prod.getGeolocationDatasetNames(); assertNull(latlon); assertEquals(false, prod.hasExternalGeolocation()); assertNull(prod.getExternalGeolocationPattern()); // set lat/lon tiepoint geocoding String expLat = "latitude"; String expLon = "lomgitude"; prod.setGeolocationDatasetNames(expLat, expLon); assertEquals(false, prod.hasExternalGeolocation()); latlon = prod.getGeolocationDatasetNames(); assertNotNull(latlon); assertEquals(2, latlon.length); assertEquals(expLat, latlon[0]); assertEquals(expLon, latlon[1]); // set external geocoding String expExter = "external"; prod.setExternalGeolocationPattern(expExter); assertEquals(true, prod.hasExternalGeolocation()); assertEquals(expExter, prod.getExternalGeolocationPattern()); prod.setExternalGeolocationPattern(null); assertEquals(false, prod.hasExternalGeolocation()); assertEquals(null, prod.getExternalGeolocationPattern()); }
public void testTiePointAccess() { assertEquals(0, prod.getTiePointNames().length); prod.addTiePointGrid(new ModisTiePointDescription(tp[n], sc[n], of[n], un[n])); String[] tpNames = prod.getTiePointNames(); assertNotNull(tpNames); assertEquals(3, tpNames.length); desc = prod.getTiePointDescription(tpNames[n]); assertNotNull(desc);
prod.addBand(expB_1_Name, expB_1_spectral, expB_1_ScaleMethod, expB_1_Scale, expB_1_Offset, expB_1_Unit, expB_1_BandName, expB_1_DescName, expB_1_SpectralWL, expB_1_SpectralBW, expB_1_SpectralBI); prod.addBand(expB_2_Name, expB_2_spectral, expB_2_ScaleMethod, expB_2_Scale, expB_2_Offset, expB_2_Unit, expB_2_BandName, expB_2_DescName); ModisBandDescription band = prod.getBandDescription(expB_1_Name); assertNotNull(band); assertEquals(expB_1_Name, band.getName()); band = prod.getBandDescription(expB_2_Name); assertNotNull(band); assertEquals(expB_2_Name, band.getName()); String[] bandNames = prod.getBandNames(); assertNotNull(bandNames); assertEquals(2, bandNames.length); assertNull(prod.getBandDescription("no_band")); assertNull(prod.getBandDescription("nonsense"));
private void addModisTiePointGeoCoding(Product product, NetCDFVariables netCDFVariables) throws IOException { ModisProductDescription prodDesc = prodDb.getProductDescription(product.getProductType()); final String[] geolocationDatasetNames; if (prodDesc.hasExternalGeolocation()) { // @todo 2 tb/tb this relies on the order of the tie point grids in the *.dd file. // better check the metadata for the lat/lon band names - // but for the test products this works fine. geolocationDatasetNames = loadExternalQCFile(product, prodDesc, netCDFVariables); } else { geolocationDatasetNames = prodDesc.getGeolocationDatasetNames(); } if (geolocationDatasetNames != null) { final TiePointGrid latGrid = product.getTiePointGrid(geolocationDatasetNames[0]); final TiePointGrid lonGrid = product.getTiePointGrid(geolocationDatasetNames[1]); if (latGrid != null && lonGrid != null) { // set cyclic behaviour lonGrid.setDiscontinuity(TiePointGrid.DISCONT_AT_180); // and create geo coding GeoCoding coding = new ModisTiePointGeoCoding(latGrid, lonGrid); product.setGeoCoding(coding); } } }
/** * Tests the correct functionality of the geolocation accessors. */ @Test public void testGeolocationAccess() { // none shall be set initially assertNull(prod.getGeolocationDatasetNames()); // set a tie point geolocation and check String expLat = "latitude"; String expLon = "longitude"; String[] geoLoc; prod.setGeolocationDatasetNames(expLat, expLon); geoLoc = prod.getGeolocationDatasetNames(); assertNotNull(geoLoc); assertEquals(2, geoLoc.length); assertEquals(expLat, geoLoc[0]); assertEquals(expLon, geoLoc[1]); }
/** * Adds a new band description to the product description. * * @param name the name of the band (without spectral extension) * @param isSpectral whether the badnd is a spectral band or not * @param scalingMethod the scaling method to be used for this band (lin, exp ..) * @param scaleName name of the attribute containing the scale factors * @param offsetName name of the attribute containing the scale offsets * @param unitName name off the attribute containing the physical unit * @param bandName name of the attribute containing the spectral extensions (band names) * @param descName name of the attribute containing a description of the band */ public void addBand(String name, String isSpectral, String scalingMethod, String scaleName, String offsetName, String unitName, String bandName, String descName) { addBand(new ModisBandDescription( name, isSpectral, scalingMethod, scaleName, offsetName, unitName, bandName, descName)); }
private static String getQcFileType(Product product, ModisProductDescription desc) { final String replaceWith = product.getProductType().substring(1, 2); final String pattern = desc.getExternalGeolocationPattern(); return pattern.replaceFirst("[xX]", replaceWith); }
/** * Retrieves the names of the tie point grids for the given product type * * @param prodType * @return the names of the tie point grids */ public String[] getTiePointNames(final String prodType) { String[] tpNames = null; try { final ModisProductDescription prod = getProductDescription(prodType); tpNames = prod.getTiePointNames(); } catch (IOException e) { logger.severe("Unable to retrieve tie point names for product type '" + prodType + "'."); } return tpNames; }
/** * Retrieves the geolocation information for the given product type * * @param prodType * @return the geolocation information */ public String[] getGeolocationInformation(final String prodType) { String[] strRet = null; try { final ModisProductDescription prod = getProductDescription(prodType); strRet = prod.getGeolocationDatasetNames(); } catch (IOException e) { logger.severe("Unable to retrieve geolocation information for product type '" + prodType + "'."); } return strRet; }
/** * Retrieves the tie point description for the given product type and tie point grid name * * @param prodType the product type * @param tpName the name of the tie point grid * @return the tie point description */ public ModisTiePointDescription getTiePointDescription(final String prodType, final String tpName) { ModisTiePointDescription tpDesc = null; try { final ModisProductDescription prod = getProductDescription(prodType); tpDesc = prod.getTiePointDescription(tpName); } catch (IOException e) { logger.severe( "Unable to retrieve description for tie point grid '" + tpName + "' of product type '" + prodType + "'."); } return tpDesc; }
@Before public void setUp() { prod = new ModisProductDescription(); }
/** * Adds a new band description to the product description. * * @param name the name of the band (without spectral extension) * @param isSpectral whether the badnd is a spectral band or not * @param scalingMethod the scaling method to be used for this band (lin, exp ..) * @param scaleName name of the attribute containing the scale factors * @param offsetName name of the attribute containing the scale offsets * @param unitName name off the attribute containing the physical unit * @param bandName name of the attribute containing the spectral extensions (band names) * @param descName name of the attribute containing a description of the band * @param spectralWaveLength the spectral wavelength in nm (nanomater) units * @param spectralBandWidth the spectral bandwidth in nm (nanomater) units * @param spectralBandIndex the (zero-based) spectral band index */ public void addBand(final String name, final String isSpectral, final String scalingMethod, final String scaleName, final String offsetName, final String unitName, final String bandName, final String descName, final String spectralWaveLength, final String spectralBandWidth, final String spectralBandIndex) { final ModisBandDescription bandDesc = new ModisBandDescription( name, isSpectral, scalingMethod, scaleName, offsetName, unitName, bandName, descName); bandDesc.setSpecInfo(new ModisSpectralInfo( spectralWaveLength, spectralBandWidth, spectralBandIndex)); addBand(bandDesc); }