@Override public Product createProduct() throws IOException { sceneHeight = ncFile.getRootGroup().findGroup("Level-3_Binned_Data").findVariable("BinIndex").getShape(0); sceneWidth = sceneHeight * 2; grid = new ISINGrid(sceneHeight); String productName = getStringAttribute("Product_Name"); Product product = new Product(productName, "NASA-OBPG-L3", sceneWidth, sceneHeight, productReader); product.setFileLocation(productReader.getInputFile()); product.setProductReader(productReader); addGlobalMetadata(product); final Variable idxVariable = ncFile.getRootGroup().findGroup("Level-3_Binned_Data").findVariable("BinList"); List<Variable> l3ProdVars = ncFile.getVariables(); variableMap = addBands(product, idxVariable, l3ProdVars); // try { // addBandsBinMap(product); // } catch (InvalidRangeException e) { // e.printStackTrace(); // } if (product.getNumBands() == 0) { throw new ProductIOException("No bands found."); } initGeoCoding(product); return product; }
/** * Provides an implementation of the <code>readProductNodes</code> interface method. Clients * implementing this method can be sure that the input object and eventually the subset * information has already been set. * * <p> * * <p>This method is called as a last step in the <code>readProductNodes(input, subsetInfo)</code> * method. * * @throws java.io.IOException if an I/O error occurs */ @Override protected Product readProductNodesImpl() throws IOException { Product product; try { final File fileFromInput = ReaderUtils.getFileFromInput(getInput()); dataDir = createDirectory(fileFromInput); dataDir.readProductDirectory(); product = dataDir.createProduct(); addCalibrationLUT(product, fileFromInput.getParentFile()); product.getGcpGroup(); product.setFileLocation(fileFromInput); product.setProductReader(this); product.setModified(false); final MetadataElement absRoot = AbstractMetadata.getAbstractedMetadata(product); isAscending = absRoot.getAttributeString(AbstractMetadata.PASS).equals("ASCENDING"); isAntennaPointingRight = absRoot.getAttributeString(AbstractMetadata.antenna_pointing).equals("right"); } catch (Exception e) { Debug.trace(e.toString()); final IOException ioException = new IOException(e.getMessage()); ioException.initCause(e); throw ioException; } return product; }
@Override public Product createProduct() throws ProductIOException { int[] dims; int sceneHeight = 0; int sceneWidth = 0; Group geodata = ncFile.findGroup("geophysical_data"); if (productReader.getProductType() == SeadasProductReader.ProductType.OISST) { dims = ncFile.getVariables().get(4).getShape(); sceneHeight = dims[2]; sceneWidth = dims[3]; mustFlipY = true; } else if (productReader.getProductType() == SeadasProductReader.ProductType.ANCCLIM) { List<Variable> vars = ncFile.getVariables(); for (Variable v : vars) { if (v.getRank() == 2) { dims = v.getShape(); sceneHeight = dims[0]; sceneWidth = dims[1]; } } } else { if (geodata != null) { dims = geodata.getVariables().get(0).getShape(); sceneHeight = dims[0]; sceneWidth = dims[1]; } else { ucar.nc2.Dimension latdim = ncFile.findDimension("lat"); ucar.nc2.Dimension londim = ncFile.findDimension("lon"); if (latdim != null) { sceneHeight = latdim.getLength(); sceneWidth = londim.getLength(); } else { dims = ncFile.getVariables().get(0).getShape(); sceneHeight = dims[0]; sceneWidth = dims[1]; } } } String productName = productReader.getInputFile().getName(); try { productName = getStringAttribute("Product_Name"); } catch (Exception ignored) { } SeadasProductReader.ProductType productType = productReader.getProductType(); Product product = new Product(productName, productType.toString(), sceneWidth, sceneHeight); product.setDescription(productName); product.setFileLocation(productReader.getInputFile()); product.setProductReader(productReader); addGlobalMetadata(product); addSmiMetadata(product); // variableMap = addBands(product, ncFile.getVariables()); variableMap = addSmiBands(product, ncFile.getVariables()); try { addGeocoding(product); } catch (Exception ignored) { } addFlagsAndMasks(product); if (productReader.getProductType() == SeadasProductReader.ProductType.Bathy) { mustFlipY = true; Dimension tileSize = new Dimension(640, 320); product.setPreferredTileSize(tileSize); } return product; }