Files
csaxs_bec/docs/user/ptychography/lamni.md
T
2026-07-12 08:07:50 +02:00

207 lines
10 KiB
Markdown

(user.ptychography.lamni)=
# LamNI
LamNI is an instrument for 3D ptychography via ptychographic X-ray computed laminography (PyXL). The instrument is described in detail [here](https://www.dora.lib4ri.ch/psi/islandora/object/psi:33067).
## How to LamNI
… a step-by-step guide for *beamline staff and expert users*.
### Sample change and alignment
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`.
#### Coarse axis alignment
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
2. `dev.rtx.controller.feedback_disable()`, disable feedback to allow lsam movements
3. `fshopen()`, open the shutter
4. `umv(dev.lsamrot,90)` to rotate the sample. One might observe the center of rotation at 0 and 180 degrees.
5. `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
6. `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})`
7. close the shutter: `dev.omnyfsh.fshclose()`
#### X-ray eye alignment
The BEC GUI is used to obtain a coarse sample alignment. Start the alignment process (which clears any previous alignment) by
`lamni.xrayeye_alignment_start()`
This opens the X-ray eye widget automatically. The procedure collects the sample centre position at 8 angles (0°–315° in 45° steps, full 360° rotation). At each angle the user clicks the sample centre in the image and presses **Submit**. After all 8 angles the data is sent to the **Fit** tab of the GUI where a sinusoidal fit runs automatically in both x and y directions. The fit parameters are loaded automatically at the end of the procedure.
With LamNI it can be difficult to relocate the sample between rotations. To keep the shutter open throughout, pass:
`lamni.xrayeye_alignment_start(keep_shutter_open=True)`
To manually reload the fit parameters after the procedure has completed:
`lamni.read_xray_eye_correction_from_gui()`
**Note:** this reads from the live GUI widget via the `omny_xray_gui` device. It only works as long as the XRayEye GUI window remains open. If the window has been closed, reload from the archived text files instead:
`lamni.read_xray_eye_correction()`
(these files are written to `~/Data10/specES1/internal/xrayeye_alignmentvalues` at the end of every alignment run)
The correction is applied at each projection angle via
`lamni.lamni_compute_additional_correction_xeye_mu(angle)`
which is called automatically inside `lamni.tomo_scan_projection()`.
To capture a single fresh frame without running the full alignment:
`lamni.xrayeye_update_frame()`
or with the shutter left open: `lamni.xrayeye_update_frame(keep_shutter_open=True)`
* 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*
#### Fine alignment
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.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.read_additional_correction_2()`
#### Shifting the FOV
* `lamni.tomo_fovx/y_offset=value` [mm] will shift the field of view. Perform this adjustment from projections collected at **lsamrot 0 degrees**. This shift will rotate. In contrast the manual shift will be a constant shift, identical at all angles.
### Laminography scan
Start the laminography scan by
1. `lamni.tomo_parameters()` adjust the parameters to the desired settings.
2. for test scans run
`lamni.tomo_scan_projection(angle)`
`lamni.tomo_reconstruct()`
3. `lamni.tomo_scan()` to start the laminography scan
### Tips and Tricks
#### Reset corrections
* `lamni.reset_correction()`
* `lamni.reset_correction_2()`
* `lamni.reset_xray_eye_correction()`
#### Adjusting beam size with feedback running
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
2. `umvr(dev.lopz,_value_)` move loptz to the desired position.
3. `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.
4. Potentially correct the alignment of the OSA
#### BEC tips
Print all global variables `bec.global_vars()`
`dev.lsamx/y.wm` or `dev.lsamx/y` prints a motor position
## How to setup LamNI (software)
This part of the manual describes the software structure in more detail.
### start the realtime feedback loop and BEC with OMNY
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.
1. Login to the computer by `ssh control@mpc2680`. The password is written on the physical machine.
2. `cd OMNY/lamni/`
3. `./startLAMNI`
Once the loop has started, it is possible to start bec with the LamNI configuration file.
Loading the LamNI scripts is done by starting bec as
`bec --session lamni`
The scripts can alternatively manually be loaded by
`from csaxs_bec.bec_ipython_client.plugins.LamNI import LamNI`
`lamni = LamNI(bec)`
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")`
If the realtime system is restarted, BEC will lose communication. To restart:
`lamni.rt_off()` … then wait a 10 seconds
`lamni.rt_on()`
### 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:
Show the status of all galil controllers (all stepper motors and the UPR rotation stage)
`dev.lsamx.controller.galil_show_all()`
The same holds true for the Smaract stages which control the OSA position. Their status can be checked by
`dev.losax.controller.show_all()`
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 script.
### 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
* `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()`
*ToDo Feedback status might be helpful. Plus make accessible via lamni.methods…*
### Scanning in 2D and sample alignment
The underlying scan function can be called as
`scans.lamni_fermat_scan()`
Use `scans.lamni_fermat_scan?` for detailed information. A prerequisite for scanning is a running feedback system.
### GUI tools
During operation the BEC GUI will show the relevant cameras or progress information. TAB completion on `lamni.lamnigui_` will show all options to control the GUI. Most useful:
* `lamni.lamnigui_show_progress()` — shows the measurement progress with ring progress bar
* `lamni.lamnigui_show_xeyealign()` — opens the X-ray eye alignment GUI on the Alignment tab
* `lamni.lamnigui_show_xeyealign_fittab()` — opens the X-ray eye GUI on the Fit tab to inspect the sinusoidal fit
* `lamni.lamnigui_idle()` — shows the LamNI idle splash screen
* `lamni.lamnigui_docs()` — opens the PDF documentation viewer
### 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})`
`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)`
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.
* `lamni.lfzp_in()`
* `lamni.loptics_in()`
* `lamni.loptics_out()`
* `lamni.losa_in()`
* `lamni.losa_out()`
* `lamni.lfzp_in()`