fio Package

fio Package

Module for file reading and writing. Defines general file reader and writer objects which decide, which plugin to use by file postfix and text. Basic read/write classes are defined in baseread/basewrite module.

For use in external programs the main instance of baseread.ReaderProxy is created and can be used as:

from plotpy.fio import reader
data=reader.open('your_file.name')

baseread Module

Define basic reader classes that should be used for all data readout. Each reader supports the open method taking a file name of raw or gzip compressed data or a file object with raw or gzip compressed data. The ReaderProxy object locates all readers defined in the fio package and selects the appropriate one using glob patterns.

class plotpy.fio.baseread.Reader[source]

Bases: object

Basic class for data file readers. Loads and caches file binary data. Files with .gz extensions get automatically unpacked. The class has no __init__ method, this should be used for derived readers to e.g. import non standard libraries or for setup purpose. Strings should always be given as unicode.

A defived class should supply at least the following attributes/methods:

name Identifier for the reader class
description Information text on the type of file the reader supports
glob_parterns List of file patterns the reader supports
session The default session name for the type
read(self) The method to be called when the raw data has been read.

Additional class attributes that can be overwritten by children:

parameters

List of (name, default) tuples of additional parameters needed by the reader to treat the data.

The reader can access each parameter as attribute when read is called. E.g. for the item (‘param1’, 5.3) the reader could use self.param1 to get it’s value. The name needs to be a valid python identifier (no spaces etc.).

The type is determined by the default value so it is not possible to supply an float when the default was integer. A tuple of strings can be used to give a selection, where the first parameter is the default.

parameter_units Dictionary containing phisical units of the parameters. Not all parameters need to be available. The special case of unit ‘file(* .fil)’ is used in the GUI to treat a text input as filename with an according dialog.
parameter_description Short info text for each parameter, which is shown when the mouse hovers the input.
store_mds If set to False the data will not be saved to a .mds file after readout.
allow_multiread If set to True the reader must support the readout of multiple files, e.g. to sum up several images.
keywords

Print information on keywords, only for interactive use

lines2data(lines, sep=' ', dtype=<type 'float'>)[source]

Return columns of data from a list of liens.

next()[source]

For multifile read the next method reads the next file. Intentionally there is no way to iterate over all files as this could lead to readers which access the same file data multiple times.

open(filename, mp_queue=None, **kwds)[source]

Open a file with this reader.

Keywords depend on the reader subclass, see instances.keywords attribute for more information.

Parameters:filename – File name to open or open file object to read from
pfile

Return nice representation of filename cropping folder if it is too long.

str2data(string, sep=' ', dtype=<type 'float'>)[source]

Return columns of data from a string consisting of only data containing lines.

class plotpy.fio.baseread.TextReader[source]

Bases: plotpy.fio.baseread.Reader

Advanced reader class converting raw binary file data to unicode and providing simple sting to data conversion methods. When read is called the data is available as self.text_data.

See Reader documentation for details.

class plotpy.fio.baseread.BinReader[source]

Bases: plotpy.fio.baseread.Reader

Advanced reader class providing data conversion for binary data types. When read is called the data is available as self.raw_data, and a filelike object as self.raw_file.

See Reader documentation for details.

raw_file

raw data as file like object

class plotpy.fio.baseread.ReaderProxy[source]

Bases: object

Abstract handling of file readout using all readers available in the plotpy.fio package. Can be used to retrieve information on the supported file types, get a fitting reader for a given file name/extension or to automatically read a list of given files (with optional multiprocessing).

The important attributes/methods are:

open(files) Open the given files with a fitting reader and return a list of FileData objects.
patterns A dictionary with glob patterns as keys and lists of associated readers as values.
sessions As patterns but with session names as keys.
types Same as patterns.keys()
kwds_callback A function taking (reader, path, name) as input which get’s called if a reader supports keyword arguments to return a dictionary of those arguments e.g. to give the user an interface to input these arguments.

Using object[‘name.extension’] can be used to get the best fitting reader for the given filename or glob pattern.

This could look as follows in a user script:

from plotpy.fio import reader
my_reader=reader['*.my_type']
for my_files in my_list:
  data=my_reader.open(my_file)
open(files)[source]

