lamni doc

This commit is contained in:
Mirko Holler
2024-12-16 16:50:53 +01:00
parent ec53bb7000
commit 9186853faf
4 changed files with 133 additions and 218 deletions

View File

@@ -280,14 +280,22 @@ class LamNIOpticsMixin:
umv(dev.losaz, losaz_out)
umv(dev.losay, losay_out)
def lfzp_info(self):
def lfzp_info(self, mokev_val=-1):
if mokev_val == -1:
try:
mokev_val = dev.mokev.readback.get()
except:
print(
"Device mokev does not exist. You can specify the energy in keV as an argument instead."
)
return
loptz_val = dev.loptz.read()["loptz"]["value"]
distance = -loptz_val + 85.6 + 52
print(f"The sample is in a distance of {distance:.1f} mm from the FZP.")
diameters = [80e-6, 100e-6, 120e-6, 150e-6, 170e-6, 200e-6, 220e-6, 250e-6]
mokev_val = dev.mokev.read()["mokev"]["value"]
console = Console()
table = Table(
title=f"At the current energy of {mokev_val:.4f} keV we have following options:",

View File

@@ -43,8 +43,6 @@ Manual operation of the gripper (do not leave it too long in open state)
Manually move the gripper to a transfer position
`flomni.ftransfer_gripper_move(<position>)`
### Alignment of samples
#### Coarse alignment
@@ -133,15 +131,15 @@ The positions of the optics stages are stored as stage parameters and are thus l
Example: The OSAx “in” position can be reviewed by `dev.fosax.user_parameter`
Update the value by (example "fosax", "in") by `dev.fosax.update_user_parameter({"in":value})`
`ffzp_info()` shows info about the available FZPs at the current energy of the beamline. Optional parameter is the photon _energy_ in keV.
`flomni.ffzp_info()` shows info about the available FZPs at the current energy of the beamline. Optional parameter is the photon _energy_ in keV.
Example: `flomni.ffzp_info(6.2)`
The [laser feedback](user.ptychography.flomni.laser_feedback) will be disabled and fine alignment lost if foptx/y are moved!
Following functions exist to move the optics in and out, with self-explaining naming.
- `ffzp_in()`
- `foptics_in()`
- `foptics_out()`
- `flomni.ffzp_in()`
- `flomni.foptics_in()`
- `flomni.foptics_out()`
- `flomni.fosa_in()`
- `flomni.fosa_out()`

View File

@@ -1,264 +1,173 @@
(user.ptychography.lamni)=
# LamNI
The LamNI part needs to be written. This is a mix from LamNI and flomni
This manual is intended for beamline staff and expert users
LamNI is an instrument for 3D ptychography via ptychographic X-ray computed lamninography (PyXL). The instrument is described in detail [here](https://www.dora.lib4ri.ch/psi/islandora/object/psi:33067).
Start the bec server and client as documented elsewhere
## How to LamNI
Loading the configuration, if not done by default
… a step-by-step guide for _beamline staff and expert users_.
bec.config.update_session_with_file("/bec/csaxs_bec/csaxs_bec/device_configs/lamni_config.yaml")
### Sample change and alignment
Loading the LamNI scripts
The access to the sample region is blocked by the flight tube during measurement. To get the flight tube out of the way use
`lamni.leye_in()`.
Mount the new sample. The X-ray eye is already in, but the X-ray optics needs to be moved out of the beam path by
`lamni.loptics_out()`. Potentially a larger area needs to be illuminated to properly see the sample, which can be done by
`open slits`.
from csaxs_bec.bec_ipython_client.plugins.LamNI import LamNI
lamni = LamNI(bec)
#### Coarse axis alignment
## Initialization of the stages
To see the status of the stages following commands are available:
The effective position of the axis of rotation shifts with sample thickness or mounting position of the sample along the axis of rotation. The position of the axis of rotation is controlled by user parameters __center__ of the __lsamx__ and __lsamy__ stages. To observe the axis of rotation obtain the position of the Fresnel zone plate on the X-ray eye, possibly in the _ueye gui_ by:
1. `lamni.lfzp_in()`, move the FZP in
1. `dev.rtx.controller.feedback_disable()`, disable feedback to allow lsam movements
1. `fshopen()`, open the shutter
1. `umv(dev.lsamrot,90)` to rotate the sample. One might observe the center of rotation at 0 and 180 degress.
1. `umvr(dev.lsamx,0.01)` to move lsamx and lsamy such that the center of rotation is at the center of the X-ray beam
1. `dev.lsamx` and `dev.lsamy` will print current position and the center value. Update the center value by
`dev.lsamx.update_user_parameter({'center':8.69})`
`dev.lsamy.update_user_parameter({'center':8.69})`
1. close the shutter: `fshclose()`
Show the status of all galil controllers (all stepper motor and rotation stage)
dev.lsamx.controller.galil_show_all()
#### X-ray eye alignment
For the smaract stages (OSA stages)
dev.losax.controller.show_all()
The GUI on the windows computer is used to obtain a coarse sample alignment. Start the alignment process (and clear any previous alignment) by
`lamni.align.align()`. With LamNI it can be very difficult to follow a region of interest as the sample rotates. Therefore the X-ray shutter will be open during the entire process. Therefore the windows software has to be set on __FORCE__ to continuously update frames and not freeze frames after rotation.
- run `SPEC_ptycho_align.m` (in matlab, use __force_ptychography = 0__)
- `lamni.align.read_xray_eye_correction()` to read the alignment parameters. The correction is based on sinusoidal fits in x and y direction. The values are computed by
`lamni_compute_additional_correction_xeye_mu(angle)`
- If slits were opened during alignment, close the slits `slits 1 to around 0.3`
- `lamni.leye_out()` remove the X-ray eye and move the flight tube in
- _possibly check slit0wh, idgap_
To only see one frame on the Windows GUI run `lamni.align.update_frame()`
To reference the stages of LamNI call
lamni.init.lamni_init_stages()
#### Fine alignment
This script will first verify that the stages are not in an initialized state, and then reference all stages in a safe way.
The sample fine alignment can be obtained using ptychography. For this a short laminogram has to be recorded.
- `lamni.tomo_parameters()` adjust the parameters for a coarse scan: A large step size and large FOV. Especially select __FOV offset = 0__ and __number of projections = 96__ (only one sub-laminogram will be recorded).
- `lamni.sub_tomo_scan(1,0)` record one sub-laminogram
- use the corresponding scan numbers in `SPEC_ptycho_align.m`
- Record a last projection for all scans to reconstruct `lamni.tomo_scan_projection(0)` and wait for the reconstructions to be complete
- Run `SPEC_ptycho_align.m` (in Matlab, __force ptycho=1__, and __correct scan numbers__)
- Click the sample position in the Matlab GUI and then load the generated file by, for example
`lamni.align.read_additional_correction('/sls/X12SA/data/e20632/Data10/cxs_software/ptycho/correction_lamni_um_S05389_lamni_fit.txt')`
- With this alignment a second iteration could be performed. To read the second correction file use `lamni.align.read_additional_correction_2()`
## Interferometer
If the realtime system is restarted, bec will lose communication. To restart:
#### Shifting the FOV
flomni.rt_off() … then wait a few seconds
flomni.rt_on()
- `lamni.align.tomo_fovx/y_offset=value` [mm] will shift the field of view. Perform this adjustment from projections collected at __lsamrot 0 degrees__.
To show the signal of the interferometers:
flomni.show_signal_strength_interferometer()
### Laminography scan
### Interferometer feedback commands
Start the laminography scan by
1. `lamni.tomo_parameters()` adjust the parameters to the desired settings.
1. for test scans run
`lamni.tomo_scan_projection(angle)`
`lamni.tomo_reconstruct()`
1. `lamni.tomo_scan()` to start the lamninography scan
dev.rtx.feedback_enable_with_reset()
dev.rtx.feedback_disable()
dev.rtx.feedback_enable_without_reset() *is only used by functions
if reset of angle interferometer is required
dev.rtx.feedback_disable_and_even_reset_lamni_angle_interferometer
dev.rtx.feedback_enable_with_reset()
### Tips and Tricks
Todo Feedback status might be helpful. Plus make accessible via lamni.feedback…
#### Reset corrections
### LamNI Fermat scan
- `lamni.align.reset_correction()`
- `lamni.align.reset_correction_2()`
- `lamni.align.reset_xray_eye_correction()`
The underlying scan function can be called as
scans.lamni_fermat_scan()
#### Adjusting beam size with feedback running
Use
scans.lamni_fermat_scan?
If the beam size needs to be changed with feedback running, e.g. to switch from near-field to far-field ptychography, following steps can be taken:
1. `dev.loptz.enable_set=True` to enable loptz movements with feedback running
1. `umvr(dev.lopz,_value_)` move loptz to the desired position.
1. `lamni._manual_shift_x/y = _value_` correct the stage run out from motion along the optical axis (units of um). The exact value can be checked by comparing feature positions in projections before/after adjusting loptz.
1. Potentially correct the alignment of the OSA
for detailed information. A prerequisite for scanning is a running feedback system.
#### BEC tips
### Alignment overview
Print all global variables `bec.global_vars()`
There are several corrections applied to get the sample to the FOV:
`dev.lsamx/y.wm` or `dev.lsamx/y` prints a motor position
## How to setup LamNI (software)
### XrayEye and sample alignment
The XrayEye can be moved in and out by
lamni.leye_in()
lamni.leye_out()
This part of the manual describes the software structure in more detail.
The in and out positions are stored as user parameters in the stage. Get the values by
dev.leyex.user_parameter
dev.leyey.user_parameter
### start the realtime feedback loop and BEC with OMNY
Update the values by example for leyex and in position
dev.leyex.update_user_parameter({"in":value})
The nano-positioning is controlled by a feedback loop running on a real-time linux based computer. With all related hardware connected, this loop has to be started manually.
To refresh the frame of the xray eye windows software
lamni.align.update_frame()
1. Login to the computer by `ssh control@mpc2680`. The password is "engine".
1. `cd OMNY/lamni/`
1. `./startLAMNI`
To start the xray eye alignment (and clear any previous alignment)
lamni.align.align()
Once the loop has started, it is possible to start bec with the LamNI configuration file.
The alignment is based on the center values of the lsamx and lsamy stages, and are stored as user parameters. To get the current values
dev.lsamx.user_parameter
dev.lsamy.user_parameter
Loading the LamNI configuration (this command will load the LamNI configuration only - isolated from the beamline)
`bec.config.update_session_with_file("/bec/csaxs_bec/csaxs_bec/device_configs/lamni_config.yaml")`
To change the values
dev.lsamx.update_user_parameter({"center":value})
dev.lsamy.update_user_parameter({"center":value})
Loading the LamNI scripts
`from csaxs_bec.bec_ipython_client.plugins.LamNI import LamNI`
`lamni = LamNI(bec)`
After running SPEC_ptycho_align the alignment data can be loaded by
lamni.align.read_xray_eye_correction()
If the realtime system is restarted, BEC will lose communication. To restart:
`lamni.rt_off()` … then wait a 10 seconds
`lamni.rt_on()`
The correction is based on sinusoidal fits in x and y direction. The values are computed by
lamni_compute_additional_correction_xeye_mu(angle)
### Initialization of the stages
The stages of LamNI are referenced in respect to their endswitches or reference marks. The stages have to be initialized at the beginning of a run or when the Galil motor controller has been reset or restarted. To see the status of the stages following commands are available:
To load from a specific directory, specify it as parameter. Example:
dir_path='/afs/psi.ch/user/h/holler/Data10/specES1/internal/'
Show the status of all galil controllers (all stepper motors and the UPR rotation stage)
`dev.lsamx.controller.galil_show_all()`
The loading routine uses default values for the vertical alignment. This behavior can be changed (e.g. for getting new default values) by the parameter use_vertical_default_values=False
The same holds true for the Smaract stages which control the OSA position. Their status can be checked by
`dev.losax.controller.show_all()`
The alignment offset is computed by
flomni.get_alignment_offset(angle)
In case referencing of the LamNI stages is required, run
`lamni.init.lamni_init_stages()`
This script will first verify that the stages are not in an initialized state, and then reference all stages in a safe way. The user will be warned in case of a potentially risky situation. This mainly involves a collision risk upstream with the exposure box exit window. It might be worth to check clearance prior to calling the init skript.
The alignment can be cleared by
flomni.reset_tomo_alignment_fit()
### Interferometer
The position feedback in LamNI is controlled in closed loop to an interferometric position measurement. To show the signal of the interferometers:
`lamni.show_signal_strength_interferometer()`
Typical values with proper alignment are
_TODO_
#### Interferometer feedback commands
### Fine alignment
Recording ptychography projections at 45 deg. intervals allow replacing the X-ray eye alignment by more accurate parameters.
Adjust the tomo parameters by
flomni.tomo_parameters()
- `dev.rtx.feedback_enable_with_reset()`
- `dev.rtx.feedback_disable()`
- `dev.rtx.feedback_enable_without_reset()` *is only used internally by lamni methods
- if reset of angle interferometer is required
`dev.rtx.feedback_disable_and_even_reset_lamni_angle_interferometer()`
- `dev.rtx.feedback_enable_with_reset()`
And run the alignment scan by
flomni.tomo_alignment_scan()
_ToDo Feedback status might be helpful. Plus make accessible via lamni.methods…_
The updated fit from SPEC_ptycho_align can be loaded by
flomni.read_alignment_offset()
### Scanning in 2D and sample alignment
For very fine vertical alignment based on output of an initial tomography reconstruction (for very tight vertical field of view) alignment, the data file can be loaded by
read_additional_correction_y(), careful a default mirror correction is loaded automatically, so likely do not use this function. One can load a second iteration instead:
read_additional_correction_y2()
The underlying scan function can be called as
`scans.lamni_fermat_scan()`
The scan offsets are computed by
compute_additional_correction_y(angle)
compute_additional_correction_y2(angle)
Use `scans.lamni_fermat_scan?`for detailed information. A prerequisite for scanning is a running feedback system.
The additional correct can be reset by
flomni.reset_correction()
It will load the default primary correction! To run without any correction run (which might be useful to obtain a new default correction file)
flomni.reset_correction(use_default_correction=False)
### X-ray optics alignment
The positions of the optics stages are stored as stage parameters and are thus linked to the configuration file.
Example: The OSAx “in” position can be reviewed by `dev.losax.user_parameter`
Update the value by (example "losax", "in") by `dev.losax.update_user_parameter({"in":value})`
### Scanning of projections
At any stage it is possible to scan a projection by
`lamni.lfzp_info()` shows info about the available FZPs at the current energy of the beamline. Optional parameter is the photon _energy_ in keV.
Example: `lamni.lfzp_info(6.2)`
Defining scan parameters by running
flomni.tomo_parameters()
A scan can be performed at projection <angle> by running
flomni.tomo_scan_projection(angle)
### Tomography
The tomo parameters have to be set by
flomni.tomo_parameters()
The tomography can be started by
tomo_scan()
Three modes for angular sampling are implemented and they have different optional parameters:
8 sub-tomograms
Parameters and their defaults: subtomo_start=1, start_angle=None
Golden ratio tomography (sorted in bunches)
Parameters and their defaults: projection_number=None
Equally spaced with golden starting angle
Parameters and their defaults: projection_number=None
The following parameters can be used to restart an interrupted acquisition.
In case of eight equally spaced sub-tomograms, an individual sub tomogram can be scanned by
flomni.sub_tomo_scan(subtomo_number, start_angle).
If the start angle is not specified, it will be computed depending on the subtomo_number, which is ranging from 1 to 8.
Optics alignment
The positions of the optics stages are stored as parameters to the stages.
Example: The OSAx “in” position can be seen by
dev.fosax.user_parameter
Update the value by (example "fosax", "in")
dev.fosax.update_user_parameter({"in":value})
ffzp_info()
Shows info about the available FZPs at the current energy of the beamline.
Optional parameter energy in keV to get values at a different energy.
Example: flomni.ffzp_info(6.2)
Feedback will be disabled and fine alignment lost if foptx/y are moved!
The laser feedback will be disabled and fine alignment lost if foptx/y are moved!
Following functions exist to move the optics in and out, the naming is self-explaining.
ffzp_in()
foptics_in()
foptics_out()
flomni.fosa_in()
flomni.fosa_out()
- `lamni.lfzp_in()`
- `lamni.loptics_in()`
- `lamni.loptics_out()`
- `lamni.losa_in()`
- `lamni.losa_out()`
- `lamni.lfzp_in()`
### quick description
This is a description of how to start a laminography measurement in bec
Created Apr 13 2023
This document is a replica of the Howto LamNI - short version
THis version v02 was done on 18th April 2023
Sample change and alignment
- lamni.leye_in(); lamni.loptics_out() to get space for mounting
- mount the sample
- maybe open slits1 (still in spec) for a larger illuminated area
To do in case the rotation center is off:
If the rotation center is far off, it needs to be adjusted using the ueye gui:
- fshopen() open the shutter
- lamni.loptics_out
- lamni.lfzp_in()
- dev.rtx.controller.feedback_disable()
- to rotate umv(dev.lsamrot,90) [go to 0 and 180 deg, for example, to see where the center is]
- to move lsamx/y umvr(dev.lsamx,0.01)
- once the position is found update the center values
dev.lsamx will print current position and center value
set it by
dev.lsamx/y.update_user_parameter({'center':8.69})
- close the shutter: fshclose()
- lamni.align.align() starts the xrayeye align. Use the windows GUI. It has to be on 'FORCE', shutter will b
e open all the time during alignment
- run SPEC_ptycho_align.m (in matlab, force ptychography = 0)
- lamni.align.read_xray_eye_correction() read the alignment parameters
- maybe close slits 1 again to around 0.3
- lamni.leye_out()
- possibly check slit0wh, idgap in SPEC
Sample fine alignment
- lamni.tomo_parameters()
make FOV offset 0
select a large step and large FOV. Number of projections 96
- important: set the exposure time in spec if changed to match!
_rtscan_pointbypoint_setup_ddg <exptime>
- record a sub-laminogram and use these scan numbers in SPECalign
- lamni.sub_tomo_scan(1,0)
- lamni.tomo_scan_projection(0)
- Wait for the wrapper to reconstruct
- Run SPEC_ptycho_align.m (in Matlab, force ptycho=1, and correct scan numbers)
- Click the sample position in the GUI and then load the generated file by, for example
lamni.align.read_additional_correction('/sls/X12SA/data/e20632/Data10/cxs_software/ptycho/correction_lamni_um_S05389_lamni_fit.txt')
- For a second correction lamni.align.read_additional_correction_2()
Shifting the FOV
- lamni.align.tomo_fovx/y_offset=value [mm] do this from a pojection collected at 0 degrees
Start the laminography scans
- lamni.tomo_parameters()
- for test scans run
lamni.tomo_scan_projection(angle)
lamni.tomo_reconstruct()
lamni.tomo_scan_projection(angle)
- start the lamni scan
lamni.tomo_scan()
Resetting corrections - to be done earlier, need to ask Mirko
- lamni.align.reset_correction()
- lamni.align.reset_correction_2()
- lamni.align.reset_xray_eye_correction()
Print all global variables
bec.global_vars()
dev.lsamx/y.wm or dev.lsamx/y to print a motor position
ctrl+c twice to break a scan. and issue an %abort and %reset after
Switching to between farfield and nearfield geometries
From FF to NF (undo these changes as required to return to FF)
- dev.loptz.enable_set=True This enables the loptz motor so that it can be used to move the focal position upstream
- umvr(dev.lopz,-5) A motion of 5 mm is about right for a 20 um beam, depending on the exact geometery required
- lamni._manual_shift_x/y = 21/6 Correct the stage run out from motion along the optical axis (units of um). The exact value can be checked by comparing feature positions in projections before/after swich to NF.
- dev.losax/y.update_user_parameter({'in':-1.442+0.004/-0.171-0.004}) Correct the alignment of the osa in x/y

View File

@@ -226,7 +226,7 @@ dev.oosax.update_user_parameter({"near_field_in":value})
The __global variable omny.near_field__ controls whether near- or far-field settings are used. To switch `omny.near-field=False` or `omny.near-field=True`.
`ofzp_info()` shows info about the available FZPs at the current energy of the beamline. Optional parameter energy in keV to get values at a different energy.
`omny.ofzp_info()` shows info about the available FZPs at the current energy of the beamline. Optional parameter energy in keV to get values at a different energy.
Example: `omny.ofzp_info(6.2)`
__Laser feedback will be disabled and thus fine alignment lost if commands are used that move optics stages!__