dataType = rangeAttribute.getDataType(); min = rangeAttribute.getNumericValue(0).doubleValue(); max = rangeAttribute.getNumericValue(1).doubleValue(); Attribute maxAttribute = var.findAttribute(VALID_MAX); if (minAttribute != null && maxAttribute != null) { dataType = minAttribute.getDataType(); min = minAttribute.getNumericValue().doubleValue(); max = maxAttribute.getNumericValue().doubleValue();
if (attr.getDataType().isString()) { metadata.add(property, attr.getStringValue()); } else if (attr.getDataType().isNumeric()) { int value = attr.getNumericValue().intValue(); metadata.add(property, String.valueOf(value));
private DataType getAttributeDataType(Attribute attribute) { DataType dataType = attribute.getDataType(); if (signedness == Signedness.UNSIGNED) { // If variable is unsigned, make its integral attributes unsigned too. dataType = dataType.withSignedness(signedness); } return dataType; }
if (attr.getDataType().isString()) { metadata.add(property, attr.getStringValue()); } else if (attr.getDataType().isNumeric()) { int value = attr.getNumericValue().intValue(); metadata.add(property, String.valueOf(value));
static private boolean hasIntAttribute_( NetcdfFile ncFile, String name, int min, int max ) { boolean result = false; Attribute a = ncFile.findGlobalAttribute( name ); if ( a != null ) { if ( a.getDataType() == DataType.INT ) { final int v = a.getNumericValue().intValue(); result = v >= min && v <= max; } } return result; }
static private boolean hasIntAttributeIn_( NetcdfFile ncFile, String name, int[] match ) { boolean result = false; Attribute a = ncFile.findGlobalAttribute( name ); if ( a != null && (a.getDataType() == DataType.INT) ) { final int value = a.getNumericValue().intValue(); final int count = match.length; for ( int index = 0; ! result && index < count; ++index ) { result = value == match[ index ]; } } return result; }
static private double getAttAsDouble( NetcdfDataset ds, String attname) { Attribute att = ds.findGlobalAttributeIgnoreCase(attname); if (null == att) throw new IllegalArgumentException("Must have a "+attname+" global attribute"); if (att.getDataType() == DataType.STRING) { return Double.parseDouble( att.getStringValue()); } else { return att.getNumericValue().doubleValue(); } }
static private double getAttAsDouble( NetcdfDataset ds, String attname) { Attribute att = ds.findGlobalAttributeIgnoreCase(attname); if (null == att) throw new IllegalArgumentException("Must have a "+attname+" global attribute"); if (att.getDataType() == DataType.STRING) { return Double.parseDouble( att.getStringValue()); } else { return att.getNumericValue().doubleValue(); } }
static private double getAttAsDouble( NetcdfDataset ds, String attname) { Attribute att = ds.findGlobalAttributeIgnoreCase(attname); if (null == att) throw new IllegalArgumentException("Must have a "+attname+" global attribute"); if (att.getDataType() == DataType.STRING) { return Double.parseDouble( att.getStringValue()); } else { return att.getNumericValue().doubleValue(); } }
static private double getAttAsDouble( NetcdfDataset ds, String attname) { Attribute att = ds.findGlobalAttributeIgnoreCase(attname); if (null == att) throw new IllegalArgumentException("Must have a "+attname+" global attribute"); if (att.getDataType() == DataType.STRING) { return Double.parseDouble( att.getStringValue()); } else { return att.getNumericValue().doubleValue(); } }
static private double getAttAsDouble( NetcdfDataset ds, String attname) { Attribute att = ds.findGlobalAttributeIgnoreCase(attname); if (null == att) throw new IllegalArgumentException("Must have a "+attname+" global attribute"); if (att.getDataType() == DataType.STRING) { return Double.parseDouble( att.getStringValue()); } else { return att.getNumericValue().doubleValue(); } }
static public Date getStartDate(NetcdfDataset ds) { Attribute att = ds.findGlobalAttributeIgnoreCase("time_coverage_start"); if (null == att) throw new IllegalArgumentException("Must have a time_coverage_start global attribute"); if (att.getDataType() == DataType.STRING) { return DateUnit.getStandardOrISO( att.getStringValue()); } else { throw new IllegalArgumentException("time_coverage_start must be a ISO or udunit date string"); } }
static public Date getStartDate(NetcdfDataset ds) { Attribute att = ds.findGlobalAttributeIgnoreCase("time_coverage_start"); if (null == att) throw new IllegalArgumentException("Must have a time_coverage_start global attribute"); if (att.getDataType() == DataType.STRING) { return DateUnit.getStandardOrISO( att.getStringValue()); } else { throw new IllegalArgumentException("time_coverage_start must be a ISO or udunit date string"); } }
static public Date getEndDate(NetcdfDataset ds) { Attribute att = ds.findGlobalAttributeIgnoreCase("time_coverage_end"); if (null == att) throw new IllegalArgumentException("Must have a time_coverage_end global attribute"); Date result; if (att.getDataType() == DataType.STRING) { result = DateUnit.getStandardOrISO( att.getStringValue()); } else { throw new IllegalArgumentException("time_coverage_end must be a ISO or udunit date string"); } return result; }
static public Date getEndDate(NetcdfDataset ds) { Attribute att = ds.findGlobalAttributeIgnoreCase("time_coverage_end"); if (null == att) throw new IllegalArgumentException("Must have a time_coverage_end global attribute"); Date result; if (att.getDataType() == DataType.STRING) { result = DateUnit.getStandardOrISO( att.getStringValue()); } else { throw new IllegalArgumentException("time_coverage_end must be a ISO or udunit date string"); } return result; }
static public Date getStartDate(NetcdfDataset ds) { Attribute att = ds.findGlobalAttributeIgnoreCase("time_coverage_start"); if (null == att) throw new IllegalArgumentException("Must have a time_coverage_start global attribute"); if (att.getDataType() == DataType.STRING) { return DateUnit.getStandardOrISO( att.getStringValue()); } else { throw new IllegalArgumentException("time_coverage_start must be a ISO or udunit date string"); } }
protected Attribute getChunkAttribute(Variable v) { Attribute att = v.findAttribute(CDM.CHUNK_SIZES); if (att != null && att.getDataType().isIntegral() && att.getLength() == v.getRank()) return att; return null; }
private Attribute convertAttribute(Attribute org) { if (version.isExtendedModel()) return org; if (!org.getDataType().isUnsigned()) return org; Array orgValues = org.getValues(); Array nc3Values = Array.makeFromJavaArray(orgValues.getStorage(), false); return new Attribute(org.getShortName(), nc3Values); }
public void testReplaceAtt() { // System.out.println("\nncfile = "+ncfile); Attribute att = ncfile.findGlobalAttribute("title"); assert null != att; assert !att.isArray(); assert att.isString(); assert att.getDataType() == DataType.STRING; assert att.getStringValue().equals("replaced"); assert att.getNumericValue() == null; assert att.getNumericValue(3) == null; }
public void testGlobalAtt() { Attribute att = ncfile.findGlobalAttribute("Conventions"); assert null != att; assert !att.isArray(); assert att.isString(); assert att.getDataType() == DataType.STRING; assert att.getStringValue().equals("Metapps"); assert att.getNumericValue() == null; assert att.getNumericValue(3) == null; }