umetrics.impdata | index (built-in)

`Contains functionality for importing data.`

Classes
`` |  | Boost.Python.instance(builtins.object) ImportData ImportSpecification
class ImportData(Boost.Python.instance)
`` | `Holds data and specifications for importing data into SIMCA. Each cell can either hold a float or a string. The precision of floats held internally are 32-bits unlike Python floats which has 64 bit precision. This sets limits on the values that can be used. Floating point values has ~6 significant digits (Python ~15) and can not be larger than ~3.4*10^38 (Python ~1.7*10^308) or smaller than ~1.2*10^-38 (Python 2.2*10^-308).`
| Method resolution order: ImportData Boost.Python.instance builtins.object Methods defined here: __init__(...) `__init__( (object)arg1) -> None __init__( (object)self) -> None : Constructs an empty ImportData. __init__( (object)self, (int)rows, (int)columns) -> None : Constructs an ImportData with the specified size. __init__( (object)self, (object)mat) -> None : Constructs an ImportData from a matrix of values containing strings and or/numbers.` __reduce__ = (...) __str__(...) `__str__( (ImportData)arg1) -> str` create_dataset(...) `create_dataset( (ImportData)self, (object)project, (str)datasetname) -> int : Create a new dataset in the specified project. Returns the number of the new dataset.` get(...) `get( (ImportData)self, (int)row, (int)column) -> object : Returns the value at the specified column and row. The value can either be a number or a string` insert_columns(...) `insert_columns( (ImportData)self, (int)insertpos, (int)count) -> None : Inserts 'count' columns at 'insertpos' to the data and ImportSpecification If insertpos is larger than the number of columns, the new columns will be appended.` insert_rows(...) `insert_rows( (ImportData)self, (int)insertpos, (int)count) -> None : Inserts 'count' row at 'insertpos' to the data and ImportSpecification If insertpos is larger than the number of rows, the new rows will be appended.` remove_columns(...) `remove_columns( (ImportData)self, (int)firstcolumn, (int)count) -> None : Removes 'count' columns starting at 'firstcolumn' from the data and ImportSpecification` remove_rows(...) `remove_rows( (ImportData)self, (int)firstrow, (int)count) -> None : Removes 'count' rows starting at 'firstrow' from the data and ImportSpecification` resize(...) `resize( (ImportData)self, (int)rows, (int)columns) -> None : Resizes the number of columns and rows in both the data and the ImportSpecification. New columns/rows will be appended and set to 'quantitaive'. If the new size is smaller, columns/rows will be removed from the end.` set(...) `set( (ImportData)self, (int)row, (int)column, (object)value) -> None : Sets the specified cell to a new value. The value can be either a string or a number. Strings representing a number will be converted to a number. Note also that the number -99 has a special meaning to SIMCA and will be converted to -99.0000991821289. Example: >>> import umetrics >>> data = umetrics.impdata.ImportData(2,2) >>> data.set(0,0,-99) >>> data.get(0,0) -99.0000991821289 >>> data.set(0,0,'12') >>> data.get(0,0) 12.0 >>> data.set(0,0,1.00000000002) >>> data.get(0,0) 1.0 set( (ImportData)self, (object)matrix) -> None : Resizes and sets all data. Example: >>> from umetrics.impdata import ImportData >>> data=ImportData(1,1) >>> data.set([[1,2],['Hello', 'Godbye']]) >>> print(data) [[1 , 2 ], ['Hello' , 'Godbye' ]] >>> # The content of the class can also be copied to native Python data types. >>> mat = [] >>> for row in range(0, data.rows): >>> mat.append([]) >>> for column in range(0, data.columns): >>> mat[-1].append(data.get(row, column)) >>> # Or, if you use period as decimal separator. >>> mat=eval(data.__str__()) >>> mat [[1, 2], ['Hello', 'Godbye']]` transpose(...) `transpose( (ImportData)self) -> None : Transposes the data.` Data descriptors defined here: columns `The number of columns` importspec `An ImportSpecification (see below) that specifies where observation/variable IDs etc can be found in the ImportData.` is_batch_data `Set to True if the imported data is a batch dataset. Default is False.` rows `The number of rows` Data and other attributes defined here: __instance_size__ = 376 Methods inherited from Boost.Python.instance: __new__(*args, **kwargs) from Boost.Python.class `Create and return a new object. See help(type) for accurate signature.` Data descriptors inherited from Boost.Python.instance: __dict__ __weakref__
class ImportSpecification(Boost.Python.instance)
`` | `Provides the specification for how rows/columns in a FileData should be interpreted when importing data.`
| Method resolution order: ImportSpecification Boost.Python.instance builtins.object Methods defined here: __init__(...) `Raises an exception This class cannot be instantiated from Python` __reduce__ = (...) get_col_block(...) `get_col_block( (ImportSpecification)self, (int)column) -> datablock : Returns the data block a column belongs to. Only columns that are of type quantitative, qualitative, batchcondition and qualitativebatchcondition can belong to a data block. All other types of column will always return X.` get_col_type(...) `get_col_type( (ImportSpecification)self, (int)column) -> columntype : Returns the type of a column.` get_row_type(...) `get_row_type( (ImportSpecification)self, (int)row) -> rowtype : Returns the type of a row.` set_col_block(...) `set_col_block( (ImportSpecification)self, (int)column, (datablock)block) -> None : Sets a column to the specified block. Only columns that are of type quantitative, qualitative, batchcondition and quwalitativebatchcondition can belong to a data block. Attempting to set any other column to a block will be ignored.` set_col_type(...) `set_col_type( (ImportSpecification)self, (int)column, (columntype)type) -> None : Sets a column to the specified type.` set_date_time(...) `set_date_time( (ImportSpecification)self, (int)column, (str)parseformat, (timeAccuracy)timeaccuracy, (str)displayformat) -> None : Sets date/time options to the specified column column the column index parseformat a string used to parse the column, if empty the current locale is used it should be in a form like this for example yyMMdd:HHmm, see details below timeaccuracy select in what unit to store your Date/Time variable. displayformat a string used to display the date in simca, if empty parseformat is used it should be in a form like this for example yyMMdd:HHmm, see details below yyyy - year using four digits (ex. 2005) yy - year using two digits (ex. 05) MMM - month using three letters (ex. Aug) MM - month using two digits (ex. 08) M - month without leading 0 (ex. 8) ddd - day of week using three letters (ex. Mon) dd - day in month using two digits (ex. 05) d - day in month without leading 0 (ex. 5) HH - hour representing 24 hour day H - hour representing 24 hour day, no leading 0 hh - hour representing 12 hour day h - hour representing 12 hour day, no leading 0 mm - minutes using 2 digits ss - seconds using 2 digits fff - fractional seconds using 3 digits (milliseconds) tt - AM or PM` set_row_type(...) `set_row_type( (ImportSpecification)self, (int)row, (rowtype)type) -> None : Sets a row to the specified type` Data descriptors defined here: columns `The number of columns` rows `The number of rows` Data and other attributes defined here: columntype = <class 'umetrics.impdata.columntype'> `Used to specify a columns type Values: excluded, quantitative, qualitative, primaryobsid, secondaryobsid, batchid, phaseid, datetime, batchcondition, qualitativebatchcondition` datablock = <class 'umetrics.impdata.datablock'> `Used to specify which data block a variable belongs to. Values: X, Y` rowtype = <class 'umetrics.impdata.rowtype'> `Used to specify a rows type Values: excluded, data, primaryvarid, secondaryvarid` timeAccuracy = <class 'umetrics.impdata.timeAccuracy'> `Used in set_date_time to specify time accuracy Values: year, month, day, hour, minute, second Second: max time span (without fractions: 11 days, with fractions: 16 minutes Minute: max time span 23 month Hour: max time span 114 years` Methods inherited from Boost.Python.instance: __new__(*args, **kwargs) from Boost.Python.class `Create and return a new object. See help(type) for accurate signature.` Data descriptors inherited from Boost.Python.instance: __dict__ __weakref__

