-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbinarydata.pro
107 lines (101 loc) · 3.2 KB
/
binarydata.pro
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
; *******************************************************************
; Multfit efficient processing of 2D diffraction images
; Copyright (C) 2000-2014 S. Merkel, Universite Lille 1
; http://merkel.zoneo.net/Multifit/
;
; This program is free software; you can redistribute it and/or
; modify it under the terms of the GNU General Public License
; as published by the Free Software Foundation; either version 2
; of the License, or (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program; if not, write to the Free Software
; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
;
; *******************************************************************
function savedata, file
common files, extension, datadirectory, outputdirectory, defaultdirectory, jcpdsdirectory
common datainfo, filenames, alphastart, alphaend, intervalle, date
common rawdata, nalpha, ntheta, alpha, twotheta, data
ON_IOERROR, IOERROR
filename = datadirectory + file
openw, /XDR, 1, filename
; basic info
writeu, 1, strlen(filenames)
writeu, 1, filenames
writeu, 1, alphastart
writeu, 1, alphaend
writeu, 1, intervalle
writeu, 1, strlen(date)
writeu, 1, date
; data
writeu, 1, nalpha
writeu, 1, ntheta
writeu, 1, alpha
writeu, 1, twotheta
writeu, 1, data
close, 1
return, 1
IOERROR:close, 1
return, !ERR_STRING
end
function readfile, file
common datainfo, filenames, alphastart, alphaend, intervalle, date
common rawdata, nalpha, ntheta, alpha, twotheta, data
ON_IOERROR, BADINPUT
openr, /XDR, 1, file
; basic info
length = fix(0)
alphastart = fix(0)
alphaend = fix(0)
intervalle = float(0)
readu, 1, length
filenames = STRING(REPLICATE(32B,length))
readu, 1, filenames
readu, 1, alphastart
readu, 1, alphaend
readu, 1, intervalle
readu, 1, length
date = STRING(REPLICATE(32B,length))
readu, 1, date
; data
nalpha = fix(0)
ntheta = fix(0)
readu, 1, nalpha
readu, 1, ntheta
twotheta = fltarr(ntheta)
alpha = fltarr(nalpha)
data = fltarr(nalpha,ntheta)
readu, 1, alpha
readu, 1, twotheta
readu, 1, data
close, 1
; fix things
; in the old days, azimuth (called alpha here) were integers. The file format was not changed.
; The lines below fixes things up
alphastart = min(alpha)
alphaend = max(alpha)
if (n_elements(alpha) gt 1) then intervalle = alpha[1]-alpha[0] else intervalle = 0.0
return, 1
BADINPUT: close, 1
return, !ERR_STRING
end
pro slicedata, min, max
common rawdata, nalpha, ntheta, alpha, twotheta, data
; finding the twotheta indexes
tmp = WHERE(twotheta GT min, count)
if (count eq 0) then indexL = 0 else indexL = tmp[0]
tmp = WHERE(twotheta LT max, count)
if (count eq 0) then indexR = N_ELEMENTS(twotheta)-1 else indexR = tmp[count-1]
; slicing the data
for i=indexL, indexR do $
data(*,i) = data(*,indexL) + $
(data(*,indexR)- data(*,indexL)) * $
(twotheta(i)-twotheta(indexL)) / $
(twotheta(indexR)-twotheta(indexL))
end