_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 31 13.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q247900 | Reader.chunk | train | def chunk(self, seek=None, lenient=False):
"""
Read the next PNG chunk from the input file
returns a (*chunk_type*, *data*) tuple. *chunk_type* is the chunk's
type as a byte string (all PNG chunk types are 4 bytes long).
*data* is the chunk's data content, as a byte string.
... | python | {
"resource": ""
} |
q247901 | Reader.deinterlace | train | def deinterlace(self, raw):
"""
Read raw pixel data, undo filters, deinterlace, and flatten.
Return in flat row flat pixel format.
"""
# Values per row (of the target image)
vpr = self.width * self.planes
# Make a result array, and make it big enough. Interleav... | python | {
"resource": ""
} |
q247902 | Reader.iterboxed | train | def iterboxed(self, rows):
"""
Iterator that yields each scanline in boxed row flat pixel format.
`rows` should be an iterator that yields the bytes of
each row in turn.
"""
def asvalues(raw):
"""
Convert a row of raw bytes into a flat row.
... | python | {
"resource": ""
} |
q247903 | Reader.iterstraight | train | def iterstraight(self, raw):
"""
Iterator that undoes the effect of filtering
Yields each row in serialised format (as a sequence of bytes).
Assumes input is straightlaced. `raw` should be an iterable
that yields the raw bytes in chunks of arbitrary size.
"""
# ... | python | {
"resource": ""
} |
q247904 | Reader.preamble | train | def preamble(self, lenient=False):
"""
Extract the image metadata
Extract the image metadata by reading the initial part of
the PNG file up to the start of the ``IDAT`` chunk. All the
chunks that precede the ``IDAT`` chunk are read and either
processed for metadata or d... | python | {
"resource": ""
} |
q247905 | Reader.idat | train | def idat(self, lenient=False):
"""Iterator that yields all the ``IDAT`` chunks as strings."""
while True:
try:
chunk_type, data = self.chunk(lenient=lenient)
except ValueError:
e = sys.exc_info()[1]
raise ChunkError(e.args[0])
... | python | {
"resource": ""
} |
q247906 | Reader.idatdecomp | train | def idatdecomp(self, lenient=False, max_length=0):
"""Iterator that yields decompressed ``IDAT`` strings."""
# Currently, with no max_length paramter to decompress, this
# routine will do one yield per IDAT chunk. So not very
| python | {
"resource": ""
} |
q247907 | Reader.read | train | def read(self, lenient=False):
"""
Read the PNG file and decode it.
Returns (`width`, `height`, `pixels`, `metadata`).
May use excessive memory.
`pixels` are returned in boxed row flat pixel format.
If the optional `lenient` argument evaluates to True,
checksu... | python | {
"resource": ""
} |
q247908 | Reader.read_flat | train | def read_flat(self):
"""
Read a PNG file and decode it into flat row flat pixel format.
Returns (*width*, *height*, *pixels*, *metadata*).
May use excessive memory.
`pixels` are returned in flat row flat pixel format.
See also the :meth:`read` method which returns pix... | python | {
"resource": ""
} |
q247909 | Reader.asRGB | train | def asRGB(self):
"""
Return image as RGB pixels.
RGB colour images are passed through unchanged;
greyscales are expanded into RGB triplets
(there is a small speed overhead for doing this).
An alpha channel in the source image will raise an exception.
The retur... | python | {
"resource": ""
} |
q247910 | Reader.asRGBA | train | def asRGBA(self):
"""
Return image as RGBA pixels.
Greyscales are expanded into RGB triplets;
an alpha channel is synthesized if necessary.
The return values are as for the :meth:`read` method
except that the *metadata* reflect the returned pixels, not the
source... | python | {
"resource": ""
} |
q247911 | chromaticity_to_XYZ | train | def chromaticity_to_XYZ(white, red, green, blue):
"""From the "CalRGB Color Spaces" section of "PDF Reference", 6th ed."""
xW, yW = white
xR, yR = red
xG, yG = green
xB, yB = blue
R = G = B = 1.0
z = yW * ((xG - xB) * yR - (xR - xB) * yG + (xR - xG) * yB)
YA = yR / R * ((xG - xB) * yW ... | python | {
"resource": ""
} |
q247912 | fallback | train | def fallback(cache):
"""
Caches content retrieved by the client, thus allowing the cached
content to be used later if the live content cannot be retrieved.
"""
log_filter = ThrottlingFilter(cache=cache)
logger.filters = []
logger.addFilter(log_filter)
def get_cache_response(cache_key)... | python | {
"resource": ""
} |
q247913 | AbstractAPIClient.build_url | train | def build_url(base_url, partial_url):
"""
Makes sure the URL is built properly.
>>> urllib.parse.urljoin('https://test.com/1/', '2/3')
https://test.com/1/2/3
>>> urllib.parse.urljoin('https://test.com/1/', '/2/3')
https://test.com/2/3
>>> urllib.parse.urljoin('ht... | python | {
"resource": ""
} |
q247914 | Tide.form_number | train | def form_number(self):
"""
Returns the model's form number, a helpful heuristic for classifying tides.
"""
k1, o1, m2, s2 | python | {
"resource": ""
} |
q247915 | Tide.normalize | train | def normalize(self):
"""
Adapt self.model so that amplitudes are positive and phases are in [0,360) as per convention
"""
for i, (_, amplitude, phase) in enumerate(self.model):
if amplitude < 0:
self.model['amplitude'][i] = -amplitude
| python | {
"resource": ""
} |
q247916 | _unescape | train | def _unescape(v):
"""Unescape characters in a TOML string."""
i = 0
backslash = False
while i < len(v):
if backslash:
backslash = False
if v[i] in _escapes:
v = v[:i - 1] + _escape_to_escapedchars[v[i]] + v[i + 1:]
elif v[i] == '\\':
... | python | {
"resource": ""
} |
q247917 | RequirementsTXTParser.parse | train | def parse(self):
"""
Parses a requirements.txt-like file
"""
index_server = None
for num, line in enumerate(self.iter_lines()):
line = line.rstrip()
if not line:
continue
if line.startswith('#'):
# comments are l... | python | {
"resource": ""
} |
q247918 | _format_help_dicts | train | def _format_help_dicts(help_dicts, display_defaults=False):
"""
Format the output of _generate_help_dicts into a str
"""
help_strs = []
for help_dict in help_dicts:
help_str = "%s (%s" % (
help_dict["var_name"],
"Required" if help_dict["required"] else "Optional",
... | python | {
"resource": ""
} |
q247919 | _generate_help_dicts | train | def _generate_help_dicts(config_cls, _prefix=None):
"""
Generate dictionaries for use in building help strings.
Every dictionary includes the keys...
var_name: The env var that should be set to populate the value.
required: A bool, True if the var is required, False if it's optional.
Conditio... | python | {
"resource": ""
} |
q247920 | generate_help | train | def generate_help(config_cls, **kwargs):
"""
Autogenerate a help string for a config class.
If a callable is provided via the "formatter" kwarg it
will be provided with the help dictionaries as an argument
and any other kwargs provided to this function. That callable
should return the help text... | python | {
"resource": ""
} |
q247921 | render_to_json | train | def render_to_json(response, request=None, **kwargs):
"""
Creates the main structure and returns the JSON response.
"""
# determine the status code
if hasattr(response, 'status_code'):
status_code = response.status_code
elif issubclass(type(response), Http404):
status_code = 404
... | python | {
"resource": ""
} |
q247922 | AJAXMixin.dispatch | train | def dispatch(self, request, *args, **kwargs):
"""
Using ajax decorator
"""
ajax_kwargs = {'mandatory': self.ajax_mandatory}
if self.json_encoder:
| python | {
"resource": ""
} |
q247923 | is_opendap | train | def is_opendap(url):
'''
Returns True if the URL is a valid OPeNDAP URL
:param str url: URL for a remote OPeNDAP endpoint
'''
# If the server replies to a Data Attribute Structure request
if url.endswith('#fillmismatch'):
das_url = url.replace('#fillmismatch', '.das')
else:
... | python | {
"resource": ""
} |
q247924 | datetime_is_iso | train | def datetime_is_iso(date_str):
"""Attempts to parse a date formatted in ISO 8601 format"""
try:
if len(date_str) > 10:
dt = isodate.parse_datetime(date_str)
else:
dt = isodate.parse_date(date_str)
return True, []
| python | {
"resource": ""
} |
q247925 | is_cdl | train | def is_cdl(filename):
'''
Quick check for .cdl ascii file
Example:
netcdf sample_file {
dimensions:
name_strlen = 7 ;
time = 96 ;
variables:
float lat ;
lat:units = "degrees_north" ;
lat:standard_name = "latitude" ;... | python | {
"resource": ""
} |
q247926 | ComplianceChecker.run_checker | train | def run_checker(cls, ds_loc, checker_names, verbose, criteria,
skip_checks=None, output_filename='-',
output_format=['text']):
"""
Static check runner.
@param ds_loc Dataset location (url or file)
@param checker_names List of string n... | python | {
"resource": ""
} |
q247927 | ComplianceChecker.stdout_output | train | def stdout_output(cls, cs, score_dict, verbose, limit):
'''
Calls output routine to display results in terminal, including scoring.
Goes to verbose function if called by user.
@param cs Compliance Checker Suite
@param score_dict Dict with dataset name as key, list of... | python | {
"resource": ""
} |
q247928 | IOOSNCCheck.check_time_period | train | def check_time_period(self, ds):
"""
Check that time period attributes are both set.
"""
start = self.std_check(ds, 'time_coverage_start')
end = self.std_check(ds, 'time_coverage_end')
msgs = []
count = 2
if not start:
count -= 1
m... | python | {
"resource": ""
} |
q247929 | IOOSNCCheck.check_station_location_lat | train | def check_station_location_lat(self, ds):
"""
Checks station lat attributes are set
"""
gmin = self.std_check(ds, 'geospatial_lat_min')
gmax = self.std_check(ds, 'geospatial_lat_max')
msgs = []
count = 2
if not gmin:
count -= 1
msg... | python | {
"resource": ""
} |
q247930 | IOOS0_1Check.check_global_attributes | train | def check_global_attributes(self, ds):
"""
Check all global NC attributes for existence.
:param netCDF4.Dataset ds: An open netCDF dataset
"""
return [
self._has_attr(ds, 'acknowledgement', 'Platform Sponsor'),
self._has_attr(ds, 'publisher_email', 'Stati... | python | {
"resource": ""
} |
q247931 | IOOS0_1Check.check_variable_attributes | train | def check_variable_attributes(self, ds):
"""
Check IOOS concepts that come from NC variable attributes.
:param netCDF4.Dataset ds: An open netCDF dataset
"""
return [
self._has_var_attr(ds, 'platform', 'long_name', 'Station Long Name'),
self._has_var_attr... | python | {
"resource": ""
} |
q247932 | IOOS0_1Check.check_variable_names | train | def check_variable_names(self, ds):
"""
Ensures all variables have a standard_name set.
"""
msgs = []
count = 0
for k, v in ds.variables.items():
| python | {
"resource": ""
} |
q247933 | IOOS0_1Check.check_altitude_units | train | def check_altitude_units(self, ds):
"""
If there's a variable named z, it must have units.
@TODO: this is duplicated with check_variable_units
:param netCDF4.Dataset ds: An open netCDF dataset
"""
if 'z' in ds.variables:
msgs = []
val = 'units' in... | python | {
"resource": ""
} |
q247934 | IOOS1_1Check.check_platform_variables | train | def check_platform_variables(self, ds):
'''
The value of platform attribute should be set to another variable which
contains the details of the platform. There can be multiple platforms
involved depending on if all the instances of the featureType in the
collection share the same... | python | {
"resource": ""
} |
q247935 | IOOS1_1Check.check_geophysical_vars_fill_value | train | def check_geophysical_vars_fill_value(self, ds):
'''
Check that geophysical variables contain fill values.
:param netCDF4.Dataset ds: An open netCDF dataset
'''
results = []
for geo_var in get_geophysical_variables(ds):
| python | {
"resource": ""
} |
q247936 | IOOS1_1Check.check_geophysical_vars_standard_name | train | def check_geophysical_vars_standard_name(self, ds):
'''
Check that geophysical variables contain standard names.
:param netCDF4.Dataset ds: An open netCDF dataset
'''
results = []
for geo_var in get_geophysical_variables(ds):
| python | {
"resource": ""
} |
q247937 | is_dimensionless_standard_name | train | def is_dimensionless_standard_name(xml_tree, standard_name):
'''
Returns True if the units for the associated standard name are
dimensionless. Dimensionless standard names include those that have no
units and units that are defined as constant units in the CF standard name
table i.e. '1', or '1e-3'... | python | {
"resource": ""
} |
q247938 | is_unitless | train | def is_unitless(ds, variable):
'''
Returns true if the variable is unitless
Note units of '1' are considered whole numbers or parts but still represent
physical units and not the absence of units.
:param netCDF4.Dataset ds: An open | python | {
"resource": ""
} |
q247939 | get_cell_boundary_map | train | def get_cell_boundary_map(ds):
'''
Returns a dictionary mapping a variable to its boundary variable. The
returned dictionary maps a string variable name to the name of the boundary
variable.
:param netCDF4.Dataset nc: netCDF dataset
'''
| python | {
"resource": ""
} |
q247940 | get_cell_boundary_variables | train | def get_cell_boundary_variables(ds):
'''
Returns a list of variable names for variables that represent cell
boundaries through the `bounds` attribute
:param netCDF4.Dataset nc: netCDF | python | {
"resource": ""
} |
q247941 | get_geophysical_variables | train | def get_geophysical_variables(ds):
'''
Returns a list of variable names for the variables detected as geophysical
variables.
:param netCDF4.Dataset nc: An open netCDF dataset
'''
parameters = | python | {
"resource": ""
} |
q247942 | get_z_variables | train | def get_z_variables(nc):
'''
Returns a list of all variables matching definitions for Z
:param netcdf4.dataset nc: an open netcdf dataset object
'''
z_variables = []
# Vertical coordinates will be identifiable by units of pressure or the
# presence of the positive attribute with a value of ... | python | {
"resource": ""
} |
q247943 | get_latitude_variables | train | def get_latitude_variables(nc):
'''
Returns a list of all variables matching definitions for latitude
:param netcdf4.dataset nc: an open netcdf dataset object
'''
latitude_variables = []
# standard_name takes precedence
for variable in nc.get_variables_by_attributes(standard_name="latitude"... | python | {
"resource": ""
} |
q247944 | get_true_latitude_variables | train | def get_true_latitude_variables(nc):
'''
Returns a list of variables defining true latitude.
CF Chapter 4 refers to latitude as a coordinate variable that can also be
used in non-standard coordinate systems like rotated pole and other
projections. Chapter 5 refers to a concept of true latitude wher... | python | {
"resource": ""
} |
q247945 | get_longitude_variables | train | def get_longitude_variables(nc):
'''
Returns a list of all variables matching definitions for longitude
:param netcdf4.dataset nc: an open netcdf dataset object
'''
longitude_variables = []
# standard_name takes precedence
for variable in nc.get_variables_by_attributes(standard_name="longit... | python | {
"resource": ""
} |
q247946 | get_true_longitude_variables | train | def get_true_longitude_variables(nc):
'''
Returns a list of variables defining true longitude.
CF Chapter 4 refers to longitude as a coordinate variable that can also be
used in non-standard coordinate systems like rotated pole and other
projections. Chapter 5 refers to a concept of true longitude ... | python | {
"resource": ""
} |
q247947 | get_platform_variables | train | def get_platform_variables(ds):
'''
Returns a list of platform variable NAMES
:param netCDF4.Dataset ds: An open netCDF4 Dataset
'''
candidates = []
for variable in ds.variables:
platform = getattr(ds.variables[variable], 'platform', '')
if platform and platform in ds.variables:... | python | {
"resource": ""
} |
q247948 | get_instrument_variables | train | def get_instrument_variables(ds):
'''
Returns a list of instrument variables
:param netCDF4.Dataset ds: An open netCDF4 Dataset
'''
candidates = []
for variable in ds.variables:
instrument = getattr(ds.variables[variable], 'instrument', '')
if instrument and instrument in ds.var... | python | {
"resource": ""
} |
q247949 | get_time_variables | train | def get_time_variables(ds):
'''
Returns a list of variables describing the time coordinate
:param netCDF4.Dataset ds: An open netCDF4 Dataset
'''
time_variables = set()
for variable in ds.get_variables_by_attributes(standard_name='time'):
time_variables.add(variable.name)
for varia... | python | {
"resource": ""
} |
q247950 | get_axis_variables | train | def get_axis_variables(ds):
'''
Returns a list of variables that define an axis of the dataset
:param netCDF4.Dataset ds: An open netCDF4 Dataset
'''
axis_variables = []
| python | {
"resource": ""
} |
q247951 | get_climatology_variable | train | def get_climatology_variable(ds):
'''
Returns the variable describing climatology bounds if it exists.
Climatology variables are similar to cell boundary variables that describe
the climatology bounds.
See Example 7.8 in CF 1.6
:param netCDF4.Dataset ds: An open netCDF4 Dataset
:rtype: st... | python | {
"resource": ""
} |
q247952 | get_flag_variables | train | def get_flag_variables(ds):
'''
Returns a list of variables that are defined as flag variables
:param netCDF4.Dataset ds: An open netCDF4 Dataset
'''
flag_variables = []
for name, ncvar in ds.variables.items():
standard_name = getattr(ncvar, 'standard_name', None)
| python | {
"resource": ""
} |
q247953 | get_grid_mapping_variables | train | def get_grid_mapping_variables(ds):
'''
Returns a list of grid mapping variables
:param netCDF4.Dataset ds: An open netCDF4 Dataset
'''
grid_mapping_variables = []
for ncvar in ds.get_variables_by_attributes(grid_mapping=lambda x: x is not None):
| python | {
"resource": ""
} |
q247954 | get_axis_map | train | def get_axis_map(ds, variable):
'''
Returns an axis_map dictionary that contains an axis key and the coordinate
names as values.
For example::
{'X': ['longitude'], 'Y': ['latitude'], 'T': ['time']}
The axis C is for compressed coordinates like a reduced grid, and U is for
unknown axis... | python | {
"resource": ""
} |
q247955 | is_coordinate_variable | train | def is_coordinate_variable(ds, variable):
'''
Returns True if the variable is a coordinate variable
:param netCDF4.Dataset nc: An open netCDF dataset
:param str variable: Variable name
| python | {
"resource": ""
} |
q247956 | is_compression_coordinate | train | def is_compression_coordinate(ds, variable):
'''
Returns True if the variable is a coordinate variable that defines a
compression scheme.
:param netCDF4.Dataset nc: An open netCDF dataset
:param str variable: Variable name
'''
# Must be a coordinate variable
if not is_coordinate_variabl... | python | {
"resource": ""
} |
q247957 | coordinate_dimension_matrix | train | def coordinate_dimension_matrix(nc):
'''
Returns a dictionary of coordinates mapped to their dimensions
:param netCDF4.Dataset nc: An open netCDF dataset
'''
retval = {}
x = get_lon_variable(nc)
if x:
retval['x'] = nc.variables[x].dimensions
y = get_lat_variable(nc)
if y:
... | python | {
"resource": ""
} |
q247958 | is_point | train | def is_point(nc, variable):
'''
Returns true if the variable is a point feature type
:param netCDF4.Dataset nc: An open netCDF dataset
:param str variable: name of the variable to check
'''
# x(o), y(o), z(o), t(o)
# X(o)
dims = nc.variables[variable].dimensions
cmatrix = coordina... | python | {
"resource": ""
} |
q247959 | is_cf_trajectory | train | def is_cf_trajectory(nc, variable):
'''
Returns true if the variable is a CF trajectory feature type
:param netCDF4.Dataset nc: An open netCDF dataset
:param str variable: name of the variable to check
'''
# x(i, o), y(i, o), z(i, o), t(i, o)
# X(i, o)
dims = nc.variables[variable].dime... | python | {
"resource": ""
} |
q247960 | is_timeseries_profile_single_station | train | def is_timeseries_profile_single_station(nc, variable):
'''
Returns true if the variable is a time-series profile that represents a
single station and each profile is the same length.
:param netCDF4.Dataset nc: An open netCDF dataset
:param str variable: name of the variable to check
'''
#... | python | {
"resource": ""
} |
q247961 | is_timeseries_profile_ortho_depth | train | def is_timeseries_profile_ortho_depth(nc, variable):
'''
Returns true if the variable is a time-series profile with orthogonal depth
only.
:param netCDF4.Dataset nc: An open netCDF dataset
:param str variable: name of the variable to check
'''
# x(i), y(i), z(z), t(i, j)
# X(i, j, z)
... | python | {
"resource": ""
} |
q247962 | is_trajectory_profile_orthogonal | train | def is_trajectory_profile_orthogonal(nc, variable):
'''
Returns true if the variable is a trajectory profile with orthogonal
depths.
:param netCDF4.Dataset nc: An open netCDF dataset
:param str variable: name of the variable to check
'''
# x(i, o), y(i, o), z(z), t(i, o)
# X(i, o, z)
... | python | {
"resource": ""
} |
q247963 | is_mapped_grid | train | def is_mapped_grid(nc, variable):
'''
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
'''
# x(j, i), y(j, i), z?, t?
... | python | {
"resource": ""
} |
q247964 | is_reduced_grid | train | def is_reduced_grid(nc, variable):
'''
Returns True if the feature-type of the variable corresponds to a reduced
horizontal grid.
:param netCDF4.Dataset nc: An open netCDF dataset
:param str variable: name of the variable to check
'''
axis_map = get_axis_map(nc, variable)
| python | {
"resource": ""
} |
q247965 | guess_feature_type | train | def guess_feature_type(nc, variable):
'''
Returns a string describing the feature type for this variable
:param netCDF4.Dataset nc: An open netCDF dataset
:param str variable: name of the variable to check
'''
if is_point(nc, variable):
return 'point'
if is_timeseries(nc, variable):... | python | {
"resource": ""
} |
q247966 | units_convertible | train | def units_convertible(units1, units2, reftimeistime=True):
"""
Return True if a Unit representing the string units1 can be converted
to a Unit representing the string units2, else False. | python | {
"resource": ""
} |
q247967 | CFBaseCheck.setup | train | def setup(self, ds):
"""
Initialize various special variable types within the class.
Mutates a number of instance variables.
:param netCDF4.Dataset ds: An open netCDF dataset
"""
self._find_coord_vars(ds)
self._find_aux_coord_vars(ds)
self._find_ancillary... | python | {
"resource": ""
} |
q247968 | CFBaseCheck._find_cf_standard_name_table | train | def _find_cf_standard_name_table(self, ds):
'''
Parse out the `standard_name_vocabulary` attribute and download that
version of the cf standard name table. If the standard name table has
already been downloaded, use the cached version. Modifies `_std_names`
attribute to store s... | python | {
"resource": ""
} |
q247969 | CFBaseCheck._find_ancillary_vars | train | def _find_ancillary_vars(self, ds, refresh=False):
'''
Returns a list of variable names that are defined as ancillary
variables in the dataset ds.
An ancillary variable generally is a metadata container and referenced
from other variables via a string reference in an attribute.
... | python | {
"resource": ""
} |
q247970 | CFBaseCheck._find_metadata_vars | train | def _find_metadata_vars(self, ds, refresh=False):
'''
Returns a list of netCDF variable instances for those that are likely metadata variables
:param netCDF4.Dataset ds: An open netCDF dataset
:param bool refresh: if refresh is set to True, the cache is
inva... | python | {
"resource": ""
} |
q247971 | CFBaseCheck._find_geophysical_vars | train | def _find_geophysical_vars(self, ds, refresh=False):
'''
Returns a list of geophysical variables. Modifies
`self._geophysical_vars`
:param netCDF4.Dataset ds: An open netCDF dataset
:param bool refresh: if refresh is set to True, the cache is
invali... | python | {
"resource": ""
} |
q247972 | CFBaseCheck._find_boundary_vars | train | def _find_boundary_vars(self, ds, refresh=False):
'''
Returns dictionary of boundary variables mapping the variable instance
to the name of the variable acting as a boundary variable.
:param netCDF4.Dataset ds: An open netCDF dataset
:param bool refresh: if refresh is set to Tru... | python | {
"resource": ""
} |
q247973 | CFBaseCheck.check_data_types | train | def check_data_types(self, ds):
'''
Checks the data type of all netCDF variables to ensure they are valid
data types under CF.
CF §2.2 The netCDF data types char, byte, short, int, float or real, and
double are all acceptable
:param netCDF4.Dataset ds: An open netCDF da... | python | {
"resource": ""
} |
q247974 | CFBaseCheck.check_naming_conventions | train | def check_naming_conventions(self, ds):
'''
Checks the variable names to ensure they are valid CF variable names under CF.
CF §2.3 Variable, dimension and attribute names should begin with a letter
and be composed of letters, digits, and underscores.
:param netCDF4.Dataset ds: ... | python | {
"resource": ""
} |
q247975 | CFBaseCheck.check_names_unique | train | def check_names_unique(self, ds):
'''
Checks the variable names for uniqueness regardless of case.
CF §2.3 names should not be distinguished purely by case, i.e., if case
is disregarded, no two names should be the same.
:param netCDF4.Dataset ds: An open netCDF dataset
... | python | {
"resource": ""
} |
q247976 | CFBaseCheck.check_dimension_names | train | def check_dimension_names(self, ds):
'''
Checks variables contain no duplicate dimension names.
CF §2.4 A variable may have any number of dimensions, including zero,
and the dimensions must all have different names.
:param netCDF4.Dataset ds: An open netCDF dataset
:rty... | python | {
"resource": ""
} |
q247977 | CFBaseCheck._get_coord_axis_map | train | def _get_coord_axis_map(self, ds):
'''
Returns a dictionary mapping each coordinate to a letter identifier
describing the _kind_ of coordinate.
:param netCDF4.Dataset ds: An open netCDF dataset
:rtype: dict
:return: A dictionary with variable names mapped to axis abbrev... | python | {
"resource": ""
} |
q247978 | CFBaseCheck._get_instance_dimensions | train | def _get_instance_dimensions(self, ds):
'''
Returns a list of dimensions marked as instance dimensions
:param netCDF4.Dataset ds: An open netCDF dataset
:rtype: list
:returns: A list of variable dimensions
'''
ret_val = []
| python | {
"resource": ""
} |
q247979 | CFBaseCheck._get_pretty_dimension_order | train | def _get_pretty_dimension_order(self, ds, name):
'''
Returns a comma seperated string of the dimensions for a specified
variable
:param netCDF4.Dataset ds: An open netCDF dataset
:param str name: A string with a valid NetCDF variable name for the
dataset... | python | {
"resource": ""
} |
q247980 | CFBaseCheck._get_dimension_order | train | def _get_dimension_order(self, ds, name, coord_axis_map):
'''
Returns a list of strings corresponding to the named axis of the dimensions for a variable.
Example::
self._get_dimension_order(ds, 'temperature', coord_axis_map)
--> ['T', 'Y', 'X']
:param netCDF4.Da... | python | {
"resource": ""
} |
q247981 | CFBaseCheck.check_convention_globals | train | def check_convention_globals(self, ds):
'''
Check the common global attributes are strings if they exist.
CF §2.6.2 title/history global attributes, must be strings. Do not need
to exist.
:param netCDF4.Dataset ds: An open netCDF dataset
:rtype: list
:return: Li... | python | {
"resource": ""
} |
q247982 | CFBaseCheck._split_standard_name | train | def _split_standard_name(self, standard_name):
'''
Returns a tuple of the standard_name and standard_name modifier
Nones are used to represent the absence of a modifier or standard_name
:rtype: tuple
:return: 2-tuple of standard_name and modifier as strings
'''
... | python | {
"resource": ""
} |
q247983 | CFBaseCheck._check_valid_cf_units | train | def _check_valid_cf_units(self, ds, variable_name):
'''
Checks that the variable contains units attribute, the attribute is a
string and the value is not deprecated by CF
:param netCDF4.Dataset ds: An open netCDF dataset
:param str variable_name: Name of the variable to be check... | python | {
"resource": ""
} |
q247984 | CFBaseCheck._check_valid_udunits | train | def _check_valid_udunits(self, ds, variable_name):
'''
Checks that the variable's units are contained in UDUnits
:param netCDF4.Dataset ds: An open netCDF dataset
:param str variable_name: Name of the variable to be checked
'''
variable = ds.variables[variable_name]
... | python | {
"resource": ""
} |
q247985 | CFBaseCheck._check_valid_standard_units | train | def _check_valid_standard_units(self, ds, variable_name):
'''
Checks that the variable's units are appropriate for the standard name
according to the CF standard name table and coordinate sections in CF
1.6
:param netCDF4.Dataset ds: An open netCDF dataset
:param str var... | python | {
"resource": ""
} |
q247986 | CFBaseCheck.check_standard_name | train | def check_standard_name(self, ds):
'''
Check a variables's standard_name attribute to ensure that it meets CF
compliance.
CF §3.3 A standard name is associated with a variable via the attribute
standard_name which takes a string value comprised of a standard name
optiona... | python | {
"resource": ""
} |
q247987 | CFBaseCheck.check_ancillary_variables | train | def check_ancillary_variables(self, ds):
'''
Checks the ancillary_variable attribute for all variables to ensure
they are CF compliant.
CF §3.4 It is a string attribute whose value is a blank separated list
of variable names. The nature of the relationship between variables
... | python | {
"resource": ""
} |
q247988 | CFBaseCheck.check_flags | train | def check_flags(self, ds):
'''
Check the flag_values, flag_masks and flag_meanings attributes for
variables to ensure they are CF compliant.
CF §3.5 The attributes flag_values, flag_masks and flag_meanings are
intended to make variables that contain flag values self describing.
... | python | {
"resource": ""
} |
q247989 | CFBaseCheck._check_flag_values | train | def _check_flag_values(self, ds, name):
'''
Checks a variable's flag_values attribute for compliance under CF
- flag_values exists as an array
- unique elements in flag_values
- flag_values si the same dtype as the variable
- flag_values is the same length as flag_meanin... | python | {
"resource": ""
} |
q247990 | CFBaseCheck._check_flag_masks | train | def _check_flag_masks(self, ds, name):
'''
Check a variable's flag_masks attribute for compliance under CF
- flag_masks exists as an array
- flag_masks is the same dtype as the variable
- variable's dtype can support bit-field
- flag_masks is the same length as flag_mean... | python | {
"resource": ""
} |
q247991 | CFBaseCheck._check_flag_meanings | train | def _check_flag_meanings(self, ds, name):
'''
Check a variable's flag_meanings attribute for compliance under CF
- flag_meanings exists
- flag_meanings is a string
- flag_meanings elements are valid strings
:param netCDF4.Dataset ds: An open netCDF dataset
:para... | python | {
"resource": ""
} |
q247992 | CFBaseCheck.check_coordinate_types | train | def check_coordinate_types(self, ds):
'''
Check the axis attribute of coordinate variables
CF §4 The attribute axis may be attached to a coordinate variable and
given one of the values X, Y, Z or T which stand for a longitude,
latitude, vertical, or time axis respectively. Alter... | python | {
"resource": ""
} |
q247993 | CFBaseCheck._check_axis | train | def _check_axis(self, ds, name):
'''
Checks that the axis attribute is a string and an allowed value, namely
one of 'T', 'X', 'Y', or 'Z'.
:param netCDF4.Dataset ds: An open netCDF dataset
:param str name: Name of the variable
:rtype: compliance_checker.base.Result
... | python | {
"resource": ""
} |
q247994 | CFBaseCheck.check_dimensional_vertical_coordinate | train | def check_dimensional_vertical_coordinate(self, ds):
'''
Check units for variables defining vertical position are valid under
CF.
CF §4.3.1 The units attribute for dimensional coordinates will be a string
formatted as per the udunits.dat file.
The acceptable units for v... | python | {
"resource": ""
} |
q247995 | CFBaseCheck.check_dimensionless_vertical_coordinate | train | def check_dimensionless_vertical_coordinate(self, ds):
'''
Check the validity of dimensionless coordinates under CF
CF §4.3.2 The units attribute is not required for dimensionless
coordinates.
The standard_name attribute associates a coordinate with its definition
from ... | python | {
"resource": ""
} |
q247996 | CFBaseCheck._check_formula_terms | train | def _check_formula_terms(self, ds, coord):
'''
Checks a dimensionless vertical coordinate contains valid formula_terms
- formula_terms is a non-empty string
- formula_terms matches regx
- every variable defined in formula_terms exists
:param netCDF4.Dataset ds: An open ... | python | {
"resource": ""
} |
q247997 | CFBaseCheck.check_time_coordinate | train | def check_time_coordinate(self, ds):
'''
Check variables defining time are valid under CF
CF §4.4 Variables representing time must always explicitly include the
units attribute; there is no default value.
The units attribute takes a string value formatted as per the
rec... | python | {
"resource": ""
} |
q247998 | CFBaseCheck.check_aux_coordinates | train | def check_aux_coordinates(self, ds):
'''
Chapter 5 paragraph 3
The dimensions of an auxiliary coordinate variable must be a subset of
the dimensions of the variable with which the coordinate is associated,
with two exceptions. First, string-valued coordinates (Section 6.1,
... | python | {
"resource": ""
} |
q247999 | CFBaseCheck.check_duplicate_axis | train | def check_duplicate_axis(self, ds):
'''
Checks that no variable contains two coordinates defining the same
axis.
Chapter 5 paragraph 6
If an axis attribute is attached to an auxiliary coordinate variable,
it can be used by applications in the same way the `axis` attribu... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.