Returns true if the feature-type of variable corresponds to a mapped grid
    type. Characterized by Appedix F of CF-1.6

    :param netCDF4.Dataset nc: An open netCDF dataset
    :param str variable: name of the variable to check
501366
def is_mapped_grid(nc, variable):
    '''
    
    '''
    # x(j, i), y(j, i), z?, t?
    # F(t?, z?, j, i)

    # The important and really defining characteristic of mapped grids is that
    # the true latitude and longitude coordinates are functions of (j,i) and
    # that the geophysical variables are also functions of (j,i) in their
    # dimensions.
    dims = nc.variables[variable].dimensions
    # For cases like ROMS, the coordinates are mapped using the coordinates attribute
    variable_coordinates = getattr(nc.variables[variable], 'coordinates', '').split()

    lons = get_longitude_variables(nc)
    for lon in lons:
        if lon in variable_coordinates:
            break
    else:
        lon = get_lon_variable(nc)

    if lon is None:
        return False

    lats = get_latitude_variables(nc)
    for lat in lats:
        if lat in variable_coordinates:
            break
    else:
        lat = get_lat_variable(nc)

    if lat is None:
        return False

    x = nc.variables[lon].dimensions
    y = nc.variables[lat].dimensions

    if len(x) != 2:
        return False
    if x != y:
        return False

    comma_dimension = ','.join(dims)
    # Dimensions must be in the same order and the mapping coordinates i and j
    # must be in the same order
    if ','.join(x) not in comma_dimension:
        return False

    return True
802646
def _maybe_dt_data(data, feature_names, feature_types):
    
    if not isinstance(data, DataTable):
        return data, feature_names, feature_types

    data_types_names = tuple(lt.name for lt in data.ltypes)
    bad_fields = [data.names[i]
                  for i, type_name in enumerate(data_types_names)
                  if type_name not in DT_TYPE_MAPPER]
    if bad_fields:
        msg = """DataFrame.types for data must be int, float or bool.
                Did not expect the data types in fields """
        raise ValueError(msg + ', '.join(bad_fields))

    if feature_names is None:
        feature_names = data.names

        # always return stypes for dt ingestion
        if feature_types is not None:
            raise ValueError('DataTable has own feature types, cannot pass them in')
        feature_types = np.vectorize(DT_TYPE_MAPPER2.get)(data_types_names)

    return data, feature_names, feature_types
1072120
def is_timeseries(nc, variable):
    '''
    
    '''

    # x, y, z, t(t)
    # X(t)
    dims = nc.variables[variable].dimensions
    cmatrix = coordinate_dimension_matrix(nc)
    time_variables = get_time_variables(nc)

    if len(dims) != 1:
        return False
    dim = dims[0]
    if dim not in time_variables:
        return False
    # No other coordinates can vary with time
    if 'x' in cmatrix:
        if len(cmatrix['x']) != 0:
            return False
    if 'y' in cmatrix:
        if len(cmatrix['y']) != 0:
            return False
    if 'z' in cmatrix:
        if len(cmatrix['z']) != 0:
            return False

    return True
1181560
def is_timeseries(nc, variable):
    '''
    
    '''

    # x, y, z, t(o)
    # X(o)
    dims = nc.variables[variable].dimensions

    cmatrix = coordinate_dimension_matrix(nc)
    for req in ('x', 'y', 't'):
        if req not in cmatrix:
            return False
    if len(cmatrix['x']) != 0:
        return False
    if len(cmatrix['y']) != 0:
        return False
    if 'z' in cmatrix and len(cmatrix['z']) != 0:
        return False
    timevar = get_time_variable(nc)

    # time has to be a coordinate variable in this case
    if cmatrix['t'] != (timevar,):
        return False
    if dims == cmatrix['t']:
        return True
    return False
818809
def _nest_variable(v, check_records=False):
    
    if (check_records and is_cwl_record(v) and len(v["id"].split("/")) > 1 and
         v.get("type", {}).get("type") == "array"):
        return v
    else:
        v = copy.deepcopy(v)
        v["type"] = {"type": "array", "items": v["type"]}
        return v
972701
def is_compression_coordinate(ds, variable):
    '''
    
    '''
    # Must be a coordinate variable
    if not is_coordinate_variable(ds, variable):
        return False
    # must have a string attribute compress
    compress = getattr(ds.variables[variable], 'compress', None)
    if not isinstance(compress, basestring):
        return False
    if not compress:
        return False
    # This should never happen or be allowed
    if variable in compress:
        return False
    # Must point to dimensions
    for dim in compress.split():
        if dim not in ds.dimensions:
            return False
    return True
331151
def has_value_of_type(self, var_type):
        
        if self.has_value() and self.has_type(var_type):
            return True
        return False
164269
public void computeNccDescriptor( NccFeature f , float x0 , float y0 , float x1 , float y1 ) {
		double mean = 0;
		float widthStep = (x1-x0)/15.0f;
		float heightStep = (y1-y0)/15.0f;

		// compute the mean value
		int index = 0;
		for( int y = 0; y < 15; y++ ) {
			float sampleY = y0 + y*heightStep;
			for( int x = 0; x < 15; x++ ) {
				mean += f.value[index++] = interpolate.get_fast(x0 + x * widthStep, sampleY);
			}
		}
		mean /= 15*15;

		// compute the variance and save the difference from the mean
		double variance = 0;
		index = 0;
		for( int y = 0; y < 15; y++ ) {
			for( int x = 0; x < 15; x++ ) {
				double v = f.value[index++] -= mean;
				variance += v*v;
			}
		}
		variance /= 15*15;
		f.mean = mean;
		f.sigma = Math.sqrt(variance);
	}
