/** * Returns {@code true} if the netCDF file contains an attribute of the given name. */ private boolean hasAttribute(final String name) { return file.findGlobalAttributeIgnoreCase(name) != null; }
/** * Returns the netCDF attribute of the given name in the given group, or {@code null} if none. * This method is invoked for every global and group attributes to be read by this class (but * not {@linkplain ucar.nc2.VariableSimpleIF variable} attributes), thus providing a single point * where we can filter the attributes to be read - if we want to do that in a future version. * * <p>The {@code name} argument is typically (but is not restricted too) one of the constants * defined in the {@link org.apache.sis.storage.netcdf.AttributeNames} class.</p> * * @param group the group in which to search the attribute, or {@code null} for global attributes. * @param name the name of the attribute to search (can not be null). * @return the attribute, or {@code null} if none. */ private Attribute findAttribute(final Group group, final String name) { return (group != null) ? group.findAttributeIgnoreCase(name) : file.findGlobalAttributeIgnoreCase(name); }
/** * Returns the netCDF attribute of the given name in the given group, or {@code null} if none. * This method is invoked for every global and group attributes to be read by this class (but * not {@linkplain ucar.nc2.VariableSimpleIF variable} attributes), thus providing a single point * where we can filter the attributes to be read - if we want to do that in a future version. * * <p>The {@code name} argument is typically (but is not restricted too) one of the constants * defined in the {@link org.apache.sis.storage.netcdf.AttributeNames} class.</p> * * @param group the group in which to search the attribute, or {@code null} for global attributes. * @param name the name of the attribute to search (can not be null). * @return the attribute, or {@code null} if none. */ private Attribute findAttribute(final Group group, final String name) { return (group != null) ? group.findAttributeIgnoreCase(name) : file.findGlobalAttributeIgnoreCase(name); }
private static boolean isSensorTypeAttributeCorrect(NetcdfFile ncFile) throws Exception { Attribute attribute = ncFile.findGlobalAttributeIgnoreCase(ChrisConstants.ATTR_NAME_SENSOR_TYPE); return (attribute != null && attribute.getDataType() == DataType.STRING && attribute.getStringValue().equalsIgnoreCase("CHRIS")); } }
static public boolean isValidFile( NetcdfFile ds) { Attribute cdmDtAtt = ds.findGlobalAttributeIgnoreCase( "cdm_data_type"); if ( cdmDtAtt == null ) cdmDtAtt = ds.findGlobalAttributeIgnoreCase( "cdm_datatype"); if ( cdmDtAtt == null ) return false; if ( ! cdmDtAtt.isString() ) return false; String cdmDtString = cdmDtAtt.getStringValue(); if ( cdmDtString == null ) return false; if ( ! cdmDtString.equalsIgnoreCase( FeatureType.TRAJECTORY.toString() )) return false; Attribute conventionsAtt = ds.findGlobalAttributeIgnoreCase( "Conventions"); if ( conventionsAtt == null) return( false); if ( ! conventionsAtt.isString()) return( false); String convString = conventionsAtt.getStringValue(); StringTokenizer stoke = new StringTokenizer( convString, "," ); while ( stoke.hasMoreTokens() ) { String toke = stoke.nextToken().trim(); if ( toke.equalsIgnoreCase( "Unidata Observation Dataset v1.0" ) ) return true; } return false; }
static public boolean isValidFile( NetcdfFile ds) { Attribute cdmDtAtt = ds.findGlobalAttributeIgnoreCase( "cdm_data_type"); if ( cdmDtAtt == null ) cdmDtAtt = ds.findGlobalAttributeIgnoreCase( "cdm_datatype"); if ( cdmDtAtt == null ) return false; if ( ! cdmDtAtt.isString() ) return false; String cdmDtString = cdmDtAtt.getStringValue(); if ( cdmDtString == null ) return false; if ( ! cdmDtString.equalsIgnoreCase( FeatureType.TRAJECTORY.toString() )) return false; Attribute conventionsAtt = ds.findGlobalAttributeIgnoreCase( "Conventions"); if ( conventionsAtt == null) return( false); if ( ! conventionsAtt.isString()) return( false); String convString = conventionsAtt.getStringValue(); StringTokenizer stoke = new StringTokenizer( convString, "," ); while ( stoke.hasMoreTokens() ) { String toke = stoke.nextToken().trim(); if ( toke.equalsIgnoreCase( "Unidata Observation Dataset v1.0" ) ) return true; } return false; }
static public boolean isValidFile( NetcdfFile ds) { Attribute cdmDtAtt = ds.findGlobalAttributeIgnoreCase( "cdm_data_type"); if ( cdmDtAtt == null ) cdmDtAtt = ds.findGlobalAttributeIgnoreCase( "cdm_datatype"); if ( cdmDtAtt == null ) return false; if ( ! cdmDtAtt.isString() ) return false; String cdmDtString = cdmDtAtt.getStringValue(); if ( cdmDtString == null ) return false; if ( ! cdmDtString.equalsIgnoreCase( FeatureType.TRAJECTORY.toString() )) return false; Attribute conventionsAtt = ds.findGlobalAttributeIgnoreCase( "Conventions"); if ( conventionsAtt == null) return( false); if ( ! conventionsAtt.isString()) return( false); String convString = conventionsAtt.getStringValue(); StringTokenizer stoke = new StringTokenizer( convString, "," ); while ( stoke.hasMoreTokens() ) { String toke = stoke.nextToken().trim(); if ( toke.equalsIgnoreCase( "Unidata Observation Dataset v1.0" ) ) return true; } return false; }
static public boolean isValidFile( NetcdfFile ds) { Attribute cdmDtAtt = ds.findGlobalAttributeIgnoreCase( "cdm_data_type"); if ( cdmDtAtt == null ) cdmDtAtt = ds.findGlobalAttributeIgnoreCase( "cdm_datatype"); if ( cdmDtAtt == null ) return false; if ( ! cdmDtAtt.isString() ) return false; String cdmDtString = cdmDtAtt.getStringValue(); if ( cdmDtString == null ) return false; if ( ! cdmDtString.equalsIgnoreCase( FeatureType.TRAJECTORY.toString() )) return false; Attribute conventionsAtt = ds.findGlobalAttributeIgnoreCase( "Conventions"); if ( conventionsAtt == null) return( false); if ( ! conventionsAtt.isString()) return( false); String convString = conventionsAtt.getStringValue(); StringTokenizer stoke = new StringTokenizer( convString, "," ); while ( stoke.hasMoreTokens() ) { String toke = stoke.nextToken().trim(); if ( toke.equalsIgnoreCase( "Unidata Observation Dataset v1.0" ) ) return true; } return false; }
static public boolean isValidFile( NetcdfFile ds) { Attribute cdmDtAtt = ds.findGlobalAttributeIgnoreCase( "cdm_data_type"); if ( cdmDtAtt == null ) cdmDtAtt = ds.findGlobalAttributeIgnoreCase( "cdm_datatype"); if ( cdmDtAtt == null ) return false; if ( ! cdmDtAtt.isString() ) return false; String cdmDtString = cdmDtAtt.getStringValue(); if ( cdmDtString == null ) return false; if ( ! cdmDtString.equalsIgnoreCase( FeatureType.TRAJECTORY.toString() )) return false; Attribute conventionsAtt = ds.findGlobalAttributeIgnoreCase( "Conventions"); if ( conventionsAtt == null) return( false); if ( ! conventionsAtt.isString()) return( false); String convString = conventionsAtt.getStringValue(); StringTokenizer stoke = new StringTokenizer( convString, "," ); while ( stoke.hasMoreTokens() ) { String toke = stoke.nextToken().trim(); if ( toke.equalsIgnoreCase( "Unidata Observation Dataset v1.0" ) ) return true; } return false; }
/** * Returns the value of the given attribute as a string. The attribute name is case-insensitive. * If non-null, the returned string is {@linkplain String#trim() trimmed} and never * {@linkplain String#isEmpty() empty}. * * @param name the case-insensitive attribute name. * @return the non-empty attribute value, or {@code null} if none. */ private String getString(final String name) { final Attribute attribute = file.findGlobalAttributeIgnoreCase(name); if (attribute != null && attribute.isString()) { String value = attribute.getStringValue(); if (value != null && !(value = value.trim()).isEmpty()) { return value; } } return null; }
static public boolean isValidFile( NetcdfFile ds) { Attribute cdmDtAtt = ds.findGlobalAttributeIgnoreCase( "cdm_data_type"); if ( cdmDtAtt == null ) cdmDtAtt = ds.findGlobalAttributeIgnoreCase( "cdm_datatype"); if ( cdmDtAtt == null ) return false; if ( ! cdmDtAtt.isString() ) return false; String cdmDtString = cdmDtAtt.getStringValue(); if ( cdmDtString == null ) return false; if ( ! cdmDtString.equalsIgnoreCase( FeatureType.TRAJECTORY.toString() )) return false; Attribute conventionsAtt = ds.findGlobalAttributeIgnoreCase( "Conventions"); if ( conventionsAtt == null) return( false); if ( ! conventionsAtt.isString()) return( false); String convString = conventionsAtt.getStringValue(); StringTokenizer stoke = new StringTokenizer( convString, "," ); while ( stoke.hasMoreTokens() ) { String toke = stoke.nextToken().trim(); if ( toke.equalsIgnoreCase( "Unidata Observation Dataset v1.0" ) ) return true; } return false; }
/** * Returns the value of the given attribute as a floating point value. * * @param name the case-insensitive attribute name. * @return the attribute value, or {@code NaN} if none. * @throws NumberFormatException if the number can not be parsed. */ private double getDouble(final String name) throws NumberFormatException { final Attribute attribute = file.findGlobalAttributeIgnoreCase(name); if (attribute != null) { if (attribute.isString()) { final String value = attribute.getStringValue(); if (value != null) { return Double.parseDouble(value); } } else { final Number value = attribute.getNumericValue(); if (value != null) { return value.doubleValue(); } } } return Double.NaN; }
public ProductType findProductType() throws ProductIOException { Attribute titleAttr = ncfile.findGlobalAttributeIgnoreCase("Title"); String title; ProductType tmp;
if (ncfile != null) { Attribute titleAttribute = ncfile.findGlobalAttributeIgnoreCase("title");
if (ncfile != null) { Attribute titleAttribute = ncfile.findGlobalAttributeIgnoreCase("title");
if (ncfile != null) { String titleattr = "title"; Attribute titleAttribute = ncfile.findGlobalAttributeIgnoreCase(titleattr);
ncfile = NetcdfFileOpener.open(file.getPath()); if (ncfile != null) { Attribute titleAttribute = ncfile.findGlobalAttributeIgnoreCase("Title");
String north = "Northernmost_Latitude"; String south = "Southernmost_Latitude"; Attribute latmax = ncFile.findGlobalAttributeIgnoreCase("geospatial_lat_max"); if (latmax != null) { east = "geospatial_lon_max"; south = "geospatial_lat_min"; } else { latmax = ncFile.findGlobalAttributeIgnoreCase("upper_lat"); if (latmax != null) { east = "right_lon";