hvPlotters function tests

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
* plotly not found, plotly plots not available.
* pyevtk not found, VTK export not available.

Load test data

[3]:
# Load data from modPath\data
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)
['/home/femtolab/github/ePSproc/data/photoionization/n2_3sg_0.1-50.1eV_A2.inp.out']

*** Reading ePS output file:  /home/femtolab/github/ePSproc/data/photoionization/n2_3sg_0.1-50.1eV_A2.inp.out
Expecting 51 energy points.
Expecting 2 symmetries.
Scanning CrossSection segments.
Expecting 102 DumpIdy 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)
['/home/femtolab/github/ePSproc/data/photoionization/n2_3sg_0.1-50.1eV_A2.inp.out']

*** Reading ePS output file:  /home/femtolab/github/ePSproc/data/photoionization/n2_3sg_0.1-50.1eV_A2.inp.out
Expecting 51 energy points.
Expecting 2 symmetries.
Scanning CrossSection segments.
Expecting 3 CrossSection 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.

[4]:
# 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
[4]:

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).

[5]:
# Set options, with different plot size (default width=500)
hvPlotters.setPlotters(width=700)
layout, *_ = hvPlotters.XCplot(dataXS[0])
layout
[5]:
[6]:
# Optional return items - tabulated dataset, hv dataset and Xarray dataset object types
layout, table, hv_ds, ds = hvPlotters.XCplot(dataXS[0])

table
[6]:
[7]:
hv_ds
[7]:
:Dataset   [Type,Eke,Cont]   (sigma,beta)
[8]:
ds
[8]:
<xarray.Dataset>
Dimensions:  (Eke: 51, Sym: 3, Type: 3)
Coordinates:
    Ehv      (Eke) float64 15.68 16.68 17.68 18.68 ... 62.68 63.68 64.68 65.68
  * Type     (Type) object 'L' 'M' 'V'
  * Sym      (Sym) MultiIndex
  - Total    (Sym) object 'SU' 'PU' 'All'
  - Cont     (Sym) object 'SU' 'PU' 'All'
  * Eke      (Eke) float64 0.1 1.1 2.1 3.1 4.1 5.1 ... 46.1 47.1 48.1 49.1 50.1
Data variables:
    sigma    (Sym, Eke, Type) float64 2.719 2.954 3.209 ... 1.013 0.9229 0.8423
    beta     (Sym, Eke, Type) float64 0.7019 0.7036 0.7053 ... 1.014 1.028 1.042
