hvPlotters function tests

27/01/22

Updated with curvePlot() and BLMplot() routine demos.

15/07/20

Testing basic plotting with Holoviews, now implemented in hvPlotters.py module.

NOTE: currently implemented for ePS cross-section data only.

Setup

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

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

# For reporting
import scooby
# scooby.Report(additional=['holoviews', 'hvplot', 'xarray', 'matplotlib', 'bokeh'])
# TODO: set up function for this, see https://github.com/banesullivan/scooby
[2]:
# Installed package version
# import epsproc as ep

# ePSproc test codebase (local)
# if sys.platform == "win32":
#     modPath = r'D:\code\github\ePSproc'  # Win test machine
# else:
#     modPath = r'/home/femtolab/github/ePSproc/'  # Linux test machine

# sys.path.append(modPath)
import epsproc as ep
* sparse not found, sparse matrix forms not available.
* natsort not found, some sorting functions not available.
* Setting plotter defaults with epsproc.basicPlotters.setPlotters(). Run directly to modify, or change options in local env.
* Set Holoviews with bokeh.
* pyevtk not found, VTK export not available.

Load test data

[5]:
# To control display of warnings... may have issues depending on XR version.
# WORKING IN SOME CASES... but not all, maybe ipython/env version issues?
# https://stackoverflow.com/a/9031848
import warnings
warnings.filterwarnings('ignore')  # set 'once' or 'ignore'
warnings.simplefilter('ignore')
[6]:
# Load data from modPath\data
modPath = Path(ep.__path__[0]).parent
dataPath = os.path.join(modPath, 'data', 'photoionization')
dataFile = os.path.join(dataPath, 'n2_3sg_0.1-50.1eV_A2.inp.out')  # Set for sample N2 data for testing

# Scan data file
dataSet = ep.readMatEle(fileIn = dataFile)
dataXS = ep.readMatEle(fileIn = dataFile, recordType = 'CrossSection')  # XS info currently not set in NO2 sample file.
*** ePSproc readMatEle(): scanning files for DumpIdy segments.

*** Scanning file(s)
['/mnt/femtobackSSHFS/DriveSyncShare/code-share/github-share/ePSproc/data/photoionization/n2_3sg_0.1-50.1eV_A2.inp.out']

*** FileListSort
  Prefix: /mnt/femtobackSSHFS/DriveSyncShare/code-share/github-share/ePSproc/data/photoionization/n2_3sg_0.1-50.1eV_A2.inp.out
  1 groups.

*** Reading ePS output file:  /mnt/femtobackSSHFS/DriveSyncShare/code-share/github-share/ePSproc/data/photoionization/n2_3sg_0.1-50.1eV_A2.inp.out
Found 2 segments.
Expecting 51 energy points.
Found 3 segments.
Expecting 2 symmetries.
Found 103 segments.
Found 102 dumpIdy segments (sets of matrix elements).

Processing segments to Xarrays...
Processed 102 sets of DumpIdy file segments, (0 blank)
*** ePSproc readMatEle(): scanning files for CrossSection segments.

*** Scanning file(s)
['/mnt/femtobackSSHFS/DriveSyncShare/code-share/github-share/ePSproc/data/photoionization/n2_3sg_0.1-50.1eV_A2.inp.out']

*** FileListSort
  Prefix: /mnt/femtobackSSHFS/DriveSyncShare/code-share/github-share/ePSproc/data/photoionization/n2_3sg_0.1-50.1eV_A2.inp.out
  1 groups.

*** Reading ePS output file:  /mnt/femtobackSSHFS/DriveSyncShare/code-share/github-share/ePSproc/data/photoionization/n2_3sg_0.1-50.1eV_A2.inp.out
Found 2 segments.
Expecting 51 energy points.
Found 3 segments.
Expecting 2 symmetries.
Found 4 segments.
Found 3 CrossSection segments (sets of results).
Processed 3 sets of CrossSection file segments, (0 blank)

hv XCplot demo

This is now working for XC data only, to give interactive plots with Holoviews + Bokeh, and all calculation gauges.

Basic use

Load functions, set defaults and plot.

[7]:
# Import plotting code
from epsproc.plot import hvPlotters

# Set options
hvPlotters.setPlotters()

# Basic use to produce two plot layout
layout, *_ = hvPlotters.XCplot(dataXS[0])

layout
* Set Holoviews with bokeh.
[7]:

This is a bit messy, but otherwise pretty functional, just need to improve a bit by, e.g., line styles by Type or Cont, to simplify plotting & legend.

Note mouse-over values, and linked axes when zooming. The legend is also interactive, and can be used to highlight different data series.

Additional options

Set plot width, grab other return items (different data formats).

[8]:
# Set options, with different plot size (default width=500)
hvPlotters.setPlotters(width=700)
layout, *_ = hvPlotters.XCplot(dataXS[0])
layout