geofip.py 21 KB
Newer Older
Yoann Sallaz Damaz's avatar
Yoann Sallaz Damaz committed
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
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
#!/bin/python3
# -*- coding: utf-8 -*-
"""
                  GEOFIP
program for geometry modelisation on beamline FIP2 

Created on Thu Nov 21 12:42:54 2019

@author: JL FERRER (C version). Conversion to Python by E. MATHIEU
"""

import sys


##########################################################################
#       ENERGY TABLE FOR EACH COMPONENT
##########################################################################
tab_nrj=[
        ("U",       "L3",   8.955,     0.72227),
        ("Y",       "K",    9.022,     0.72766),
        ("Bi",      "L1",   9.387,     0.75710),
        ("Sr",      "K",    9.544,     0.76973),
        ("Pb",      "L1",   9.695,     0.78196),
        ("Bi",      "L2",   9.779,     0.78870),
        ("Tl",      "L1",   10.019,    0.80810),
        ("Pb",      "L2",   10.110,    0.81538),
        ("Rb",      "K",    10.111,    0.81554),
        ("Hg",      "L1",   10.356,    0.83530),
        ("Tl",      "L2",   10.457,    0.84340),
        ("Au",      "L1",   10.709,    0.86376),
        ("Kr",      "K",    10.731,    0.86552),
        ("Hg",      "L2",   10.814,    0.87220),
        ("Pt",      "L1",   11.073,    0.89310),
        ("Au",      "L2",   11.191,    0.90259),
        ("Br",      "K",    11.412,    0.92040),
        ("Bi",      "L3",   11.449,    0.92340),
        ("Ir",      "L1",   11.451,    0.92360),
        ("Pt",      "L2",   11.582,    0.93414),
        ("Pb",      "L3",   11.788,    0.95073),
        ("Os",      "L1",   11.851,    0.95580),
        ("Ir",      "L2",   11.991,    0.96710),
        ("Tl",      "L3",   12.142,    0.97930),
        ("Se",      "K",    12.147,    0.97974),
        ("Re",      "L1",   12.267,    0.98940),
        ("Os",      "L2",   12.416,    1.00140),
        ("Hg",      "L3",   12.511,    1.00910),
        ("W",       "L1",   12.704,    1.02467),
        ("Re",      "L2",   12.859,    1.03710),
        ("Au",      "L3",   12.894,    1.04000),
        ("As",      "K",    12.956,    1.04500),
        ("Ta",      "L1",   13.159,    1.06130),
        ("Pt",      "L3",   13.295,    1.07230),
        ("W",       "L2",   13.322,    1.07450),
        ("Hf",      "L1",   13.635,    1.09970),
        ("Ir",      "L3",   13.710,    1.10580),
        ("Ta",      "L2",   13.808,    1.11370),
        ("Ge",      "K",    13.844,    1.11658),
        ("Lu",      "L1",   14.137,    1.14020),
        ("Os",      "L3",   14.144,    1.14080),
        ("Hf",      "L2",   14.318,    1.15480),
        ("Re",      "L3",   14.597,    1.17730),
        ("Yb",      "L1",   14.653,    1.18180),
        ("Ga",      "K",    14.826,    1.19580),
        ("Lu",      "L2",   14.860,    1.19850),
        ("W",       "L3",   15.070,    1.21550),
        ("Tm",      "L1",   15.188,    1.22500),
        ("Yb",      "L2",   15.409,    1.24280),
        ("Ta",      "L3",   15.564,    1.25530),
        ("Er",      "L1",   15.754,    1.27060),
        ("Zn",      "K",    15.912,    1.28340),
        ("Tm",      "L2",   15.984,    1.28920),
        ("Hf",      "L3",   16.083,    1.29720),
        ("Ho",      "L1",   16.354,    1.31900),
        ("Er",      "L2",   16.597,    1.33860),
        ("Lu",      "L3",   16.620,    1.34050),
        ("Dy",      "L1",   16.976,    1.36920),
        ("Cu",      "K",    17.117,    1.38059),
        ("Yb",      "L3",   17.187,    1.38620),
        ("Ho",      "L2",   17.240,    1.39050),
        ("Tb",      "L1",   17.634,    1.42230),
        ("Tm",      "L3",   17.772,    1.43340),
        ("Dy",      "L2",   17.910,    1.44450),
        ("Gd",      "L1",   18.330,    1.47840),
        ("Er",      "L3",   18.393,    1.48350),
        ("Ni",      "K",    18.450,    1.48807),
        ("Tb",      "L2",   18.626,    1.50230),
        ("Ho",      "L3",   19.054,    1.53680),
        ("Eu",      "L1",   19.070,    1.53810),
        ("Cu",      "Em",   19.094,    1.54000),
        ("Gd",      "L2",   19.381,    1.56320),
        ("Dy",      "L3",   19.733,    1.59160),
        ("Sm",      "L1",   19.840,    1.60020),
        ("Co",      "K",    19.939,    1.60815),
        ("Eu",      "L2",   20.174,    1.62710),
        ("Tb",      "L3",   20.454,    1.64970),
        ("Pm",      "L1",   20.673,    1.66740),
        ("Sm",      "L2",   21.019,    1.69530),
        ("Gd",      "L3",   21.223,    1.71170),
        ("Nd",      "L1",   21.561,    1.73900),
        ("Fe",      "K",    21.616,    1.74346),
        ("Pm",      "L2",   21.916,    1.76760),
        ("Eu",      "L3",   22.021,    1.77610),
        ("Nd",      "L2",   22.863,    1.84400),
        ("Sm",      "L3",   22.884,    1.84570),
        ("Mn",      "K",    23.513,    1.89643)] 


