orto 1.3.0__py3-none-any.whl → 1.4.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 CHANGED
@@ -1 +1 @@
1
- __version__ = '1.3.0'
1
+ __version__ = '1.4.0'
orto/cli.py CHANGED
@@ -593,28 +593,30 @@ def plot_abs_func(uargs):
593
593
  version = [6, 0, 0]
594
594
 
595
595
  if version[0] < 6:
596
- if uargs.intensity_type == 'electric':
596
+ if uargs.intensities == 'electric':
597
597
  all_data = oe.OldAbsorptionElectricDipoleExtractor.extract(
598
598
  uargs.output_file
599
599
  )
600
- elif uargs.intensity_type == 'velocity':
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.intensity_type == 'electric':
605
+ if uargs.intensities == 'electric':
606
606
  all_data = oe.AbsorptionElectricDipoleExtractor.extract(
607
607
  uargs.output_file
608
608
  )
609
- elif uargs.intensity_type == 'velocity':
609
+ elif uargs.intensities == 'velocity':
610
610
  all_data = oe.AbsorptionVelocityDipoleExtractor.extract(
611
611
  uargs.output_file
612
612
  )
613
- elif uargs.intensity_type == 'semi-classical':
613
+ elif uargs.intensities == 'semi-classical':
614
614
  all_data = oe.AbsorptionSemiClassicalDipoleExtractor.extract(
615
615
  uargs.output_file
616
616
  )
617
617
 
618
+ ut.cprint('Using intensities: {}'.format(uargs.intensities), 'cyan')
619
+
618
620
  # Plot each section
619
621
  for it, data in enumerate(all_data):
620
622
 
@@ -644,7 +646,7 @@ def plot_abs_func(uargs):
644
646
  linewidth=uargs.linewidth,
645
647
  lineshape=uargs.lineshape,
646
648
  window_title=f'Absorption Spectrum from {uargs.output_file}',
647
- show_osc=not uargs.no_osc,
649
+ osc_style=uargs.osc_style,
648
650
  normalise=uargs.normalise_absorption
649
651
  )
650
652
 
@@ -1606,7 +1608,7 @@ def read_args(arg_list=None):
1606
1608
  )
1607
1609
 
1608
1610
  plot_abs.add_argument(
1609
- '--intensity_type',
1611
+ '--intensities',
1610
1612
  '-i',
1611
1613
  type=str,
1612
1614
  choices=['velocity', 'electric', 'semi-classical'],
@@ -1626,10 +1628,15 @@ def read_args(arg_list=None):
1626
1628
  )
1627
1629
 
1628
1630
  plot_abs.add_argument(
1629
- '--no_osc',
1630
- action='store_true',
1631
+ '--osc_style',
1632
+ type=str,
1633
+ default='combined',
1631
1634
  help=(
1632
- 'Disables oscillator strength stem plots'
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'
1633
1640
  )
1634
1641
  )
1635
1642
 
orto/plotter.py CHANGED
@@ -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
 
@@ -81,8 +82,9 @@ def plot_abs(x_values: ArrayLike, x_type: str, foscs: ArrayLike,
81
82
  abs_type: str = 'napierian',
82
83
  y_lim: list[float] = [0., 'auto'],
83
84
  x_shift: float = 0., normalise: bool = False,
84
- show_osc: bool = True, save: bool = False,
85
+ osc_style: str = 'separate', save: bool = False,
85
86
  save_name: str = 'absorption_spectrum.png', show: bool = False,
87
+ verbose: bool = True,
86
88
  window_title: str = 'Absorption Spectrum') -> tuple[plt.Figure, list[plt.Axes]]: # noqa
87
89
  '''
88
90
  Plots absorption spectrum with intensity specified by oscillator strength.\n # noqa
@@ -112,14 +114,19 @@ def plot_abs(x_values: ArrayLike, x_type: str, foscs: ArrayLike,
112
114
  Absorbance (and epsilon) type to use. Orca_mapspc uses napierian
113
115
  normalise: bool, default False
114
116
  If True, normalise the absorption spectrum to the maximum value.
115
- show_osc: bool, default True
116
- If True, show oscillator strength stemplots
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
117
122
  save: bool, default False
118
123
  If True, plot is saved to save_name
119
- save_name: str
124
+ save_name: str | pathlib.Path, default 'absorption_spectrum.png'
120
125
  If save is True, plot is saved to this location/filename
121
126
  show: bool, default False
122
127
  If True, plot is shown on screen
128
+ verbose: bool, default True
129
+ If True, plot file location is written to terminal
123
130
  window_title: str, default 'UV-Visible Absorption Spectrum'
124
131
  Title of figure window, not of plot
125
132
 
@@ -132,6 +139,8 @@ def plot_abs(x_values: ArrayLike, x_type: str, foscs: ArrayLike,
132
139
  Matplotlib Axis object for twinx oscillator strength axis
133
140
  '''
134
141
 
142
+ save_name = pathlib.Path(save_name)
143
+
135
144
  x_values = np.asarray(x_values) + x_shift
136
145
  foscs = np.asarray(foscs)
137
146
  if len(x_values) != len(foscs):
