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 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421
|
# -*- coding: utf-8 -*-
__author__ = "Konstantin Klementiev"
__date__ = "08 Mar 2016"
import os, sys; sys.path.append(os.path.join('..', '..', '..')) # analysis:ignore
#import math
import xrt.plotter as xrtp
import xrt.runner as xrtr
import BalderBL
showIn3D = False
BalderBL.showIn3D = showIn3D
def add_plot(plots, plot, prefix, suffix):
plots.append(plot)
fileName = '{0}{1:02d}{2}{3}'.format(
prefix, len(plots), plot.title, suffix)
if not plot.fluxKind.startswith('power'):
plot.fluxFormatStr = '%.1p'
plot.saveName = [fileName + '.png', ]
# plot.persistentName = fileName + '.pickle'
def define_plots(beamLine, prefix, suffix):
dE = eMaxRays - eMinRays
if dE < eTune / 20.:
fwhmFormatStrE = '%.2f'
offsetE = eTune
else:
fwhmFormatStrE = None
offsetE = 0
plots = []
plot = xrtp.XYCPlot(
'beamFSM0', (1,),
xaxis=xrtp.XYCAxis(r'$x$', 'mm', limits=None),
yaxis=xrtp.XYCAxis(r'$z$', 'mm', limits=None),
caxis='category', ePos=0, title=beamLine.fsm0.name)
add_plot(plots, plot, prefix, suffix)
plot = xrtp.XYCPlot(
'beamFilter1local1', (1,),
xaxis=xrtp.XYCAxis(r'$x$', 'mm', limits=[-7, 7]),
yaxis=xrtp.XYCAxis(r'$y$', 'mm'),
ePos=1, title='Filter1 footprint1 I')
plot.caxis.fwhmFormatStr = fwhmFormatStrE
plot.fluxFormatStr = '%.2e'
plot.caxis.limits = [0, eMaxRays]
add_plot(plots, plot, prefix, suffix)
plot = xrtp.XYCPlot(
'beamFilter1local1', (1,),
xaxis=xrtp.XYCAxis(r'$x$', 'mm', limits=[-7, 7]),
yaxis=xrtp.XYCAxis(r'$y$', 'mm'),
fluxKind='power', ePos=1, title='Filter1 footprint1 P',
contourLevels=[0.85, 0.95], contourColors=['b', 'r'],
contourFmt=r'%.1f W/mm$^2$')
plot.caxis.fwhmFormatStr = fwhmFormatStrE
plot.fluxFormatStr = '%.0f'
plot.caxis.limits = [0, eMaxRays]
add_plot(plots, plot, prefix, suffix)
plot = xrtp.XYCPlot(
'beamFilter1local2', (1,),
xaxis=xrtp.XYCAxis(r'$x$', 'mm', limits=[-7, 7]),
yaxis=xrtp.XYCAxis(r'$y$', 'mm'),
fluxKind='power', ePos=1, title='Filter1 footprint2 P',
contourLevels=[0.85, 0.95], contourColors=['b', 'r'],
contourFmt=r'%.1f W/mm$^2$')
plot.caxis.fwhmFormatStr = fwhmFormatStrE
plot.fluxFormatStr = '%.0f'
plot.caxis.limits = [0, eMaxRays]
add_plot(plots, plot, prefix, suffix)
if hasattr(beamLine, 'filter2'):
plot = xrtp.XYCPlot(
'beamFilter2local1', (1,),
xaxis=xrtp.XYCAxis(r'$x$', 'mm', limits=[-7, 7]),
yaxis=xrtp.XYCAxis(r'$y$', 'mm'),
ePos=1, title='Filter2 footprint1 I')
plot.caxis.fwhmFormatStr = fwhmFormatStrE
plot.fluxFormatStr = '%.2e'
plot.caxis.limits = [0, eMaxRays]
add_plot(plots, plot, prefix, suffix)
plot = xrtp.XYCPlot(
'beamFilter2local1', (1,),
xaxis=xrtp.XYCAxis(r'$x$', 'mm', limits=[-7, 7]),
yaxis=xrtp.XYCAxis(r'$y$', 'mm'),
fluxKind='power', ePos=1, title='Filter2 footprint1 P')
plot.caxis.fwhmFormatStr = fwhmFormatStrE
plot.fluxFormatStr = '%.0f'
plot.caxis.limits = [0, eMaxRays]
add_plot(plots, plot, prefix, suffix)
plot = xrtp.XYCPlot(
'beamFilter2local2', (1,),
xaxis=xrtp.XYCAxis(r'$x$', 'mm', limits=[-7, 7]),
yaxis=xrtp.XYCAxis(r'$y$', 'mm'),
fluxKind='power', ePos=1, title='Filter2 footprint2 P',
contourLevels=[0.85, 0.95], contourColors=['b', 'r'],
contourFmt=r'%.1f W/mm$^2$')
plot.caxis.fwhmFormatStr = fwhmFormatStrE
plot.fluxFormatStr = '%.0f'
plot.caxis.limits = [0, eMaxRays]
add_plot(plots, plot, prefix, suffix)
plot = xrtp.XYCPlot(
'beamVCMlocal', (1, 2, 3), aspect='auto',
xaxis=xrtp.XYCAxis(r'$x$', 'mm', limits=[-16, 16]),
yaxis=xrtp.XYCAxis(r'$y$', 'mm', limits=[-660, 660]),
fluxKind='power', title='VCM footprint P', # oe=beamLine.vcm,
contourLevels=[0.85, 0.95], contourColors=['b', 'r'],
contourFmt=r'%.3f W/mm$^2$')
plot.caxis.fwhmFormatStr = fwhmFormatStrE
plot.fluxFormatStr = '%.0f'
plot.xaxis.fwhmFormatStr = '%.1f'
plot.yaxis.fwhmFormatStr = '%.0f'
plot.caxis.limits = [0, eMaxRays]
add_plot(plots, plot, prefix, suffix)
plot = xrtp.XYCPlot(
'beamDCMlocal1', (1, 2, 4), aspect='auto',
xaxis=xrtp.XYCAxis(r'$x$', 'mm', limits=[-12, 12]),
yaxis=xrtp.XYCAxis(r'$y$', 'mm', limits=[-32, 32]),
caxis='category', title='Xtal1_footprint C', oe=beamLine.dcm)
add_plot(plots, plot, prefix, suffix)
plot = xrtp.XYCPlot(
'beamDCMlocal1', (1,), aspect='auto',
xaxis=xrtp.XYCAxis(r'$x$', 'mm', limits=[-12, 12]),
yaxis=xrtp.XYCAxis(r'$y$', 'mm', limits=[-32, 32]),
fluxKind='power', title='Xtal1_footprint P', oe=beamLine.dcm,
contourLevels=[0.85, 0.95], contourColors=['b', 'r'],
contourFmt=r'%.1f W/mm$^2$')
plot.fluxFormatStr = '%.0f'
plot.caxis.fwhmFormatStr = fwhmFormatStrE
add_plot(plots, plot, prefix, suffix)
plot = xrtp.XYCPlot(
'beamDCMlocal2', (1, 2, 4, -2), aspect='auto',
xaxis=xrtp.XYCAxis(r'$x$', 'mm', limits=[-12, 12]),
yaxis=xrtp.XYCAxis(r'$y$', 'mm', limits=[-92, 92]),
caxis='category', title='Xtal2_footprint', oe=beamLine.dcm,
raycingParam=2)
add_plot(plots, plot, prefix, suffix)
plot = xrtp.XYCPlot(
'beamDCMlocal2', (1, 4), aspect='auto',
xaxis=xrtp.XYCAxis(r'$x$', 'mm', limits=[-12, 12]),
yaxis=xrtp.XYCAxis(r'$y$', 'mm', limits=[-92, 92]),
ePos=1, title='Xtal2_footprintE', oe=beamLine.dcm, raycingParam=2)
plot.fluxFormatStr = '%.2e'
plot.caxis.fwhmFormatStr = fwhmFormatStrE
plot.caxis.offset = offsetE
add_plot(plots, plot, prefix, suffix)
plot = xrtp.XYCPlot(
'beamBSBlocklocal',
(1, 2, beamLine.BSBlock.lostNum),
xaxis=xrtp.XYCAxis(r'$x$', 'mm', limits=[-15, 15]),
yaxis=xrtp.XYCAxis(r'$z$', 'mm', limits=[20, 50]),
caxis='category', title=beamLine.BSBlock.name, oe=beamLine.BSBlock)
add_plot(plots, plot, prefix, suffix)
op = beamLine.slitAfterDCM.opening
cz = (op[2] + op[3]) / 2
plot = xrtp.XYCPlot(
'beamSlitAfterDCMlocal', (1, 2, beamLine.slitAfterDCM.lostNum),
xaxis=xrtp.XYCAxis(r'$x$', 'mm', limits=[-8, 8]),
yaxis=xrtp.XYCAxis(r'$z$', 'mm', limits=[cz-8, cz+8]),
caxis='category', title=beamLine.slitAfterDCM.name,
oe=beamLine.slitAfterDCM)
add_plot(plots, plot, prefix, suffix)
plot = xrtp.XYCPlot(
'beamVFMlocal', (1, 2, 3), aspect='auto',
xaxis=xrtp.XYCAxis(r'$x$', 'mm', limits=[-12, 12]),
yaxis=xrtp.XYCAxis(r'$y$', 'mm', limits=[-710, 710]),
caxis='category', title='VFM_footprint', oe=beamLine.vfm)
add_plot(plots, plot, prefix, suffix)
op = beamLine.slitAfterVFM.opening
cz = (op[2] + op[3]) / 2
plot = xrtp.XYCPlot(
'beamSlitAfterVFMlocal', (1, 2, beamLine.slitAfterVFM.lostNum),
xaxis=xrtp.XYCAxis(r'$x$', 'mm', limits=[-8, 8]),
yaxis=xrtp.XYCAxis(r'$z$', 'mm', limits=[cz-8, cz+8]),
caxis='category', title=beamLine.slitAfterVFM.name,
oe=beamLine.slitAfterVFM)
add_plot(plots, plot, prefix, suffix)
plot = xrtp.XYCPlot(
'beamPSLocal', (1, 2, 4, beamLine.ohPS.lostNum),
xaxis=xrtp.XYCAxis(r'$x$', 'mm', limits=[-10, 10]),
yaxis=xrtp.XYCAxis(r'$z$', 'mm', limits=[30, 50]),
caxis='category', title=beamLine.ohPS.name, oe=beamLine.ohPS)
add_plot(plots, plot, prefix, suffix)
#
op = beamLine.slitEH.opening
cz = (op[2] + op[3]) / 2
dx = (op[1] - op[0]) / 2
plot = xrtp.XYCPlot(
'beamSlitEHLocal', (1, 2, beamLine.slitEH.lostNum),
xaxis=xrtp.XYCAxis(r'$x$', 'mm', limits=[-dx, dx]),
yaxis=xrtp.XYCAxis(r'$z$', 'mm', limits=[cz-dx, cz+dx]),
caxis='category', title=beamLine.slitEH.name, oe=beamLine.slitEH)
add_plot(plots, plot, prefix, suffix)
# dz = max(0.1, beamLine.spotSizeH*0.55)
dz = 2
plot = xrtp.XYCPlot(
'beamFSMSample', (1, 2),
xaxis=xrtp.XYCAxis(r'$x$', 'mm', limits=[-dz, dz],
fwhmFormatStr='%1.3f'),
yaxis=xrtp.XYCAxis(r'$z$', 'mm', limits=[cz-dz, cz+dz],
fwhmFormatStr='%1.3f'),
caxis='category', title=beamLine.fsmSample.name)
add_plot(plots, plot, prefix, suffix)
plot = xrtp.XYCPlot(
'beamFSMSample', (1,),
xaxis=xrtp.XYCAxis(r'$x$', 'mm', limits=[-dz, dz],
fwhmFormatStr='%1.3f'),
yaxis=xrtp.XYCAxis(r'$z$', 'mm', limits=[cz-dz, cz+dz],
fwhmFormatStr='%1.3f'),
ePos=1, title=beamLine.fsmSample.name+'E')
plot.fluxFormatStr = '%.2e'
plot.caxis.fwhmFormatStr = fwhmFormatStrE
plot.caxis.offset = offsetE
add_plot(plots, plot, prefix, suffix)
return plots
def main(pitch, fixedExit, hkl, stripe, eMinRays, eMaxRays, eTune, vfmR,
prefix):
myBalder = BalderBL.build_beamline(100000, hkl, stripe, eMinRays, eMaxRays)
BalderBL.align_beamline(
myBalder, pitch=pitch, energy=eTune, fixedExit=fixedExit, vfmR=vfmR)
suffix = ''
#= touch the beam with the EH slit: ===========================================
# note that for using `touch_beam` the beams must exist, therefore you should
# run the source shrinkage above or `run_process` below this line.
# BalderBL.run_process(myBalder)
# myBalder.slitEH.touch_beam(myBalder.beams['beamVFMglobal'])
if showIn3D:
myBalder.glow(centerAt='VFM')
return
plots = define_plots(myBalder, prefix, suffix)
xrtr.run_ray_tracing(plots, repeats=8, beamLine=myBalder, processes='half')
# myBalder.glow()
#this is necessary to use multiprocessing in Windows, otherwise the new Python
#contexts cannot be initialized:
if __name__ == '__main__':
# pitchNo = '00'; pitch = 2.0e-3; fixedExit = 20.86
# pitchNo = '02'; pitch = 1.0e-3; fixedExit = 31.43
# pitchNo = '03'; pitch = 1.5e-3; fixedExit = 26.14
# pitchNo = '04'; pitch = 3.0e-3; fixedExit = 10.2
pitchNo = '05'
pitch = 2.2e-3
fixedExit = 18.6
vfmR = 'auto'
case = 7, 1
if case == 1:
stripe = 'Si'
eMinRays, eMaxRays = None, None
eTune = 9000
hkl = (1, 1, 1)
estr = '01-whiteSi'
elif case == 2:
stripe = 'Ir'
eMinRays, eMaxRays = None, None
eTune = 9000
hkl = (1, 1, 1)
estr = '02-whiteIr'
elif case == 3:
stripe = 'Si'
eMinRays, eMaxRays = 3999.5, 4001.5
eTune = 4000
hkl = (1, 1, 1)
estr = '03-04keV'
elif case == (3, 2):
stripe = 'Si'
eMinRays, eMaxRays = 12000.0, 12000.5
eTune = 4000*3
hkl = (3, 3, 3)
estr = '03h-04keV'
elif case == 4:
stripe = 'Si'
eMinRays, eMaxRays = 9000, 9002
eTune = 9000
hkl = (1, 1, 1)
estr = '04-09keV'
elif case == (4, 2):
stripe = 'Si'
eMinRays, eMaxRays = 27000, 27001
eTune = 9000*3
hkl = (3, 3, 3)
estr = '04h-09keV'
elif case == 5:
stripe = 'Ir'
eMinRays, eMaxRays = 15000.5, 15004
eTune = 15000
hkl = (1, 1, 1)
estr = '05-15keV'
elif case == (5, 2):
stripe = 'Ir'
eMinRays, eMaxRays = 45000, 45002
eTune = 15000*3
hkl = (3, 3, 3)
estr = '05h-15keV'
elif case == 6:
stripe = 'Ir'
eMinRays, eMaxRays = 26000, 26002
eTune = 26000
hkl = (3, 1, 1)
estr = '06-26keV'
elif case == (6, 2):
stripe = 'Ir'
eMinRays, eMaxRays = 78000, 78002
eTune = 26000*3
hkl = (9, 3, 3)
estr = '06h-26keV'
elif case == (7, 1):
stripe = 'Si'
eTune = 10000
eMinRays, eMaxRays = eTune, eTune + 2.5
hkl = (1, 1, 1)
estr = '07-10keV-focused'
elif case == (7, 2):
stripe = 'Si'
eTune = 10000
eMinRays, eMaxRays = eTune, eTune + 2.5
hkl = (1, 1, 1)
pitch = 1.5e-3
estr = '07-10keV-focusedV'
elif case == (7, 3):
stripe = 'Si'
eTune = 10000
eMinRays, eMaxRays = eTune, eTune + 2.5
hkl = (1, 1, 1)
pitch = 1.5e-3
vfmR = 1e20
estr = '07-10keV-unfocused'
elif case == (7, 4):
stripe = 'Si'
eMinRays, eMaxRays = 4000, 4001
eTune = 4000
hkl = (1, 1, 1)
pitch = 3.0e-3
estr = '07-04keV-focusedV'
elif case == (7, 5):
stripe = 'Si'
eMinRays, eMaxRays = 4000, 4001
eTune = 4000
hkl = (1, 1, 1)
pitch = 3.0e-3
vfmR = 1e20
estr = '07-04keV-unfocused'
elif case == (8, 1):
stripe = 'Si'
eTune = 10000
eMinRays, eMaxRays = eTune, eTune + 2.5
hkl = (1, 1, 1)
pitch = 2.2e-3
estr = '08-10keV-focusedV'
elif case == (8, 2):
stripe = 'Si'
eTune = 10000
eMinRays, eMaxRays = eTune, eTune + 2.5
hkl = (1, 1, 1)
pitch = 2.2e-3
vfmR = 1e20
estr = '08-10keV-unfocused'
elif case == (8, 3):
stripe = 'Si'
eTune = 10000
eMinRays, eMaxRays = eTune, eTune + 2.5
hkl = (1, 1, 1)
pitch = 2.2e-3
vfmR = 20e6
estr = '08-10keV-half-unfocused'
elif case == (8, 4):
stripe = 'Si'
eMinRays, eMaxRays = 4000, 4001
eTune = 4000
hkl = (1, 1, 1)
pitch = 2.2e-3
estr = '08-04keV-focusedV'
elif case == (8, 5):
stripe = 'Si'
eMinRays, eMaxRays = 4000, 4001
eTune = 4000
hkl = (1, 1, 1)
pitch = 2.2e-3
vfmR = 1e20
estr = '08-04keV-unfocused'
elif case == (8, 6):
stripe = 'Si'
eMinRays, eMaxRays = 4000, 4001
eTune = 4000
hkl = (1, 1, 1)
pitch = 2.2e-3
vfmR = 20e6
estr = '08-04keV-half-unfocused'
else:
print('unknown case')
raise
prefix = '{0}-{1}mrad-{2}-'.format(pitchNo, pitch*1e3, estr)
main(pitch, fixedExit, hkl, stripe, eMinRays, eMaxRays, eTune, vfmR,
prefix)
|