read_data

pySurf.data2D.read_data(file, rreader, **kwargs)

Read data from a file using a given raw reader rreader, with custom options in args, kwargs.

The function calls raw reader, but, before this, strips all options that are recognized by register_data,

all remaining unkown parameters are passed to rreader.

Then register_data is called with the previously stored settings (or defaults if not present).

This was made to hide messy code beyond interface. See old notes below, internal behavior can be better fixed e.g. by using dataIO.dicts.pop_kw and inspect.signature and fixing header interface.

Old notes say:

Division of parameters is hard coded, that is neither too elegant or maintainable. Note however that with this structure it is possible to call the read_data procedure with specific parameters, for example in example below, the reader for Zygo cannot be called directly with intensity keyword set to True without making a specific case from the other readers, while this can be done using read_data.

this is an ugly way to deal with the fact that return arguments are different if header is set, so when assigned to a variable as in patch routines in pySurf instrumentReader it fails. Workaround has been calling directly read_data, not optimal.

2019/04/09 merged from data2D and instrumentReader to data2D. Mostly code from data2D and comments

from instrumentReader. code commented with ## was excluded.

non essendo sicuro dell’interfaccia per ora faccio cosi’. The function first calls the (raw) data reader, then applies the register_data function to address changes of scale etc, arguments are filtered and passed each one to the proper routine. 18/06/18 add all optional parameters, if reader is not passed, only registering is done. note that already if no register_data arguments are passed, registration is skipped. 18/06/18 add action argument. Can be ‘read’, ‘register’ or ‘all’ (default, =read and register). This is useful to give fine control, for example to modify x and y after reading and still make it possible to register data (e.g. this is done in Data2D.__init__).