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

empty_entry(f)

Check for attributes with empty string

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
fCDF

Open CDF file 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.

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 empty_entry(f)[source]

Check for attributes with empty string

Checks global attributes for this variable for any entries consisting of an empty string. These should be replaced with a single space.

Parameters
fCDF

Open CDF file to check

Returns
list of str

Description of each validation failure.

classmethod filename(f)[source]

Compare filename to global attributes

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

Parameters
fCDF

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
fCDF

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
fCDF

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.)