orto 1.11.2__tar.gz → 1.11.3__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.11.2 → orto-1.11.3}/PKG-INFO +1 -1
- orto-1.11.3/orto/__version__.py +1 -0
- {orto-1.11.2 → orto-1.11.3}/orto/cli.py +119 -66
- {orto-1.11.2 → orto-1.11.3}/orto/plotter.py +19 -2
- {orto-1.11.2 → orto-1.11.3}/orto.egg-info/PKG-INFO +1 -1
- {orto-1.11.2 → orto-1.11.3}/setup.py +1 -1
- orto-1.11.2/orto/__version__.py +0 -1
- {orto-1.11.2 → orto-1.11.3}/LICENSE +0 -0
- {orto-1.11.2 → orto-1.11.3}/README.md +0 -0
- {orto-1.11.2 → orto-1.11.3}/orto/__init__.py +0 -0
- {orto-1.11.2 → orto-1.11.3}/orto/constants.py +0 -0
- {orto-1.11.2 → orto-1.11.3}/orto/data.py +0 -0
- {orto-1.11.2 → orto-1.11.3}/orto/exceptions.py +0 -0
- {orto-1.11.2 → orto-1.11.3}/orto/extractor.py +0 -0
- {orto-1.11.2 → orto-1.11.3}/orto/input.py +0 -0
- {orto-1.11.2 → orto-1.11.3}/orto/job.py +0 -0
- {orto-1.11.2 → orto-1.11.3}/orto/utils.py +0 -0
- {orto-1.11.2 → orto-1.11.3}/orto.egg-info/SOURCES.txt +0 -0
- {orto-1.11.2 → orto-1.11.3}/orto.egg-info/dependency_links.txt +0 -0
- {orto-1.11.2 → orto-1.11.3}/orto.egg-info/entry_points.txt +0 -0
- {orto-1.11.2 → orto-1.11.3}/orto.egg-info/requires.txt +0 -0
- {orto-1.11.2 → orto-1.11.3}/orto.egg-info/top_level.txt +0 -0
- {orto-1.11.2 → orto-1.11.3}/pyproject.toml +0 -0
- {orto-1.11.2 → orto-1.11.3}/setup.cfg +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = '1.11.3'
|
|
@@ -1098,42 +1098,12 @@ def plot_abs_func(uargs, save_data_only=False):
|
|
|
1098
1098
|
-------
|
|
1099
1099
|
None
|
|
1100
1100
|
'''
|
|
1101
|
-
import matplotlib.pyplot as plt
|
|
1102
|
-
import matplotlib as mpl
|
|
1103
|
-
import matplotlib.colors as mcolors
|
|
1104
1101
|
from . import plotter
|
|
1105
1102
|
from . import extractor as oe
|
|
1106
1103
|
from . import data as d
|
|
1107
1104
|
|
|
1108
|
-
# Change matplotlib font size to be larger
|
|
1109
|
-
mpl.rcParams.update({'font.size': 12})
|
|
1110
|
-
# Set user specified font name
|
|
1111
|
-
ut.check_font_envvar()
|
|
1112
|
-
|
|
1113
|
-
# Change matplotlib font size to be larger
|
|
1114
|
-
mpl.rcParams.update({'font.size': 12})
|
|
1115
|
-
|
|
1116
|
-
if len(uargs.output_file) == 1:
|
|
1117
|
-
colours = ['black']
|
|
1118
|
-
else:
|
|
1119
|
-
colours = list(mcolors.TABLEAU_COLORS.values())
|
|
1120
1105
|
|
|
1121
|
-
|
|
1122
|
-
oax = ax.twinx()
|
|
1123
|
-
|
|
1124
|
-
# Find unique name from multiple file names
|
|
1125
|
-
if len(uargs.output_file) > 1:
|
|
1126
|
-
if uargs.unique_names:
|
|
1127
|
-
base_names = [of.stem for of in uargs.output_file]
|
|
1128
|
-
unique_names = ut.find_unique_substring(base_names)
|
|
1129
|
-
else:
|
|
1130
|
-
unique_names = [of.stem for of in uargs.output_file]
|
|
1131
|
-
legend = True
|
|
1132
|
-
else:
|
|
1133
|
-
legend = False
|
|
1134
|
-
unique_names = ['']
|
|
1135
|
-
|
|
1136
|
-
# Handle x_shift argument
|
|
1106
|
+
# Process x_shift argument
|
|
1137
1107
|
if uargs.x_shift is None:
|
|
1138
1108
|
uargs.x_shift = [0.0 for _ in uargs.output_file]
|
|
1139
1109
|
elif len(uargs.x_shift) != len(uargs.output_file):
|
|
@@ -1141,6 +1111,10 @@ def plot_abs_func(uargs, save_data_only=False):
|
|
|
1141
1111
|
'Number of x_shift values must match number of output files'
|
|
1142
1112
|
)
|
|
1143
1113
|
|
|
1114
|
+
# Create dictionary to hold absorption data for plotting later
|
|
1115
|
+
spectra_dict = {}
|
|
1116
|
+
|
|
1117
|
+
# Extract data from each output file
|
|
1144
1118
|
for it, output_file in enumerate(uargs.output_file):
|
|
1145
1119
|
|
|
1146
1120
|
version = oe.OrcaVersionExtractor.extract(output_file)
|
|
@@ -1152,6 +1126,9 @@ def plot_abs_func(uargs, save_data_only=False):
|
|
|
1152
1126
|
)
|
|
1153
1127
|
version = [6, 0, 0]
|
|
1154
1128
|
|
|
1129
|
+
# Extract absorption data from file
|
|
1130
|
+
# using appropriate extractor for version
|
|
1131
|
+
# and intensity type
|
|
1155
1132
|
if version[0] < 6:
|
|
1156
1133
|
if uargs.intensities == 'electric':
|
|
1157
1134
|
all_datasets = oe.OldAbsorptionElectricDipoleExtractor.extract(
|
|
@@ -1177,6 +1154,9 @@ def plot_abs_func(uargs, save_data_only=False):
|
|
|
1177
1154
|
|
|
1178
1155
|
ut.cprint('Using intensities: {}'.format(uargs.intensities), 'cyan')
|
|
1179
1156
|
|
|
1157
|
+
# Create absorption data object
|
|
1158
|
+
# one per dataset extracted
|
|
1159
|
+
# (doubtful multiple datasets will be present, but just in case)
|
|
1180
1160
|
all_abs_data = [
|
|
1181
1161
|
d.AbsorptionData.from_extractor_dataset(
|
|
1182
1162
|
dataset,
|
|
@@ -1186,10 +1166,12 @@ def plot_abs_func(uargs, save_data_only=False):
|
|
|
1186
1166
|
for dataset in all_datasets
|
|
1187
1167
|
]
|
|
1188
1168
|
|
|
1169
|
+
# Check absorption data was found
|
|
1189
1170
|
if len(all_abs_data) == 0:
|
|
1190
1171
|
ut.red_exit(
|
|
1191
1172
|
f'No ABSORPTION data found in file {output_file}', 'red'
|
|
1192
1173
|
)
|
|
1174
|
+
# report if multiple absorption sections found
|
|
1193
1175
|
elif len(all_abs_data) > 1:
|
|
1194
1176
|
ut.cprint(
|
|
1195
1177
|
f'Found {len(all_abs_data)} ABSORPTION sections in '
|
|
@@ -1197,9 +1179,11 @@ def plot_abs_func(uargs, save_data_only=False):
|
|
|
1197
1179
|
f'Plotting final section ONLY',
|
|
1198
1180
|
'cyan'
|
|
1199
1181
|
)
|
|
1200
|
-
|
|
1182
|
+
# and only use final one
|
|
1183
|
+
# (again, doubtful multiple sections will be present, but just in case)
|
|
1201
1184
|
abs_data = all_abs_data[-1]
|
|
1202
1185
|
|
|
1186
|
+
# Determine x values for setting x limits of computed spectrum
|
|
1203
1187
|
if uargs.x_unit == 'wavenumber':
|
|
1204
1188
|
x_vals = abs_data.wavenumbers
|
|
1205
1189
|
min_factor = 0.8
|
|
@@ -1222,7 +1206,8 @@ def plot_abs_func(uargs, save_data_only=False):
|
|
|
1222
1206
|
max_factor = 1.0005
|
|
1223
1207
|
x_reversed = False
|
|
1224
1208
|
|
|
1225
|
-
# Set x_min
|
|
1209
|
+
# Set x_min
|
|
1210
|
+
# based on user arguments
|
|
1226
1211
|
if isinstance(uargs.x_lim[0], str):
|
|
1227
1212
|
if uargs.x_lim[0] == 'auto':
|
|
1228
1213
|
x_min = min(x_vals) * min_factor
|
|
@@ -1233,6 +1218,8 @@ def plot_abs_func(uargs, save_data_only=False):
|
|
|
1233
1218
|
else:
|
|
1234
1219
|
x_min = uargs.x_lim[0]
|
|
1235
1220
|
|
|
1221
|
+
# Set x_max
|
|
1222
|
+
# based on user arguments
|
|
1236
1223
|
if isinstance(uargs.x_lim[1], str):
|
|
1237
1224
|
if uargs.x_lim[1] == 'auto':
|
|
1238
1225
|
x_max = max(x_vals) * max_factor
|
|
@@ -1247,7 +1234,7 @@ def plot_abs_func(uargs, save_data_only=False):
|
|
|
1247
1234
|
if uargs.trim_transitions is not None:
|
|
1248
1235
|
abs_data.trim_to_n(uargs.trim_transitions)
|
|
1249
1236
|
|
|
1250
|
-
# Generate spectrum
|
|
1237
|
+
# Generate spectrum data
|
|
1251
1238
|
abs_data.generate_spectrum(
|
|
1252
1239
|
fwhm=uargs.linewidth,
|
|
1253
1240
|
lineshape=uargs.lineshape,
|
|
@@ -1255,12 +1242,12 @@ def plot_abs_func(uargs, save_data_only=False):
|
|
|
1255
1242
|
num_points=10000,
|
|
1256
1243
|
x_min=x_min,
|
|
1257
1244
|
x_max=x_max,
|
|
1258
|
-
comment=
|
|
1245
|
+
comment=output_file,
|
|
1259
1246
|
x_reversed=x_reversed
|
|
1260
1247
|
)
|
|
1261
1248
|
|
|
1249
|
+
# Save spectrum data to file
|
|
1262
1250
|
if save_data_only:
|
|
1263
|
-
# Save spectrum data to file
|
|
1264
1251
|
abs_data.save_spectrum_data(
|
|
1265
1252
|
f'absorption_spectrum_{output_file.stem}.csv',
|
|
1266
1253
|
comments='Data from {}\nfwhm={}, lineshape={}\nintensities={}'.format( # noqa
|
|
@@ -1286,33 +1273,98 @@ def plot_abs_func(uargs, save_data_only=False):
|
|
|
1286
1273
|
'cyan'
|
|
1287
1274
|
)
|
|
1288
1275
|
else:
|
|
1289
|
-
#
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1276
|
+
# Add to dictionary of spectra for plotting later
|
|
1277
|
+
spectra_dict[output_file] = abs_data
|
|
1278
|
+
|
|
1279
|
+
# Exit if only saving data
|
|
1280
|
+
if save_data_only:
|
|
1281
|
+
return
|
|
1282
|
+
|
|
1283
|
+
## Plot all spectra
|
|
1284
|
+
import matplotlib.pyplot as plt
|
|
1285
|
+
import matplotlib.colors as mcolors
|
|
1286
|
+
|
|
1287
|
+
# Set font name and size
|
|
1288
|
+
plt.rcParams['font.family'] = 'Arial'
|
|
1289
|
+
plt.rcParams['font.size'] = 10
|
|
1290
|
+
plt.rcParams['legend.fontsize'] = 9
|
|
1291
|
+
plt.rcParams['legend.loc'] = 'center right'
|
|
1292
|
+
|
|
1293
|
+
# Create list of colours for plotting
|
|
1294
|
+
if len(uargs.output_file) == 1:
|
|
1295
|
+
colours = ['black']
|
|
1296
|
+
else:
|
|
1297
|
+
colours = list(mcolors.TABLEAU_COLORS.values())
|
|
1307
1298
|
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1299
|
+
# Width of figure in inches
|
|
1300
|
+
# Make wider if multiple spectra to plot
|
|
1301
|
+
# to include legend
|
|
1302
|
+
if len(spectra_dict) > 1:
|
|
1303
|
+
width = 6.
|
|
1304
|
+
else:
|
|
1305
|
+
width = 4
|
|
1306
|
+
# width in cm
|
|
1307
|
+
width_cm = 2.54 * width
|
|
1308
|
+
|
|
1309
|
+
# Create figure and axis with
|
|
1310
|
+
# height based on golden ratio
|
|
1311
|
+
golden = (1 + np.sqrt(5))/2
|
|
1312
|
+
fig, ax = plt.subplots(
|
|
1313
|
+
1,
|
|
1314
|
+
1,
|
|
1315
|
+
num='Absorption Spectrum',
|
|
1316
|
+
figsize=(width, 4. / golden)
|
|
1317
|
+
)
|
|
1318
|
+
# Secondary axis for oscillator strength sticks
|
|
1319
|
+
oax = ax.twinx()
|
|
1313
1320
|
|
|
1314
|
-
|
|
1315
|
-
|
|
1321
|
+
# Plot absorption spectrum for each file
|
|
1322
|
+
for it, (output_file, abs_data) in enumerate(spectra_dict.items()): # noqa
|
|
1323
|
+
|
|
1324
|
+
plotter.plot_absorption_spectrum(
|
|
1325
|
+
abs_data,
|
|
1326
|
+
linecolor=colours[it],
|
|
1327
|
+
stickcolour=colours[it],
|
|
1328
|
+
osc_style=uargs.osc_style,
|
|
1329
|
+
normalise=uargs.normalise,
|
|
1330
|
+
window_title='',
|
|
1331
|
+
fig=fig,
|
|
1332
|
+
ax=ax,
|
|
1333
|
+
oax=oax,
|
|
1334
|
+
show=False,
|
|
1335
|
+
save=False,
|
|
1336
|
+
x_lim=[x_min, x_max],
|
|
1337
|
+
y_lim=uargs.y_lim,
|
|
1338
|
+
x_shift=uargs.x_shift[it],
|
|
1339
|
+
legend=False
|
|
1340
|
+
)
|
|
1341
|
+
|
|
1342
|
+
if uargs.x_lim != ['auto', 'auto']:
|
|
1343
|
+
ax.set_xlim(float(uargs.x_lim[0]), float(uargs.x_lim[1]))
|
|
1344
|
+
|
|
1345
|
+
fig.tight_layout()
|
|
1346
|
+
|
|
1347
|
+
if len(spectra_dict) > 1:
|
|
1348
|
+
fig.subplots_adjust(right=3.3/6.)
|
|
1349
|
+
if uargs.legend is None:
|
|
1350
|
+
legend_labels = [
|
|
1351
|
+
f'{output_file.stem}' for output_file in spectra_dict.keys()
|
|
1352
|
+
]
|
|
1353
|
+
fig.legend(legend_labels, loc=7)
|
|
1354
|
+
else:
|
|
1355
|
+
fig.legend(uargs.legend, loc=7)
|
|
1356
|
+
|
|
1357
|
+
if _SAVE_CONV[uargs.plot]:
|
|
1358
|
+
savename = f'absorption_spectrum_{output_file.stem}.png'
|
|
1359
|
+
plt.savefig(savename, dpi=500)
|
|
1360
|
+
ut.cprint(f'Saved image to {savename}', 'cyan')
|
|
1361
|
+
ut.cprint(
|
|
1362
|
+
f'Use width={width:.1f} in. or {width_cm:.1f} cm',
|
|
1363
|
+
'cyan'
|
|
1364
|
+
)
|
|
1365
|
+
|
|
1366
|
+
if _SHOW_CONV[uargs.plot]:
|
|
1367
|
+
plt.show()
|
|
1316
1368
|
|
|
1317
1369
|
return
|
|
1318
1370
|
|
|
@@ -2604,12 +2656,13 @@ def read_args(arg_list=None):
|
|
|
2604
2656
|
)
|
|
2605
2657
|
|
|
2606
2658
|
plot_abs.add_argument(
|
|
2607
|
-
'--
|
|
2608
|
-
|
|
2609
|
-
|
|
2659
|
+
'--legend',
|
|
2660
|
+
type=str,
|
|
2661
|
+
nargs='+',
|
|
2662
|
+
default=None,
|
|
2610
2663
|
help=(
|
|
2611
|
-
'
|
|
2612
|
-
'
|
|
2664
|
+
'Legend labels for each spectrum plotted\n'
|
|
2665
|
+
'If not provided, file names are used\n'
|
|
2613
2666
|
)
|
|
2614
2667
|
)
|
|
2615
2668
|
|
|
@@ -79,7 +79,18 @@ def plot_absorption_spectrum(abs_data: data.AbsorptionData,
|
|
|
79
79
|
raise ValueError('AbsorptionData object does not contain spectrum')
|
|
80
80
|
|
|
81
81
|
if fig is None or ax is None:
|
|
82
|
-
|
|
82
|
+
width = 4
|
|
83
|
+
width_cm = 10.4
|
|
84
|
+
golden = (1 + np.sqrt(5))/2
|
|
85
|
+
fig, ax = plt.subplots(
|
|
86
|
+
1,
|
|
87
|
+
1,
|
|
88
|
+
num=window_title,
|
|
89
|
+
figsize=(width, width / golden)
|
|
90
|
+
)
|
|
91
|
+
else:
|
|
92
|
+
width = fig.get_size_inches()[0]
|
|
93
|
+
width_cm = width * 2.54
|
|
83
94
|
|
|
84
95
|
if oax is None and osc_style == 'separate':
|
|
85
96
|
oax = ax.twinx()
|
|
@@ -143,18 +154,20 @@ def plot_absorption_spectrum(abs_data: data.AbsorptionData,
|
|
|
143
154
|
x_values,
|
|
144
155
|
_y_values,
|
|
145
156
|
color=linecolor,
|
|
157
|
+
lw=1.1,
|
|
146
158
|
label=abs_data.spectrum.comment
|
|
147
159
|
)
|
|
148
160
|
|
|
149
161
|
if osc_style == 'separate':
|
|
150
162
|
# Oscillator strength twin axis
|
|
151
|
-
oax.stem(
|
|
163
|
+
_, stemlines, _ = oax.stem(
|
|
152
164
|
stick_x_values,
|
|
153
165
|
_osc,
|
|
154
166
|
basefmt=' ',
|
|
155
167
|
markerfmt=' ',
|
|
156
168
|
linefmt=stickcolour
|
|
157
169
|
)
|
|
170
|
+
plt.setp(stemlines, 'linewidth', 1.1)
|
|
158
171
|
oax.yaxis.set_minor_locator(AutoMinorLocator())
|
|
159
172
|
if normalise:
|
|
160
173
|
oax.set_ylabel(r'Normalised $f_\mathregular{osc}$')
|
|
@@ -218,6 +231,10 @@ def plot_absorption_spectrum(abs_data: data.AbsorptionData,
|
|
|
218
231
|
f'\nSpectrum saved to\n {save_name}',
|
|
219
232
|
'cyan'
|
|
220
233
|
)
|
|
234
|
+
ut.cprint(
|
|
235
|
+
f'Use width={width:.1f} in. or {width_cm:.1f} cm',
|
|
236
|
+
'cyan'
|
|
237
|
+
)
|
|
221
238
|
|
|
222
239
|
if show:
|
|
223
240
|
plt.show()
|
orto-1.11.2/orto/__version__.py
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = '1.11.2'
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|