def import_jv_data(folder_path, file_pattern='*.use', interpolate='linear', fillna=np.nan, reindex='voltage', **kwargs): """ Imports JV data from EC Lab .use output files. :param folder_path: The file path containing the data files. :param file_pattern: A glob pattern to filter the imported files [Default: '*.use'] :param interpolate: How to interpolate data for a common index [Default: linear] Use None to prevent reindexing :param fillna: Value to fill NaN values with [Default: np.nan] :param kwargs: Additional parameters to pass to import_datum. :returns: A Pandas DataFrame with MultiIndexed columns :raises RuntimeError: if no files are found """ df = std.import_data(import_jv_datum, folder_path, file_pattern=file_pattern, interpolate=interpolate, fillna=fillna, reindex=reindex, **kwargs) return df.sort_index(axis=1)
def import_data(folder, file_pattern='*.txt'): """ Imports QCM data from a QSense experiment. :param folder: Folder path containing the data files. :param file_pattern: File pattern of data files, in glob format. [Default: *.txt] :returns: DataFrame containing imported data. """ return std.import_data(import_datum, folder, file_pattern=file_pattern)
def import_jv_data( folder, file_pattern = '*_JVs.txt', **kwargs ): """ Imports aging data. :param folder: Folder path containing data files. :param file_pattern: File pattern of data files, in glob format. [Default: *.JVs.txt] :param kwargs: Arguments passed to standard_functions import_data() :returns: DataFrame containg imported data. """ return std.import_data( import_jv_datum, folder, file_pattern = file_pattern, **kwargs )
def import_mpp_tracking_data_channel(folder, file_pattern='mpp.csv', **kwargs): """ Imports MPP data from an MPP measuremnt. :param folder: Folder path containing data files. :param file_pattern: File pattern of data files, in glob format. [Default: mpp.csv] :param kwargs: Arguments passed to #import_mpp_tracking_datum. :returns: DataFrame containg imported data. """ return std.import_data(import_mpp_tracking_datum_channel, folder, file_pattern=file_pattern, **kwargs)
def import_data(folder_path, file_pattern='*.mpt', interpolate='linear', fillna=np.nan, programs=False, resolution=None, **kwargs): """ Imports measurement data from EC Lab .mpt output files. :param folder_path: The file path containing the data files. :param file_pattern: A glob pattern to filter the imported files [Default: '*.use'] :param interpolate: How to interpolate data for a common index [Default: linear] Use None to prevent reindexing :param fillna: Value to fill NaN values with [Default: np.nan] :param programs: Concatenates programs. [Default: False] :param resolution: The time resolution to use, in same units as measured time (usually seconds). If None, does not change time step. [Default: None] :param kwargs: Additional parameters to pass to import_datum. :returns: A Pandas DataFrame with MultiIndexed columns :raises RuntimeError: if no files are found """ if programs: if 'metadata' in kwargs: if 'program' not in kwargs['metadata']: kwargs['metadata'].append('program') else: kwargs['metadata'] = ['program'] df = std.import_data(import_datum, folder_path, file_pattern=file_pattern, interpolate=None, fillna=fillna, **kwargs) # merge programs if programs: tdf = [] # group data by levels above program program_level = df.columns.names.index('program') group_levels = list(range(program_level)) program_groups = (df.groupby(level=group_levels, axis=1) if len(group_levels) > 0 else [('', df)]) for name, data in program_groups: # for each group of programs concatenate them along the 0 axis pdf = [] time_header = (*name, 'time') if (type(name) is tuple) else 'time' for pname, pdata in data.groupby(level='program', axis=1): pdata.columns = pdata.columns.droplevel('program') pdata = pdata.dropna() pdata.set_index(time_header, inplace=True) pdata.index = pdata.index.rename('time') pdf.append(pdata) pdf = pd.concat(pdf) tdf.append(pdf) df = pd.concat(tdf, axis=1).interpolate(interpolate).sort_index(axis=1) # average data if resolution is not None: t_min = df.index.min() t_max = df.index.max() bins = math.ceil((t_max - t_min) / resolution) bins = np.linspace(t_min, t_max, bins) times = df.index.to_series() cuts = pd.cut(times, bins, include_lowest=True) df = df.groupby(cuts, as_index=True).mean() df = df.dropna(how='all') # remove empty bins # remove insignificant figures insig = resolution / 10 df.index = pd.IntervalIndex(df.index).mid df.index = pd.Index(df.index.to_series().apply( lambda x: np.round(x, int(-np.log10(insig)))), name='time') return df