Basic PEMtk fitting class demo

01/09/22

Outline of this notebook:

  • Load required packages.

  • Setup pemtkFit object.

    • Set various parameters, either from existing data or new values.

    • Data is handled as a set of dictionaries within the class, self.data[key][dataType], where key is an arbitrary label for, e.g. a specific experiment, calculation etc, and dataType contains a set of values, parameters etc. (Should become clear below!)

    • Methods operate on all self.data items in general, with some special cases: self.data['subset'] contains data to be used in fitting.

  • Simulate data

    • Use ePSproc to simulated aligned-frame measurements.

  • Fit data (serial version)

For batch and parallel fitting see the multi-fit demo notebook

Prerequisities

  • Working installation of ePSproc + PEMtk (or local copies of the Git repos, which can be pointed at for setup below).

  • Test/demo data, from ePSproc Github repo.

Setup

Imports

A few standard imports…

[1]:
import sys
import os
from pathlib import Path
# import numpy as np
# import epsproc as ep
# import xarray as xr

from datetime import datetime as dt
timeString = dt.now()

And local module imports. This should work either for installed versions (e.g. via pip install), or for test code via setting the base path below to point at your local copies.

[2]:
# For module testing, include path to module here, otherwise use global installation
if sys.platform == "win32":
    modPath = Path(r'D:\code\github')  # Win test machine
    winFlag = True
else:
    modPath = Path(r'/home/femtolab/github')  # Linux test machine
    winFlag = False

# Append to sys path
sys.path.append((modPath/'ePSproc').as_posix())
sys.path.append((modPath/'PEMtk').as_posix())
[3]:
# ePSproc
import epsproc as ep

# Set data path
# Note this is set here from ep.__path__, but may not be correct in all cases - depends on where the Github repo is.
epDemoDataPath = Path(ep.__path__[0]).parent/'data'
* Setting plotter defaults with epsproc.basicPlotters.setPlotters(). Run directly to modify, or change options in local env.
* Set Holoviews with bokeh.
[4]:
# PEMtk
# import pemtk as pm
# from pemtk.data.dataClasses import dataClass

# Import fitting class
from pemtk.fit.fitClass import pemtkFit
C:\Users\femtolab\.conda\envs\ePSdev\lib\site-packages\xyzpy\plot\xyz_cmaps.py:6: MatplotlibDeprecationWarning:
The revcmap function was deprecated in Matplotlib 3.2 and will be removed two minor releases later. Use Colormap.reversed() instead.
  return LinearSegmentedColormap(name, cm.revcmap(cmap._segmentdata))
[5]:
# Set HTML output style for Xarray in notebooks (optional), may also depend on version of Jupyter notebook or lab, or Xr
# See http://xarray.pydata.org/en/stable/generated/xarray.set_options.html
# if isnotebook():
# xr.set_options(display_style = 'html')
[6]:
# Set some plot options
ep.plot.hvPlotters.setPlotters()