@@ -199,20 +208,43 @@ def plot_abs(x_values: ArrayLike, x_type: str, foscs: ArrayLike,
199
208
  else:
200
209
  ax.set_ylabel(r'$\epsilon$ (cm$^\mathregular{-1}$ mol$^\mathregular{-1}$ L)') # noqa
201
210
 
202
- np.savetxt('spectrum.txt', np.vstack([x_grid, spectrum]).T, fmt='%.5f')
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
+ )
203
223
 
204
224
  # Main spectrum
205
225
  ax.plot(x_grid, spectrum, color='k')
206
226
 
207
- if show_osc:
227
+ if osc_style == 'separate':
208
228
  fax = ax.twinx()
209
229
  # Oscillator strength twin axis
210
- plt.stem(x_values, foscs, basefmt=' ')
230
+ fax.stem(x_values, foscs, basefmt=' ', markerfmt=' ')
211
231
  fax.yaxis.set_minor_locator(AutoMinorLocator())
212
232
  fax.set_ylabel(r'$f_\mathregular{osc}$')
213
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)
214
245
  else:
215
246
  fax = None
247
+ # No oscillator strength plot
216
248
  plt.subplots_adjust(right=0.2)
217
249
  ax.spines['right'].set_visible(False)
218
250
  ax.spines['top'].set_visible(False)
@@ -245,7 +277,9 @@ def plot_abs(x_values: ArrayLike, x_type: str, foscs: ArrayLike,
245
277
 
246
278
  if save:
247
279
  plt.savefig(save_name, dpi=500)
248
-
280
+ if verbose:
281
+ ut.cprint(f'\nAbsorption spectrum saved to\n {save_name}', 'cyan')
282
+
249
283
  if show:
250
284
  plt.show()
251
285
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: orto
3
- Version: 1.3.0
3
+ Version: 1.4.0
4
4
  Summary: A package to make life easier when performing Orca calculations.
5
5
  Home-page: https://orto.kragskow.group
6
6
  Author: Jon Kragskow
@@ -1,15 +1,15 @@
1
1
  orto/__init__.py,sha256=IedlltYr3qYZxChNUdz62qogXA9Pos_MUvXdGXqAa0E,41
2
- orto/__version__.py,sha256=zi_LaUT_OsChAtsPXbOeRpQkCohSsOyeXfavQPM0GoE,22
3
- orto/cli.py,sha256=_PVQjeH1mIy_P-WegHllvpGWzhNaEpQuAA8Ht-PkLKQ,63161
2
+ orto/__version__.py,sha256=EyMGX1ADFzN6XVXHWbJUtKPONYKeFkvWoKIFPDDB2I8,22
3
+ orto/cli.py,sha256=CvRhsHcUs0PjoxqqxKiCkqNZySn8z1HfbBBoi9JbLDc,63487
4
4
  orto/constants.py,sha256=2obWYg306Lce4U9Qs4MHg1yZq7SHFkazG-cnkD5svpo,343
5
5
  orto/exceptions.py,sha256=D7oNeAEGeJNt5thzt6PaCn5FY6JcbJOWUE1N1LVhhuE,159
6
6
  orto/extractor.py,sha256=NJaqpH6iLtzEMuYGJrpbZ5vKJrtE5rQOXLLPjm0acGQ,69536
7
7
  orto/input.py,sha256=N8JbySSVEC_qmXZ7ppJsZ7Z1qel6PfalGYRtnX1hJ6U,9900
8
8
  orto/job.py,sha256=SM0nlc_bqhhPvfuuykhMvaUnkwC3Gp-6RvYw_a0TyGc,5855
9
- orto/plotter.py,sha256=vXEfFLxdejt0YbKgCI4PUgBBX3a7SfGlqOQY0Mh4Wak,17562
9
+ orto/plotter.py,sha256=onvevzjbhsb18DY8DiMGuDOLOjQ-Ore6eBybMkIUs7U,18817
10
10
  orto/utils.py,sha256=gVfGplkfc6xGYgLMi_7I_yAdWG-QKRaqQdy9v5F4Mck,7279
11
- orto-1.3.0.dist-info/METADATA,sha256=1fJYXo4-HhO0oB_CPjen8HldS-iatuOeSzm7KDiHLB0,1140
12
- orto-1.3.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
13
- orto-1.3.0.dist-info/entry_points.txt,sha256=HXenCglMp_03JkN34pK2phkjXK9CFcXTGHKv5QaVY8I,39
14
- orto-1.3.0.dist-info/top_level.txt,sha256=hQ-z28gTN_FZ2B5Kiwxr_9cUTcCoib9W5HjbkceDXw4,5
15
- orto-1.3.0.dist-info/RECORD,,
11
+ orto-1.4.0.dist-info/METADATA,sha256=TFoHVG_EWEI1lBEltHKXyQ7AnUw3b5yYZeT6MJq8JyU,1140
12
+ orto-1.4.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
13
+ orto-1.4.0.dist-info/entry_points.txt,sha256=HXenCglMp_03JkN34pK2phkjXK9CFcXTGHKv5QaVY8I,39
14
+ orto-1.4.0.dist-info/top_level.txt,sha256=hQ-z28gTN_FZ2B5Kiwxr_9cUTcCoib9W5HjbkceDXw4,5
15
+ orto-1.4.0.dist-info/RECORD,,
File without changes