orto 1.5.0__py3-none-any.whl → 1.6.0__py3-none-any.whl
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/__version__.py +1 -1
- orto/cli.py +212 -43
- orto/constants.py +2 -0
- orto/data.py +351 -0
- orto/extractor.py +151 -10
- orto/plotter.py +124 -200
- orto/utils.py +123 -0
- {orto-1.5.0.dist-info → orto-1.6.0.dist-info}/METADATA +3 -1
- orto-1.6.0.dist-info/RECORD +17 -0
- orto-1.6.0.dist-info/licenses/LICENSE +165 -0
- orto-1.5.0.dist-info/RECORD +0 -15
- {orto-1.5.0.dist-info → orto-1.6.0.dist-info}/WHEEL +0 -0
- {orto-1.5.0.dist-info → orto-1.6.0.dist-info}/entry_points.txt +0 -0
- {orto-1.5.0.dist-info → orto-1.6.0.dist-info}/top_level.txt +0 -0
orto/__version__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = '1.
|
|
1
|
+
__version__ = '1.6.0'
|
orto/cli.py
CHANGED
|
@@ -15,6 +15,7 @@ from shutil import move as shutilmove
|
|
|
15
15
|
from . import job
|
|
16
16
|
from . import utils as ut
|
|
17
17
|
from . import constants as cst
|
|
18
|
+
from . import data as d
|
|
18
19
|
from .exceptions import DataNotFoundError, DataFormattingError
|
|
19
20
|
|
|
20
21
|
_SHOW_CONV = {
|
|
@@ -573,12 +574,7 @@ def plot_xes_func(uargs):
|
|
|
573
574
|
from . import extractor as oe
|
|
574
575
|
|
|
575
576
|
# Set user specified font name
|
|
576
|
-
|
|
577
|
-
try:
|
|
578
|
-
plt.rcParams['font.family'] = os.getenv('orto_fontname')
|
|
579
|
-
except ValueError:
|
|
580
|
-
ut.cprint('Error in orto_fontname environment variable', 'red')
|
|
581
|
-
sys.exit(1)
|
|
577
|
+
ut.check_font_envvar()
|
|
582
578
|
|
|
583
579
|
# Change matplotlib font size to be larger
|
|
584
580
|
mpl.rcParams.update({'font.size': 12})
|
|
@@ -618,7 +614,7 @@ def plot_xes_func(uargs):
|
|
|
618
614
|
uargs.output_file
|
|
619
615
|
)
|
|
620
616
|
elif version[0] < 6:
|
|
621
|
-
ut.
|
|
617
|
+
ut.red_exit('Unsupported version of Orca for XES extraction', 'red')
|
|
622
618
|
|
|
623
619
|
ut.cprint('Using intensities: {}'.format(uargs.intensities), 'cyan')
|
|
624
620
|
|
|
@@ -675,9 +671,9 @@ def plot_xes_func(uargs):
|
|
|
675
671
|
plt.show()
|
|
676
672
|
|
|
677
673
|
|
|
678
|
-
def
|
|
674
|
+
def plot_xas_func(uargs):
|
|
679
675
|
'''
|
|
680
|
-
Wrapper for CLI plot
|
|
676
|
+
Wrapper for CLI plot xas call
|
|
681
677
|
|
|
682
678
|
Parameters
|
|
683
679
|
----------
|
|
@@ -694,12 +690,7 @@ def plot_abs_func(uargs):
|
|
|
694
690
|
from . import extractor as oe
|
|
695
691
|
|
|
696
692
|
# Set user specified font name
|
|
697
|
-
|
|
698
|
-
try:
|
|
699
|
-
plt.rcParams['font.family'] = os.getenv('orto_fontname')
|
|
700
|
-
except ValueError:
|
|
701
|
-
ut.cprint('Error in orto_fontname environment variable', 'red')
|
|
702
|
-
sys.exit(1)
|
|
693
|
+
ut.check_font_envvar()
|
|
703
694
|
|
|
704
695
|
# Change matplotlib font size to be larger
|
|
705
696
|
mpl.rcParams.update({'font.size': 12})
|
|
@@ -713,28 +704,21 @@ def plot_abs_func(uargs):
|
|
|
713
704
|
)
|
|
714
705
|
version = [6, 0, 0]
|
|
715
706
|
|
|
716
|
-
if version[0]
|
|
717
|
-
if uargs.intensities == 'electric':
|
|
718
|
-
all_data = oe.OldAbsorptionElectricDipoleExtractor.extract(
|
|
719
|
-
uargs.output_file
|
|
720
|
-
)
|
|
721
|
-
elif uargs.intensities == 'velocity':
|
|
722
|
-
all_data = oe.OldAbsorptionVelocityDipoleExtractor.extract(
|
|
723
|
-
uargs.output_file
|
|
724
|
-
)
|
|
725
|
-
elif version[0] >= 6:
|
|
707
|
+
if version[0] >= 6:
|
|
726
708
|
if uargs.intensities == 'electric':
|
|
727
|
-
all_data = oe.
|
|
709
|
+
all_data = oe.XASElectricDipoleExtractor.extract(
|
|
728
710
|
uargs.output_file
|
|
729
711
|
)
|
|
730
712
|
elif uargs.intensities == 'velocity':
|
|
731
|
-
all_data = oe.
|
|
713
|
+
all_data = oe.XASVelocityDipoleExtractor.extract(
|
|
732
714
|
uargs.output_file
|
|
733
715
|
)
|
|
734
716
|
elif uargs.intensities == 'semi-classical':
|
|
735
|
-
all_data = oe.
|
|
717
|
+
all_data = oe.XASSemiClassicalDipoleExtractor.extract(
|
|
736
718
|
uargs.output_file
|
|
737
719
|
)
|
|
720
|
+
elif version[0] < 6:
|
|
721
|
+
ut.red_exit('Unsupported version of Orca for XAS extraction', 'red')
|
|
738
722
|
|
|
739
723
|
ut.cprint('Using intensities: {}'.format(uargs.intensities), 'cyan')
|
|
740
724
|
|
|
@@ -792,6 +776,194 @@ def plot_abs_func(uargs):
|
|
|
792
776
|
return
|
|
793
777
|
|
|
794
778
|
|
|
779
|
+
def plot_abs_func(uargs):
|
|
780
|
+
'''
|
|
781
|
+
Wrapper for CLI plot abs call\n\n
|
|
782
|
+
|
|
783
|
+
Plots ABSORPTION blocks from orca output\n
|
|
784
|
+
- UVVIS (TDDFT)\n
|
|
785
|
+
- XAS (TDDFT)\n\n
|
|
786
|
+
|
|
787
|
+
Parameters
|
|
788
|
+
----------
|
|
789
|
+
uargs : argparser object
|
|
790
|
+
User arguments
|
|
791
|
+
|
|
792
|
+
Returns
|
|
793
|
+
-------
|
|
794
|
+
None
|
|
795
|
+
'''
|
|
796
|
+
import matplotlib.pyplot as plt
|
|
797
|
+
import matplotlib as mpl
|
|
798
|
+
import matplotlib.colors as mcolors
|
|
799
|
+
from . import plotter
|
|
800
|
+
from . import extractor as oe
|
|
801
|
+
|
|
802
|
+
# Change matplotlib font size to be larger
|
|
803
|
+
mpl.rcParams.update({'font.size': 12})
|
|
804
|
+
# Set user specified font name
|
|
805
|
+
ut.check_font_envvar()
|
|
806
|
+
|
|
807
|
+
# Change matplotlib font size to be larger
|
|
808
|
+
mpl.rcParams.update({'font.size': 12})
|
|
809
|
+
|
|
810
|
+
if len(uargs.output_file) == 1:
|
|
811
|
+
colours = ['black']
|
|
812
|
+
else:
|
|
813
|
+
colours = list(mcolors.TABLEAU_COLORS.values())
|
|
814
|
+
|
|
815
|
+
fig, ax = plt.subplots(1, 1, figsize=(6, 4))
|
|
816
|
+
oax = ax.twinx()
|
|
817
|
+
|
|
818
|
+
# Find unique name from multiple file names
|
|
819
|
+
if len(uargs.output_file) > 1:
|
|
820
|
+
base_names = [of.stem for of in uargs.output_file]
|
|
821
|
+
unique_names = ut.find_unique_substring(base_names)
|
|
822
|
+
legend = True
|
|
823
|
+
else:
|
|
824
|
+
legend = False
|
|
825
|
+
unique_names = ['']
|
|
826
|
+
|
|
827
|
+
# Handle x_shift argument
|
|
828
|
+
if uargs.x_shift is None:
|
|
829
|
+
uargs.x_shift = [0.0 for _ in uargs.output_file]
|
|
830
|
+
elif len(uargs.x_shift) != len(uargs.output_file):
|
|
831
|
+
ut.red_exit(
|
|
832
|
+
'Number of x_shift values must match number of output files'
|
|
833
|
+
)
|
|
834
|
+
|
|
835
|
+
for it, output_file in enumerate(uargs.output_file):
|
|
836
|
+
|
|
837
|
+
version = oe.OrcaVersionExtractor.extract(output_file)
|
|
838
|
+
|
|
839
|
+
if not len(version):
|
|
840
|
+
ut.cprint(
|
|
841
|
+
'Warning: Cannot find version number in Orca output file',
|
|
842
|
+
'black_yellowbg'
|
|
843
|
+
)
|
|
844
|
+
version = [6, 0, 0]
|
|
845
|
+
|
|
846
|
+
if version[0] < 6:
|
|
847
|
+
if uargs.intensities == 'electric':
|
|
848
|
+
all_datasets = oe.OldAbsorptionElectricDipoleExtractor.extract(
|
|
849
|
+
output_file
|
|
850
|
+
)
|
|
851
|
+
elif uargs.intensities == 'velocity':
|
|
852
|
+
all_datasets = oe.OldAbsorptionVelocityDipoleExtractor.extract(
|
|
853
|
+
output_file
|
|
854
|
+
)
|
|
855
|
+
elif version[0] >= 6:
|
|
856
|
+
if uargs.intensities == 'electric':
|
|
857
|
+
all_datasets = oe.AbsorptionElectricDipoleExtractor.extract(
|
|
858
|
+
output_file
|
|
859
|
+
)
|
|
860
|
+
elif uargs.intensities == 'velocity':
|
|
861
|
+
all_datasets = oe.AbsorptionVelocityDipoleExtractor.extract(
|
|
862
|
+
output_file
|
|
863
|
+
)
|
|
864
|
+
elif uargs.intensities == 'semi-classical':
|
|
865
|
+
all_datasets = oe.AbsorptionSemiClassicalDipoleExtractor.extract(
|
|
866
|
+
output_file
|
|
867
|
+
)
|
|
868
|
+
|
|
869
|
+
ut.cprint('Using intensities: {}'.format(uargs.intensities), 'cyan')
|
|
870
|
+
|
|
871
|
+
all_abs_data = [
|
|
872
|
+
d.AbsorptionData.from_extractor_dataset(
|
|
873
|
+
dataset,
|
|
874
|
+
uargs.intensities,
|
|
875
|
+
remove_zero_osc=True
|
|
876
|
+
)
|
|
877
|
+
for dataset in all_datasets
|
|
878
|
+
]
|
|
879
|
+
|
|
880
|
+
if len(all_abs_data) == 0:
|
|
881
|
+
ut.red_exit(
|
|
882
|
+
f'No ABSORPTION data found in file {output_file}', 'red'
|
|
883
|
+
)
|
|
884
|
+
elif len(all_abs_data) > 1:
|
|
885
|
+
ut.cprint(
|
|
886
|
+
f'Found {len(all_abs_data)} ABSORPTION sections in '
|
|
887
|
+
f'file {output_file}\n'
|
|
888
|
+
f'Plotting final section ONLY',
|
|
889
|
+
'cyan'
|
|
890
|
+
)
|
|
891
|
+
|
|
892
|
+
abs_data = all_abs_data[-1]
|
|
893
|
+
|
|
894
|
+
if uargs.x_unit == 'wavenumber':
|
|
895
|
+
x_vals = abs_data.wavenumbers
|
|
896
|
+
min_factor = 0.8
|
|
897
|
+
max_factor = 1.1
|
|
898
|
+
elif uargs.x_unit == 'wavelength':
|
|
899
|
+
x_vals = abs_data.wavelengths
|
|
900
|
+
max_factor = 1.1
|
|
901
|
+
min_factor = 0.8
|
|
902
|
+
elif uargs.x_unit == 'energy':
|
|
903
|
+
x_vals = abs_data.energies
|
|
904
|
+
min_factor = 0.9995
|
|
905
|
+
max_factor = 1.0005
|
|
906
|
+
|
|
907
|
+
# Set x_min and x_max
|
|
908
|
+
if isinstance(uargs.x_lim[0], str):
|
|
909
|
+
if uargs.x_lim[0] == 'auto':
|
|
910
|
+
x_min = min(x_vals) * min_factor
|
|
911
|
+
elif ut.is_floatable(uargs.x_lim[0]):
|
|
912
|
+
x_min = float(uargs.x_lim[0])
|
|
913
|
+
else:
|
|
914
|
+
raise ValueError(f'Invalid x_min value: {uargs.x_lim[0]}')
|
|
915
|
+
else:
|
|
916
|
+
x_min = uargs.x_lim[0]
|
|
917
|
+
|
|
918
|
+
if isinstance(uargs.x_lim[1], str):
|
|
919
|
+
if uargs.x_lim[1] == 'auto':
|
|
920
|
+
x_max = max(x_vals) * max_factor
|
|
921
|
+
elif ut.is_floatable(uargs.x_lim[1]):
|
|
922
|
+
x_max = float(uargs.x_lim[1])
|
|
923
|
+
else:
|
|
924
|
+
raise ValueError(f'Invalid x_max value: {uargs.x_lim[1]}')
|
|
925
|
+
else:
|
|
926
|
+
x_max = uargs.xlim[1]
|
|
927
|
+
|
|
928
|
+
# Generate spectrum
|
|
929
|
+
abs_data.generate_spectrum(
|
|
930
|
+
fwhm=uargs.linewidth,
|
|
931
|
+
lineshape=uargs.lineshape,
|
|
932
|
+
x_type=uargs.x_unit,
|
|
933
|
+
num_points=10000,
|
|
934
|
+
x_min=x_min,
|
|
935
|
+
x_max=x_max,
|
|
936
|
+
comment=unique_names[it]
|
|
937
|
+
)
|
|
938
|
+
|
|
939
|
+
# Plot absorption spectrum
|
|
940
|
+
plotter.plot_absorption_spectrum(
|
|
941
|
+
abs_data,
|
|
942
|
+
linecolor=colours[it],
|
|
943
|
+
stickcolour=colours[it],
|
|
944
|
+
osc_style=uargs.osc_style,
|
|
945
|
+
normalise=uargs.normalise,
|
|
946
|
+
window_title='',
|
|
947
|
+
fig=fig,
|
|
948
|
+
ax=ax,
|
|
949
|
+
oax=oax,
|
|
950
|
+
show=False,
|
|
951
|
+
save=False,
|
|
952
|
+
x_lim=[x_min, x_max],
|
|
953
|
+
y_lim=uargs.y_lim,
|
|
954
|
+
x_shift=uargs.x_shift[it],
|
|
955
|
+
legend=legend
|
|
956
|
+
)
|
|
957
|
+
|
|
958
|
+
if _SAVE_CONV[uargs.plot]:
|
|
959
|
+
plt.savefig('absorption_spectrum.png', dpi=500)
|
|
960
|
+
|
|
961
|
+
if _SHOW_CONV[uargs.plot]:
|
|
962
|
+
plt.show()
|
|
963
|
+
|
|
964
|
+
return
|
|
965
|
+
|
|
966
|
+
|
|
795
967
|
def plot_ir_func(uargs):
|
|
796
968
|
'''
|
|
797
969
|
Wrapper for CLI plot_ir call
|
|
@@ -811,12 +983,7 @@ def plot_ir_func(uargs):
|
|
|
811
983
|
from . import extractor as oe
|
|
812
984
|
|
|
813
985
|
# Set user specified font name
|
|
814
|
-
|
|
815
|
-
try:
|
|
816
|
-
plt.rcParams['font.family'] = os.getenv('orto_fontname')
|
|
817
|
-
except ValueError:
|
|
818
|
-
ut.cprint('Error in orto_fontname environment variable', 'red')
|
|
819
|
-
sys.exit(1)
|
|
986
|
+
ut.check_font_envvar()
|
|
820
987
|
|
|
821
988
|
# Change matplotlib font size to be larger
|
|
822
989
|
mpl.rcParams.update({'font.size': 12})
|
|
@@ -1728,7 +1895,7 @@ def read_args(arg_list=None):
|
|
|
1728
1895
|
|
|
1729
1896
|
plot_abs = plot_parser.add_parser(
|
|
1730
1897
|
'abs',
|
|
1731
|
-
description='Plots absorption spectrum from CI calculation output',
|
|
1898
|
+
description='Plots absorption spectrum from TDDFT/CI calculation output', # noqa
|
|
1732
1899
|
usage=ut.cstring('orto plot abs <output_file> [options]', 'cyan'),
|
|
1733
1900
|
formatter_class=argparse.RawTextHelpFormatter
|
|
1734
1901
|
)
|
|
@@ -1739,6 +1906,7 @@ def read_args(arg_list=None):
|
|
|
1739
1906
|
plot_abs.add_argument(
|
|
1740
1907
|
'output_file',
|
|
1741
1908
|
type=pathlib.Path,
|
|
1909
|
+
nargs='+',
|
|
1742
1910
|
help='Orca output file name'
|
|
1743
1911
|
)
|
|
1744
1912
|
|
|
@@ -1755,17 +1923,17 @@ def read_args(arg_list=None):
|
|
|
1755
1923
|
'--linewidth',
|
|
1756
1924
|
'-lw',
|
|
1757
1925
|
type=float,
|
|
1758
|
-
default=
|
|
1926
|
+
default=1,
|
|
1759
1927
|
help=(
|
|
1760
1928
|
'Width of signal (FWHM for Gaussian, Width for Lorentzian),'
|
|
1761
|
-
' in
|
|
1929
|
+
' in same unit as x axis'
|
|
1762
1930
|
)
|
|
1763
1931
|
)
|
|
1764
1932
|
|
|
1765
1933
|
plot_abs.add_argument(
|
|
1766
1934
|
'--osc_style',
|
|
1767
1935
|
type=str,
|
|
1768
|
-
default='
|
|
1936
|
+
default='separate',
|
|
1769
1937
|
help=(
|
|
1770
1938
|
'Style of oscillators to plot\n'
|
|
1771
1939
|
' - \'separate\' plots oscillator strengths as stems on separate axis\n' # noqa
|
|
@@ -1804,18 +1972,19 @@ def read_args(arg_list=None):
|
|
|
1804
1972
|
plot_abs.add_argument(
|
|
1805
1973
|
'--x_unit',
|
|
1806
1974
|
type=str,
|
|
1807
|
-
choices=['
|
|
1808
|
-
default='
|
|
1975
|
+
choices=['energy', 'wavelength', 'wavenumber'],
|
|
1976
|
+
default='energy',
|
|
1809
1977
|
help='x units to use for spectrum'
|
|
1810
1978
|
)
|
|
1811
1979
|
|
|
1812
1980
|
plot_abs.add_argument(
|
|
1813
|
-
'--
|
|
1981
|
+
'--x_shift',
|
|
1814
1982
|
type=float,
|
|
1815
|
-
default=
|
|
1983
|
+
default=None,
|
|
1984
|
+
nargs='+',
|
|
1816
1985
|
help=(
|
|
1817
1986
|
'Shift spectrum by this amount in x units\n'
|
|
1818
|
-
'Default:
|
|
1987
|
+
'Default: 0.'
|
|
1819
1988
|
)
|
|
1820
1989
|
)
|
|
1821
1990
|
|
orto/constants.py
CHANGED