PEARL Procedures rev-distro-2.1.1-1-gf419e92-dirty Igor procedures for the analysis of PEARL data

pearl-pmsco-import.ipf
Go to the documentation of this file.
1 #pragma rtGlobals=3 // Use modern global access method and strict wave access.
2 #pragma IgorVersion = 6.2
3 #pragma ModuleName = PearlPmscoImport
4
5 // copyright (c) 2018 Paul Scherrer Institut
6 //
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
10 // http:///www.apache.org/licenses/LICENSE-2.0
11 //
12 // Please acknowledge the use of this code.
13
28
33
34
88 function /s pmsco_save_scan(pathname, filename, energy, theta, phi, alpha, intensity, sigma, [sdfr])
89 string pathname
90 string filename
91 string energy
92 string theta
93 string phi
94 string alpha
95 string intensity
96 string sigma
97 dfref sdfr
98
99 //string fileext
100 //fileext = StringFromList(ItemsInList(filename, ".") - 1, filename, ".")
101
102 dfref savedf = GetDataFolderDFR()
103 dfref tempdf = NewFreeDataFolder()
104
105 if (ParamIsDefault(sdfr))
106 dfref sdfr = savedf
107 endif
108 SetDataFolder sdfr
109 wave w_intensity = $intensity
110 string wavenames = ""
111
112 wavenames = save_scan_helper("w_energy", energy, w_intensity, tempdf, wavenames)
113 wavenames = save_scan_helper("w_theta", theta, w_intensity, tempdf, wavenames)
114 wavenames = save_scan_helper("w_phi", phi, w_intensity, tempdf, wavenames)
115 wavenames = save_scan_helper("w_alpha", alpha, w_intensity, tempdf, wavenames)
116 wavenames = save_scan_helper("w_intensity", intensity, w_intensity, tempdf, wavenames)
117 wavenames = save_scan_helper("w_sigma", sigma, w_intensity, tempdf, wavenames)
118
119 setdatafolder tempdf
120 save /b /g /m="\n" /p=$pathname wavenames as filename
121 setdatafolder savedf
122 end
123
126 static function /s save_scan_helper(destname, value, template, destdfr, wavenames)
127 string destname
128 string value
129 wave template
130 dfref destdfr
131 string wavenames
132
133 variable err = 0
134 if (strlen(value) > 0)
135 if (exists(value) == 1)
136 duplicate $value, destdfr:$destname
137 wave /sdfr=destdfr w=$destname
138 else
139 duplicate template, destdfr:$destname
140 wave /sdfr=destdfr w=$destname
141 variable numval = str2num(value)
142 string msg
143 if (numtype(numval) == 0)
144 w = numval
145 //elseif (cmpstr(value[0,0], "%") == 0)
146 else
147 strswitch(value)
148 case "x":
149 w = DimOffset(template, 0) + DimDelta(template, 0) * p
150 break
151 case "y":
152 w = DimOffset(template, 1) + DimDelta(template, 1) * q
153 break
154 case "z":
155 w = DimOffset(template, 2) + DimDelta(template, 2) * r
156 break
157 case "t":
158 w = DimOffset(template, 3) + DimDelta(template, 3) * s
159 break
160 default:
161 err = 1
162 sprintf msg, "invalid %s argument", StringFromList(1, destname, "_")
163 endswitch
164 endif
165 endif
166 if (err == 0)
167 wavenames = AddListItem(destname, wavenames, ";", inf)
168 variable npts = DimSize(w, 0) * max(DimSize(w, 1), 1) * max(DimSize(w, 2), 1) * max(DimSize(w, 3), 1)
169 Redimension /n=(npts) w
170 else
171 abort msg
172 endif
173 endif
174 return wavenames
175 end
176
188 function /s pmsco_load_xyz(pathname, filename)
189 string pathname
190 string filename
191
192 string cis = "N=at;N=xx;N=yy;N=zz;"
193 LoadWave /A /B=cis /J /K=0 /L={0, 2, 0, 0, 0} /V={" ", " ", 0, 0} /O /P=$pathname filename
194 wave /t at
195 at = unpadstring(at, 32)
196 end
pmsco_save_scan
string pmsco_save_scan(string pathname, string filename, string energy, string theta, string phi, string alpha, string intensity, string sigma, dfref sdfr=defaultValue)
save waves in a PMSCO scan data file.
Definition: pearl-pmsco-import.ipf:88
save_scan_helper
static string save_scan_helper(string destname, string value, wave template, dfref destdfr, string wavenames)
helper function for save_pmsco_scan()
Definition: pearl-pmsco-import.ipf:126
pmsco_load_xyz
string pmsco_load_xyz(string pathname, string filename)
load an xyz cluster file
Definition: pearl-pmsco-import.ipf:188