/** * Checks the product type against the list of known types. Throws ProductIOException if it doesn't fit. */ private void checkProductType() throws IOException { final String productType = globalAttributes.getProductType(); final ModisProductDb db = ModisProductDb.getInstance(); if (!db.isSupportedProduct(productType)) { throw new ProductIOException("Unsupported product of type '" + productType + '\''); } } }
/** * Checks whether the given product type is suported by the reader - or not. * * @param typeString the product type * @return <code>true</code> if the given product type is suported, otherwise <code>false</code>. */ public boolean isSupportedProduct(final String typeString) throws ProductIOException { ensureSupportedProductTypes(); return _productTypes.get(typeString) != null; }
/** * Loads the list of supported product types. */ private void loadProductTypes() throws IOException { _productTypes = new HashMap<String, String>(); final CsvReader reader = getCsvReader("products.dd"); for (String[] records = reader.readRecord(); records != null; records = reader.readRecord()) { if (records.length == 2) { _productTypes.put(records[0], records[1]); } else { logger.severe( "Invalid number of records in MODISDB - please check the resources for correctness."); } } reader.close(); }
public void testAllProductTypes_InTheMiddle() throws ProductIOException { final String[] supportetProductTypes = ModisProductDb.getInstance().getSupportetProductTypes(); for (int i = 0; i < supportetProductTypes.length; i++) { final String type = supportetProductTypes[i]; final String toTest = "anyPrefix." + type + ".anySuffix"; assertEquals("Index = " + i, ModisDaacUtils.extractProductType(toTest), type); } }
/** * Constructs the object with default parameters */ public ModisFileReader() { prodDb = ModisProductDb.getInstance(); logger = BeamLogManager.getSystemLogger(); bandReaderMap = new HashMap<Band, ModisBandReader>(); }
/** * 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; }
ensureSupportedProductTypes(); final CsvReader reader = getCsvReader(productFile);
final int height = product.getSceneRasterHeight(); final String[] bandNames = prodDb.getBandNames(prodType); final ModisBandDescription bandDesc = prodDb.getBandDescription(prodType, bandName); if (bandDesc == null) { logger.warning("No band description for band '" + bandName + "' of product type '" + prodType + "'");
/** * Adds all tie point grids to the product * * @param netCDFVariables * @param productType * @param prod * @throws IOException */ private void addTiePointGrids(NetCDFVariables netCDFVariables, String productType, Product prod, ModisGlobalAttributes globalAttribs) throws IOException { TiePointGrid grid; String[] tiePointGridNames = prodDb.getTiePointNames(productType); for (String tiePointGridName : tiePointGridNames) { final Variable variable = netCDFVariables.get(tiePointGridName); if (variable == null) { logger.warning("Unable to access tie point grid: '" + tiePointGridName + '\''); continue; } final NetCDFAttributes attributes = new NetCDFAttributes(); attributes.add(variable.getAttributes()); grid = readNamedTiePointGrid(variable, attributes, productType, tiePointGridName, globalAttribs); if (grid != null) { prod.addTiePointGrid(grid); } } }
/** * Retrieves a csv reader opened at the first line of the file pased in * * @param filename * @return * @throws java.io.IOException */ private CsvReader getCsvReader(final String filename) throws IOException { final URL dbResource = getDatabaseResource(filename); final CsvReader reader; try { reader = new CsvReader(new InputStreamReader(dbResource.openStream()), ModisConstants.FIELD_SEPARATORS, true, "#"); } catch (MalformedURLException e) { throw new IOException(e.getMessage()); } return reader; }
final ModisBandDescription desc = prodDb.getBandDescription(productType, correspBand); final String bandAttribName = desc.getBandAttribName(); final String attributeValue = NetCDFUtils.getNamedStringAttribute(bandAttribName, attributes);
ModisGlobalAttributes globalAttribs) throws IOException { TiePointGrid gridRet = null; final ModisTiePointDescription desc = prodDb.getTiePointDescription(prodType, name); final DataType ncDataType = variable.getDataType(); final int dataType1 = DataTypeUtils.getEquivalentProductDataType(ncDataType, false, false); // @todo tb/tb rename variable
public void testAllProductTypes_AtStart() throws ProductIOException { final String[] supportetProductTypes = ModisProductDb.getInstance().getSupportetProductTypes(); for (int i = 0; i < supportetProductTypes.length; i++) { final String type = supportetProductTypes[i]; final String toTest = type + ".anySuffix"; assertEquals("Index = " + i, ModisDaacUtils.extractProductType(toTest), type); } }
public static String extractProductType(String s) throws ProductIOException { final ModisProductDb db = ModisProductDb.getInstance(); ArrayList<String> prodType = extractProductTypeBySeparatorChar(s, db, "."); if (prodType.size() == 1) { return prodType.get(0); } prodType = extractProductTypeBySeparatorChar(s, db, "_"); if (prodType.size() == 1) { return prodType.get(0); } return ""; }
/** * Retrieves whether the product must be flipped top down or not * * @param prodType * @return <code>true</code> if the product must be flipped top down, otherwise <code>false</code>. */ public boolean mustFlip(final String prodType) { boolean bRet = false; try { final ModisProductDescription prod = getProductDescription(prodType); bRet = prod.mustFlipTopDown(); } catch (IOException e) { logger.severe("Unable to retrieve flipping information for product type '" + prodType + "'."); } return bRet; }
final String[] tiePointGridNames = prodDb.getTiePointNames(qcFileContainer.getType()); for (String tiePointGridName : tiePointGridNames) { final Variable variable = netCDFQCVariables.get(tiePointGridName);
public void testShittyEsaNotFollowingTheConventionsNameHandling() throws ProductIOException { final String[] supportetProductTypes = ModisProductDb.getInstance().getSupportetProductTypes(); for (int i = 0; i < supportetProductTypes.length; i++) { final String type = supportetProductTypes[i]; final String toTest = type + "_anySuffix"; if (isImapp(toTest)) { // this does not work for IMAPP types - intentionally! tb 2008-06-17 continue; } assertEquals("Index = " + i, ModisDaacUtils.extractProductType(toTest), type); } }
if (ModisProductDb.getInstance().isSupportedProduct(productType)) { if (modisAttributes.isImappFormat()) { return DecodeQualification.INTENDED;
/** * 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; }
public String[] getSupportetProductTypes() throws ProductIOException { ensureSupportedProductTypes(); final Set<String> keySet = _productTypes.keySet(); final String[] result = new String[keySet.size()]; return keySet.toArray(result); }