sda.io.load#

Created on Thu Apr 2 19:15:16 2015.

@author: Erwan

A serie of functions used to import any data file and return an array

Features: - work with .txt, .csv, .spe (Winspec files) - work with dot or comma for floating point numbers - work with either column or line based data files - distinguish headers

To do : - read Specair files - - (WIP) re-write this module with more conventional class structure.


Classes#

FileOpener

Open any file type in the Lab.

Functions#

loadany(fname[, transpose])

Open and read any kind of file.

Module Contents#

class sda.io.load.FileOpener(fname, transpose=-1, verbose=False, warnings=True, **kwargs)#

Open any file type in the Lab.

Examples

>>> F = FileOpener(
...     fname,
...     verbose=verbose,
...     warnings=warnings,
... )
>>> t = F.get_format()
>>> d = F.get_data()
fname#
type#
transpose = -1#
verbose = False#
warnings = True#
kwargs#
delimiters = [';', ',', '\t']#
header = None#
known_formats#
get_format()#
get_data()#
get_header()#
is_tektronix()#

Tektronix oscilloscope format.

is_lecroy()#

LeCroy oscilloscope format.

is_lecroytrc()#

LeCroy raw oscilloscope format.

is_tektronixwfm()#

Tektronix raw oscilloscope format.

is_winspec()#

Winspec - Princeton Instrument Camera format.

is_ocean()#
is_csv()#
is_txt()#
is_npy()#
load_tektronix()#
load_tektronixwfm()#

Tektronix Oscilloscope files are binary files with a header.

Returns:

  • time (np.ndarray) – Time values.

  • voltage (np.ndarray) – Y-axis values (voltage, current…).

load_lecroy()#

Import data from Lecroy Oscilloscope.

Function is a modified version of the Numpy loadtxt function

Notes

Known variants in formats:

WP7100A: - delimiter = spaces

WS434 - delimiter = commas

Can probably be changed on the system

load_lecroytrc()#

Import data from Lecroy Oscilloscope.

load_winspec()#

Load a Winspec file.

Note:

In imaging mode, output is a (i,x,y) array

i: frame number x, y: 2D pixels luminescence value for frame i

In spectrum mode, output is a tuple: (wavelength, (i,x,y)) wavelength: calibrated wavelength

i: frame number x, y: 2D luminescence value for frame i

See loadspe doc for more details

load_ocean()#

Ocean Optics files can have different header sizes (usually 14 or 17).

Usually there is also an extra line at the end.

load_csv()#

Open csv files as standard text files.

load_txt()#

Open text files.

try to guess the actual format of the text file.

guess_delimiter(delimiters=None)#
is_using_commas_instead_of_dots()#
replace_commas_with_dots(d)#

Will work with numbers not starting with , (e.g ,52).

Turns abc , 2,5 def ,5,88 or (2,5, 8,12, 8945,3 ) Into abc , 2.5 def ,5.88 or (2.5, 8.12, 8945.3 )

Originally from: http://stackoverflow.com/questions/7106417/convert-decimal-mark

sda.io.load.loadany(fname, transpose=-1, **kwargs)#

Open and read any kind of file.

Equivalent to :

F = FileOpener(fname,transpose,**kwargs) F.get_format() F.get_data()