orto 1.12.0__py3-none-any.whl → 1.13.1__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 +378 -249
- orto/data.py +129 -3
- orto/extractor.py +81 -12
- orto/plotter.py +163 -118
- orto/utils.py +43 -1
- {orto-1.12.0.dist-info → orto-1.13.1.dist-info}/METADATA +3 -3
- orto-1.13.1.dist-info/RECORD +17 -0
- orto-1.12.0.dist-info/RECORD +0 -17
- {orto-1.12.0.dist-info → orto-1.13.1.dist-info}/WHEEL +0 -0
- {orto-1.12.0.dist-info → orto-1.13.1.dist-info}/entry_points.txt +0 -0
- {orto-1.12.0.dist-info → orto-1.13.1.dist-info}/licenses/LICENSE +0 -0
- {orto-1.12.0.dist-info → orto-1.13.1.dist-info}/top_level.txt +0 -0
orto/data.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import numpy as np
|
|
2
2
|
from numpy.typing import NDArray, ArrayLike
|
|
3
|
+
import pandas as pd
|
|
3
4
|
|
|
4
5
|
from .exceptions import DataFormattingError
|
|
5
6
|
from . import constants as const
|
|
@@ -188,11 +189,11 @@ class AbsorptionData():
|
|
|
188
189
|
def from_extractor(cls, extractor: oe.AbsorptionExtractor,
|
|
189
190
|
remove_zero_osc: float = 1E-4) -> list['AbsorptionData']: # noqa
|
|
190
191
|
'''
|
|
191
|
-
Creates AbsorptionData object from data extractor
|
|
192
|
+
Creates AbsorptionData object(s) from data extractor
|
|
192
193
|
|
|
193
194
|
Parameters
|
|
194
195
|
----------
|
|
195
|
-
extractor:
|
|
196
|
+
extractor: oe.AbsorptionExtractor
|
|
196
197
|
Data extractor object containing transition data
|
|
197
198
|
remove_zero_osc: float, default=1E-4
|
|
198
199
|
Remove transitions with oscillator strength below this value
|
|
@@ -220,7 +221,7 @@ class AbsorptionData():
|
|
|
220
221
|
operator: str,
|
|
221
222
|
remove_zero_osc: float = 1E-7) -> 'AbsorptionData': # noqa
|
|
222
223
|
'''
|
|
223
|
-
Creates AbsorptionData object from data extractor
|
|
224
|
+
Creates AbsorptionData object(s) from data extractor
|
|
224
225
|
|
|
225
226
|
Parameters
|
|
226
227
|
----------
|
|
@@ -458,3 +459,128 @@ class AbsorptionData():
|
|
|
458
459
|
header=header,
|
|
459
460
|
comments='#',
|
|
460
461
|
)
|
|
462
|
+
|
|
463
|
+
|
|
464
|
+
class SusceptibilityData():
|
|
465
|
+
'''
|
|
466
|
+
Stores magnetic susceptibility data
|
|
467
|
+
|
|
468
|
+
Parameters
|
|
469
|
+
----------
|
|
470
|
+
chis: array_like
|
|
471
|
+
Susceptibility values in cm^3 K mol^-1
|
|
472
|
+
temperatures: array_like
|
|
473
|
+
Temperatures in K
|
|
474
|
+
field: float
|
|
475
|
+
Static magnetic field in Oe
|
|
476
|
+
|
|
477
|
+
Attributes
|
|
478
|
+
----------
|
|
479
|
+
chis: ndarray of floats
|
|
480
|
+
Susceptibility values in cm^3 K mol^-1
|
|
481
|
+
temperature: ndarray of floats
|
|
482
|
+
Temperatures in K
|
|
483
|
+
field: float
|
|
484
|
+
Static magnetic field in Oe
|
|
485
|
+
'''
|
|
486
|
+
|
|
487
|
+
def __init__(self, chis: ArrayLike, temperatures: ArrayLike,
|
|
488
|
+
field: float) -> None:
|
|
489
|
+
self.chis = chis
|
|
490
|
+
self.temperatures = temperatures
|
|
491
|
+
self.field = field
|
|
492
|
+
return
|
|
493
|
+
|
|
494
|
+
@property
|
|
495
|
+
def chis(self) -> NDArray:
|
|
496
|
+
'''Magnetic susceptibility values in cm^3 K mol^-1'''
|
|
497
|
+
return self._chis
|
|
498
|
+
|
|
499
|
+
@chis.setter
|
|
500
|
+
def chis(self, chis: ArrayLike) -> None:
|
|
501
|
+
self._chis = np.asarray(chis)
|
|
502
|
+
return
|
|
503
|
+
|
|
504
|
+
@property
|
|
505
|
+
def temperatures(self) -> NDArray:
|
|
506
|
+
'''Temperature values in K`'''
|
|
507
|
+
return self._temperatures
|
|
508
|
+
|
|
509
|
+
@temperatures.setter
|
|
510
|
+
def temperatures(self, temperatures: ArrayLike) -> None:
|
|
511
|
+
self._temperatures = np.asarray(temperatures)
|
|
512
|
+
return
|
|
513
|
+
|
|
514
|
+
@property
|
|
515
|
+
def field(self) -> float:
|
|
516
|
+
'''Static magnetic field in Oe'''
|
|
517
|
+
return self._field
|
|
518
|
+
|
|
519
|
+
@field.setter
|
|
520
|
+
def field(self, field: float) -> None:
|
|
521
|
+
self._field = float(field)
|
|
522
|
+
return
|
|
523
|
+
|
|
524
|
+
@classmethod
|
|
525
|
+
def from_extractor(cls, extractor: oe.AbsorptionExtractor) -> list['SusceptibilityData']: # noqa
|
|
526
|
+
'''
|
|
527
|
+
Creates SusceptibilityData object(s) from data extractor
|
|
528
|
+
|
|
529
|
+
Parameters
|
|
530
|
+
----------
|
|
531
|
+
extractor: oe.SusceptibilityExtractor
|
|
532
|
+
Data extractor object containing susceptibility data
|
|
533
|
+
|
|
534
|
+
Returns
|
|
535
|
+
-------
|
|
536
|
+
list['SusceptibilityData']
|
|
537
|
+
SusceptibilityData objects, one for each section in extractor
|
|
538
|
+
'''
|
|
539
|
+
|
|
540
|
+
all_abs_data = [
|
|
541
|
+
cls.from_extractor_dataset(
|
|
542
|
+
dataset
|
|
543
|
+
)
|
|
544
|
+
for dataset in extractor.data
|
|
545
|
+
]
|
|
546
|
+
|
|
547
|
+
return all_abs_data
|
|
548
|
+
|
|
549
|
+
@classmethod
|
|
550
|
+
def from_extractor_data(cls, data: list[pd.DataFrame]) -> list['SusceptibilityData']: # noqa
|
|
551
|
+
'''
|
|
552
|
+
Creates SusceptibilityData object(s) extractor.data attribute
|
|
553
|
+
|
|
554
|
+
Parameters
|
|
555
|
+
----------
|
|
556
|
+
data: list[pd.DataFrame]
|
|
557
|
+
List of dataframes from orto SusceptibilityExtractor.data attribute
|
|
558
|
+
|
|
559
|
+
Returns
|
|
560
|
+
-------
|
|
561
|
+
list['SusceptibilityData']
|
|
562
|
+
SusceptibilityData objects, one for each dataframe in data
|
|
563
|
+
'''
|
|
564
|
+
|
|
565
|
+
all_data = []
|
|
566
|
+
|
|
567
|
+
# Generate a susceptibility data object for each dataframe
|
|
568
|
+
# and static field value
|
|
569
|
+
for dataset in data:
|
|
570
|
+
# Get unique fields and split indices
|
|
571
|
+
ufields, splindices = np.unique(
|
|
572
|
+
dataset['Static Field (Gauss)'],
|
|
573
|
+
return_index=True
|
|
574
|
+
)
|
|
575
|
+
splindices = list(splindices) + [len(dataset)]
|
|
576
|
+
|
|
577
|
+
for it, field in enumerate(ufields):
|
|
578
|
+
subdata = dataset[splindices[it]:splindices[it + 1]]
|
|
579
|
+
|
|
580
|
+
temperatures = subdata['Temperature (K)']
|
|
581
|
+
chis = subdata['chi*T (cm3*K/mol)'] / temperatures
|
|
582
|
+
all_data.append(
|
|
583
|
+
cls(chis, temperatures, field)
|
|
584
|
+
)
|
|
585
|
+
|
|
586
|
+
return all_data
|
orto/extractor.py
CHANGED
|
@@ -17,6 +17,16 @@ from . import constants as const
|
|
|
17
17
|
def EPRNMRDetector(file_name: str | pathlib.Path) -> bool:
|
|
18
18
|
'''
|
|
19
19
|
Detects if Orca output file contains an EPRNMR section
|
|
20
|
+
|
|
21
|
+
Parameters
|
|
22
|
+
----------
|
|
23
|
+
file_name: str | pathlib.Path
|
|
24
|
+
File to parse
|
|
25
|
+
|
|
26
|
+
Returns
|
|
27
|
+
-------
|
|
28
|
+
bool
|
|
29
|
+
True if EPRNMR present, else False
|
|
20
30
|
'''
|
|
21
31
|
with open(file_name, 'rb') as f:
|
|
22
32
|
file_content = f.read()
|
|
@@ -27,6 +37,30 @@ def EPRNMRDetector(file_name: str | pathlib.Path) -> bool:
|
|
|
27
37
|
return False
|
|
28
38
|
|
|
29
39
|
|
|
40
|
+
def NEVDetector(file_name: str | pathlib.Path) -> re.Match | None:
|
|
41
|
+
'''
|
|
42
|
+
Detects NEVPT2 section of output file
|
|
43
|
+
|
|
44
|
+
Parameters
|
|
45
|
+
----------
|
|
46
|
+
file_name: str | pathlib.Path
|
|
47
|
+
File to parse
|
|
48
|
+
|
|
49
|
+
Returns
|
|
50
|
+
-------
|
|
51
|
+
re.Match | None
|
|
52
|
+
re Match object, or None if no match found
|
|
53
|
+
'''
|
|
54
|
+
|
|
55
|
+
with open(file_name, 'rb') as f:
|
|
56
|
+
file_content = f.read()
|
|
57
|
+
|
|
58
|
+
# Find line containing < NEVPT2 >
|
|
59
|
+
match = re.search(rb'< NEVPT2 >', file_content)
|
|
60
|
+
|
|
61
|
+
return match
|
|
62
|
+
|
|
63
|
+
|
|
30
64
|
class OrcaVersionExtractor(extto.LineExtractor):
|
|
31
65
|
'''
|
|
32
66
|
Extracts Orca version from Orca output file
|
|
@@ -213,7 +247,8 @@ class SusceptibilityExtractor(extto.BetweenExtractor):
|
|
|
213
247
|
return data
|
|
214
248
|
|
|
215
249
|
@classmethod
|
|
216
|
-
def extract(cls, file_name: str | pathlib.Path
|
|
250
|
+
def extract(cls, file_name: str | pathlib.Path,
|
|
251
|
+
before: str = None, after: str = None) -> list[pd.DataFrame]:
|
|
217
252
|
'''
|
|
218
253
|
Convenience method which instantiates class, extracts blocks, and
|
|
219
254
|
returns processed datasets
|
|
@@ -222,6 +257,10 @@ class SusceptibilityExtractor(extto.BetweenExtractor):
|
|
|
222
257
|
----------
|
|
223
258
|
file_name: str | pathlib.Path
|
|
224
259
|
File to parse
|
|
260
|
+
before: str, default None
|
|
261
|
+
Only consider data before this string (first occurrence, exclusive)
|
|
262
|
+
after: str, default None
|
|
263
|
+
Only consider data after this string (first occurrence, inclusive)
|
|
225
264
|
|
|
226
265
|
Returns
|
|
227
266
|
-------
|
|
@@ -229,7 +268,7 @@ class SusceptibilityExtractor(extto.BetweenExtractor):
|
|
|
229
268
|
Each entry contains processed data, as defined in cls.data
|
|
230
269
|
'''
|
|
231
270
|
_ext = cls()
|
|
232
|
-
_ext(file_name, process=True)
|
|
271
|
+
_ext(file_name, process=True, before=before, after=after)
|
|
233
272
|
return _ext.data
|
|
234
273
|
|
|
235
274
|
|
|
@@ -2676,7 +2715,9 @@ class GMatrixDFTExtractor(extto.BetweenExtractor):
|
|
|
2676
2715
|
return data
|
|
2677
2716
|
|
|
2678
2717
|
@classmethod
|
|
2679
|
-
def extract(cls, file_name: str | pathlib.Path
|
|
2718
|
+
def extract(cls, file_name: str | pathlib.Path,
|
|
2719
|
+
before: str = None,
|
|
2720
|
+
after: str = None) -> list[dict[str, NDArray]]:
|
|
2680
2721
|
'''
|
|
2681
2722
|
Convenience method which instantiates class, extracts blocks, and
|
|
2682
2723
|
returns processed datasets
|
|
@@ -2685,6 +2726,10 @@ class GMatrixDFTExtractor(extto.BetweenExtractor):
|
|
|
2685
2726
|
----------
|
|
2686
2727
|
file_name: str | pathlib.Path
|
|
2687
2728
|
File to parse
|
|
2729
|
+
before: str, default None
|
|
2730
|
+
Only consider data before this string (first occurrence, exclusive)
|
|
2731
|
+
after: str, default None
|
|
2732
|
+
Only consider data after this string (first occurrence, inclusive)
|
|
2688
2733
|
|
|
2689
2734
|
Returns
|
|
2690
2735
|
-------
|
|
@@ -2692,7 +2737,7 @@ class GMatrixDFTExtractor(extto.BetweenExtractor):
|
|
|
2692
2737
|
Each entry contains processed data, as defined in cls.data
|
|
2693
2738
|
'''
|
|
2694
2739
|
_ext = cls()
|
|
2695
|
-
_ext(file_name, process=True)
|
|
2740
|
+
_ext(file_name, process=True, after=after, before=before)
|
|
2696
2741
|
return _ext.data
|
|
2697
2742
|
|
|
2698
2743
|
|
|
@@ -2766,7 +2811,9 @@ class GMatrixExtractor(extto.BetweenExtractor):
|
|
|
2766
2811
|
return data
|
|
2767
2812
|
|
|
2768
2813
|
@classmethod
|
|
2769
|
-
def extract(cls, file_name: str | pathlib.Path
|
|
2814
|
+
def extract(cls, file_name: str | pathlib.Path,
|
|
2815
|
+
before: str = None,
|
|
2816
|
+
after: str = None) -> list[dict[str, NDArray]]:
|
|
2770
2817
|
'''
|
|
2771
2818
|
Convenience method which instantiates class, extracts blocks, and
|
|
2772
2819
|
returns processed datasets
|
|
@@ -2775,6 +2822,10 @@ class GMatrixExtractor(extto.BetweenExtractor):
|
|
|
2775
2822
|
----------
|
|
2776
2823
|
file_name: str | pathlib.Path
|
|
2777
2824
|
File to parse
|
|
2825
|
+
before: str, default None
|
|
2826
|
+
Only consider data before this string (first occurrence, exclusive)
|
|
2827
|
+
after: str, default None
|
|
2828
|
+
Only consider data after this string (first occurrence, inclusive)
|
|
2778
2829
|
|
|
2779
2830
|
Returns
|
|
2780
2831
|
-------
|
|
@@ -2782,7 +2833,7 @@ class GMatrixExtractor(extto.BetweenExtractor):
|
|
|
2782
2833
|
Each entry contains processed data, as defined in cls.data
|
|
2783
2834
|
'''
|
|
2784
2835
|
_ext = cls()
|
|
2785
|
-
_ext(file_name, process=True)
|
|
2836
|
+
_ext(file_name, process=True, after=after, before=before)
|
|
2786
2837
|
return _ext.data
|
|
2787
2838
|
|
|
2788
2839
|
|
|
@@ -2853,7 +2904,9 @@ class GMatrixEffectiveExtractor(GMatrixExtractor):
|
|
|
2853
2904
|
return data
|
|
2854
2905
|
|
|
2855
2906
|
@classmethod
|
|
2856
|
-
def extract(cls, file_name: str | pathlib.Path
|
|
2907
|
+
def extract(cls, file_name: str | pathlib.Path,
|
|
2908
|
+
before: str = None,
|
|
2909
|
+
after: str = None) -> list[dict[str, NDArray | int]]:
|
|
2857
2910
|
'''
|
|
2858
2911
|
Convenience method which instantiates class, extracts blocks, and
|
|
2859
2912
|
returns processed datasets
|
|
@@ -2862,6 +2915,10 @@ class GMatrixEffectiveExtractor(GMatrixExtractor):
|
|
|
2862
2915
|
----------
|
|
2863
2916
|
file_name: str | pathlib.Path
|
|
2864
2917
|
File to parse
|
|
2918
|
+
before: str, default None
|
|
2919
|
+
Only consider data before this string (first occurrence, exclusive)
|
|
2920
|
+
after: str, default None
|
|
2921
|
+
Only consider data after this string (first occurrence, inclusive)
|
|
2865
2922
|
|
|
2866
2923
|
Returns
|
|
2867
2924
|
-------
|
|
@@ -2869,7 +2926,7 @@ class GMatrixEffectiveExtractor(GMatrixExtractor):
|
|
|
2869
2926
|
Each entry contains processed data, as defined in cls.data
|
|
2870
2927
|
'''
|
|
2871
2928
|
_ext = cls()
|
|
2872
|
-
_ext(file_name, process=True)
|
|
2929
|
+
_ext(file_name, process=True, after=after, before=before)
|
|
2873
2930
|
return _ext.data
|
|
2874
2931
|
|
|
2875
2932
|
|
|
@@ -2962,7 +3019,9 @@ class SpinFreeEnergyExtractor(extto.BetweenExtractor):
|
|
|
2962
3019
|
return data
|
|
2963
3020
|
|
|
2964
3021
|
@classmethod
|
|
2965
|
-
def extract(cls, file_name: str | pathlib.Path
|
|
3022
|
+
def extract(cls, file_name: str | pathlib.Path,
|
|
3023
|
+
before: str = None,
|
|
3024
|
+
after: str = None) -> list[dict[str, NDArray]]:
|
|
2966
3025
|
'''
|
|
2967
3026
|
Convenience method which instantiates class, extracts blocks, and
|
|
2968
3027
|
returns processed datasets
|
|
@@ -2971,6 +3030,10 @@ class SpinFreeEnergyExtractor(extto.BetweenExtractor):
|
|
|
2971
3030
|
----------
|
|
2972
3031
|
file_name: str | pathlib.Path
|
|
2973
3032
|
File to parse
|
|
3033
|
+
before: str, default None
|
|
3034
|
+
Only consider data before this string (first occurrence, exclusive)
|
|
3035
|
+
after: str, default None
|
|
3036
|
+
Only consider data after this string (first occurrence, inclusive)
|
|
2974
3037
|
|
|
2975
3038
|
Returns
|
|
2976
3039
|
-------
|
|
@@ -2978,7 +3041,7 @@ class SpinFreeEnergyExtractor(extto.BetweenExtractor):
|
|
|
2978
3041
|
Each entry contains processed data, as defined in cls.data
|
|
2979
3042
|
'''
|
|
2980
3043
|
_ext = cls()
|
|
2981
|
-
_ext(file_name, process=True)
|
|
3044
|
+
_ext(file_name, process=True, before=before, after=after)
|
|
2982
3045
|
return _ext.data
|
|
2983
3046
|
|
|
2984
3047
|
|
|
@@ -3026,7 +3089,9 @@ class SpinOrbitEnergyExtractor(extto.BetweenExtractor):
|
|
|
3026
3089
|
return result
|
|
3027
3090
|
|
|
3028
3091
|
@classmethod
|
|
3029
|
-
def extract(cls, file_name: str | pathlib.Path
|
|
3092
|
+
def extract(cls, file_name: str | pathlib.Path,
|
|
3093
|
+
before: str = None,
|
|
3094
|
+
after: str = None) -> list[dict[str, NDArray]]: # noqa
|
|
3030
3095
|
'''
|
|
3031
3096
|
Convenience method which instantiates class, extracts blocks, and
|
|
3032
3097
|
returns processed datasets
|
|
@@ -3035,6 +3100,10 @@ class SpinOrbitEnergyExtractor(extto.BetweenExtractor):
|
|
|
3035
3100
|
----------
|
|
3036
3101
|
file_name: str | pathlib.Path
|
|
3037
3102
|
File to parse
|
|
3103
|
+
before: str, default None
|
|
3104
|
+
Only consider data before this string (first occurrence, exclusive)
|
|
3105
|
+
after: str, default None
|
|
3106
|
+
Only consider data after this string (first occurrence, inclusive)
|
|
3038
3107
|
|
|
3039
3108
|
Returns
|
|
3040
3109
|
-------
|
|
@@ -3042,5 +3111,5 @@ class SpinOrbitEnergyExtractor(extto.BetweenExtractor):
|
|
|
3042
3111
|
Each entry contains processed data, as defined in cls.data
|
|
3043
3112
|
'''
|
|
3044
3113
|
_ext = cls()
|
|
3045
|
-
_ext(file_name, process=True)
|
|
3114
|
+
_ext(file_name, process=True, before=before, after=after)
|
|
3046
3115
|
return _ext.data
|