spacepy.pycdf.istp.FileChecks

class spacepy.pycdf.istp.FileChecks[source]

ISTP compliance checks for a CDF file.

Checks a file’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(f[, catch]) Perform all variable and file-level tests
filename(f) Compare filename to global attributes
time_monoton(f) Checks that times are monotonic
times(f) Compare filename to times
classmethod all(f, catch=False)[source]

Perform all variable and file-level tests

In addition to calling every test in this class, will also call VariableChecks.all() for every variable in the file.

Parameters:

f : CDF

Open CDF file 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.FileChecks.all(f)
['No Logical_source in global attrs.',
'No Logical_file_id in global attrs.',
'Cannot parse date from filename foo.cdf.',
'Var: No FIELDNAM attribute.']
classmethod filename(f)[source]

Compare filename to global attributes

Check global attribute Logical_file_id and Logical_source for consistency with CDF filename.

Parameters:

f : CDF

Open CDF file to check

Returns:

list of str

Description of each validation failure.

classmethod time_monoton(f)[source]

Checks that times are monotonic

Check that all Epoch variables are monotonically increasing.

Parameters:

f : CDF

Open CDF file to check

Returns:

list of str

Description of each validation failure.

classmethod times(f)[source]

Compare filename to times

Check that all Epoch variables only contain times matching filename.

Parameters:

f : CDF

Open CDF file to check

Returns:

list of str

Description of each validation failure.

Notes

This function assumes daily files and should be extended based on the File_naming_convention global attribute (which itself is another good check to have.)