spacepy.pycdf.istp.VariableChecks¶
- class spacepy.pycdf.istp.VariableChecks[source]¶
ISTP compliance checks for a single variable.
Checks a variable’s compliance with ISTP standards. This mostly performs checks that are not currently performed by the ISTP skeleton editor. All tests return a list, one error string for every noncompliance found (empty list if compliant).
all
will perform all tests and concatenate all errors.- __init__(*args, **kwargs)¶
Methods
all
(v[, catch])Perform all variable tests
deltas
(v)Check DELTA variables
depends
(v)Checks that DELTA, DEPEND, and LABL_PTR variables exist
depsize
(v)Checks that DEPEND has same shape as that dim
empty_entry
(v)Check for attributes with empty string
fieldnam
(v)Check that FIELDNAM attribute matches variable name.
fillval
(v)Check for FILLVAL presence, type, value
recordcount
(v)Check that the DEPEND_0 has same record count as variable
Check that plottype matches dimensions.
validrange
(v)Check that all values are within VALIDMIN/VALIDMAX, or FILLVAL
validscale
(v)Check SCALEMIN<=SCALEMAX, and both in range for CDF datatype.
- classmethod all(v, catch=False)[source]¶
Perform all variable tests
- Parameters:
- v
Var
Variable to check
- catchbool
Catch exceptions in tests (default False). If True, any exceptions in subtests will result in an addition to the validation failures of the form “Test x did not complete.” Calling the individual test will reveal the full traceback.
- v
- Returns:
- list of str
Description of each validation failure.
Examples
>>> import spacepy.pycdf >>> import spacepy.pycdf.istp >>> f = spacepy.pycdf.CDF('foo.cdf', create=True) >>> v = f.new('Var', data=[1, 2, 3]) >>> spacepy.pycdf.istp.VariableChecks.all(v) ['No FIELDNAM attribute.']
- classmethod deltas(v)[source]¶
Check DELTA variables
Check that variables specified in the variable attributes for DELTA match the type, size, and units of this variable.
- Parameters:
- v
Var
Variable to check
- v
- Returns:
- list of str
Description of each validation failure.
- classmethod depends(v)[source]¶
Checks that DELTA, DEPEND, and LABL_PTR variables exist
Check that variables specified in the variable attributes for DELTA, DEPEND, and LABL_PTR exist in the CDF.
- Parameters:
- v
Var
Variable to check
- v
- Returns:
- list of str
Description of each validation failure.
- classmethod depsize(v)[source]¶
Checks that DEPEND has same shape as that dim
Compares the size of variables specified in the variable attributes for DEPEND and compares to the size of the corresponding dimension in this variable.
- Parameters:
- v
Var
Variable to check
- v
- Returns:
- list of str
Description of each validation failure.
- classmethod empty_entry(v)[source]¶
Check for attributes with empty string
Checks attributes for this variable for any entries consisting of an empty string. These should be replaced with a single space.
- Parameters:
- v
Var
Variable to check
- v
- Returns:
- list of str
Description of each validation failure.
- classmethod fieldnam(v)[source]¶
Check that FIELDNAM attribute matches variable name.
Compare FIELDNAM attribute to the variable name; fail validation if they don’t match.
- Parameters:
- v
Var
Variable to check
- v
- Returns:
- list of str
Description of each validation failure.
- classmethod fillval(v)[source]¶
Check for FILLVAL presence, type, value
Checks variable for existence of FILLVAL attribute and makes sure it is the same type as variable and matches ISTP value.
- Parameters:
- v
Var
Variable to check
- v
- Returns:
- list of str
Description of each validation failure.
See also
spacepy.pycdf.istp.fillval
Automatic setting of this value.
- classmethod recordcount(v)[source]¶
Check that the DEPEND_0 has same record count as variable
Checks the record count of the variable specified in the variable attribute for DEPEND_0 and compares to the record count for this variable.
- Parameters:
- v
Var
Variable to check
- v
- Returns:
- list of str
Description of each validation failure.
- classmethod validdisplaytype(v)[source]¶
Check that plottype matches dimensions.
Check DISPLAYTYPE of this variable and makes sure it is reasonable for the variable dimensions.
- Parameters:
- v
Var
Variable to check
- v
- Returns:
- list of str
Description of each validation failure.
- classmethod validrange(v)[source]¶
Check that all values are within VALIDMIN/VALIDMAX, or FILLVAL
Compare all values of this variable to VALIDMIN and
VALIDMAX
; fails validation if any values are below VALIDMIN or aboveVALIDMAX
unless equal to FILLVAL.- Parameters:
- v
Var
Variable to check
- v
- Returns:
- list of str
Description of each validation failure.
- classmethod validscale(v)[source]¶
Check SCALEMIN<=SCALEMAX, and both in range for CDF datatype.
Compares SCALEMIN to
SCALEMAX
to make sure it isn’t larger and both are within range of the variable CDF datatype.- Parameters:
- v
Var
Variable to check
- v
- Returns:
- list of str
Description of each validation failure.