##########################################################################
#       GEOFIP FUNCTION
# LAMBDA in angstroem
# VERBOSE >= 2 => full display, 1 => one line output, 0 => silent
##########################################################################
def geofip(LAMBDA=0.97974,VERBOSE=2):
    import sys
    import math as math
    
    #--------------------------------------------------------------------
    #VARIABLES DEFINITION
    #--------------------------------------------------------------------
    DILAT_C1  = -0.00023   # DL/L de c1 with respect to c2   
                           #0.0     at Tc1 = 293 K  
                           #-0.00023 at Tc1 =  75 K 
                           #-0.00024 at Tc1 = 100 K 
    PARAM_SI  = 6.271       # 2d of Si at 20degC, in Ang.
                           #  Si 111: 6.271  
                           #  Si 311: 3.274 
    CUTOFF    = 0.75          # default value of the cutoff
    CUT_ANGLE = 0.00563    # 0.00685 for Pt 
                           # 0.00563 for Rh
    
    
    
    
    
    #--------------------------------------------------------------------             
    #FIP2 PARAMETERS
    #--------------------------------------------------------------------
    X_SOURCE  = 0.00  #everything shifted -2800.00
    X_MASK    = 23455.00  #masque dans le front end 
    X_CACHE   = 28965.25  #cache a l entree de M1  
    X_M1      = 29615.25
    X_BE      = 30515.25
    X_FILW    = 31329.25
    X_C1      = 32344.05
    X_M2      = 35072.85
    X_FLUO1   = 33705.85
    X_FLUO2   = 36257.85
    X_FLUO3   = 54970.69
    X_SP      = 57149.69
    
    #-------------------
    
    Z_SOURCE        = 0.0         # altitude first mirror           
    SLOPE_SOURCE    = 0.0         # assuming z magnet = 0           
    FAN_SOURCE      = 0.001663    # div horiz du faisceau, en rad   
    DIV_V_SOURCE    = 0.0002      # div vert du faisceau a 10 keV, en rad FWMH 
    APERT_V_MASK    = 8.0         # ouverture verticale du mask (mm)
    APERT_V_CACHE   = 6.8         # ouverture verticale du cache a l entree de M1 (mm)
    Z_SAMPLE        = -20.        # altitude second mirror          
    LENGTH_MIRRORS  = 1300.0      # longueur des miroirs            
    
    RATE_Z_MIRRORS  = 20000.
    ORIG_INCL1      = 0.0         # -0.0435  0.03344                
    ORIG_INCL2      = 0.0         # last modif. 21 Apr 99           
    RATE_INCL       = -1.
    RATE_M1_MOT     = -25151.     # motor steps per deg.            
    RATE_M2_MOT     = -23057.     # motor steps per deg.            
    ORIG_H          = 0.0         # altitude C1 fin de course bas   
                                        # crystal1 111: -2.86             
                                        # crystal1 311: -3.29             
    RATE_H      = 2000.       # steps per mm                    
    ORIG_B      = 0.0         # origine codeur                  
    ASYM_B      = 0.0         # crystal asymetry                
                                        # crystal 111: 0.087              
                                        # crystal 111: ?                  
    RATE_B      = 20000.      # steps per deg.                  
    RATE_B_MOT  = 4000.       # steps per deg.                  
    ORIG_X      = 134.        # 130.                            
    RATE_X      = -2000.      # steps per mm                    
    ORIG_Z      = 18.0        # gap vertical entre les crystaux 
                                        # crystal2 peigne: 27.5           
                                        # crystal2 311 sur bender: 38.5   
    RATE_Z      = -2000.      # steps per mm           
    
    step_B      = 0.
    fstep       = 0.
    
    '''
    z_mask,z_m1,z_be,z_filw,z_c1,z_c2,z_m2,z_fluo1,z_fluo2,z_fluo3 = float()
    cutoff,param_c1 = float()
    # cutoff   : ratio actual angle/critical angle for mirrors
    # param_c1 : param Si C1, including thermal effect (cryo) 
    bragg_angle,critic_angle,mirror_angle,mono_angle,equiv_angle = float()
    # mirror_angle : angle of incident beam / surface M1      
    # equiv_angle  : geom. equiv. angle of M1 with SLOPE = 0. 
    br_angle_c1,br_angle_c2,angle_m1,angle_m2 = float()
    radius_m1,radius_m2,radius_c2 = float()
    l,d,x_c2,dx,dz,resol = float()
    f1,f2,dist_m1c1,dist_c2m2 = float()
    incl_M1,incl_M2,depth_M1,depth_M2 = float()
    result = str()
    
    error,ltmp,lstep,lstep2,lvoid,status = str()
    fstep = float()
    device = str()
      
    H_MASK, L_MASK, z_MASK = float()  # hauteur, largeur et altitude du faisceau au niveau du mask du FE              
    H_M1, L_M1, z_M1  = float()       # hauteur, largeur et altitude du faisceau au niveau de M1                      
    H_BE, L_BE, z_BE  = float()       # hauteur, largeur et altitude du faisceau au niveau de la fenetre Be           
    H_C1, L_C1, z_C1  = float()       # hauteur, largeur et altitude du faisceau au niveau de C1                      
    H_C2, L_C2, z_C2  = float()       # hauteur, largeur et altitude du faisceau au niveau de C2                      
    H_M2, L_M2, z_M2  = float()       # hauteur, largeur et altitude du faisceau au niveau de M2                      
    H_SP, L_SP, z_SP  = float()       # hauteur, largeur et altitude du faisceau au niveau de l'echantillon (sans KB) 
    
    div_v_source,div_v_mask,div_v_cache,div_v_m1,div_v_min, vert_collected = float()
    footprint_c1,footprint_c2 = float()
    '''
    z_mask  = Z_SOURCE
    z_m1    = Z_SOURCE
    z_m2    = Z_SAMPLE
    z_fluo2 = Z_SAMPLE
    z_fluo3 = Z_SAMPLE
    cutoff  = CUTOFF
    param_c1= PARAM_SI*(1.+DILAT_C1)


    
    #-------------------------------------------------------------------------
    # computation: physical parameters 
    # ------------------------------------------------------------------------
      
    resol        = LAMBDA/(2.*math.sin(math.atan(172.5/219.)/2.))
    br_angle_c1  = math.asin(LAMBDA/param_c1)
    br_angle_c2  = math.asin(LAMBDA/PARAM_SI)
    bragg_angle  = br_angle_c1
    critic_angle = CUT_ANGLE*LAMBDA
    mirror_angle = cutoff*critic_angle
    equiv_angle  = mirror_angle + SLOPE_SOURCE*math.pi/360.
    angle_m1     = mirror_angle + SLOPE_SOURCE*math.pi/180.
    angle_m2     = mirror_angle + br_angle_c2 - br_angle_c1 + SLOPE_SOURCE*math.pi/360.
    mono_angle   = bragg_angle - 2.*mirror_angle - SLOPE_SOURCE*math.pi/180.
    radius_m1    = 2.*X_M1/math.sin(mirror_angle)
    radius_m2    = 2.*(X_SP - X_M2)/math.sin(angle_m2)
    
    z_be   = (X_BE - X_M1)*math.tan(2.*equiv_angle) + z_m1
    z_filw = (X_FILW - X_M1)*math.tan(2.*equiv_angle) + z_m1
    z_c1   = (X_C1 - X_M1)*math.tan(2.*equiv_angle) + z_m1
    l      = (X_M2 - X_M1)/2.
    d      = 2.*l*math.sin(2.*equiv_angle) + (z_m1 - z_m2)/math.cos(2.*equiv_angle)
    dist_m1c1    = (X_C1 - X_M1)/math.cos(2.*equiv_angle)
    dist_c2m2    = (2.*l - (X_C1 - X_M1) - d/math.sin(2.*bragg_angle)*math.cos(2.*bragg_angle-2.*equiv_angle))/math.cos(2.*equiv_angle)
    f1           = X_M1 + dist_m1c1 + d/math.sin(2.*bragg_angle)
    f2           = dist_c2m2 + (X_SP - X_M2)
    radius_c2    = 2.*f1*f2*math.sin(bragg_angle)/(f1+f2)
    x_c2   = X_C1 + l*math.sin(2.*equiv_angle)*math.cos(2.*bragg_angle - 2.*equiv_angle)/(math.sin(bragg_angle)*math.cos(bragg_angle))
    z_c2   = (x_c2 - X_M2)*math.tan(2.*angle_m2) + z_m2
    dx     = d/(2.*math.sin(bragg_angle))
    dz     = d/(2.*math.cos(bragg_angle))
    z_fluo1= (X_FLUO1 - X_M2)*math.tan(2.*angle_m2) + z_m2
    depth_M1= 1200.*1200./(8.*radius_m1)
    depth_M2= 1200.*1200./(8.*radius_m2)
    
    # ------------------------------------------------------------------------
    # computation: technical parameters 
    # ------------------------------------------------------------------------
     
    incl_M1= (angle_m1*180./math.pi + ORIG_INCL1)*RATE_INCL
    incl_M2= (angle_m2*180./math.pi + ORIG_INCL2)*RATE_INCL
     
    # output 
    # ------ 
    
    if(VERBOSE>=2): print("(max resol with Mar345 at 0 deg: %f Ang)" % (resol)) 
    if(VERBOSE>=2): print("bragg angle c1 = %6.4g deg" % (br_angle_c1*180./math.pi))
    if(VERBOSE>=2): print("bragg angle c2 = %6.4g deg" % (br_angle_c2*180./math.pi))
    if(VERBOSE>=2): print("mono angle     = %6.4g deg" % (mono_angle*180./math.pi))
    if(VERBOSE>=2): print("critical angle = %6.4g deg\n" % (critic_angle*180./math.pi))
    if(VERBOSE>=2): print("mirror 1:  angle = %6.4g deg" % (angle_m1*180./math.pi))
    if(VERBOSE>=2): print("                    (%6.4g deg incl. M1)" % (incl_M1))
    if(VERBOSE>=2): print("           radius= %6.4g km    depth=%4.2g microns\n" % (radius_m1/1000000.,1000.*depth_M1))
    if(VERBOSE>=2): print("mirror 2:  angle = %6.4g deg" % (angle_m2*180./math.pi))
    if(VERBOSE>=2): print("                    (%6.4g deg incl. M2)" % (incl_M2))
    if(VERBOSE>=2): print("           radius= %6.4g km    depth=%4.2g microns\n" % (radius_m2/1000000.,1000.*depth_M2))
    if(VERBOSE>=2): print("") 
    # print("alt. Be window = %6.4g mm" % (z_be)    )
    # print("alt. wires mon.= %6.4g mm" % (z_filw)  )
    # print("alt. fluor. 1  = %6.4g mm" % (z_fluo1) )
    # print("")                                  
    if(VERBOSE>=2): print("alt. 1st cryst.= %6.4g mm" % (z_c1))
    if(VERBOSE>=2): print("alt. 2nd cryst.= %6.4g mm" % (z_c2))
    if(VERBOSE>=2): print("long. dist. between cryst.= %6.4g mm" % (dx))
    if(VERBOSE>=2): print("vert. dist. between cryst.= %6.4g mm" % (dz))
    if(VERBOSE>=2): print("R 2nd crystal  = %6.4g m" % (radius_c2/1000.))
    if(VERBOSE>=2): print("-------------------------------------------------------------") 
    
    if(VERBOSE==1): print("%6.4g %6.4g %6.4g %6.4g %6.4g" % (LAMBDA,dx,dz,z_c1,radius_c2/1000.))
    
      
    # limitation de la taille verticale du faisceau    
    # calcul de la divergence verticale, en mrad, FWMH 
      
    # divergence verticale de la source, profil gaussien 
    div_v_source = (DIV_V_SOURCE-0.00002)*pow((1.2402/LAMBDA),(-0.66))+0.00002
    if(VERBOSE>=2): print("vert divergence of the source  : %6.4g (mrad)" % (1000*div_v_source))
    
    # divergence verticale limitee par le mask     
    div_v_mask = 2.0*math.atan(APERT_V_MASK/(2.0*X_MASK))
    if(VERBOSE>=2): print("vert divergence due to the mask: %6.4g (mrad)" % (1000*div_v_mask))
    
    # divergence verticale limitee par le cache de M1  
    div_v_cache = 2.0*math.atan(APERT_V_CACHE/(2.0*X_CACHE))
    if(VERBOSE>=2): print("vert divergence due au cache M1: %6.4g (mrad)" % (1000*div_v_cache))
    
    # divergence verticale limitee par M1    
    div_v_m1 = 2.0*math.atan(LENGTH_MIRRORS * math.tan(angle_m1)/(2.0*X_M1))
    if(VERBOSE>=2): print("vert divergence due to M1      : %6.4g (mrad)" % (1000*div_v_m1))
    
    # divergence verticale due a l'element le plus limitant 
    div_v_min = min([div_v_source,div_v_mask])
    div_v_min = min([div_v_min,div_v_cache])
    div_v_min = min([div_v_min,div_v_m1])
    vert_collected = div_v_min / div_v_source
    if(VERBOSE>=2): print("minimal vert divergence        : %6.4g (mrad)" % (1000*div_v_min))
    if(VERBOSE>=2): print("part of vertical beam collected: %6.4g (ratio)" % (vert_collected))
    if(VERBOSE>=2): print("-------------------------------------------------------------") 
      
    # hauteur, largeur et altitude du faisceau         
    # hauteur naturelle de la source 
     
    H_MASK = 2.0 * math.tan(div_v_min/2.0) * X_MASK
    L_MASK = 2.0 * math.tan(FAN_SOURCE/2.0) * X_MASK
    z_MASK = 0
    # H_M1 = 2.0 * tan(div_v_min/2.0) * X_M1 
    # H_M1 = 2.0 * tan(div_v_min/2.0) * X_M1; #To be used to get the max height limited by other OE
    H_M1 = 2.0 * math.tan(div_v_source/2.0) * X_M1
    L_M1 = 2.0 * X_M1 * math.tan(FAN_SOURCE/2.0)
    z_M1 = 0
    H_BE = H_M1
    L_BE = 2.0 * X_BE * math.tan(FAN_SOURCE/2.0)
    z_BE = z_be
    H_C1 = H_M1
    L_C1 = 2.0 * X_C1 * math.tan(FAN_SOURCE/2.0)
    z_C1 = z_c1
    H_C2 = H_M1
    L_C2 = 2.0 * x_c2 * math.tan(FAN_SOURCE/2.0)
    z_C2 = z_c2
    H_M2 = H_M1
    L_M2 = L_C2 * (X_SP-X_M2)/(X_SP-x_c2)
    z_M2 = Z_SAMPLE
    H_SP = 0.0
    L_SP = 0.0
    z_SP = Z_SAMPLE
    
    if(VERBOSE>=2): print("Beam height, width and altitude at FE mask: %6.4g %6.4g %6.4g (mm)" % (H_MASK,L_MASK,z_MASK))
    if(VERBOSE>=2): print("Beam height, width and altitude at M1     : %6.4g %6.4g %6.4g (mm)" % (H_M1,L_M1,z_M1))
    if(VERBOSE>=2): print("Beam height, width and altitude at BE wind: %6.4g %6.4g %6.4g (mm)" % (H_BE,L_BE,z_BE))
    if(VERBOSE>=2): print("          Bottom / top of the beam :%6.4g %6.4g (mm)" % (z_BE-H_BE/2.,z_BE+H_BE/2.))
    if(VERBOSE>=2): print("Beam height, width and altitude at C1     : %6.4g %6.4g %6.4g (mm)" % (H_C1,L_C1,z_C1))
    if(VERBOSE>=2): print("Beam height, width and altitude at C2     : %6.4g %6.4g %6.4g (mm)" % (H_C2,L_C2,z_C2))
    if(VERBOSE>=2): print("Beam height, width and altitude at M2     : %6.4g %6.4g %6.4g (mm)" % (H_M2,L_M2,z_M2))
    if(VERBOSE>=2): print("Beam height, width and altitude at SP     : %6.4g %6.4g %6.4g (mm)" % (H_SP,L_SP,z_SP))
    if(VERBOSE>=2): print("-------------------------------------------------------------") 
    
    
    # footprint on crystals    
    footprint_c1 = H_C1 / math.sin(bragg_angle)
    if(VERBOSE>=2): print("Beam footprint on C1: %6.4g (mm)" % (footprint_c1))
    if(VERBOSE>=2): print("-------------------------------------------------------------") 
    
    
    #write computed data into a dictionnary and return it
    geofipdata = {
      "lambda": LAMBDA,
      "resol": resol,
      "br_angle_c1": br_angle_c1,
      "br_angle_c2": br_angle_c2,
      "mono_angle": mono_angle,
      "critic_angle": critic_angle, 
      "angle_m1": angle_m1,
      "incl_M1": incl_M1,
      "radius_m1": radius_m1,
      "depth_M1": depth_M1,
      "angle_m2": angle_m2,
      "incl_M2": incl_M2,
      "radius_m2": radius_m2,
      "depth_M2": depth_M2,
      "z_be": z_be,
      "z_filw": z_filw,
      "z_fluo1": z_fluo1,
      "z_c1": z_c1,
      "z_c2": z_c2,
      "dx": dx,
      "dz": dz,
      "radius_c2": radius_c2,
      "div_v_source": div_v_source,
      "div_v_mask": div_v_mask,
      "div_v_m1": div_v_m1,
      "div_v_min": div_v_min,
      "vert_collected": vert_collected,
      "H_MASK": H_MASK,
      "L_MASK": L_MASK,
      "z_MASK": z_MASK,
      "H_M1": H_M1,
      "L_M1": L_M1,
      "z_M1": z_M1,
      "H_BE": H_BE,
      "L_BE": L_BE,
      "z_BE": z_BE,
      "H_C1": H_C1,
      "L_C1": L_C1,
      "z_C1": z_C1,
      "H_C2": H_C2,
      "L_C2": L_C2,
      "z_C2": z_C2,
      "H_M2": H_M2,
      "L_M2": L_M2,
      "z_M2": z_M2,
      "H_SP": H_SP,
      "L_SP": L_SP,
      "z_SP": z_SP,
      "footprint_c1": footprint_c1,
    }
    return geofipdata
    




