forked from aklnk/xaesa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxaesa_xes_class.py
73 lines (50 loc) · 2.02 KB
/
xaesa_xes_class.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# -*- coding: utf-8 -*-
"""
Created on Fri Mar 2 15:07:33 2018
@author: akali
"""
from numpy import concatenate, logical_and, polyfit, where
from scipy.integrate import simps
class xaesa_xes_class():
def __init__(self):
self.name = ""
#raw data loaded from experimantal file
self.energy = [] #1D array
self.energyRebined = []
self.energyOriginal = []
self.xes = []
self.xesBackground = []
self.xesBkgrCorrected = []
self.xesAreaNorm = []
self.xesMaxNorm = []
self.xesRebinned = []
self.xesOriginal = []
#energy windows for background removal
self.E0 = 0
self.E1 = 0
self.E2 = 0
self.E3 = 0
#energy window for area normalization
self.eAreaNormMin = 0
self.eAreaNormMax = 0
self.eMinRebin = 0
self.emaxRemin = 0
self.deRebin = 0
def removeBackground(self):
where1 = where( logical_and(self.energy > self.E0, self.energy < self.E1) )
where2 = where( logical_and(self.energy > self.E2, self.energy < self.E3) )
energy_sliced = concatenate( (self.energy[where1], self.energy[where2]) )
xes_sliced = concatenate( (self.xes[where1], self.xes[where2]) )
pf = polyfit(energy_sliced, xes_sliced, 1)
self.xesBackground = self.energy * pf[0] + pf[1]
self.xesBkgrCorrected = self.xes - self.xesBackground
def areaNormalize(self):
where3 = where( logical_and(self.energy > self.eAreaNormMin, self.energy < self.eAreaNormMax) )
self.xesAreaNorm = self.xesBkgrCorrected / simps(self.xesBkgrCorrected[where3], self.energy[where3])
def maxNormalize(self):
pass
def rebin():
pass
class xaesa_transient_class():
def __init__(self):
pass