Functions
`` |  | open_file_dialog(...) `Displays a file open dialog and returns a list of selected files and selected file type The method is almost a plug in replacement for tkFileDialog.askopenfilename but has support for file types that Umetrics software can read. Options: filetypes -- Sets the types in the 'File Types' list box. Default is [('All files', '.*')] initialdir -- The initial directory shown in the dialog. Default is to show the last directory in which a file was selected or the 'documents' directory if no file has been previously selected. initialfile -- Specifies a filename to be displayed in the dialog when it pops up. multiple -- Allows the user to choose multiple files from the Open dialog. Default is not to allow multi selection (False). mustexist -- Specifies whether the user may specify non-existent files. Default is (True) title -- The text shown in the caption of the dialog. supportedfiletypes -- Adds all file types that SIMCA can read to the 'File Types' list box. Default is to add them (True) Returns: A tuple containing a list of the selected files and a string containing the selected file type. If the user didn't select any file (pressed cancel), the method returns (None, None).` read_file(...) `read_file( (object)files [, (str)filetype='' [, (str)openoptions='']]) -> ImportData : Reads a file or files and returns the content. The following file types are supported. Brimrose Files (*.dat) Brookside Files (*.trn; *.pkg) Brookside Ver. 2.6 XML Files (*.xml) Bruker OPUS File (*.*) Bruker OPUS Interpolated File (*.*) CSV Files (*.csv) DIF Files (*.dif) Excel 97-2003 Workbook (*.xl*) Excel Workbook (*.xlsx; *.xlsb) Galactic SPC Files (*.spc) HPLC ChemStation Files (*.ch, *.uv) JCAMP-DX Files (*.jcm; *.dx; *.jdx) Lotus 1-2-3 Files (*.wks; *.wk1) MODDE Files (*.mip; *.dat) Matlab Files (*.mat) NSAS Files (*.da) NetCDF Files (*.nc; *.cdf) (MVACDF, ANDI) SIMCA project file (*.usp) Text Files (*.txt; *.dat) Thermo SIEVE Files (*.txt) Unscrambler Files (*.uns; *.inp) Arguments: files -- A list containing the paths(s) of the file(s) to read. filetype -- This string is usually obtained from SelectFileDialog.open_file_dialog() and is used to determine the file type. If omitted (or unrecognized) SIMCA will try to determine the file type from the files content and extension. openoptions -- An XML formatted string containing file type specific options for reading files It can for example be text file encoding, decimal separator or excel worksheet name All files types expects a root section call "Settings" With options in the attributes Excel. "Sheets" is a semicolon separated list of worksheet names "ReadOrder" can be 1 to merge above/below or 2 to merge side by side, default 1 "AllSheets" 1 to import all sheets, 0 to import those specified by the sheets option, default 0 "UseIndexes" 1 if the sheets option is worksheet indexes, 0 if it is worksheet names, default 0 Example: <Settings ReadOrder=\"1\" Sheets=\"WSName1;WSName2;WSName3\" UseIndexes=\"0\" AllSheets=\"0\"/> or <Settings ReadOrder=\"2\" Sheets=\"0;1;3\" UseIndexes=\"1\" AllSheets=\"0\"/> SIMCA USP "Sheets" is the dataset name to import Example: <Settings Sheets=\"DatasetName\"/> DIF Encoding is the locale names, valid locales are ibm420, iso88596, windows1256, iso88592, windows1250, gb18030, iso2022cn, big5, iso88595, koi8r, windows1251, iso88597, windows1253, ibm424, iso88598, windows1255, eucjp, iso2022jp, shiftjis, euckr, iso2022kr, , iso88599, windows1254, utf16be, utf16le, utf32be, utf32le, utf8, cp850, iso88591 and windows1252 Example: <Settings Encoding=\"iso88592\"/> CSV Encoding is the same as for DIF files Delimiter is the delimiter used to separate values. comma and cp1252 Example: <Settings Delimiter=\",\" Encoding=\"cp1252\"/> or with tab and utf8 <Settings Delimiter=\"&#x9;\" Encoding=\"utf8\"/> Text Same as CSV with the addition of ... IgnoreConsecutiveDelimiters, which can have the value 0 for false and 1 for true Example: <Settings Delimiter=\"-\" Encoding=\"gb18030\" IgnoreConsecutiveDelimiters=\"0\"/> Galactic SPC IncludeOrdinalValues, Value 0 for false and 1 for true. If 1, the ordinal values (wavelengths etc) will be included as a row. IncludeAllValues, Value 0 for false and 1 for true IncludeXStartPt, Semicolon separated list of start points, empty when IncludeAllValues is 1 IncludeXEndPt, Semicolon separated list of end points, empty when IncludeAllValues is 1 NumberOfIncludedIntervals, the lengt of the two lists above, 0 when IncludeAllValues is 1 UseAverage, integer value >=0 the length between each point when averaging, 0 when IncludeAllValues is 1 or when averaging is not to be used. examples <Settings IncludeOrdinalValues=\"1\" IncludeAllValues=\"1\" IncludeXEndPt=\"\" IncludeXStartPt=\"\" NumberOfIncludedIntervals=\"0\" UseAverage=\"0\"/> <Settings IncludeOrdinalValues=\"0\" IncludeAllValues=\"0\" IncludeXEndPt=\"5000;5058\" IncludeXStartPt=\"3929.43;5001.43\" NumberOfIncludedIntervals=\"2\" UseAverage = \"2\"/> JCAMP-DX DataBlocks is a semicolon separated list of indexes of the series to include. Note that the first index is 0 InterPolationFile and InterPolationSerie is the index of the file and the index of the series in that file that is to be used as template if input needs to be interpolated. The data needs to be interpolated if the series are of different length and/or they start/end at different points. After interpolation, all series will have the same ordinal values as the selected series. These two options are optional and are defaulted to the first series in the first file. Example: <Settings InterPolationFile=\"0\" InterPolationSerie= \"0\" DataBlocks=\"0;4;6\"/> Unscrambler files Encoding is the locale names, valid locales are ibm420, iso88596, windows1256, iso88592, windows1250, gb18030, iso2022cn, big5, iso88595, koi8r, windows1251, iso88597, windows1253, ibm424, iso88598, windows1255, eucjp, iso2022jp, shiftjis, euckr, iso2022kr, , iso88599, windows1254, utf16be, utf16le, utf32be, utf32le, utf8, cp850, iso88591 and windows1252`