[9]:
# Cf. original data, as Xarray dataarray
dataXS[0]
[9]:
<xarray.DataArray 'n2_3sg_0.1-50.1eV_A2.inp.out' (Sym: 3, Eke: 51, XC: 2, Type: 3)>
array([[[[0.7019, 0.7036, 0.7053],
         [2.7193, 2.9539, 3.209 ]],

        [[0.2617, 0.2661, 0.2704],
         [2.8151, 3.0229, 3.2464]],

        [[0.0986, 0.1011, 0.1037],
         [2.9628, 3.1452, 3.3388]],

        [[0.0426, 0.0438, 0.0449],
         [3.1519, 3.3087, 3.4734]],

        [[0.0477, 0.0482, 0.0488],
         [3.3779, 3.5088, 3.6449]],

        [[0.0899, 0.0902, 0.0905],
         [3.6388, 3.7439, 3.8521]],

        [[0.1546, 0.1549, 0.1552],
         [3.9332, 4.0131, 4.0947]],

        [[0.2327, 0.233 , 0.2334],
         [4.2582, 4.3144, 4.3716]],

        [[0.3179, 0.3185, 0.3191],
         [4.6072, 4.6426, 4.6786]],

        [[0.406 , 0.407 , 0.4081],
         [4.9678, 4.9865, 5.0058]],

        [[0.4942, 0.4958, 0.4975],
         [5.3175, 5.3251, 5.3332]],

        [[0.5804, 0.583 , 0.5856],
         [5.6207, 5.6238, 5.6274]],

        [[0.6637, 0.6673, 0.6709],
         [5.8265, 5.8324, 5.8388]],

        [[0.7432, 0.7478, 0.7525],
         [5.8749, 5.8905, 5.9067]],

        [[0.8186, 0.8242, 0.8298],
         [5.7136, 5.7439, 5.775 ]],

        [[0.8896, 0.8961, 0.9024],
         [5.3238, 5.3706, 5.4185]],

        [[0.9562, 0.9631, 0.97  ],
         [4.7392, 4.8006, 4.8633]],

        [[1.018 , 1.0252, 1.0322],
         [4.0392, 4.1103, 4.1831]],

        [[1.075 , 1.0819, 1.0888],
         [3.3171, 3.392 , 3.4689]],

        [[1.1268, 1.1331, 1.1392],
         [2.6476, 2.721 , 2.7966]],

        [[1.1729, 1.1781, 1.1832],
         [2.0719, 2.1401, 2.2106]],

        [[1.2126, 1.2163, 1.2198],
         [1.6018, 1.6626, 1.7258]],

        [[1.2448, 1.2467, 1.2485],
         [1.2307, 1.2833, 1.3383]],

        [[1.2682, 1.2681, 1.268 ],
         [0.9437, 0.9883, 1.0351]],

        [[1.281 , 1.279 , 1.2769],
         [0.7246, 0.7617, 0.8008]],

        [[1.2812, 1.2775, 1.2738],
         [0.5585, 0.589 , 0.6212]],

        [[1.2661, 1.2614, 1.2566],
         [0.4331, 0.4578, 0.484 ]],

        [[1.2332, 1.2284, 1.2233],
         [0.3386, 0.3584, 0.3795]],

        [[1.1799, 1.1763, 1.1722],
         [0.2675, 0.2832, 0.3   ]],

        [[1.1044, 1.1036, 1.1018],
         [0.2142, 0.2265, 0.2396]],

        [[1.0069, 1.0101, 1.012 ],
         [0.1745, 0.1838, 0.1939]],

        [[0.8899, 0.898 , 0.9046],
         [0.145 , 0.1519, 0.1595]],

        [[0.7597, 0.7725, 0.7838],
         [0.1234, 0.1282, 0.1337]],

        [[0.6254, 0.6417, 0.6567],
         [0.1078, 0.1109, 0.1146]],

        [[0.4984, 0.5158, 0.5325],
         [0.0968, 0.0985, 0.1006]],

        [[0.3893, 0.405 , 0.4209],
         [0.0894, 0.0898, 0.0906]],

        [[0.306 , 0.3176, 0.3301],
         [0.0848, 0.084 , 0.0836]],

        [[0.2519, 0.2579, 0.2654],
         [0.0823, 0.0804, 0.079 ]],

        [[0.2261, 0.2263, 0.228 ],
         [0.0815, 0.0786, 0.0762]],

        [[0.2248, 0.2198, 0.2161],
         [0.0819, 0.078 , 0.0747]],

        [[0.2428, 0.2337, 0.2255],
         [0.0832, 0.0785, 0.0743]],

        [[0.2747, 0.2627, 0.2512],
         [0.0852, 0.0796, 0.0747]],

        [[0.3157, 0.302 , 0.2884],
         [0.0878, 0.0813, 0.0756]],

        [[0.3621, 0.3477, 0.3329],
         [0.0907, 0.0834, 0.077 ]],

        [[0.4109, 0.3964, 0.3814],
         [0.0938, 0.0857, 0.0786]],

        [[0.4601, 0.4461, 0.4313],
         [0.097 , 0.0882, 0.0803]],

        [[0.5085, 0.4952, 0.481 ],
         [0.1003, 0.0907, 0.0822]],

        [[0.555 , 0.5427, 0.5294],
         [0.1036, 0.0933, 0.0841]],

        [[0.5992, 0.588 , 0.5756],
         [0.1068, 0.0957, 0.086 ]],

        [[0.6409, 0.6307, 0.6194],
         [0.1099, 0.0982, 0.0878]],

        [[0.6798, 0.6707, 0.6604],
         [0.1128, 0.1005, 0.0896]]],


       [[[1.2439, 1.2565, 1.2683],
         [2.6162, 2.8237, 3.0523]],

        [[1.5711, 1.5715, 1.5698],
         [2.553 , 2.7137, 2.8896]],

        [[1.6932, 1.6952, 1.6947],
         [2.5309, 2.6527, 2.7856]],

        [[1.7285, 1.7352, 1.7392],
         [2.5369, 2.6244, 2.72  ]],

        [[1.7105, 1.7226, 1.7319],
         [2.5639, 2.6194, 2.6812]],

        [[1.6589, 1.6761, 1.6907],
         [2.6067, 2.6315, 2.6618]],

        [[1.5866, 1.6084, 1.6276],
         [2.6609, 2.6561, 2.6566]],

        [[1.503 , 1.5284, 1.5515],
         [2.722 , 2.6888, 2.6616]],

        [[1.4144, 1.4424, 1.4685],
         [2.7858, 2.7261, 2.6732]],

        [[1.3255, 1.355 , 1.3829],
         [2.8484, 2.7644, 2.6884]],

        [[1.2391, 1.269 , 1.2978],
         [2.9063, 2.8009, 2.7046]],

        [[1.1569, 1.1865, 1.2154],
         [2.9569, 2.833 , 2.7195]],

        [[1.08  , 1.1086, 1.1367],
         [2.9981, 2.8591, 2.7313]],

        [[1.0087, 1.0358, 1.0627],
         [3.0286, 2.8776, 2.7384]],

        [[0.9431, 0.9684, 0.9938],
         [3.0477, 2.8876, 2.7399]],

        [[0.883 , 0.9063, 0.93  ],
         [3.0551, 2.8887, 2.7349]],

        [[0.8281, 0.8495, 0.8713],
         [3.0511, 2.8806, 2.7229]],

        [[0.7781, 0.7976, 0.8175],
         [3.036 , 2.8634, 2.7035]],

        [[0.7327, 0.7504, 0.7685],
         [3.0106, 2.8374, 2.6767]],

        [[0.6916, 0.7075, 0.724 ],
         [2.9758, 2.8031, 2.6426]],

        [[0.6543, 0.6687, 0.6836],
         [2.9323, 2.7609, 2.6016]],

        [[0.6206, 0.6336, 0.6472],
         [2.8812, 2.7117, 2.554 ]],

        [[0.5903, 0.6021, 0.6145],
         [2.8234, 2.6561, 2.5004]],

        [[0.563 , 0.5738, 0.5852],
         [2.7599, 2.5949, 2.4413]],

        [[0.5387, 0.5485, 0.559 ],
         [2.6915, 2.529 , 2.3776]],

        [[0.5169, 0.5261, 0.5358],
         [2.6192, 2.459 , 2.3098]],

        [[0.4977, 0.5062, 0.5153],
         [2.5437, 2.3857, 2.2388]],

        [[0.4807, 0.4887, 0.4973],
         [2.4657, 2.31  , 2.1653]],

        [[0.4658, 0.4734, 0.4817],
         [2.386 , 2.2325, 2.09  ]],

        [[0.453 , 0.4603, 0.4682],
         [2.3051, 2.1538, 2.0135]],

        [[0.442 , 0.449 , 0.4568],
         [2.2237, 2.0745, 1.9364]],

        [[0.4327, 0.4396, 0.4472],
         [2.1421, 1.9952, 1.8595]],

        [[0.4251, 0.4318, 0.4394],
         [2.0609, 1.9163, 1.783 ]],

        [[0.4189, 0.4257, 0.4332],
         [1.9804, 1.8383, 1.7075]],

        [[0.4142, 0.4209, 0.4286],
         [1.901 , 1.7615, 1.6334]],

        [[0.4108, 0.4176, 0.4253],
         [1.8228, 1.6862, 1.561 ]],

        [[0.4086, 0.4156, 0.4235],
         [1.7463, 1.6127, 1.4905]],

        [[0.4076, 0.4147, 0.4228],
         [1.6715, 1.5411, 1.4221]],

        [[0.4077, 0.415 , 0.4234],
         [1.5987, 1.4717, 1.356 ]],

        [[0.4089, 0.4164, 0.425 ],
         [1.5279, 1.4045, 1.2923]],

        [[0.411 , 0.4187, 0.4277],
         [1.4593, 1.3397, 1.231 ]],

        [[0.414 , 0.4221, 0.4314],
         [1.3929, 1.2772, 1.1723]],

        [[0.418 , 0.4263, 0.4359],
         [1.3288, 1.2172, 1.1161]],

        [[0.4227, 0.4314, 0.4414],
         [1.267 , 1.1596, 1.0624]],

        [[0.4283, 0.4373, 0.4477],
         [1.2076, 1.1044, 1.0112]],

        [[0.4347, 0.444 , 0.4547],
         [1.1506, 1.0517, 0.9624]],

        [[0.4417, 0.4514, 0.4625],
         [1.0959, 1.0013, 0.916 ]],

        [[0.4495, 0.4595, 0.471 ],
         [1.0435, 0.9533, 0.8719]],

        [[0.458 , 0.4683, 0.4801],
         [0.9933, 0.9075, 0.8301]],

        [[0.4671, 0.4777, 0.4898],
         [0.9454, 0.8639, 0.7904]],

        [[0.4768, 0.4877, 0.5002],
         [0.8997, 0.8224, 0.7527]]],


       [[[1.6814, 1.6939, 1.7058],
         [5.3355, 5.7775, 6.2613]],

        [[1.4403, 1.4581, 1.4754],
         [5.3681, 5.7366, 6.136 ]],

        [[1.3098, 1.3285, 1.3466],
         [5.4937, 5.7979, 6.1244]],

        [[1.2206, 1.2397, 1.2582],
         [5.6888, 5.9332, 6.1934]],

        [[1.1568, 1.1761, 1.1949],
         [5.9418, 6.1282, 6.3261]],

        [[1.1102, 1.1296, 1.1484],
         [6.2455, 6.3754, 6.5138]],

        [[1.0759, 1.0949, 1.1135],
         [6.5941, 6.6691, 6.7512]],

        [[1.0499, 1.0683, 1.0862],
         [6.9802, 7.0032, 7.0332]],

        [[1.0294, 1.0468, 1.0639],
         [7.393 , 7.3687, 7.3519]],

        [[1.0116, 1.0282, 1.0443],
         [7.8161, 7.751 , 7.6942]],

        [[0.9945, 1.0102, 1.0256],
         [8.2238, 8.126 , 8.0378]],

        [[0.9761, 0.9914, 1.0063],
         [8.5776, 8.4568, 8.3469]],

        [[0.9551, 0.9703, 0.9852],
         [8.8246, 8.6915, 8.5701]],

        [[0.9306, 0.9462, 0.9615],
         [8.9035, 8.7681, 8.6452]],

        [[0.9024, 0.9189, 0.935 ],
         [8.7613, 8.6315, 8.515 ]],

        [[0.8709, 0.8887, 0.9061],
         [8.3789, 8.2593, 8.1534]],

        [[0.8377, 0.8569, 0.8759],
         [7.7903, 7.6812, 7.5862]],

        [[0.8047, 0.8254, 0.8459],
         [7.0752, 6.9737, 6.8865]],

        [[0.7745, 0.7964, 0.8182],
         [6.3278, 6.2294, 6.1456]],

        [[0.7493, 0.7719, 0.7947],
         [5.6234, 5.524 , 5.4392]],

        [[0.7307, 0.7536, 0.7767],
         [5.0042, 4.901 , 4.8122]],

        [[0.7194, 0.7421, 0.7652],
         [4.4831, 4.3743, 4.2798]],

        [[0.7151, 0.7374, 0.76  ],
         [4.0541, 3.9394, 3.8387]],

        [[0.717 , 0.7386, 0.7605],
         [3.7036, 3.5832, 3.4764]],

        [[0.7237, 0.7446, 0.7658],
         [3.4161, 3.2907, 3.1784]],

        [[0.7341, 0.7543, 0.7747],
         [3.1777, 3.048 , 2.931 ]],

        [[0.7468, 0.7665, 0.7863],
         [2.9767, 2.8435, 2.7228]],

        [[0.761 , 0.7803, 0.7996],
         [2.8043, 2.6684, 2.5448]],

        [[0.776 , 0.7949, 0.8138],
         [2.6535, 2.5157, 2.3899]],

        [[0.7912, 0.8099, 0.8285],
         [2.5194, 2.3803, 2.2531]],

        [[0.8063, 0.8248, 0.8431],
         [2.3981, 2.2583, 2.1304]],

        [[0.8212, 0.8395, 0.8576],
         [2.2871, 2.1471, 2.019 ]],

        [[0.8355, 0.8537, 0.8716],
         [2.1843, 2.0446, 1.9167]],

        [[0.8493, 0.8673, 0.8851],
         [2.0882, 1.9492, 1.8221]],

        [[0.8626, 0.8804, 0.8981],
         [1.9978, 1.86  , 1.734 ]],

        [[0.8753, 0.8929, 0.9104],
         [1.9123, 1.776 , 1.6516]],

        [[0.8874, 0.9048, 0.9222],
         [1.8311, 1.6967, 1.5741]],

        [[0.899 , 0.9162, 0.9334],
         [1.7539, 1.6216, 1.5011]],

        [[0.9101, 0.927 , 0.944 ],
         [1.6801, 1.5503, 1.4321]],

        [[0.9206, 0.9374, 0.9542],
         [1.6098, 1.4825, 1.367 ]],

        [[0.9308, 0.9473, 0.9639],
         [1.5425, 1.4181, 1.3054]],

        [[0.9405, 0.9568, 0.9731],
         [1.4781, 1.3568, 1.247 ]],

        [[0.9499, 0.9658, 0.982 ],
         [1.4166, 1.2985, 1.1917]],

        [[0.9588, 0.9746, 0.9905],
         [1.3577, 1.243 , 1.1394]],

        [[0.9675, 0.983 , 0.9987],
         [1.3014, 1.1902, 1.0898]],

        [[0.9759, 0.9911, 1.0065],
         [1.2476, 1.1399, 1.0428]],

        [[0.984 , 0.9989, 1.0142],
         [1.1962, 1.092 , 0.9982]],

        [[0.9918, 1.0065, 1.0215],
         [1.1471, 1.0465, 0.9561]],

        [[0.9994, 1.0139, 1.0286],
         [1.1001, 1.0032, 0.9161]],

        [[1.0068, 1.0211, 1.0356],
         [1.0553, 0.962 , 0.8782]],

        [[1.014 , 1.028 , 1.0423],
         [1.0126, 0.9229, 0.8423]]]])
