/** Add global attributes to the Dataset if needed */ protected void initializeGlobalAttributes() { copyGlobalAttribute(); addGlobalAttributesFromSettings(); }
@Override protected boolean checkCompliant(Variable var) { // Check the layer name if (variableName == null || variableName.isEmpty()) { // Wrong Layer name return false; } return super.checkCompliant(var); } }
/** * {@link DefaultNetCDFEncoder} constructor. * * @param granuleStack the granule stack to be written * @param file an output file * @param encodingParameters customized encoding params * @throws IOException */ public AbstractNetCDFEncoder( GranuleStack granuleStack, File file, Map<String, String> encodingParameters, String outputFormat) throws IOException { this.granuleStack = granuleStack; this.sampleGranule = granuleStack.getGranules().get(0); NetCDFLayerSettingsContainer settings = getSettings(encodingParameters); if (settings != null) { initializeFromSettings(settings); } this.writer = getWriter(file, outputFormat); dimensionsManager.collectCoverageDimensions(this.granuleStack); initializeNetCDF(); }
/** Basic NetCDF Initialization */ protected void initializeNetCDF() { // Initialize the coordinates writer crsWriter = new NetCDFCRSWriter(writer, sampleGranule); // Initialize the Dimensions and coordinates variable initializeDimensions(); // Initialize the variable by setting proper coordinates and attributes initializeVariables(); initializeGlobalAttributes(); }
/** Copies over the global attributes, if enabled */ protected void copyGlobalAttribute() { // Copy global attributes from source NetCDF if (copyGlobalAttributes) { try (NetcdfDataset source = getSourceNetcdfDataset(sampleGranule)) { if (source != null) { for (Attribute att : source.getGlobalAttributes()) { // part of the blacklist? String shortName = att.getShortName(); if (!COPY_GLOBAL_ATTRIBUTES_BLACKLIST.contains(shortName)) { writer.addGroupAttribute(null, att); } } } } catch (Exception e) { if (LOGGER.isLoggable(Level.SEVERE)) { LOGGER.severe("Failed to copy from source NetCDF: " + e.getMessage()); } } } }
@Override protected void initializeFromSettings(NetCDFLayerSettingsContainer settings) { super.initializeFromSettings(settings); variableName = settings.getLayerName(); variableUoM = settings.getLayerUOM(); }
/** Adds the global attributes from the settings in the UI */ protected void addGlobalAttributesFromSettings() { // Add global attributes from settings if (globalAttributes != null) { for (NetCDFSettingsContainer.GlobalAttribute att : globalAttributes) { if (att.getKey().equalsIgnoreCase(NetCDFUtilities.CONVENTIONS)) { writer.addGroupAttribute( null, new Attribute( NetCDFUtilities.COORD_SYS_BUILDER, NetCDFUtilities.COORD_SYS_BUILDER_CONVENTION)); } writer.addGroupAttribute(null, buildAttribute(att.getKey(), att.getValue())); } } }
protected void initializeFromSettings(NetCDFLayerSettingsContainer settings) { shuffle = settings.isShuffle(); copyAttributes = settings.isCopyAttributes(); copyGlobalAttributes = settings.isCopyGlobalAttributes(); dataPacking = settings.getDataPacking(); compressionLevel = checkLevel(settings.getCompressionLevel()); globalAttributes = settings.getGlobalAttributes(); variableAttributes = settings.getVariableAttributes(); extraVariables = settings.getExtraVariables(); }
try (NetcdfDataset source = getSourceNetcdfDataset(sampleGranule)) { for (NetCDFSettingsContainer.ExtraVariable extra : scalarExtraVariables) { writer.write(