orto 1.2.0__tar.gz → 1.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {orto-1.2.0 → orto-1.4.0}/PKG-INFO +1 -1
- orto-1.4.0/orto/__version__.py +1 -0
- {orto-1.2.0 → orto-1.4.0}/orto/cli.py +58 -51
- {orto-1.2.0 → orto-1.4.0}/orto/extractor.py +62 -1
- {orto-1.2.0 → orto-1.4.0}/orto/plotter.py +121 -33
- {orto-1.2.0 → orto-1.4.0}/orto.egg-info/PKG-INFO +1 -1
- {orto-1.2.0 → orto-1.4.0}/setup.py +1 -1
- orto-1.2.0/orto/__version__.py +0 -1
- {orto-1.2.0 → orto-1.4.0}/README.md +0 -0
- {orto-1.2.0 → orto-1.4.0}/orto/__init__.py +0 -0
- {orto-1.2.0 → orto-1.4.0}/orto/constants.py +0 -0
- {orto-1.2.0 → orto-1.4.0}/orto/exceptions.py +0 -0
- {orto-1.2.0 → orto-1.4.0}/orto/input.py +0 -0
- {orto-1.2.0 → orto-1.4.0}/orto/job.py +0 -0
- {orto-1.2.0 → orto-1.4.0}/orto/utils.py +0 -0
- {orto-1.2.0 → orto-1.4.0}/orto.egg-info/SOURCES.txt +0 -0
- {orto-1.2.0 → orto-1.4.0}/orto.egg-info/dependency_links.txt +0 -0
- {orto-1.2.0 → orto-1.4.0}/orto.egg-info/entry_points.txt +0 -0
- {orto-1.2.0 → orto-1.4.0}/orto.egg-info/requires.txt +0 -0
- {orto-1.2.0 → orto-1.4.0}/orto.egg-info/top_level.txt +0 -0
- {orto-1.2.0 → orto-1.4.0}/pyproject.toml +0 -0
- {orto-1.2.0 → orto-1.4.0}/setup.cfg +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = '1.4.0'
|
|
@@ -593,78 +593,65 @@ def plot_abs_func(uargs):
|
|
|
593
593
|
version = [6, 0, 0]
|
|
594
594
|
|
|
595
595
|
if version[0] < 6:
|
|
596
|
-
if uargs.
|
|
596
|
+
if uargs.intensities == 'electric':
|
|
597
597
|
all_data = oe.OldAbsorptionElectricDipoleExtractor.extract(
|
|
598
598
|
uargs.output_file
|
|
599
599
|
)
|
|
600
|
-
|
|
600
|
+
elif uargs.intensities == 'velocity':
|
|
601
601
|
all_data = oe.OldAbsorptionVelocityDipoleExtractor.extract(
|
|
602
602
|
uargs.output_file
|
|
603
603
|
)
|
|
604
604
|
elif version[0] >= 6:
|
|
605
|
-
if uargs.
|
|
605
|
+
if uargs.intensities == 'electric':
|
|
606
606
|
all_data = oe.AbsorptionElectricDipoleExtractor.extract(
|
|
607
607
|
uargs.output_file
|
|
608
608
|
)
|
|
609
|
-
|
|
609
|
+
elif uargs.intensities == 'velocity':
|
|
610
610
|
all_data = oe.AbsorptionVelocityDipoleExtractor.extract(
|
|
611
611
|
uargs.output_file
|
|
612
612
|
)
|
|
613
|
+
elif uargs.intensities == 'semi-classical':
|
|
614
|
+
all_data = oe.AbsorptionSemiClassicalDipoleExtractor.extract(
|
|
615
|
+
uargs.output_file
|
|
616
|
+
)
|
|
617
|
+
|
|
618
|
+
ut.cprint('Using intensities: {}'.format(uargs.intensities), 'cyan')
|
|
613
619
|
|
|
614
620
|
# Plot each section
|
|
615
621
|
for it, data in enumerate(all_data):
|
|
616
622
|
|
|
617
|
-
if uargs.x_lim is None:
|
|
618
|
-
if uargs.x_unit == 'wavenumber':
|
|
619
|
-
uargs.x_lim = [0, max(data['energy (cm^-1)'])]
|
|
620
|
-
if uargs.x_unit == 'wavelength':
|
|
621
|
-
# 1 to 2000 nm
|
|
622
|
-
uargs.x_lim = [5000., 10000000.]
|
|
623
|
-
|
|
624
|
-
if uargs.x_cut is None:
|
|
625
|
-
iup = -2
|
|
626
|
-
ilow = 0
|
|
627
|
-
else:
|
|
628
|
-
ilow = min(
|
|
629
|
-
[
|
|
630
|
-
it
|
|
631
|
-
for it, val in enumerate(data['energy (cm^-1)'])
|
|
632
|
-
if (val - uargs.x_cut[0]) > 0
|
|
633
|
-
]
|
|
634
|
-
)
|
|
635
|
-
iup = max(
|
|
636
|
-
[
|
|
637
|
-
it
|
|
638
|
-
for it, val in enumerate(data['energy (cm^-1)'])
|
|
639
|
-
if (uargs.x_cut[1] - val) > 0
|
|
640
|
-
]
|
|
641
|
-
)
|
|
642
|
-
|
|
643
623
|
if len(all_data) > 1:
|
|
644
624
|
save_name = f'absorption_spectrum_section_{it:d}.png'
|
|
645
625
|
else:
|
|
646
|
-
save_name = '
|
|
626
|
+
save_name = 'absorption_spectrum.png'
|
|
627
|
+
|
|
628
|
+
if uargs.x_unit == 'wavenumber':
|
|
629
|
+
x_values = data['energy (cm^-1)']
|
|
630
|
+
elif uargs.x_unit == 'wavelength':
|
|
631
|
+
x_values = 1E7 / data['energy (cm^-1)']
|
|
632
|
+
elif uargs.x_unit == 'energy':
|
|
633
|
+
x_values = data['energy (ev)']
|
|
647
634
|
|
|
648
635
|
# Plot absorption spectrum
|
|
649
636
|
fig, ax = plotter.plot_abs(
|
|
650
|
-
|
|
651
|
-
|
|
637
|
+
x_values,
|
|
638
|
+
uargs.x_unit,
|
|
639
|
+
data['fosc'],
|
|
652
640
|
show=_SHOW_CONV[uargs.plot],
|
|
653
641
|
save=_SAVE_CONV[uargs.plot],
|
|
654
642
|
save_name=save_name,
|
|
655
643
|
x_lim=uargs.x_lim,
|
|
656
644
|
y_lim=uargs.y_lim,
|
|
657
|
-
|
|
645
|
+
x_shift=uargs.shift,
|
|
658
646
|
linewidth=uargs.linewidth,
|
|
659
647
|
lineshape=uargs.lineshape,
|
|
660
648
|
window_title=f'Absorption Spectrum from {uargs.output_file}',
|
|
661
|
-
|
|
649
|
+
osc_style=uargs.osc_style,
|
|
650
|
+
normalise=uargs.normalise_absorption
|
|
662
651
|
)
|
|
663
652
|
|
|
664
653
|
if uargs.x_unit == 'wavenumber':
|
|
665
654
|
ax[0].set_xlim([0, 50000])
|
|
666
|
-
if uargs.x_unit == 'wavelength':
|
|
667
|
-
ax[0].set_xlim([0, 2000])
|
|
668
655
|
plt.show()
|
|
669
656
|
|
|
670
657
|
return
|
|
@@ -1621,9 +1608,10 @@ def read_args(arg_list=None):
|
|
|
1621
1608
|
)
|
|
1622
1609
|
|
|
1623
1610
|
plot_abs.add_argument(
|
|
1624
|
-
'--
|
|
1611
|
+
'--intensities',
|
|
1612
|
+
'-i',
|
|
1625
1613
|
type=str,
|
|
1626
|
-
choices=['velocity', 'electric'],
|
|
1614
|
+
choices=['velocity', 'electric', 'semi-classical'],
|
|
1627
1615
|
default='electric',
|
|
1628
1616
|
help='Type of intensity to plot (orca_mapspc uses electric)'
|
|
1629
1617
|
)
|
|
@@ -1640,10 +1628,15 @@ def read_args(arg_list=None):
|
|
|
1640
1628
|
)
|
|
1641
1629
|
|
|
1642
1630
|
plot_abs.add_argument(
|
|
1643
|
-
'--
|
|
1644
|
-
|
|
1631
|
+
'--osc_style',
|
|
1632
|
+
type=str,
|
|
1633
|
+
default='combined',
|
|
1645
1634
|
help=(
|
|
1646
|
-
'
|
|
1635
|
+
'Style of oscillators to plot\n'
|
|
1636
|
+
' - \'separate\' plots oscillator strengths as stems on separate axis\n'
|
|
1637
|
+
' - \'combined\' plots oscillator strengths on intensity axis\n'
|
|
1638
|
+
' - \'off\' does not plot oscillator strengths\n'
|
|
1639
|
+
'Default: %(default)s'
|
|
1647
1640
|
)
|
|
1648
1641
|
)
|
|
1649
1642
|
|
|
@@ -1676,32 +1669,46 @@ def read_args(arg_list=None):
|
|
|
1676
1669
|
plot_abs.add_argument(
|
|
1677
1670
|
'--x_unit',
|
|
1678
1671
|
type=str,
|
|
1679
|
-
choices=['wavenumber', 'wavelength'],
|
|
1672
|
+
choices=['wavenumber', 'energy', 'wavelength'],
|
|
1680
1673
|
default='wavenumber',
|
|
1681
1674
|
help='x units to use for spectrum'
|
|
1682
1675
|
)
|
|
1683
1676
|
|
|
1684
1677
|
plot_abs.add_argument(
|
|
1685
|
-
'--
|
|
1678
|
+
'--shift',
|
|
1686
1679
|
type=float,
|
|
1687
|
-
|
|
1688
|
-
help=
|
|
1680
|
+
default=0.,
|
|
1681
|
+
help=(
|
|
1682
|
+
'Shift spectrum by this amount in x units\n'
|
|
1683
|
+
'Default: %(default)s'
|
|
1684
|
+
)
|
|
1689
1685
|
)
|
|
1690
1686
|
|
|
1691
1687
|
plot_abs.add_argument(
|
|
1692
|
-
'--
|
|
1693
|
-
type=float,
|
|
1688
|
+
'--x_lim',
|
|
1694
1689
|
nargs=2,
|
|
1695
|
-
|
|
1690
|
+
default=['auto', 'auto'],
|
|
1691
|
+
help='x limits of spectrum'
|
|
1696
1692
|
)
|
|
1697
1693
|
|
|
1698
1694
|
plot_abs.add_argument(
|
|
1699
1695
|
'--y_lim',
|
|
1700
1696
|
nargs=2,
|
|
1701
|
-
default=[
|
|
1697
|
+
default=[0., 'auto'],
|
|
1702
1698
|
help='Epsilon limits of spectrum in cm^-1 mol^-1 L'
|
|
1703
1699
|
)
|
|
1704
1700
|
|
|
1701
|
+
plot_abs.add_argument(
|
|
1702
|
+
'--normalise_absorption',
|
|
1703
|
+
'-na',
|
|
1704
|
+
action='store_true',
|
|
1705
|
+
default=False,
|
|
1706
|
+
help=(
|
|
1707
|
+
'Normalises absorption spectrum to maximum value\n'
|
|
1708
|
+
'Default: %(default)s'
|
|
1709
|
+
)
|
|
1710
|
+
)
|
|
1711
|
+
|
|
1705
1712
|
plot_ailft = plot_parser.add_parser(
|
|
1706
1713
|
'ailft_orbs',
|
|
1707
1714
|
description='Plots AI-LFT orbital energies from output file',
|
|
@@ -1911,7 +1918,7 @@ def read_args(arg_list=None):
|
|
|
1911
1918
|
default=5,
|
|
1912
1919
|
help=(
|
|
1913
1920
|
'Width of signal (FWHM for Gaussian, Width for Lorentzian),'
|
|
1914
|
-
' in
|
|
1921
|
+
' in same unit as plot x unit'
|
|
1915
1922
|
)
|
|
1916
1923
|
)
|
|
1917
1924
|
|
|
@@ -1359,7 +1359,7 @@ class AbsorptionElectricDipoleExtractor(extto.BetweenExtractor):
|
|
|
1359
1359
|
'''
|
|
1360
1360
|
|
|
1361
1361
|
result = re.findall(
|
|
1362
|
-
r'\s+(\d
|
|
1362
|
+
r'\s+(\d+[A-Za-z]*-\d*[A-Za-z]\s+->\s+\d+[A-Za-z]*-\d*[A-Za-z])\s+(\d+\.\d+)\s+(\d+\.\d+)\s+(\d+\.\d+)\s+(\d+\.\d+)\s+(\d\.\d{5})\s+(-*\d\.\d{5})\s+(-*\d\.\d{5})\s+(-*\d\.\d{5})', # noqa
|
|
1363
1363
|
block
|
|
1364
1364
|
)
|
|
1365
1365
|
|
|
@@ -1415,6 +1415,67 @@ class AbsorptionVelocityDipoleExtractor(AbsorptionElectricDipoleExtractor):
|
|
|
1415
1415
|
END_PATTERN = rb'(?=-{77})'
|
|
1416
1416
|
|
|
1417
1417
|
|
|
1418
|
+
class AbsorptionSemiClassicalDipoleExtractor(AbsorptionElectricDipoleExtractor): # noqa
|
|
1419
|
+
'''
|
|
1420
|
+
Extracts ABSORPTION SPECTRUM VIA FULL SEMI-CLASSICAL FORMULATION table
|
|
1421
|
+
from ORCA output file for versions newer than 6.
|
|
1422
|
+
'''
|
|
1423
|
+
|
|
1424
|
+
# Regex Start Pattern
|
|
1425
|
+
START_PATTERN = rb'(?<=ABSORPTION SPECTRUM VIA FULL SEMI-CLASSICAL FORMULATION\s[\S\s]{408}\s)' # noqa
|
|
1426
|
+
|
|
1427
|
+
# Regex End Pattern
|
|
1428
|
+
END_PATTERN = rb'(?=-{77})'
|
|
1429
|
+
|
|
1430
|
+
@property
|
|
1431
|
+
def data(self) -> dict[str, list[str | float]]:
|
|
1432
|
+
'''
|
|
1433
|
+
Absorption spectrum data:\n
|
|
1434
|
+
A dictionary with keys:\n
|
|
1435
|
+
transition\n
|
|
1436
|
+
energy (cm^-1)\n
|
|
1437
|
+
energy (ev)\n
|
|
1438
|
+
wavelength (nm)\n
|
|
1439
|
+
fosc\n
|
|
1440
|
+
All values are list[float], but 'transition' entries are list[str]
|
|
1441
|
+
'''
|
|
1442
|
+
return self._data
|
|
1443
|
+
|
|
1444
|
+
@staticmethod
|
|
1445
|
+
def _process_block(block: str) -> dict[str, list[int | float]]: # noqa
|
|
1446
|
+
'''
|
|
1447
|
+
Converts single block into data entries described in self.data
|
|
1448
|
+
|
|
1449
|
+
Parameters
|
|
1450
|
+
----------
|
|
1451
|
+
block: str
|
|
1452
|
+
String block extracted from file
|
|
1453
|
+
|
|
1454
|
+
Returns
|
|
1455
|
+
-------
|
|
1456
|
+
dict[str, list[float]]
|
|
1457
|
+
'''
|
|
1458
|
+
|
|
1459
|
+
result = re.findall(
|
|
1460
|
+
r'\s+(\d+[A-Za-z]*-\d*[A-Za-z]\s+->\s+\d+[A-Za-z]*-\d*[A-Za-z])\s+(\d+\.\d+)\s+(\d+\.\d+)\s+(\d+\.\d+)\s+(\d+\.\d+)', # noqa
|
|
1461
|
+
block
|
|
1462
|
+
)
|
|
1463
|
+
|
|
1464
|
+
result = np.asarray(result, dtype=str).T
|
|
1465
|
+
|
|
1466
|
+
fresult = result[1:].astype(float)
|
|
1467
|
+
|
|
1468
|
+
data = {
|
|
1469
|
+
'state': result[0].tolist(),
|
|
1470
|
+
'energy (ev)': fresult[0].tolist(),
|
|
1471
|
+
'energy (cm^-1)': fresult[1].tolist(),
|
|
1472
|
+
'wavelength (nm)': fresult[2].tolist(),
|
|
1473
|
+
'fosc': fresult[3].tolist(),
|
|
1474
|
+
}
|
|
1475
|
+
|
|
1476
|
+
return data
|
|
1477
|
+
|
|
1478
|
+
|
|
1418
1479
|
class OldAbsorptionElectricDipoleExtractor(extto.BetweenExtractor):
|
|
1419
1480
|
'''
|
|
1420
1481
|
Extracts ABSORPTION SPECTRUM VIA TRANSITION ELECTRIC DIPOLE MOMENTS table
|
|
@@ -4,6 +4,7 @@ from matplotlib.ticker import AutoMinorLocator
|
|
|
4
4
|
import numpy as np
|
|
5
5
|
from numpy.typing import ArrayLike, NDArray
|
|
6
6
|
import itertools
|
|
7
|
+
import pathlib
|
|
7
8
|
|
|
8
9
|
from . import utils as ut
|
|
9
10
|
|
|
@@ -75,45 +76,60 @@ def lorentzian(p: ArrayLike, fwhm, p0, area) -> NDArray:
|
|
|
75
76
|
return lor
|
|
76
77
|
|
|
77
78
|
|
|
78
|
-
def plot_abs(
|
|
79
|
+
def plot_abs(x_values: ArrayLike, x_type: str, foscs: ArrayLike,
|
|
79
80
|
lineshape: str = 'gaussian', linewidth: float = 100.,
|
|
80
|
-
x_lim: list[float] =
|
|
81
|
-
abs_type: str = 'napierian',
|
|
82
|
-
|
|
81
|
+
x_lim: list[float] = ['auto', 'auto'],
|
|
82
|
+
abs_type: str = 'napierian',
|
|
83
|
+
y_lim: list[float] = [0., 'auto'],
|
|
84
|
+
x_shift: float = 0., normalise: bool = False,
|
|
85
|
+
osc_style: str = 'separate', save: bool = False,
|
|
83
86
|
save_name: str = 'absorption_spectrum.png', show: bool = False,
|
|
87
|
+
verbose: bool = True,
|
|
84
88
|
window_title: str = 'Absorption Spectrum') -> tuple[plt.Figure, list[plt.Axes]]: # noqa
|
|
85
89
|
'''
|
|
86
|
-
Plots absorption spectrum with oscillator
|
|
90
|
+
Plots absorption spectrum with intensity specified by oscillator strength.\n # noqa
|
|
91
|
+
Spectrum is computed as a sum of Gaussian or Lorentzian lineshapes.\n
|
|
92
|
+
The x_values can be either wavenumbers [cm^-1], wavelengths [nm] or\n
|
|
93
|
+
energies [eV].\n
|
|
87
94
|
|
|
88
95
|
Parameters
|
|
89
96
|
----------
|
|
90
|
-
|
|
91
|
-
|
|
97
|
+
x_values: array_like
|
|
98
|
+
x_values for each transition, either wavenumber, wavelength or energy\n
|
|
99
|
+
with unit type specified by x_type
|
|
100
|
+
x_type: str {'wavenumber', 'wavelength', 'energy'}
|
|
101
|
+
Type of x_values, either wavenumber [cm^-1], wavelength [nm] or\n
|
|
102
|
+
energy [eV].
|
|
92
103
|
foscs: array_like
|
|
93
104
|
Oscillator strength of each transition
|
|
94
105
|
lineshape: str {'gaussian', 'lorentzian'}
|
|
95
106
|
Lineshape function to use for each transition/signal
|
|
96
107
|
linewidth: float
|
|
97
108
|
Linewidth used in lineshape [cm^-1]
|
|
98
|
-
x_lim: list[float], default [
|
|
109
|
+
x_lim: list[float], default ['auto', 'auto']
|
|
99
110
|
Minimum and maximum x-values to plot [cm^-1 or nm]
|
|
100
|
-
y_lim: list[float | str], default 'auto'
|
|
111
|
+
y_lim: list[float | str], default [0., 'auto']
|
|
101
112
|
Minimum and maximum y-values to plot [cm^-1 mol^-1 L]
|
|
102
|
-
x_unit: str {'wavenumber', 'wavelength'}
|
|
103
|
-
X-unit to use, data will be converted internally.\n
|
|
104
|
-
Assumes cm^-1 for wavenumber and nm for wavelength.
|
|
105
113
|
abs_type: str {'napierian', 'logarithmic'}
|
|
106
114
|
Absorbance (and epsilon) type to use. Orca_mapspc uses napierian
|
|
107
|
-
|
|
108
|
-
If True,
|
|
115
|
+
normalise: bool, default False
|
|
116
|
+
If True, normalise the absorption spectrum to the maximum value.
|
|
117
|
+
osc_style: str, default 'separate'
|
|
118
|
+
Style of oscillator strength plots:
|
|
119
|
+
- 'separate': plots oscillator strengths as stems on separate axis
|
|
120
|
+
- 'combined': plots oscillator strengths on intensity axis
|
|
121
|
+
- 'off': does not plot oscillator strengths
|
|
109
122
|
save: bool, default False
|
|
110
123
|
If True, plot is saved to save_name
|
|
111
|
-
save_name: str
|
|
124
|
+
save_name: str | pathlib.Path, default 'absorption_spectrum.png'
|
|
112
125
|
If save is True, plot is saved to this location/filename
|
|
113
126
|
show: bool, default False
|
|
114
127
|
If True, plot is shown on screen
|
|
128
|
+
verbose: bool, default True
|
|
129
|
+
If True, plot file location is written to terminal
|
|
115
130
|
window_title: str, default 'UV-Visible Absorption Spectrum'
|
|
116
131
|
Title of figure window, not of plot
|
|
132
|
+
|
|
117
133
|
Returns
|
|
118
134
|
-------
|
|
119
135
|
plt.Figure
|
|
@@ -123,6 +139,13 @@ def plot_abs(wavenumbers: ArrayLike, foscs: ArrayLike,
|
|
|
123
139
|
Matplotlib Axis object for twinx oscillator strength axis
|
|
124
140
|
'''
|
|
125
141
|
|
|
142
|
+
save_name = pathlib.Path(save_name)
|
|
143
|
+
|
|
144
|
+
x_values = np.asarray(x_values) + x_shift
|
|
145
|
+
foscs = np.asarray(foscs)
|
|
146
|
+
if len(x_values) != len(foscs):
|
|
147
|
+
raise ValueError('x_values and foscs must have the same length')
|
|
148
|
+
|
|
126
149
|
fig, ax = plt.subplots(1, 1, num=window_title)
|
|
127
150
|
|
|
128
151
|
ls_func = {
|
|
@@ -130,7 +153,38 @@ def plot_abs(wavenumbers: ArrayLike, foscs: ArrayLike,
|
|
|
130
153
|
'lorentzian': lorentzian
|
|
131
154
|
}
|
|
132
155
|
|
|
133
|
-
|
|
156
|
+
if not isinstance(x_lim, list):
|
|
157
|
+
raise ValueError('`x_lim` must be a list of values')
|
|
158
|
+
|
|
159
|
+
if x_lim[0] != x_lim[1]:
|
|
160
|
+
if isinstance(x_lim[0], str):
|
|
161
|
+
if x_lim[0] == 'auto':
|
|
162
|
+
x_lim[0] = ax.get_ylim()[0]
|
|
163
|
+
else:
|
|
164
|
+
x_lim[0] = float(x_lim[0])
|
|
165
|
+
if isinstance(x_lim[1], str):
|
|
166
|
+
if x_lim[1] == 'auto':
|
|
167
|
+
x_lim[1] = ax.get_ylim()[1]
|
|
168
|
+
else:
|
|
169
|
+
x_lim[1] = float(x_lim[1])
|
|
170
|
+
else:
|
|
171
|
+
x_lim = [np.min(x_values), np.max(x_values)]
|
|
172
|
+
|
|
173
|
+
# Set limits and range of continuous variable
|
|
174
|
+
ax.set_xlim([x_lim[0], x_lim[1]])
|
|
175
|
+
x_grid = np.linspace(x_lim[0], x_lim[1], 100000)
|
|
176
|
+
|
|
177
|
+
# Exclude values of x_values out of the range of x_lim
|
|
178
|
+
x_values = np.asarray(
|
|
179
|
+
[val for val in x_values if x_lim[0] <= val <= x_lim[1]]
|
|
180
|
+
)
|
|
181
|
+
# Exclude oscillator strengths for those values
|
|
182
|
+
foscs = np.asarray(
|
|
183
|
+
[
|
|
184
|
+
fosc
|
|
185
|
+
for val, fosc in zip(x_values, foscs)
|
|
186
|
+
if x_lim[0] <= val <= x_lim[1]]
|
|
187
|
+
)
|
|
134
188
|
|
|
135
189
|
# Conversion from oscillator strength to napierian integrated absorption
|
|
136
190
|
# coefficient
|
|
@@ -143,55 +197,89 @@ def plot_abs(wavenumbers: ArrayLike, foscs: ArrayLike,
|
|
|
143
197
|
|
|
144
198
|
# Spectrum as sum of signals. Always computed in wavenumbers.
|
|
145
199
|
spectrum = np.sum([
|
|
146
|
-
ls_func[lineshape](
|
|
147
|
-
for x_value, A_log in zip(
|
|
200
|
+
ls_func[lineshape](x_grid, linewidth, x_value, A_log)
|
|
201
|
+
for x_value, A_log in zip(x_values, A_logs)
|
|
148
202
|
], axis=0)
|
|
149
203
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
204
|
+
if normalise:
|
|
205
|
+
# Normalise the spectrum to the maximum value
|
|
206
|
+
spectrum /= np.max(spectrum)
|
|
207
|
+
ax.set_ylabel('Normalised Absorbance (arbitrary units)') # noqa
|
|
208
|
+
else:
|
|
209
|
+
ax.set_ylabel(r'$\epsilon$ (cm$^\mathregular{-1}$ mol$^\mathregular{-1}$ L)') # noqa
|
|
210
|
+
|
|
211
|
+
_txt_save_name = save_name.with_suffix('.txt')
|
|
212
|
+
np.savetxt(
|
|
213
|
+
_txt_save_name,
|
|
214
|
+
np.vstack([x_grid, spectrum]).T,
|
|
215
|
+
fmt='%.5f',
|
|
216
|
+
header='Absorption spectrum data\nx (wavenumber, wavelength or energy), y (absorbance)' # noqa
|
|
217
|
+
)
|
|
218
|
+
if verbose:
|
|
219
|
+
ut.cprint(
|
|
220
|
+
f'\nAbsorption spectrum data saved to\n {_txt_save_name}',
|
|
221
|
+
'cyan'
|
|
222
|
+
)
|
|
156
223
|
|
|
157
224
|
# Main spectrum
|
|
158
|
-
ax.plot(
|
|
225
|
+
ax.plot(x_grid, spectrum, color='k')
|
|
159
226
|
|
|
160
|
-
if
|
|
227
|
+
if osc_style == 'separate':
|
|
161
228
|
fax = ax.twinx()
|
|
162
229
|
# Oscillator strength twin axis
|
|
163
|
-
|
|
230
|
+
fax.stem(x_values, foscs, basefmt=' ', markerfmt=' ')
|
|
164
231
|
fax.yaxis.set_minor_locator(AutoMinorLocator())
|
|
165
232
|
fax.set_ylabel(r'$f_\mathregular{osc}$')
|
|
233
|
+
fax.set_ylim([0., fax.get_ylim()[1]])
|
|
234
|
+
elif osc_style == 'combined':
|
|
235
|
+
fax = None
|
|
236
|
+
plt.subplots_adjust(right=0.2)
|
|
237
|
+
ax.stem(
|
|
238
|
+
x_values,
|
|
239
|
+
foscs/np.max(foscs) * np.max(spectrum),
|
|
240
|
+
basefmt=' ',
|
|
241
|
+
markerfmt=' '
|
|
242
|
+
)
|
|
243
|
+
ax.spines['right'].set_visible(False)
|
|
244
|
+
ax.spines['top'].set_visible(False)
|
|
166
245
|
else:
|
|
167
246
|
fax = None
|
|
247
|
+
# No oscillator strength plot
|
|
168
248
|
plt.subplots_adjust(right=0.2)
|
|
169
249
|
ax.spines['right'].set_visible(False)
|
|
170
250
|
ax.spines['top'].set_visible(False)
|
|
171
251
|
|
|
172
252
|
if y_lim[0] != y_lim[1]:
|
|
173
253
|
if isinstance(y_lim[0], str):
|
|
174
|
-
y_lim[0]
|
|
254
|
+
if y_lim[0] == 'auto':
|
|
255
|
+
y_lim[0] = ax.get_ylim()[0]
|
|
256
|
+
else:
|
|
257
|
+
y_lim[0] = float(y_lim[0])
|
|
175
258
|
if isinstance(y_lim[1], str):
|
|
176
|
-
y_lim[1]
|
|
259
|
+
if y_lim[1] == 'auto':
|
|
260
|
+
y_lim[1] = ax.get_ylim()[1]
|
|
261
|
+
else:
|
|
262
|
+
y_lim[1] = float(y_lim[1])
|
|
177
263
|
ax.set_ylim([y_lim[0], y_lim[1]])
|
|
178
264
|
|
|
179
265
|
ax.xaxis.set_minor_locator(AutoMinorLocator())
|
|
180
266
|
ax.yaxis.set_minor_locator(AutoMinorLocator())
|
|
181
267
|
|
|
182
|
-
|
|
268
|
+
xtype_to_label = {
|
|
183
269
|
'wavenumber': r'Wavenumber (cm$^\mathregular{-1}$)',
|
|
184
270
|
'wavelength': 'Wavelength (nm)',
|
|
271
|
+
'energy': r'Energy (eV)'
|
|
185
272
|
}
|
|
186
273
|
|
|
187
|
-
ax.set_xlabel(
|
|
188
|
-
ax.set_ylabel(r'$\epsilon$ (cm$^\mathregular{-1}$ mol$^\mathregular{-1}$ L)') # noqa
|
|
274
|
+
ax.set_xlabel(xtype_to_label[x_type.lower()])
|
|
189
275
|
|
|
190
276
|
fig.tight_layout()
|
|
191
277
|
|
|
192
278
|
if save:
|
|
193
279
|
plt.savefig(save_name, dpi=500)
|
|
194
|
-
|
|
280
|
+
if verbose:
|
|
281
|
+
ut.cprint(f'\nAbsorption spectrum saved to\n {save_name}', 'cyan')
|
|
282
|
+
|
|
195
283
|
if show:
|
|
196
284
|
plt.show()
|
|
197
285
|
|
orto-1.2.0/orto/__version__.py
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = '1.2.0'
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|