Skip to content

Commit 9c8428b

Browse files
Exported visualization to
opxrd
1 parent a032e23 commit 9c8428b

File tree

2 files changed

+13
-172
lines changed

2 files changed

+13
-172
lines changed

xrdpattern/pattern/db.py

Lines changed: 13 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@
66
from dataclasses import dataclass
77
from typing import Optional
88

9-
import matplotlib.gridspec as gridspec
109
from matplotlib import pyplot as plt
1110

1211
from xrdpattern.parsing import MasterParser, Formats
1312
from xrdpattern.xrd import XrayInfo, XrdData
1413
from .pattern import XrdPattern
1514
from .progress_tracker import TrackedCollection
16-
from .visualization import multiplot, define_angle_start_stop_ax, define_recorded_angles_ax, define_spg_ax
1715

1816
patterdb_logger = logging.getLogger(__name__)
1917
patterdb_logger.setLevel(logging.INFO)
@@ -165,38 +163,17 @@ def show_gallery(self):
165163
if user_input.lower() == 'q':
166164
break
167165

168-
def show_histograms(self, save_fpath : Optional[str] = None, attach_colorbar : bool = True):
169-
fig = plt.figure(figsize=(12, 8))
170-
171-
figure = gridspec.GridSpec(nrows=2, ncols=1, figure=fig, hspace=0.35)
172-
figure.update(top=0.96, bottom=0.075)
173-
upper_half = figure[0].subgridspec(1, 3)
174-
ax2 = fig.add_subplot(upper_half[:, :])
175-
define_spg_ax(patterns=self.patterns, ax=ax2)
176-
177-
lower_half = figure[1].subgridspec(1, 2)
178-
ax3 = fig.add_subplot(lower_half[:, 0])
179-
define_recorded_angles_ax(patterns=self.patterns, ax=ax3)
180-
181-
if attach_colorbar:
182-
lower_half_right = lower_half[1].subgridspec(nrows=3, ncols=3, width_ratios=[3, 3, 4] , hspace=0, wspace=0)
183-
ax4 = fig.add_subplot(lower_half_right[1:, :2]) # scaatter
184-
ax5 = fig.add_subplot(lower_half_right[:1, :2], sharex=ax4) # Above
185-
ax6 = fig.add_subplot(lower_half_right[1:, 2:], sharey=ax4) # Right
186-
ax7 = fig.add_subplot(lower_half_right[:1, 2:])
187-
ax7.axis('off')
188-
else:
189-
lower_half_right = lower_half[1].subgridspec(nrows=3, ncols=4, width_ratios=[2.75, 3, 3, 3], hspace=0, wspace=0)
190-
ax4 = fig.add_subplot(lower_half_right[1:, 1:3]) # scatter
191-
ax5 = fig.add_subplot(lower_half_right[:1, 1:3], sharex=ax4) # Above
192-
ax6 = fig.add_subplot(lower_half_right[1:, 3:4], sharey=ax4) # Right
193-
ax7 = fig.add_subplot(lower_half_right[:4, :1])
194-
195-
define_angle_start_stop_ax(patterns=self.patterns, density_ax=ax4, top_marginal=ax5, right_marginal=ax6, cmap_ax=ax7, attach_colorbar=attach_colorbar)
196-
197-
if save_fpath:
198-
plt.savefig(save_fpath)
199-
plt.show()
200-
201-
202166

167+
def multiplot(patterns : list[XrdPattern], start_idx : int):
168+
labels = [p.get_name() for p in patterns]
169+
fig, axes = plt.subplots(4, 8, figsize=(20, 10))
170+
for i, pattern in enumerate(patterns):
171+
ax = axes[i // 8, i % 8]
172+
x_values, intensities = pattern.get_pattern_data(apply_standardization=False)
173+
ax.set_xlabel(r'$2\theta$ (Degrees)')
174+
ax.plot(x_values, intensities, label='Interpolated Intensity')
175+
ax.set_ylabel('Intensity')
176+
ax.set_title(f'({i+start_idx}){labels[i][:20]}')
177+
ax.legend(fontsize=8)
178+
plt.tight_layout()
179+
plt.show()

xrdpattern/pattern/visualization.py

Lines changed: 0 additions & 136 deletions
This file was deleted.

0 commit comments

Comments
 (0)