##########################################################################
#       MAIN
##########################################################################
def main():  
    import argparse
    parser = argparse.ArgumentParser()    
    parser.add_argument("LAMBDA", metavar='?', help="Provide the wavelength (Å) or the energy (eV or keV) or the element (ex: Se) or the element_shell (ex: Se_k)", type=str)   
    try:
        args = parser.parse_args() # read given arguments
    except:
        print("--------------------------------------------------")
        parser.print_help()
        print("--------------------------------------------------")
        sys.exit(0)
    
    LAMBDA = args.LAMBDA
    if LAMBDA.isdigit():
        # lambda is wavelength or energy
        LAMBDA=float(LAMBDA)
        if LAMBDA > 1000:
            #LAMBDA is eV -> Anglstroem
            LAMBDA /= 12398.56
        elif LAMBDA<2:
            #LAMBDA is Angstroem -> OK
            pass
        else:
            #LAMBDA is keV -> Anglstroem
            LAMBDA /= 12.39856
    else:
        # lambda is an element
        element = LAMBDA.split("_")
        if len(element)==1:
            tab_nrj_search = [i for i in tab_nrj if i[0].upper()==element[0].upper()] 
            if len(tab_nrj_search)!=1:
                print("ERROR You need to specify also the electron shell\nex: W_L1")
                sys.exit(0)
            else:
                LAMBDA=tab_nrj_search[0][3]
        else:
            tab_nrj_search = [i for i in tab_nrj if i[0].upper()==element[0].upper() and i[1].upper()==element[1].upper()] 
            if len(tab_nrj_search)!=1:
                print("ERROR element not found")
                sys.exit(0)
            else:
                LAMBDA=tab_nrj_search[0][3]
                
    print("lambda: %0.5fÅ" % LAMBDA)
    
    geofipdata = geofip(LAMBDA)
    print("*************** GEOFIP COMPUTATION PERFORMED *******************")


if __name__ == "__main__":
    # execute only if run as a script
    main()