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.

all(v[, catch]) Perform all variable tests
depends(v) Checks that DEPEND and LABL_PTR variables actually exist
depsize(v) Checks that DEPEND has same shape as that dim
fieldnam(v) Check that FIELDNAM attribute matches variable name.
recordcount(v) Check that the DEPEND_0 has same record count as variable
validdisplaytype(v) 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

catch : bool

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.

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 depends(v)[source]

Checks that DEPEND and LABL_PTR variables actually exist

Check that variables specified in the variable attributes for DEPEND and LABL_PTR exist in the CDF.

Parameters:

v : Var

Variable to check

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

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

Returns:

list of str

Description of each validation failure.

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

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

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 above VALIDMAX unless equal to FILLVAL.

Parameters:

v : Var

Variable to check

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

Returns:

list of str

Description of each validation failure.