sda.io.load =========== .. py:module:: sda.io.load .. autoapi-nested-parse:: 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 ------- .. autoapisummary:: sda.io.load.FileOpener Functions --------- .. autoapisummary:: sda.io.load.loadany Module Contents --------------- .. py:class:: FileOpener(fname, transpose=-1, verbose=False, warnings=True, **kwargs) Open any file type in the Lab. .. rubric:: Examples >>> F = FileOpener( ... fname, ... verbose=verbose, ... warnings=warnings, ... ) >>> t = F.get_format() >>> d = F.get_data() .. py:attribute:: fname .. py:attribute:: type .. py:attribute:: transpose :value: -1 .. py:attribute:: verbose :value: False .. py:attribute:: warnings :value: True .. py:attribute:: kwargs .. py:attribute:: delimiters :value: [';', ',', '\t'] .. py:attribute:: header :value: None .. py:attribute:: known_formats .. py:method:: get_format() .. py:method:: get_data() .. py:method:: get_header() .. py:method:: is_tektronix() Tektronix oscilloscope format. .. py:method:: is_lecroy() LeCroy oscilloscope format. .. py:method:: is_lecroytrc() LeCroy raw oscilloscope format. .. py:method:: is_tektronixwfm() Tektronix raw oscilloscope format. .. py:method:: is_winspec() Winspec - Princeton Instrument Camera format. .. py:method:: is_ocean() .. py:method:: is_csv() .. py:method:: is_txt() .. py:method:: is_npy() .. py:method:: load_tektronix() .. py:method:: load_tektronixwfm() Tektronix Oscilloscope files are binary files with a header. :returns: * **time** (:py:class:`np.ndarray`) -- Time values. * **voltage** (:py:class:`np.ndarray`) -- Y-axis values (voltage, current...). .. py:method:: load_lecroy() Import data from Lecroy Oscilloscope. Function is a modified version of the Numpy loadtxt function .. rubric:: Notes Known variants in formats: WP7100A: - delimiter = spaces WS434 - delimiter = commas Can probably be changed on the system .. py:method:: load_lecroytrc() Import data from Lecroy Oscilloscope. .. py:method:: 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 .. py:method:: load_ocean() Ocean Optics files can have different header sizes (usually 14 or 17). Usually there is also an extra line at the end. .. py:method:: load_csv() Open csv files as standard text files. .. py:method:: load_txt() Open text files. try to guess the actual format of the text file. .. py:method:: guess_delimiter(delimiters=None) .. py:method:: is_using_commas_instead_of_dots() .. py:method:: 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 .. py:function:: 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()