Coordinates:
  * XC       (XC) object 'BETA' 'SIGMA'
    Ehv      (Eke) float64 15.68 16.68 17.68 18.68 ... 62.68 63.68 64.68 65.68
  * Type     (Type) object 'L' 'M' 'V'
  * Sym      (Sym) MultiIndex
  - Total    (Sym) object 'SU' 'PU' 'All'
  - Cont     (Sym) object 'SU' 'PU' 'All'
  * Eke      (Eke) float64 0.1 1.1 2.1 3.1 4.1 5.1 ... 46.1 47.1 48.1 49.1 50.1
Attributes:
    dataType:  XSect
    units:     Mb
    file:      n2_3sg_0.1-50.1eV_A2.inp.out
    fileBase:  /home/femtolab/github/ePSproc/data/photoionization

Versions

[10]:
import scooby
scooby.Report(additional=['epsproc', 'holoviews', 'hvplot', 'xarray', 'matplotlib', 'bokeh'])
[10]:
Wed Jul 15 12:06:31 2020 EDT
OS Linux CPU(s) 4 Machine x86_64
Architecture 64bit RAM 7.7 GB Environment Jupyter
Python 3.7.6 (default, Jan 8 2020, 19:59:22) [GCC 7.3.0]
epsproc 1.2.5-dev holoviews 1.12.6 hvplot 0.6.0
xarray 0.13.0 matplotlib 3.2.0 bokeh 1.4.0
numpy 1.18.1 scipy 1.3.1 IPython 7.13.0
scooby 0.5.5
Intel(R) Math Kernel Library Version 2019.0.4 Product Build 20190411 for Intel(R) 64 architecture applications
[ ]: