-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReflectoPlot_processing.py
More file actions
115 lines (106 loc) · 3.83 KB
/
Copy pathReflectoPlot_processing.py
File metadata and controls
115 lines (106 loc) · 3.83 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/usr/bin/env python
# coding: utf-8
inputParameters={}
inputParametersForScaled={}
fileListRefl=[]
fileListTrans=[]
name=""
optionalParameters={
"customLims":False,
"xOrigLims":[None,None,None,None],
"yAxisLims":[None,None,None,None],
"scaled":False
}
cls=None
def initPlot(xCol=1, showColTup=(2,0), xCol2=0, customInputParameters=None):
if customInputParameters is not None:
inputParameters.update(customInputParameters)
inputParametersForScaled.update(customInputParameters)
scPlot=None
if optionalParameters["customLims"]:
plot=cls(
name,
fileListRefl,
fileListTrans,
xCol=xCol,
xCol2=xCol2,
showColTup=showColTup,
xLimOrig=optionalParameters["xOrigLims"][showColTup[0]],
showColAxLim=optionalParameters["yAxisLims"],
**inputParameters)
if optionalParameters["scaled"]:
scPlot=cls(
name,
fileListRefl,
fileListTrans,
xCol=xCol,
xCol2=xCol2,
showColTup=showColTup,
**inputParametersForScaled)
else:
plot=cls(name,
fileListRefl,
fileListTrans,
xCol=xCol,
xCol2=xCol2,
showColTup=showColTup,
**inputParameters)
if optionalParameters["scaled"]:
scPlot=cls(name,
fileListRefl,
fileListTrans,
xCol=xCol,
xCol2=xCol2,
showColTup=showColTup,
**inputParametersForScaled)
if scPlot is None:
return [plot]
return [plot,scPlot]
def buildPlotList(desiredPlot):
try:
yCol2=desiredPlot["yCol2"]
except KeyError:
yCol2=0
try:
cusPara=desiredPlot["custom"]
except KeyError:
cusPara=None
if desiredPlot["yCol"]==0 or desiredPlot["xCol"]==0:
raise
return initPlot(xCol=desiredPlot["xCol"], showColTup=(desiredPlot["yCol"],yCol2), customInputParameters=cusPara)
def processPlotPair(plotpair):
return [plot.doPlot() for plot in plotpair]
def calc(name_local, fileListRefl_local, fileListTrans_local, desiredPlots, inputParameters_local, cls_local, inputParametersForScaled_local, optionalParameterDict=None, multithreaded=True):
global name
global fileListRefl
global fileListTrans
global cls
global inputParameters
global inputParametersForScaled
global optionalParameters
name=name_local
fileListRefl=fileListRefl_local
fileListTrans=fileListTrans_local
cls=cls_local
inputParameters=inputParameters_local
inputParametersForScaled=inputParametersForScaled_local
if optionalParameterDict is not None:
optionalParameters=optionalParameterDict
if multithreaded:
import os
from multiprocessing import Pool
pool = Pool(os.cpu_count())
plotList=pool.map(buildPlotList,desiredPlots)
multiOutput=pool.map(processPlotPair,plotList)
pool.close()
else:
#singlethreaded
plotList=[buildPlotList(desiredPlot) for desiredPlot in desiredPlots]
multiOutput=[processPlotPair(plotPair) for plotPair in plotList]
plots=[[plotOutput[0] for plotOutput in plotPair] for plotPair in multiOutput]
files=[[plotOutput[1] for plotOutput in plotPair] for plotPair in multiOutput]
return (plots,files)
def export_data(plots):
for plotpair in plots:
for plot in plotpair:
plot.processAllAndExport()