Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 83 additions & 25 deletions examples/calibration.ipynb

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion f3ast/calibration/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from .set_scale import select_scale
from .picture_processing import *
from .vertical_structures import export_spot_calibration
from .sigma_structures import get_sigma_structures
from .sigma_structures import (
get_combined_sigma_structures, get_sigma_structures)
55 changes: 45 additions & 10 deletions f3ast/calibration/sigma_structures.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,32 @@
from f3ast.utils import load_settings
import os

import numpy as np
from ..structure import Structure
from scipy.spatial.transform import Rotation as R
from ..stream_builder import StreamBuilder
from trimesh.creation import box
from trimesh.exchange.export import export_mesh

from ..stream import Stream
import os
from ..stream_builder import StreamBuilder
from ..structure import Structure

dirname = os.path.dirname(__file__)
CUBE_PATH = os.path.join(dirname, 'cube.stl')


def get_sigma_structures(model, sigma_list, width=75, length=800, angle=45):
"""Gets the structures for sigma calibration and returns a single stream file
def get_sigma_structures(
model, sigma_list, settings, width=75, length=800, angle=45):
"""Gets the structures for sigma calibration and returns them in a
list of stream objects together with the stream for 1px structure.

Args:
model : Deposit model
sigma_list (list): List of sigma values to try
settings: export settings
width (float, optional): Width of the structures. Defaults to 75.
length (float, optional): Length of the structures. Defaults to 800.
angle (float, optional): Angle to xy plane of the structures. Defaults to 45.
angle (float, optional): Angle to xy plane of the structures.
Defaults to 45.
"""
settings = load_settings()

# get the straight ramp of minimal thickness
struct = get_straight_ramp(length, width, 0.1, angle)
Expand All @@ -41,10 +47,33 @@ def get_sigma_structures(model, sigma_list, width=75, length=800, angle=45):
model, **settings['stream_builder'])
strm_1px = stream_builder.get_stream()

return sigma_strm_list, strm_1px


def get_combined_sigma_structures(
model, sigma_list, settings, width=75, length=800, angle=45):
"""Gets the structures for sigma calibration and returns a single
stream file

Args:
model : Deposit model
sigma_list (list): List of sigma values to try
settings: export settings
width (float, optional): Width of the structures. Defaults to 75.
length (float, optional): Length of the structures. Defaults to 800.
angle (float, optional): Angle to xy plane of the structures.
Defaults to 45.
"""
sigma_strm_list, strm_1px = get_sigma_structures(
model, sigma_list, settings, width=width, length=length, angle=angle)

# arange on a screen
addressable_pixels = settings['stream_builder']['addressable_pixels']
y_positions = np.linspace(
0.1 * addressable_pixels[1], 0.9 * addressable_pixels[1], len(sigma_list))
0.1 * addressable_pixels[1],
0.9 * addressable_pixels[1],
len(sigma_strm_list)
)
positions_list = [(addressable_pixels[0] / 2, y) for y in y_positions]
for strm, pos in zip(sigma_strm_list, positions_list):
strm.recentre(position=pos)
Expand Down Expand Up @@ -73,7 +102,13 @@ def get_straight_ramp(length, width, thickness, angle):
Returns:
Structure: The ramp with desired parameters.
"""
struct = Structure.from_file(CUBE_PATH)

try:
struct = Structure.from_file(file_path=CUBE_PATH)
except:
export_mesh(box((1, 1, 1)), CUBE_PATH, file_type='stl')
struct = Structure.from_file(file_path=CUBE_PATH)

transf_matrix = np.eye(4)
transf_matrix[3, 3] = 0 # don't translate
transf_matrix[0, 0] = length
Expand Down