|
53 | 53 | "path = 'entry/instrument/histogram_mode_detectors/orca/data/'\n", |
54 | 54 | "\n", |
55 | 55 | "with h5.File(ymir_lego_images_path()) as f:\n", |
56 | | - " lego_data = f[path + 'value'][()]\n", |
57 | | - " lego_time = f[path + 'time'][()]" |
| 56 | + " lego_data = f[path+'value'][()]\n", |
| 57 | + " lego_time = f[path+'time'][()]" |
58 | 58 | ] |
59 | 59 | }, |
60 | 60 | { |
|
93 | 93 | "metadata": {}, |
94 | 94 | "outputs": [], |
95 | 95 | "source": [ |
96 | | - "exposure_time = int(5e8) # 0.5s (made up)\n", |
97 | | - "period = 1e9 / 14\n", |
| 96 | + "exposure_time = int(5e8) # 0.5s (made up)\n", |
| 97 | + "period = 1e9/14\n", |
98 | 98 | "\n", |
99 | | - "dark_charge_time = np.arange(\n", |
100 | | - " float(dark_time[0]), float(dark_time[-1] + exposure_time), period\n", |
101 | | - ").astype('uint64')\n", |
102 | | - "dark_charge_value = np.random.uniform(0.99, 1.01, size=len(dark_charge_time)).astype(\n", |
103 | | - " 'float64'\n", |
104 | | - ")\n", |
| 99 | + "dark_charge_time = np.arange(float(dark_time[0]), float(dark_time[-1] + exposure_time), period).astype('uint64')\n", |
| 100 | + "dark_charge_value = np.random.uniform(0.99, 1.01, size=len(dark_charge_time)).astype('float64')\n", |
105 | 101 | "\n", |
106 | | - "ob_charge_time = np.arange(\n", |
107 | | - " float(ob_time[0]), float(ob_time[-1] + exposure_time), period\n", |
108 | | - ").astype('uint64')\n", |
109 | | - "ob_charge_value = np.random.uniform(0.99, 1.01, size=len(ob_charge_time)).astype(\n", |
110 | | - " 'float64'\n", |
111 | | - ")\n", |
| 102 | + "ob_charge_time = np.arange(float(ob_time[0]), float(ob_time[-1] + exposure_time), period).astype('uint64')\n", |
| 103 | + "ob_charge_value = np.random.uniform(0.99, 1.01, size=len(ob_charge_time)).astype('float64')\n", |
112 | 104 | "\n", |
113 | | - "sample_charge_time = np.arange(\n", |
114 | | - " float(sample_time[0]), float(sample_time[-1] + exposure_time), period\n", |
115 | | - ").astype('uint64')\n", |
116 | | - "sample_charge_value = np.random.uniform(\n", |
117 | | - " 0.99, 1.01, size=len(sample_charge_time)\n", |
118 | | - ").astype('float64')" |
| 105 | + "sample_charge_time = np.arange(float(sample_time[0]), float(sample_time[-1] + exposure_time), period).astype('uint64')\n", |
| 106 | + "sample_charge_value = np.random.uniform(0.99, 1.01, size=len(sample_charge_time)).astype('float64')" |
119 | 107 | ] |
120 | 108 | }, |
121 | 109 | { |
|
157 | 145 | " dset = entry.create_dataset(name, data=values)\n", |
158 | 146 | " dset.attrs.update(attrs)\n", |
159 | 147 | "\n", |
160 | | - "\n", |
161 | 148 | "def make_new_file(template_nexus_file, outfile, data, proton_charge):\n", |
162 | 149 | " import shutil\n", |
163 | | - "\n", |
164 | 150 | " shutil.copyfile(template_nexus_file, outfile)\n", |
165 | 151 | "\n", |
166 | 152 | " # detector_path = 'entry/instrument/histogram_mode_detectors/orca' # ODIN\n", |
167 | 153 | " detector_path = 'entry/instrument/orca_detector/' # TBL\n", |
168 | 154 | " proton_charge_path = 'entry/neutron_prod_info/pulse_charge'\n", |
169 | 155 | "\n", |
170 | 156 | " with h5.File(outfile, \"r+\") as f:\n", |
171 | | - " detector_data = f[detector_path + \"data\"]\n", |
| 157 | + "\n", |
| 158 | + " detector_data = f[detector_path+\"data\"]\n", |
172 | 159 | " replace_dataset(detector_data, name=\"value\", values=data[\"value\"])\n", |
173 | 160 | " replace_dataset(detector_data, name=\"time\", values=data[\"time\"])\n", |
174 | 161 | "\n", |
175 | 162 | " detector = f[detector_path]\n", |
176 | 163 | " detector.copy('intensifier', detector, 'camera_exposure')\n", |
177 | | - " exp = f[detector_path + \"camera_exposure\"]\n", |
| 164 | + " exp = f[detector_path+\"camera_exposure\"]\n", |
178 | 165 | " replace_dataset(exp, name=\"value\", values=np.array([exposure_time]))\n", |
179 | 166 | " replace_dataset(exp, name=\"average_value\", values=exposure_time)\n", |
180 | 167 | " replace_dataset(exp, name=\"minimum_value\", values=exposure_time)\n", |
181 | 168 | " replace_dataset(exp, name=\"maximum_value\", values=exposure_time)\n", |
182 | | - " f[detector_path + \"camera_exposure/value\"].attrs['units'] = 'ns'\n", |
183 | | - " f[detector_path + \"camera_exposure/average_value\"].attrs['units'] = 'ns'\n", |
184 | | - " f[detector_path + \"camera_exposure/minimum_value\"].attrs['units'] = 'ns'\n", |
185 | | - " f[detector_path + \"camera_exposure/maximum_value\"].attrs['units'] = 'ns'\n", |
| 169 | + " f[detector_path+\"camera_exposure/value\"].attrs['units'] = 'ns'\n", |
| 170 | + " f[detector_path+\"camera_exposure/average_value\"].attrs['units'] = 'ns'\n", |
| 171 | + " f[detector_path+\"camera_exposure/minimum_value\"].attrs['units'] = 'ns'\n", |
| 172 | + " f[detector_path+\"camera_exposure/maximum_value\"].attrs['units'] = 'ns'\n", |
186 | 173 | "\n", |
187 | 174 | " xoff = detector.create_dataset('x_pixel_offset', data=x_pixel_offset.values)\n", |
188 | 175 | " xoff.attrs['units'] = str(x_pixel_offset.unit)\n", |
|
195 | 182 | " pcharge = f[proton_charge_path]\n", |
196 | 183 | " replace_dataset(pcharge, name=\"value\", values=proton_charge[\"value\"])\n", |
197 | 184 | " replace_dataset(pcharge, name=\"time\", values=proton_charge[\"time\"])\n", |
198 | | - " replace_dataset(\n", |
199 | | - " pcharge, name=\"average_value\", values=proton_charge[\"value\"].mean()\n", |
200 | | - " )\n", |
201 | | - " replace_dataset(\n", |
202 | | - " pcharge, name=\"minimum_value\", values=proton_charge[\"value\"].min()\n", |
203 | | - " )\n", |
204 | | - " replace_dataset(\n", |
205 | | - " pcharge, name=\"maximum_value\", values=proton_charge[\"value\"].max()\n", |
206 | | - " )" |
| 185 | + " replace_dataset(pcharge, name=\"average_value\", values=proton_charge[\"value\"].mean())\n", |
| 186 | + " replace_dataset(pcharge, name=\"minimum_value\", values=proton_charge[\"value\"].min())\n", |
| 187 | + " replace_dataset(pcharge, name=\"maximum_value\", values=proton_charge[\"value\"].max())" |
207 | 188 | ] |
208 | 189 | }, |
209 | 190 | { |
|
219 | 200 | " template_nexus_file=template_nexus_file,\n", |
220 | 201 | " outfile=\"ymir_lego_dark_run.hdf\",\n", |
221 | 202 | " data={\"value\": dark_data, \"time\": dark_time},\n", |
222 | | - " proton_charge={\"value\": dark_charge_value, \"time\": dark_charge_time},\n", |
| 203 | + " proton_charge={\"value\": dark_charge_value, \"time\": dark_charge_time}\n", |
223 | 204 | ")" |
224 | 205 | ] |
225 | 206 | }, |
|
234 | 215 | " template_nexus_file=template_nexus_file,\n", |
235 | 216 | " outfile=\"ymir_lego_openbeam_run.hdf\",\n", |
236 | 217 | " data={\"value\": ob_data, \"time\": ob_time},\n", |
237 | | - " proton_charge={\"value\": ob_charge_value, \"time\": ob_charge_time},\n", |
| 218 | + " proton_charge={\"value\": ob_charge_value, \"time\": ob_charge_time}\n", |
238 | 219 | ")" |
239 | 220 | ] |
240 | 221 | }, |
|
249 | 230 | " template_nexus_file=template_nexus_file,\n", |
250 | 231 | " outfile=\"ymir_lego_sample_run.hdf\",\n", |
251 | 232 | " data={\"value\": sample_data, \"time\": sample_time},\n", |
252 | | - " proton_charge={\"value\": sample_charge_value, \"time\": sample_charge_time},\n", |
| 233 | + " proton_charge={\"value\": sample_charge_value, \"time\": sample_charge_time}\n", |
253 | 234 | ")" |
254 | 235 | ] |
255 | 236 | } |
|
0 commit comments