viscid.readers.vfile module

class viscid.readers.vfile.DataWrapper[source]

Bases: object

dtype
len()[source]
read_direct(*args, **kwargs)[source]
shape
class viscid.readers.vfile.VFile(fname, parent_bucket=None, grid_type=None, grid_opts=None, **kwargs)[source]

Bases: viscid.dataset.Dataset

Generic File

Note

If you want a file that can load other files (like how XDMF files need to be able to load HDF5 files) then subclass off of viscid.readers.vfile_bucket.ContainerFile instead.

Note

Important when subclassing: Do not call the constructors for a dataset / grid yourself, dispatch through _make_dataset and _make_grid.

SAVE_ONLY = False
classmethod collective_name(group)[source]
Parameters:group – single file name or list of file names that would be grouped by group_fnames
Returns:a single name
Return type:str
classmethod collective_name_from_group(group)[source]
classmethod detect_type(fname, mode='r', prefer=None)[source]

recursively detect a filetype using _detector regex string.

This is called recursively for all subclasses and results further down the tree are given precedence.

TODO: move this functionality into a more robust/extendable factory
class… that can also take care of the bucket / circular reference problem maybe
Parameters:
  • fname (str) – Filename
  • mode (str) – ‘r’ or ‘w’
  • prefer (str) – If multiple file types match, give some part of the class name for the reader that you prefer
Note: THIS WILL ONLY WORK FOR CLASSES THAT HAVE ALREADY BEEN
IMPORTED. THIS IS A FRAGILE MECHANISM IN THAT SENSE.
Returns:Some reader that matches fname
Return type:VFile subclass
dirname = None
file = None
fname = None
classmethod group_fnames(fnames)[source]

Group File names

The default implementation just returns fnames, but some file types might do something fancy here

Parameters:fnames (list) – names that can be logically grouped, as in a bunch of file names that are different time steps of a given run
Returns:A list of things that can be given to the constructor of this class
handle_name = None
load(fname)[source]
load_time = None
parent_bucket = None
reload()[source]
classmethod resolve_type(ftype)[source]
save(fname=None, **kwargs)[source]

save an instance of VFile, fname defaults to the name of the file object as read

classmethod save_field(fname, fld, **kwargs)[source]
classmethod save_fields(fname, flds, **kwargs)[source]

save some fields using the format given by the class

classmethod save_grid(fname, grd, **kwargs)[source]
unload(**kwargs)[source]

Really unload a file, don’t just clear the cache

viscid.readers.vfile.serialize_subclasses(root, _lst=None)[source]