671524
def is_config_var(var):
    

    return (
        isinstance(var, (attr._make.Attribute, attr._make._CountingAttr))
        and hasattr(var, "metadata")
        and CONFIG_KEY in var.metadata
    )
96811
def has_ndarray_int_columns(features, X):
    
    _, ncols = X.shape
    if not all(d.isdigit() for d in features if isinstance(d, str)) or not isinstance(X, np.ndarray):
        return False
    ndarray_columns = np.arange(0, ncols)
    feature_cols = np.unique([int(d) for d in features])
    return all(np.in1d(feature_cols, ndarray_columns))
865525
def get_var(self, name):
        """"""
        # How many dimensions.
        rank = self.get_var_rank(name)
        # The shape array is fixed size
        shape = np.empty((MAXDIMS, ), dtype='int32', order='F')
        shape = self.get_var_shape(name)
        # there should be nothing here...
        assert sum(shape[rank:]) == 0
        # variable type name
        type_ = self.get_var_type(name)

        is_numpytype = type_ in TYPEMAP

        if is_numpytype:
            # Store the data in this type
            arraytype = ndpointer(dtype=TYPEMAP[type_],
                                  ndim=rank,
                                  shape=shape,
                                  flags='F')
        # '' or b''
        elif not type_:
            raise ValueError('type not found for variable {}'.format(name))
        else:
            arraytype = self.make_compound_ctype(name)
        # Create a pointer to the array type
        data = arraytype()
        # The functions get_var_type/_shape/_rank are already wrapped with
        # python function converter, get_var isn't.
        c_name = create_string_buffer(name)
        get_var = self.library.get_var
        get_var.argtypes = [c_char_p, POINTER(arraytype)]
        get_var.restype = None
        # Get the array
        get_var(c_name, byref(data))
        if not data:
            logger.info("NULL pointer returned")
            return None

        if is_numpytype:
            # for now always a pointer, see python-subgrid for advanced examples
            array = np.ctypeslib.as_array(data)
        else:
            array = structs2pandas(data.contents)

        return array
1025322
def get_z_variable(nc):
    '''
    
    '''
    z_variables = get_z_variables(nc)
    if not z_variables:
        return None

    # Priority is standard_name, units
    for var in z_variables:
        ncvar = nc.variables[var]
        if getattr(ncvar, 'standard_name', None) in ('depth', 'height', 'altitude'):
            return var

    for var in z_variables:
        ncvar = nc.variables[var]
        units = getattr(ncvar, 'units', None)
        if isinstance(units, basestring):
            if units_convertible(units, 'bar'):
                return var
            if units_convertible(units, 'm'):
                return var

    return z_variables[0]
502190
private static boolean variableIsParameter(Var variable) {
    Node variableParent = variable.getParentNode();

    return variableParent != null && variableParent.isParamList();
  }
1163890
def setType(self, polygonID, polygonType):
        
        self._connection._beginMessage(
            tc.CMD_SET_POLYGON_VARIABLE, tc.VAR_TYPE, polygonID, 1 + 4 + len(polygonType))
        self._connection._packString(polygonType)
        self._connection._sendExact()
789700
def is_coordinate_variable(ds, variable):
    '''
    
    '''
    if variable not in ds.variables:
        return False
    return ds.variables[variable].dimensions == (variable,)
92056
def get_grid_spatial_dimensions(self, variable):
        """"""

        data = self.open_dataset(self.service).variables[variable.variable]
        dimensions = list(data.dimensions)
        return data.shape[dimensions.index(variable.x_dimension)], data.shape[dimensions.index(variable.y_dimension)]
1341355
def is_geophysical(ds, variable):
    '''
    
    '''
    ncvar = ds.variables[variable]

    if getattr(ncvar, 'cf_role', None):
        return False

    # Check for axis
    if getattr(ncvar, 'axis', None):
        return False

    standard_name_test = getattr(ncvar, 'standard_name', '')
    unitless = is_unitless(ds, variable)

    if not isinstance(standard_name_test, basestring):
        warnings.warn("Variable {} has non string standard name, "
                      "Attempting cast to string".format(variable))
        try:
            standard_name = str(standard_name_test)
        except ValueError:
            warnings.warn("Unable to cast standard name to string, excluding "
                          "from geophysical variables")
    else:
        standard_name = standard_name_test

    # Is the standard name associated with coordinates
    if standard_name in {'time', 'latitude', 'longitude',
                         'height', 'depth', 'altitude'}:
        return False

    if variable in get_coordinate_variables(ds):
        return False

    if variable in get_auxiliary_coordinate_variables(ds):
        return False

    # Is it dimensionless and unitless?
    if len(ncvar.shape) == 0 and unitless:
        return False

    # Is it a QC Flag?
    if 'status_flag' in standard_name or hasattr(ncvar, 'flag_meanings'):
        return False

    # Is it a §7.1 Cell Boundaries variable
    if variable in get_cell_boundary_variables(ds):
        return False

    if variable == get_climatology_variable(ds):
        return False

    # Is it a string but with no defined units?
    if ncvar.dtype.char == 'S':
        return False

    # Is it an instrument descriptor?
    if variable in get_instrument_variables(ds):
        return False

    # What about a platform descriptor?
    if variable in get_platform_variables(ds):
        return False

    # Skip count variables too
    if hasattr(ncvar, 'sample_dimension'):
        return False

    return True