BasicObsData

class tolteca.datamodels.toltec.BasicObsData(source, open_=True)[source]

Bases: tolteca.datamodels.io.base.DataFileIO

A class that provides unified IO interface to TolTEC basic obs data.

This class acts as a simple wrapper around the data file IO classes defined in toltec module, and provides an unified interface to handle high level information of data items that are of different types, or located on remote file systems.

If the source points to a local file, the file_obj is available and can be used to access the data:

>>> from tolteca.datamodels.toltec import BasicObsData
>>> bod = BasicObsData('toltec0.nc')
>>> with bod.open() as fo:
>>>     # ``fo`` is a `~tolteca.datamodels.io.toltec.NcFileIO`
>>>     # instance.
>>>     kidsdata = fo.read()

The above can also be done via the BasicObsData.open() shortcut as follows:

>>> with BasicObsData.open('toltec0.nc') as fo:
>>>     kidsdata = fo.read()

This can further be shortened as:

>>> kidsdata = BasicObsData.read('toltec0.nc')

When file_loc is a remote file, file_obj is None, and (of course) attempting to open the file will raise DataFileIOError.

In both cases, various information of the data is pulled and stored in meta. In particular, when file_obj is available (local file), the meta data includes those from the header of the opened data file.

Parameters
sourcestr, Path, FileLoc.

The data file location. Remote locations can be specified in either URL or SFTP format <host>:<path>.

open_: bool

If True, attemp to open the file to load meta data.

Attributes Summary

logger

Methods Summary

open(*args, **kwargs)

Shortcut to open the file.

read(*args, **kwargs)

Shortcut to read the file.

update_meta_from_file_loc(meta, file_loc)

Update meta with info encoded in file_loc.

update_meta_from_file_obj(meta, file_obj)

Update meta with header of file_obj.

Attributes Documentation

logger = <Logger BasicObsData (DEBUG)>

Methods Documentation

classmethod open(*args, **kwargs)[source]

Shortcut to open the file.

classmethod read(*args, **kwargs)[source]

Shortcut to read the file.

classmethod update_meta_from_file_loc(meta, file_loc)[source]

Update meta with info encoded in file_loc.

This modifies meta in-place.

classmethod update_meta_from_file_obj(meta, file_obj)[source]

Update meta with header of file_obj.

This modifies meta in-place.