If you are using GitLab outside of the ILL, then you will need to use HTTPS and not SSH for clone/push/pull operations. SSH will work normally if you are using the VPN.

Commit a589d746 authored by Tobias WEBER's avatar Tobias WEBER

adapted grid example

parent 80cfaa2b
......@@ -35,10 +35,13 @@
#include <string>
#include <unordered_map>
using t_float_src = double;
using t_float_dst = double;
int main()
{
const double eps = 1e-8;
const t_float_dst eps = 1e-8;
std::string filenameIdx = "grid_ver1.idx";
......@@ -46,18 +49,19 @@ int main()
std::string filenameNewDat = "grid_ver2.bin";
// dimensions of version 1 grid (TODO: load from config file)
double hmin = -0.096;
double hmax = 0.096;
double hstep = 0.002;
t_float_dst hmin = -0.096;
t_float_dst hmax = 0.096;
t_float_dst hstep = 0.002;
double kmin = -0.096;
double kmax = 0.096;
double kstep = 0.002;
t_float_dst kmin = -0.096;
t_float_dst kmax = 0.096;
t_float_dst kstep = 0.002;
double lmin = -0.096;
double lmax = 0.096;
double lstep = 0.002;
t_float_dst lmin = -0.096;
t_float_dst lmax = 0.096;
t_float_dst lstep = 0.002;
std::cout << "Converting data file ..." << std::endl;
......@@ -115,17 +119,21 @@ int main()
for(unsigned int branch=0; branch<numBranches; ++branch)
{
// in case more than one weigh factor is stored in original grid:
//double vals[4] = {0, 0, 0, 0};
//t_float_src vals[4] = {0, 0, 0, 0};
double vals[2] = {0, 0};
t_float_src vals[2] = { 0, 0 };
ifDat.read((char*)vals, sizeof(vals));
//double w = std::abs(vals[1])+std::abs(vals[2])+std::abs(vals[3]);
double w = std::abs(vals[1]);
t_float_dst E = vals[0];
if(std::abs(E) < eps)
E = t_float_dst(0);
//t_float_dst w = std::abs(vals[1])+std::abs(vals[2])+std::abs(vals[3]);
t_float_dst w = std::abs(vals[1]);
if(w >= eps)
{
double newvals[2] = {vals[0], w};
t_float_dst newvals[2] = { E, w };
ofDat.write((char*)newvals, sizeof(newvals));
++numNewBranches;
......
......@@ -31,14 +31,17 @@ numvals = 2 # [E, w]
# longitudinal
plot_hklbegin = np.array([-0.09, -0.09, -0.])
plot_hklend = np.array([0.09, 0.09, 0.])
plot_dir = 0
# transversal
#plot_hklbegin = np.array([0.09, -0.09, 0.])
#plot_hklend = np.array([-0.09, 0.09, 0.])
#plot_dir = 0
# up
#plot_hklbegin = np.array([0, 0, -0.09])
#plot_hklend = np.array([0, 0, 0.09])
#plot_dir = 2
plot_hklsteps = 512
# -----------------------------------------------------------------------------
......@@ -147,7 +150,12 @@ def plot_disp(idxfilehandle, datafilehandle, hklbegin, hklend, hklsteps):
plt.set_ylabel("E (meV)")
plt.set_xlim(-0.09, 0.09)
plt.set_ylim(-1., 1.)
plt.scatter(qs_h, Es, marker=".", s=ws*symscale)
if plot_dir == 0:
plt.scatter(qs_h, Es, marker=".", s=ws*symscale)
elif plot_dir == 1:
plt.scatter(qs_k, Es, marker=".", s=ws*symscale)
else:
plt.scatter(qs_l, Es, marker=".", s=ws*symscale)
plot.tight_layout()
plot.show()
......
......@@ -15,14 +15,17 @@ datafile = "grid.bin"
# longitudinal
plot_hklbegin = np.array([-0.09, -0.09, -0.])
plot_hklend = np.array([0.09, 0.09, 0.])
plot_dir = 0
# transversal
#plot_hklbegin = np.array([0.09, -0.09, 0.])
#plot_hklend = np.array([-0.09, 0.09, 0.])
#plot_dir = 0
# up
#plot_hklbegin = np.array([0, 0, -0.09])
#plot_hklend = np.array([0, 0, 0.09])
#plot_dir = 2
numdatavals = 2 # [E, w]
plot_hklsteps = 512
......@@ -32,14 +35,15 @@ plot_hklsteps = 512
# -----------------------------------------------------------------------------
size_uint32 = 4
size_uint64 = 8
size_float64 = 8
size_float = 8
float_type = "float64"
# -----------------------------------------------------------------------------
def get_dims(datafilehandle):
header_data = np.memmap(datafilehandle, dtype="uint8", mode="r")
dims_data = np.ndarray.view(header_data[8 : 8+size_float64*9], dtype="float64")
dims_data = np.ndarray.view(header_data[8 : 8+size_float*9], dtype=float_type)
dims = {}
......@@ -102,10 +106,10 @@ def getE(datafilehandle, hkl):
# offset to index block
header_data = np.memmap(datafilehandle, dtype="uint8", mode="r")
idx_offs = np.ndarray.view(header_data[0 : 8], dtype="uint64")
dims = get_dims(datafilehandle)
hklidx = hkl_to_idx(hkl, dims)
# index of (energy, weights) data
idx = np.memmap(datafilehandle, dtype="uint64", mode="r", offset=int(idx_offs + hklidx*size_uint64))[0]
......@@ -113,7 +117,7 @@ def getE(datafilehandle, hkl):
data = np.memmap(datafilehandle, dtype="uint32", mode="r", offset=int(idx))
numbranches = data[0]
values = np.ndarray.view(data[1 : 1+numbranches*numdatavals * int(size_float64/size_uint32)], dtype="float64")
values = np.ndarray.view(data[1 : 1+numbranches*numdatavals * int(size_float/size_uint32)], dtype=float_type)
values.shape = (numbranches, numdatavals)
return values
......@@ -161,7 +165,12 @@ def plot_disp(datafilehandle, hklbegin, hklend, hklsteps):
plt.set_ylabel("E (meV)")
plt.set_xlim(-0.09, 0.09)
plt.set_ylim(-1., 1.)
plt.scatter(qs_h, Es, marker=".", s=ws*symscale)
if plot_dir == 0:
plt.scatter(qs_h, Es, marker=".", s=ws*symscale)
elif plot_dir == 1:
plt.scatter(qs_k, Es, marker=".", s=ws*symscale)
else:
plt.scatter(qs_l, Es, marker=".", s=ws*symscale)
plot.tight_layout()
plot.show()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment