2 {-# LANGUAGE OverloadedStrings #-}
4 module Hkl
.Projects
.Diffabs
.Martinetto
9 import Control
.Concurrent
(setNumCapabilities
)
10 import Control
.Concurrent
.Async
(mapConcurrently
)
11 import Data
.Array.Repa
(DIM1
, ix1
)
12 import Data
.Char (toUpper)
13 import Numeric
.LinearAlgebra
(ident
)
14 import System
.FilePath ((</>))
15 import Text
.Printf
(printf
)
17 import Prelude
hiding (concat, lookup, readFile, writeFile)
24 project
= "/nfs/ruche-diffabs/diffabs-users/99160066/"
27 published
= project
</> "published-data"
29 beamlineUpper
:: Beamline
-> String
30 beamlineUpper b
= [Data
.Char.toUpper x | x
<- show b
]
32 nxs
' :: FilePath -> NxEntry
-> (NxEntry
-> DataFrameH5Path
) -> Nxs
33 nxs
' f e h
= Nxs f e
(h e
)
35 nxs
:: FilePath -> NxEntry
-> (NxEntry
-> DataFrameH5Path
) -> XrdSource
36 nxs f e h
= XrdSourceNxs
(nxs
' f e h
)
38 h5path
' :: NxEntry
-> DataFrameH5Path
40 DataFrameH5Path
{ h5pImage
= DataItemH5
(nxentry
</> image
) StrictDims
41 , h5pGamma
= DataItemH5
(nxentry
</> beamline
</> gamma
) ExtendDims
42 , h5pDelta
= DataItemH5
(nxentry
</> delta
) ExtendDims
43 , h5pWavelength
= DataItemH5
(nxentry
</> beamline
</> wavelength
) StrictDims
47 beamline
= beamlineUpper Diffabs
49 image
= "scan_data/data_53"
50 gamma
= "d13-1-cx1__EX__DIF.1-GAMMA__#1/raw_value"
51 delta
= "scan_data/actuator_1_1"
52 wavelength
= "D13-1-C03__OP__MONO__#1/wavelength"
54 sampleCalibration
:: XRDCalibration
55 sampleCalibration
= XRDCalibration
{ xrdCalibrationName
= "calibration"
56 , xrdCalibrationOutputDir
= published
</> "calibration"
57 , xrdCalibrationEntries
= entries
62 idxs
= [3, 6, 9, 15, 18, 21, 24, 27, 30, 33, 36, 39, 43]
64 entry
:: Int -> XRDCalibrationEntry
65 entry idx
= XRDCalibrationEntryNxs
66 { xrdCalibrationEntryNxs
'Nxs
= nxs
' (published
</> "calibration" </> "XRD18keV_26.nxs") "scan_26" h5path
'
67 , xrdCalibrationEntryNxs
'Idx
= idx
68 , xrdCalibrationEntryNxs
'NptPath
= published
</> "calibration" </> printf
"XRD18keV_26.nxs_%02d.npt" idx
71 entries
:: [XRDCalibrationEntry
]
72 entries
= [ entry idx | idx
<- idxs
]
76 sampleRef
= XRDRef
"reference"
77 (published
</> "calibration")
79 (nxs
' (published
</> "calibration" </> "XRD18keV_26.nxs") "scan_26" h5path
')
80 6 -- BEWARE only the 6th poni was generated with the right Xpad_flat geometry.
83 h5path
:: NxEntry
-> DataFrameH5Path
85 DataFrameH5Path
{ h5pImage
= DataItemH5
(nxentry
</> image
) StrictDims
86 , h5pGamma
= DataItemH5
(nxentry
</> beamline
</> gamma
) ExtendDims
87 , h5pDelta
= DataItemH5
(nxentry
</> delta
) ExtendDims
88 , h5pWavelength
= DataItemH5
(nxentry
</> beamline
</> wavelength
) StrictDims
92 beamline
= beamlineUpper Diffabs
94 image
= "scan_data/data_58"
95 gamma
= "D13-1-CX1__EX__DIF.1-GAMMA__#1/raw_value"
96 delta
= "scan_data/actuator_1_1"
97 wavelength
= "D13-1-C03__OP__MONO__#1/wavelength"
103 multibins
= ix1
25000
105 threshold
:: Threshold
106 threshold
= Threshold
800
109 ceo2
= XRDSample
"CeO2"
110 (published
</> "CeO2")
111 [ XrdNxs bins multibins threshold n | n
<-
112 [ nxs
(published
</> "calibration" </> "XRD18keV_26.nxs") "scan_26" h5path
' ]
116 n27t2
= XRDSample
"N27T2"
117 (published
</> "N27T2")
118 [ XrdNxs bins multibins threshold n | n
<-
119 [ nxs
(project
</> "2016" </> "Run2" </> "2016-03-27" </> "N27T2_14.nxs") "scan_14" h5path
120 , nxs
(project
</> "2016" </> "Run2" </> "2016-03-27" </> "N27T2_17.nxs") "scan_17" h5path
125 r23
= XRDSample
"R23"
126 (published
</> "R23")
127 [ XrdNxs bins multibins threshold n | n
<-
128 [ nxs
(project
</> "2016" </> "Run2" </> "2016-03-27" </> "R23_6.nxs") "scan_6" h5path
129 , nxs
(project
</> "2016" </> "Run2" </> "2016-03-27" </> "R23_12.nxs") "scan_12" h5path
134 r18
= XRDSample
"R18"
135 (published
</> "R18")
136 [ XrdNxs bins multibins threshold n | n
<-
137 [ nxs
(project
</> "2016" </> "Run2" </> "2016-03-27" </> "R18_20.nxs") "scan_20" h5path
138 , nxs
(project
</> "2016" </> "Run2" </> "2016-03-27" </> "R18_24.nxs") "scan_24" h5path
145 [ XrdNxs bins multibins threshold n | n
<-
146 [ nxs
(project
</> "2016" </> "Run2" </> "2016-03-27" </> "A3_13.nxs") "scan_13" h5path
147 , nxs
(project
</> "2016" </> "Run2" </> "2016-03-27" </> "A3_14.nxs") "scan_14" h5path
148 , nxs
(project
</> "2016" </> "Run2" </> "2016-03-27" </> "A3_15.nxs") "scan_15" h5path
155 [ XrdNxs bins multibins threshold n | n
<-
156 [ nxs
(project
</> "2016" </> "Run2" </> "2016-03-27" </> "A2_14.nxs") "scan_14" h5path
157 , nxs
(project
</> "2016" </> "Run2" </> "2016-03-27" </> "A2_17.nxs") "scan_17" h5path
162 a26
= XRDSample
"A26"
163 (published
</> "A26")
164 [ XrdNxs bins multibins threshold n | n
<-
165 [ nxs
(project
</> "2016" </> "Run2" </> "2016-03-26" </> "A26_50.nxs") "scan_50" h5path
166 , nxs
(project
</> "2016" </> "Run2" </> "2016-03-26" </> "A26_51.nxs") "scan_51" h5path
167 , nxs
(project
</> "2016" </> "Run2" </> "2016-03-26" </> "A26_52.nxs") "scan_52" h5path
168 , nxs
(project
</> "2016" </> "Run2" </> "2016-03-26" </> "A26_53.nxs") "scan_53" h5path
169 , nxs
(project
</> "2016" </> "Run2" </> "2016-03-26" </> "A26_54.nxs") "scan_54" h5path
170 , nxs
(project
</> "2016" </> "Run2" </> "2016-03-26" </> "A26_55.nxs") "scan_55" h5path
171 , nxs
(project
</> "2016" </> "Run2" </> "2016-03-26" </> "A26_56.nxs") "scan_56" h5path
172 , nxs
(project
</> "2016" </> "Run2" </> "2016-03-26" </> "A26_57.nxs") "scan_57" h5path
173 , nxs
(project
</> "2016" </> "Run2" </> "2016-03-26" </> "A26_58.nxs") "scan_58" h5path
174 , nxs
(project
</> "2016" </> "Run2" </> "2016-03-26" </> "A26_59.nxs") "scan_59" h5path
181 [ XrdNxs bins multibins threshold n | n
<-
182 [ nxs
(project
</> "2016" </> "Run2" </> "2016-03-27" </> "D2_16.nxs") "scan_16" h5path
183 , nxs
(project
</> "2016" </> "Run2" </> "2016-03-27" </> "D2_17.nxs") "scan_17" h5path
190 [ XrdNxs bins multibins threshold n | n
<-
191 [ nxs
(project
</> "2016" </> "Run2" </> "2016-03-27" </> "D3_14.nxs") "scan_14" h5path
192 , nxs
(project
</> "2016" </> "Run2" </> "2016-03-27" </> "D3_15.nxs") "scan_15" h5path
197 f30
= XRDSample
"F30"
198 (published
</> "F30")
199 [ XrdNxs bins multibins threshold n | n
<-
200 [ nxs
(project
</> "2016" </> "Run2" </> "2016-03-26" </> "F30_11.nxs") "scan_11" h5path
201 , nxs
(project
</> "2016" </> "Run2" </> "2016-03-26" </> "F30_12.nxs") "scan_12" h5path
202 , nxs
(project
</> "2016" </> "Run2" </> "2016-03-26" </> "F30_13.nxs") "scan_13" h5path
207 r11
= XRDSample
"R11"
208 (published
</> "R11")
209 [ XrdNxs bins multibins threshold n | n
<-
210 [ nxs
(project
</> "2016" </> "Run2" </> "2016-03-27" </> "R11_5.nxs") "scan_5" h5path
211 , nxs
(project
</> "2016" </> "Run2" </> "2016-03-27" </> "R11_6.nxs") "scan_6" h5path
212 , nxs
(project
</> "2016" </> "Run2" </> "2016-03-27" </> "R11_7.nxs") "scan_7" h5path
217 d16
= XRDSample
"D16"
218 (published
</> "D16")
219 [ XrdNxs bins multibins threshold n | n
<-
220 [ nxs
(project
</> "2016" </> "Run2" </> "2016-03-27" </> "D16_12.nxs") "scan_12" h5path
221 , nxs
(project
</> "2016" </> "Run2" </> "2016-03-27" </> "D16_15.nxs") "scan_15" h5path
222 , nxs
(project
</> "2016" </> "Run2" </> "2016-03-27" </> "D16_17.nxs") "scan_17" h5path
227 k9a2
= XRDSample
"K9A2"
228 (published
</> "K9A2")
229 [ XrdNxs bins multibins threshold n | n
<-
230 [ nxs
(project
</> "2016" </> "Run2" </> "2016-03-27" </> "K9A2_1_31.nxs") "scan_31" h5path
231 , nxs
(project
</> "2016" </> "Run2" </> "2016-03-27" </> "K9A2_1_32.nxs") "scan_32" h5path
236 r34n1
= XRDSample
"R34N1"
237 (published
</> "R34N1")
238 [ XrdNxs bins multibins threshold n | n
<-
239 [ nxs
(project
</> "2016" </> "Run2" </> "2016-03-27" </> "R34N1_28.nxs") "scan_28" h5path
240 , nxs
(project
</> "2016" </> "Run2" </> "2016-03-27" </> "R34N1_37.nxs") "scan_37" h5path
245 r35n1
= XRDSample
"R35N1"
246 (published
</> "R35N1")
247 [ XrdNxs bins multibins threshold n | n
<-
248 [ nxs
(project
</> "2016" </> "Run2" </> "2016-03-26" </> "R35N1_25.nxs") "scan_19" h5path
249 , nxs
(project
</> "2016" </> "Run2" </> "2016-03-26" </> "R35N1_26.nxs") "scan_20" h5path
250 , nxs
(project
</> "2016" </> "Run2" </> "2016-03-26" </> "R35N1_27.nxs") "scan_21" h5path
254 -- meshSample :: String
255 -- meshSample = project </> "2016" "Run2" "2016-03-28" "MELLE_29.nxs"
256 -- scan_29 scan_data actuator_1_1 actuator_2_1 data_58 (images)
262 -- lire le ou les ponis de référence ainsi que leur géométrie
265 -- let samples = [ceo2, a2, a3, a26, d2, d3, d16, f30, k9a2, n27t2, r11, r18, r23, r34n1, r35n1]
268 p
<- getPoniExtRef sampleRef
270 -- flip the ref poni in order to fit the reality
271 -- let poniextref = Hkl.PyFAI.PoniExt.flip p
273 -- integrate each step of the scan
274 _
<- mapConcurrently
(integrate poniextref
) samples
276 -- plot de la figure. (script python ou autre ?)
281 let samples
= [ceo2
, a2
, a3
, a26
, d2
, d3
, d16
, f30
, k9a2
, n27t2
, r11
, r18
, r23
, r34n1
, r35n1
]
283 p
<- getPoniExtRef sampleRef
285 -- flip the ref poni in order to fit the reality
286 -- let poniextref = p
287 let poniextref
= setPose p
(MyMatrix HklB
(ident
3))
288 -- let poniextref = setPose (Hkl.PyFAI.PoniExt.flip p) (MyMatrix HklB (ident 3))
291 poniextref
' <- calibrate sampleCalibration poniextref Xpad32
296 -- integrate each step of the scan
298 _
<- mapM_ (integrateMulti poniextref
') samples