Skip to content

Commit 05273f6

Browse files
authored
Merge pull request #91 from rest-for-physics/jgalan_axion_docs
Documenting TRestAxionField
2 parents 351c6d8 + 867a4af commit 05273f6

5 files changed

+367
-26
lines changed

Diff for: scripts/xlsBikovskiyToBin.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222

2323
print("Starting to read")
2424
# loading the data into a matrix (xyzBdata)
25-
file = r"../../../data/magneticField/Bykovskiy_201906.xls"
25+
file = r"../data/magneticField/Bykovskiy_202004.xls"
2626
df = pd.read_excel(file)
2727

2828
print(df[1:5])
2929

3030
print("Translating to matrix")
31-
xyzBdata = df.as_matrix(columns=df.columns[0:])
31+
xyzBdata = df[df.columns[0:]].values
3232

3333
print(xyzBdata[0][0:6])
3434

Diff for: scripts/xlsMentinkToBin.py

+153
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
#!/usr/bin/python
2+
3+
# This basic script serves to create a plain binary file from the XLS files provided by Bykovsky
4+
# for the Baby-IAXO magnet. We will only upload the resulting bin file, if the original XLS file
5+
# would be required at some point, do not hesitate to contact me at [email protected].
6+
#
7+
# I upload this script in case it is necessary to convert future field maps. Some revision will be
8+
# needed in order to adapt to other input/output schemes.
9+
#
10+
11+
import sys
12+
import struct
13+
from pandas import DataFrame, read_csv
14+
import matplotlib.pyplot as plt
15+
import pandas as pd
16+
17+
# Field map is provided only for the top magnetic bore. We will recenter the field map.
18+
# Since this is a condition for TRestAxionMagneticField.
19+
xCenter = 0
20+
yCenter = 0.8
21+
zCenter = 0
22+
23+
print("Starting to read")
24+
# loading the data into a matrix (xyzBdata)
25+
file = r"../data/magneticField/Mentink_202401.txt"
26+
df = pd.read_excel(file)
27+
28+
print(df[1:5])
29+
30+
print("Translating to matrix")
31+
# xyzBdata = df.values(columns=df.columns[0:])
32+
xyzBdata = df[df.columns[0:]].values
33+
34+
print(xyzBdata[0][0:6])
35+
36+
print(len(xyzBdata))
37+
38+
# Printing out some info about data
39+
xMax = -100000
40+
xMin = 100000
41+
yMax = -100000
42+
yMin = 100000
43+
zMax = -100000
44+
zMin = 100000
45+
46+
xBMax = -100000
47+
xBMin = 100000
48+
yBMax = -100000
49+
yBMin = 100000
50+
zBMax = -100000
51+
zBMin = 100000
52+
53+
f = open("output.txt", "wt")
54+
55+
for x in xyzBdata:
56+
f.write(
57+
str(x[0])
58+
+ "\t"
59+
+ str(x[1])
60+
+ "\t"
61+
+ str(x[2])
62+
+ "\t"
63+
+ str(x[3])
64+
+ "\t"
65+
+ str(x[4])
66+
+ "\t"
67+
+ str(x[5])
68+
+ "\n"
69+
)
70+
if xMax < x[0]:
71+
xMax = x[0]
72+
if yMax < x[1]:
73+
yMax = x[1]
74+
if zMax < x[2]:
75+
zMax = x[2]
76+
77+
if xMin > x[0]:
78+
xMin = x[0]
79+
if yMin > x[1]:
80+
yMin = x[1]
81+
if zMin > x[2]:
82+
zMin = x[2]
83+
84+
if xBMax < x[3]:
85+
xBMax = x[3]
86+
if yBMax < x[4]:
87+
yBMax = x[4]
88+
if zBMax < x[5]:
89+
zBMax = x[5]
90+
91+
if xBMin > x[3]:
92+
xBMin = x[3]
93+
if yBMin > x[4]:
94+
yBMin = x[4]
95+
if zBMin > x[5]:
96+
zBMin = x[5]
97+
98+
f.close()
99+
100+
print("X max : " + str(xMax))
101+
print("Y max : " + str(yMax))
102+
print("Z max : " + str(zMax) + "\n")
103+
104+
print("X min : " + str(xMin))
105+
print("Y min : " + str(yMin))
106+
print("Z min : " + str(zMin) + "\n")
107+
108+
print("BX max : " + str(xBMax))
109+
print("BY max : " + str(yBMax))
110+
print("BZ max : " + str(zBMax) + "\n")
111+
112+
print("BX min : " + str(xBMin))
113+
print("BY min : " + str(yBMin))
114+
print("BZ min : " + str(zBMin) + "\n")
115+
116+
# Creating the binary file
117+
fbin = open("output.bin", "wb")
118+
count = 0
119+
for x in xyzBdata:
120+
# We recenter the volume and redefine axis (x becomes z, y becomes x and z becomes y)
121+
# XLS file distances are expressed in m. We translate to mm.
122+
y = [
123+
1000 * (x[0] - xCenter),
124+
1000 * (x[1] - yCenter),
125+
1000 * (x[2] - zCenter),
126+
x[3],
127+
x[4],
128+
x[5],
129+
]
130+
131+
# Baby-IAXO is symmetric respect to z (direction along axis) and x (direction parallel to the ground).
132+
# I.e. x and y in the previous axis definition.
133+
# The y-axis symmetry (in the new axis definition) affects the second bore that is not described in this map.
134+
# We apply the corresponding symmetries to define the full map of one magnetic bore in the output binary file.
135+
136+
count = count + 1
137+
fbin.write(struct.pack("<%df" % len(y), *y))
138+
if count < 6:
139+
print(len(y))
140+
print(x[0:6])
141+
print(y[0:6])
142+
# The original file was only missing the x-axis, when we change the sign of x-axis we must change the sign of Bx.
143+
if y[0] < 0:
144+
y[0] = -y[0]
145+
y[3] = -y[3]
146+
count = count + 1
147+
fbin.write(struct.pack("<%df" % len(y), *y))
148+
if count < 6:
149+
print(len(y))
150+
print(x[0:6])
151+
print(y[0:6])
152+
fbin.close()
153+
print("Lines writen : " + str(count))

Diff for: src/TRestAxionBufferGas.cxx

+10
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
/// gas->SetGasMixture( "He+Xe", "2.6e-6g/dm^3+5.6mg/m^3" );
5252
/// \endcode
5353
///
54+
///
5455
/// The corresponding RML section for initialization through a configuration
5556
/// file would be as follows.
5657
///
@@ -61,6 +62,15 @@
6162
/// </TRestAxionBufferGas>
6263
/// \endcode
6364
///
65+
/// Example 3:
66+
///
67+
/// We may also use a definition found inside the official REST-for-Physics
68+
/// data directory.
69+
///
70+
/// \code
71+
/// TRestAxionBufferGas *gas = new TRestAxionBufferGas("bufferGases.rml", "helium");
72+
/// \endcode
73+
///
6474
///--------------------------------------------------------------------------
6575
///
6676
/// RESTsoft - Software for Rare Event Searches with TPCs

0 commit comments

Comments
 (0)