generated from neutrons/python_project_template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated Ellipsoid class to return None when the (Q,E) point cannot be…
… reached
- Loading branch information
Bing Li
committed
Nov 14, 2024
1 parent
7c8b1d8
commit 226b933
Showing
7 changed files
with
68 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
from mpl_toolkits.axisartist import Axes | ||
|
||
from tavi.data.nxdict import NXdataset, NXentry | ||
from tavi.data.nxentry import NexusEntry | ||
from tavi.data.tavi import TAVI | ||
from tavi.instrument.resolution.cooper_nathans import CN | ||
from tavi.plotter import Plot2D | ||
from tavi.sample.xtal import Xtal | ||
|
||
instrument_config_json_path = "./src/tavi/instrument/instrument_params/cg4c.json" | ||
tas = CN(SPICE_CONVENTION=False) | ||
tas.load_instrument_params_from_json(instrument_config_json_path) | ||
|
||
sample_json_path = "./test_data/test_samples/nitio3.json" | ||
sample = Xtal.from_json(sample_json_path) | ||
tas.mount_sample(sample) | ||
|
||
|
||
tavi = TAVI() | ||
|
||
# calculate resolution ellipses | ||
R0 = False | ||
hkl_list = [(qh, 0, 0) for qh in np.arange(1, 2.01, 0.1)] | ||
ef = 4.8 | ||
ei_list = [e + ef for e in np.arange(0, 5.1, 0.2)] | ||
|
||
# genreate plot | ||
p = Plot2D() | ||
|
||
for i, hkl in enumerate(hkl_list, 1): | ||
rez_list = tas.cooper_nathans(hkl_list=hkl, ei=ei_list, ef=ef, R0=R0) | ||
sz = len(rez_list) | ||
rez_entry = NXentry( | ||
hkl=NXdataset(ds=[rez.hkl for rez in rez_list]), | ||
en=NXdataset(ds=[rez.en for rez in rez_list]), | ||
rez_mat=NXdataset(ds=[rez.mat for rez in rez_list]), | ||
rez_r0=NXdataset(ds=[rez.r0 for rez in rez_list]), | ||
) | ||
tavi.processed_data.update(NexusEntry._dict_to_nexus_entry({f"scan{i:04}": rez_entry})) | ||
|
||
for rez in rez_list: | ||
e_co = rez.get_ellipse(axes=(0, 3), PROJECTION=False) | ||
e_inco = rez.get_ellipse(axes=(0, 3), PROJECTION=True) | ||
if e_co is not None: | ||
p.add_reso(e_co, c="k", linestyle="solid") | ||
if e_inco is not None: | ||
p.add_reso(e_inco, c="k", linestyle="dashed") | ||
|
||
tavi.save("./test_data/rez_dispH.h5") | ||
|
||
|
||
fig = plt.figure() | ||
ax = fig.add_subplot(111, axes_class=Axes) | ||
im = p.plot(ax) | ||
plt.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.