Skip to content

Commit

Permalink
Refactor plotting
Browse files Browse the repository at this point in the history
  • Loading branch information
ka-sarthak committed Mar 1, 2024
1 parent 68e0f54 commit b468bf5
Show file tree
Hide file tree
Showing 3 changed files with 202 additions and 211 deletions.
32 changes: 32 additions & 0 deletions src/nomad_measurements/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,3 +261,35 @@ def modify_scan_data(scan_data: dict, scan_type: str):
data = data[0].reshape(-1)
output[key] = data * value[0].units
return output

def get_bounding_range_2d(ax1, ax2):
'''
Calculates the range of the smallest rectangular grid that can contain arbitrarily
distributed 2D data.
Args:
ax1 (np.ndarray): array of first axis values
ax2 (np.ndarray): array of second axis values
Returns:
(list, list): ax1_range, ax2_range
'''
ax1_range_length = np.max(ax1) - np.min(ax1)
ax2_range_length = np.max(ax2) - np.min(ax2)

if ax1_range_length > ax2_range_length:
ax1_range = [np.min(ax1),np.max(ax1)]
ax2_mid = np.min(ax2) + ax2_range_length/2
ax2_range = [
ax2_mid-ax1_range_length/2,
ax2_mid+ax1_range_length/2,
]
else:
ax2_range = [np.min(ax2),np.max(ax2)]
ax1_mid = np.min(ax1) + ax1_range_length/2
ax1_range = [
ax1_mid-ax2_range_length/2,
ax1_mid+ax2_range_length/2,
]

return ax1_range, ax2_range
165 changes: 0 additions & 165 deletions src/nomad_measurements/xrd/plotting.py

This file was deleted.

Loading

0 comments on commit b468bf5

Please sign in to comment.