Load a list of files by automatically choosing the appropriate reader according to the file pattern. Readers with the same patterns are tried one after another and increased in priority after on successful read attempt.

mds Module

Reader and Writer for the binary plotpy format (mds, mdd)

gisas Module

Collection of different GISAS file formats (2D detector images). The default xy-axes are Qy and Qz.

class plotpy.fio.gisas.GISASBase[source]

Bases: object

Base class for GISAS readers to provide general purpose methods.

correct_background()[source]

General background correction function. For this to work the read_raw_data method has to be defined in a subclass.

correct_sensitivity()[source]

General background correction function. For this to work the read_background method has to be defined in a subclass.

create_dataobj(start_progess=30, end_progress=100)[source]

Creat a HugeMD object for the data

object_creator

alias of HugeMD

read_header()[source]

If filetype has no header to read.

read_raw_data(filename)[source]

Default implementation of read_raw_data stores information needed later for object creation and than calls read_header and read_data. The raw data is than returned and saved settings restored.

squid Module

Functions to read from a SQUID data file. Mostly just string processing. MeasurementData Object from ‘mds’ is used to store the data points. read_data is the main procedure, returning a list of MeasurementData objects

class plotpy.fio.squid.Squid[source]

Bases: plotpy.fio.baseread.TextReader

Read ascii data files from Quantum Design MultiVu software.

check_type(data_1, data_2, type_i)[source]

Check if the data from two lines belong to the same sequence.

read()[source]

Read the ppms/mpms datafile.

Parameters:
  • input_file – Name of the file to read
  • COLUMNS_MAPPING – A list of column names with the associated column in the MeasurementData object
  • MEASUREMENT_TYPES – List of measurements with at least one constant data column (e.g. T=const)
Returns:

List of MeasurementData objects for all measured sequences of None

read_data_line(input_file_line, columns)[source]

Read one line of data and output the data as a list of floats.

Returns:List of floats or None
read_data_lines(input_file_lines, info)[source]

Read data points line by line.

Returns:List of MeasurementData objects
read_header(input_file_lines)[source]

Read header of the datafile.

Returns:Measurement information and Name of the sample
split_after_read(dataset, split)[source]

Split a dataset by a specific column after the file has been read.

Parameters:
  • dataset – A MeasurementData object
  • split – A list of ‘dimension name’, ‘sensitivity’
Returns:

list of MeasurementData objects

treff_maria Module

Functions to read from treff data and .img. files. MeasurementData Object from ‘mds’ is used to store the data points. read_data is the main procedure, returning a list of MeasurementData objects. Image files can be gziped or plain.

xrd Module

Data formats from xrd experiments.

class plotpy.fio.xrd.APS4ID[source]

Bases: plotpy.fio.baseread.TextReader

Read ascii scan files created by spec (fourc).

extract_columns_and_data(data_with_head)[source]

Extract the data and columns of the file.

extract_headerinfo(header)[source]

Extract some infor from the file header.

read()[source]

Read data from 4-ID-C station at APS.

class plotpy.fio.xrd.Online[source]

Bases: plotpy.fio.baseread.TextReader

Read ascii scan files created by spec (fourc).

read()[source]

Read data aquired at P09 beamlime of PETRA III.

class plotpy.fio.xrd.Spec[source]

Bases: plotpy.fio.baseread.TextReader

Read ascii scan files created by spec (fourc).

get_scan_header(scan_lines)[source]

Read header of scan and return the data lines and some information of the header.

Parameters:scan_lines – lines corresponding to one scan
Returns:dictionary with header informations and lines containing data
get_type_columns(type_line, columns)[source]

Return the indices of columns to plot.

read_data_lines(input_file_lines, sample_name, last_comments)[source]

Read data points line by line.

Parameters:
  • input_file_lines – List of lines from the input file
  • sample_name – Sample Name from file header
  • last_comments – comment lines from before the scan
Returns:

MeasurementData objects

read_file_header(input_file_lines)[source]

Read the header of the file.

Parameters:input_file_lines – List of lines to be evaluated
Returns:The sample name defined in the file or None if the wron filetype.
read_scan(scan_lines, last_comments)[source]

Read and evaluate the lines of one scan.

Table Of Contents

Previous topic

config Package

Next topic

gtkgui Package

This Page