List<NetCDFSettingsContainer.ExtraVariable> scalarExtraVariables = new ArrayList<>(); for (NetCDFSettingsContainer.ExtraVariable extra : extraVariables) { if (extra.getDimensions().isEmpty()) { scalarExtraVariables.add(extra); } else { if (extra.getDimensions().equals(dimName[dimensionIndex])) { nonscalarExtraVariables.add( new ExtraVariableRecord(extra, dimensionIndex)); for (NetCDFSettingsContainer.ExtraVariable extra : scalarExtraVariables) { writer.write( writer.findVariable(extra.getOutput()), source.findVariable(extra.getSource()).read());
Variable sourceVar = source.findVariable(extra.getSource()); if (sourceVar == null) { LOGGER.info( "Could not find extra variable source '%s' " + "in NetCDF/GRIB %s", extra.getSource(), source.getLocation())); } else if (!sourceVar.getDimensionsString().isEmpty()) { LOGGER.info( "Only scalar extra variables are supported but source " + "'%s' in NetCDF/GRIB %s has dimensions '%s'", extra.getSource(), source.getLocation(), sourceVar.getDimensionsString())); } else if (writer.findVariable(extra.getOutput()) != null) { LOGGER.info( String.format( "Extra variable output '%s' already exists", extra.getOutput())); } else if (extra.getDimensions().split("\\s").length > 1) { LOGGER.info( String.format( "Extra variable output '%s' " + "has too many dimensions '%s'", extra.getOutput(), extra.getDimensions())); } else { Variable outputVar = writer.addVariable(
Variable sourceVar = source.findVariable(extra.getSource()); if (sourceVar == null) { LOGGER.info( "Could not find extra variable source '%s' " + "in NetCDF/GRIB %s", extra.getSource(), source.getLocation())); } else if (!sourceVar.getDimensionsString().isEmpty()) { LOGGER.info( "Only scalar extra variables are supported but source " + "'%s' in NetCDF/GRIB %s has dimensions '%s'", extra.getSource(), source.getLocation(), sourceVar.getDimensionsString())); } else if (writer.findVariable(extra.getOutput()) != null) { LOGGER.info( String.format( "Extra variable output '%s' already exists", extra.getOutput())); } else if (extra.getDimensions().split("\\s").length > 1) { LOGGER.info( String.format( "Extra variable output '%s' " + "has too many dimensions '%s'", extra.getOutput(), extra.getDimensions())); } else { Variable outputVar = writer.addVariable(
tester.assertNoErrorMessage(); assertEquals(1, actualContainer.getExtraVariables().size()); assertEquals("reftime", actualContainer.getExtraVariables().get(0).getSource()); assertEquals( "forecast_reference_time", actualContainer.getExtraVariables().get(0).getOutput()); assertEquals("time", actualContainer.getExtraVariables().get(0).getDimensions());
@Override protected void onClick(AjaxRequestTarget ajaxTarget, Form form) { newSource.processInput(); newOutput.processInput(); newDimensions.processInput(); String source = newSource.getModelObject(); String output = newOutput.getModelObject(); String dimensions = newDimensions.getModelObject(); if ((source == null || source.trim().isEmpty()) && (output == null || output.trim().isEmpty())) { ParamResourceModel rm = new ParamResourceModel( "NetCDFOut.emptySourceOutput", null, ""); error(rm.getString()); } else if (dimensions != null && dimensions.split("\\s").length > 1) { ParamResourceModel rm = new ParamResourceModel( "NetCDFOut.tooManyDimensions", null, ""); error(rm.getString()); } else { extraVariables .getModelObject() .add(new ExtraVariable(source, output, dimensions)); newOutput.setModel(Model.of("")); newSource.setModel(Model.of("")); newDimensions.setModel(Model.of("")); ajaxTarget.add(container); } } };
/** Configure NetCDF output settings for <code>Temperature_surface</code>. */ private void configureTemperatureSurface() { NetCDFLayerSettingsContainer container = new NetCDFLayerSettingsContainer(); container.setCopyAttributes(true); List<VariableAttribute> variableAttributes = new ArrayList<VariableAttribute>(); variableAttributes.add( new VariableAttribute("test-variable-attribute", "Test Variable Attribute")); variableAttributes.add(new VariableAttribute("Grib2_Parameter_Category", "Test Category")); container.setVariableAttributes(variableAttributes); List<ExtraVariable> extraVariables = new ArrayList<ExtraVariable>(); extraVariables.add(new ExtraVariable("reftime", "forecast_reference_time", "time")); extraVariables.add(new ExtraVariable("reftime", "scalar_forecast_reference_time", "")); container.setExtraVariables(extraVariables); List<GlobalAttribute> globalAttributes = new ArrayList<GlobalAttribute>(); globalAttributes.add(new GlobalAttribute("test-global-attribute", "Test Global Attribute")); globalAttributes.add(new GlobalAttribute("test-global-attribute-integer", "42")); globalAttributes.add(new GlobalAttribute("test-global-attribute-double", "1.5")); container.setGlobalAttributes(globalAttributes); CoverageInfo info = getCatalog().getCoverageByName(getLayerId(TEMPERATURE_SURFACE)); info.getMetadata().put(NetCDFSettingsContainer.NETCDFOUT_KEY, container); getCatalog().save(info); }
/** @see java.lang.Object#hashCode() */ @Override public int hashCode() { return getSource().hashCode() + getOutput().hashCode() + getDimensions().hashCode(); } }
/** @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals(Object other) { return other instanceof ExtraVariable && getSource().equals(((ExtraVariable) other).getSource()) && getOutput().equals(((ExtraVariable) other).getOutput()) && getDimensions().equals(((ExtraVariable) other).getDimensions()); }