Skip to content
Merged
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
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ include src/instamatic/config/microscope/*.yaml
include src/instamatic/config/scripts/*.md
include src/instamatic/neural_network/*.p
include src/instamatic/processing/PETS_input_keywords.csv
include src/instamatic/processing/XDS_template.inp
2 changes: 1 addition & 1 deletion src/instamatic/processing/ImgConversionDM.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def __init__(
self.name = 'DigitalMicrograph'
self.method = method

from .XDS_templateDM import XDS_template
from .XDS_template import XDS_template_DM as XDS_template

self.XDS_template = XDS_template

Expand Down
2 changes: 1 addition & 1 deletion src/instamatic/processing/ImgConversionTPX.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def __init__(
self.name = 'TimePix_SU'
self.method = method

from .XDS_templateTPX import XDS_template
from .XDS_template import XDS_template_TPX as XDS_template

self.XDS_template = XDS_template

Expand Down
2 changes: 1 addition & 1 deletion src/instamatic/processing/ImgConversionTVIPS.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def __init__(
self.name = 'TVIPS F416'
self.method = method

from .XDS_templateTVIPS import XDS_template
from .XDS_template import XDS_template_TVIPS as XDS_template

self.XDS_template = XDS_template

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from __future__ import annotations

XDS_template = """! XDS.INP file for Rotation Electron Diffraction generated by `instamatic`
! XDS.INP file for Rotation Electron Diffraction generated by `instamatic`
! {date}
! For definitions of input parameters, see:
! http://xds.mpimf-heidelberg.mpg.de/html_doc/xds_parameters.html
Expand Down Expand Up @@ -37,8 +35,8 @@
STARTING_ANGLE= {starting_angle:0.4f}
STARTING_FRAME= 1

MAX_CELL_AXIS_ERROR= 0.03 !0.03 is default
MAX_CELL_ANGLE_ERROR= 2.0 !2.0 is default
MAX_CELL_AXIS_ERROR= {max_cell_axis_error} !0.03 is default
MAX_CELL_ANGLE_ERROR= {max_cell_angle_error} !2.0 is default

TEST_RESOLUTION_RANGE=10. 1.0 !for calculation of Rmeas when analysing the intensity data for space group symmetry in the CORRECT step.
!MIN_RFL_Rmeas=50 !50 is default - used in the CORRECT step for identification of possible space groups.
Expand All @@ -49,7 +47,7 @@
NX={NX} NY={NY} !Number of pixels
QX={QX:.4f} QY={QY:.4f} !Physical size of pixels (mm)
OVERLOAD= 130000 !default value dependent on the detector used
TRUSTED_REGION= 0.0 1.05 !default \"0.0 1.05\". Corners for square detector max \"0.0 1.4142\"
TRUSTED_REGION= 0.0 1.05 !default "0.0 1.05". Corners for square detector max "0.0 1.4142"
{untrusted_areas}
{stretch_correction}
SENSOR_THICKNESS=0.30
Expand Down Expand Up @@ -95,7 +93,7 @@

!NBX=7 NBY=7 ! 3 is default, used to estimate the expected variation in a data image, see GAIN.cbf
!BACKGROUND_PIXEL= 6.0 ! Background pixel belongs to background if variation less than given esds
!STRONG_PIXEL= 3.0 ! Strong pixel must exceed background by more than number of given esds
{strong_pixel_line} ! Strong pixel must exceed background by more than number of given esds
!MAXIMUM_NUMBER_OF_STRONG_PIXELS= 1500000 ! Approximate upper limit for the total number of 'strong' pixels
!MINIMUM_NUMBER_OF_PIXELS_IN_A_SPOT= 6 ! Used to suppress spurious, isolated 'strong' pixels from entering the spot list
!SPOT_MAXIMUM-CENTROID= 3.0 ! Maximum deviation of spot maximum from spot centroid
Expand All @@ -109,10 +107,9 @@

! ********** Indexing **********

MINIMUM_FRACTION_OF_INDEXED_SPOTS= 0.25 ! 0.50 is default.
{min_fraction_line} !0.50 is default.
!MAXIMUM_ERROR_OF_SPOT_POSITION=6.0 ! 3.0 is default
!REFLECTING_RANGE=
!REFLECTING_RANGE_E.S.D.=
!BEAM_DIVERGENCE=
!BEAM_DIVERGENCE_E.S.D.=
"""
128 changes: 20 additions & 108 deletions src/instamatic/processing/XDS_template.py
Original file line number Diff line number Diff line change
@@ -1,118 +1,30 @@
from __future__ import annotations

XDS_template = """! XDS.INP file for Rotation Electron Diffraction generated by `instamatic`
! {date}
! For definitions of input parameters, see:
! http://xds.mpimf-heidelberg.mpg.de/html_doc/xds_parameters.html
!
! cRED implementation reference paper:
! J. Appl. Cryst. (2018). 51, 1652–1661. http://dx.doi.org/10.1107/S1600576718015145
from dataclasses import asdict, dataclass
from importlib.resources import files

! ********** Job control **********
from instamatic._collections import PartialFormatter

!JOB= XYCORR INIT COLSPOT IDXREF
!JOB= DEFPIX INTEGRATE CORRECT
!JOB= CORRECT
XDS_template_path = files('instamatic.processing').joinpath('XDS_template.inp')
XDS_template_base = XDS_template_path.read_text(encoding='utf-8')

MAXIMUM_NUMBER_OF_JOBS=4
MAXIMUM_NUMBER_OF_PROCESSORS=4

! ********** Data images **********
@dataclass
class XDSPreset:
max_cell_axis_error: str = '0.05'
max_cell_angle_error: str = '3.0'
strong_pixel_line: str = '!STRONG_PIXEL= 3.0'
min_fraction_line: str = '!MINIMUM_FRACTION_OF_INDEXED_SPOTS= 0.25'

NAME_TEMPLATE_OF_DATA_FRAMES= {data_drc}/0????.img SMV
DATA_RANGE= {data_begin:d} {data_end:d}
SPOT_RANGE= {data_begin:d} {data_end:d}
BACKGROUND_RANGE= {data_begin:d} {data_end:d}
{exclude:s}

! ********** Crystal **********
mce = {'max_cell_axis_error': '0.03', 'max_cell_angle_error': '2.0'}

!SPACE_GROUP_NUMBER= 0
!UNIT_CELL_CONSTANTS= 10 20 30 90 90 90
xds_preset_base = XDSPreset()
xds_preset_dm = XDSPreset(min_fraction_line='MINIMUM_FRACTION_OF_INDEXED_SPOTS= 0.25 ', **mce)
xds_preset_tvips = XDSPreset(strong_pixel_line='STRONG_PIXEL= 6.0 ', **mce)

!REIDX= !Optional reindexing transformation to apply on reflection indices
FRIEDEL'S_LAW=TRUE !TRUE is default

!phi(i) = STARTING_ANGLE + OSCILLATION_RANGE * (i - STARTING_FRAME)
STARTING_ANGLE= {starting_angle:0.4f}
STARTING_FRAME= 1

MAX_CELL_AXIS_ERROR= 0.05 !0.03 is default
MAX_CELL_ANGLE_ERROR= 3.0 !2.0 is default

TEST_RESOLUTION_RANGE=10. 1.0 !for calculation of Rmeas when analysing the intensity data for space group symmetry in the CORRECT step.
!MIN_RFL_Rmeas=50 !50 is default - used in the CORRECT step for identification of possible space groups.
!MAX_FAC_Rmeas=2.0 !2.0 is default - used in the CORRECT step for identification of possible space groups.

! ********** Detector hardware **********

NX={NX} NY={NY} !Number of pixels
QX={QX:.4f} QY={QY:.4f} !Physical size of pixels (mm)
OVERLOAD= 130000 !default value dependent on the detector used
TRUSTED_REGION= 0.0 1.05 !default \"0.0 1.05\". Corners for square detector max \"0.0 1.4142\"
{untrusted_areas}
{stretch_correction}
SENSOR_THICKNESS=0.30
AIR=0.0

! ********** Trusted detector region **********

VALUE_RANGE_FOR_TRUSTED_DETECTOR_PIXELS= 10 30000 !Values are defined in `ABS.CBF`, check mask in `BKGPIX.CBF`, used in DEFPIX
!MINIMUM_ZETA= !0.05 is default

INCLUDE_RESOLUTION_RANGE= 20 0.8

!Ice Ring exclusion, important for data collected using cryo holders
!EXCLUDE_RESOLUTION_RANGE= 3.93 3.87 !ice-ring at 3.897 Angstrom
!EXCLUDE_RESOLUTION_RANGE= 3.70 3.64 !ice-ring at 3.669 Angstrom
!EXCLUDE_RESOLUTION_RANGE= 3.47 3.41 !ice-ring at 3.441 Angstrom (Main)
!EXCLUDE_RESOLUTION_RANGE= 2.70 2.64 !ice-ring at 2.671 Angstrom
!EXCLUDE_RESOLUTION_RANGE= 2.28 2.22 !ice-ring at 2.249 Angstrom (Main)
!EXCLUDE_RESOLUTION_RANGE= 2.102 2.042 !ice-ring at 2.072 Angstrom - strong
!EXCLUDE_RESOLUTION_RANGE= 1.978 1.918 !ice-ring at 1.948 Angstrom - weak
!EXCLUDE_RESOLUTION_RANGE= 1.948 1.888 !ice-ring at 1.918 Angstrom - strong
!EXCLUDE_RESOLUTION_RANGE= 1.913 1.853 !ice-ring at 1.883 Angstrom - weak
!EXCLUDE_RESOLUTION_RANGE= 1.751 1.691 !ice-ring at 1.721 Angstrom - weak

! ********** Detector geometry & Rotation axis **********

DIRECTION_OF_DETECTOR_X-AXIS= 1 0 0
DIRECTION_OF_DETECTOR_Y-AXIS= 0 1 0

ORGX= {origin_x:.2f} ORGY= {origin_y:.2f} !Detector origin (pixels). Often close to the image center, i.e. ORGX=NX/2; ORGY=NY/2
DETECTOR_DISTANCE= {sign}{detector_distance:.2f} !Can be negative. Positive because the detector normal points away from the crystal.

OSCILLATION_RANGE= {osc_angle:.4f}

ROTATION_AXIS= {rot_x:.4f} {rot_y:.4f} {rot_z:.4f}

! ********** Incident beam **********

X-RAY_WAVELENGTH= {wavelength:.4f} !used by IDXREF
INCIDENT_BEAM_DIRECTION= 0 0 1 !The vector points from the source towards the crystal

! ********** Background and peak pixels **********

!NBX=7 NBY=7 ! 3 is default, used to estimate the expected variation in a data image, see GAIN.cbf
!BACKGROUND_PIXEL= 6.0 ! Background pixel belongs to background if variation less than given esds
!STRONG_PIXEL= 3.0 ! Strong pixel must exceed background by more than number of given esds
!MAXIMUM_NUMBER_OF_STRONG_PIXELS= 1500000 ! Approximate upper limit for the total number of 'strong' pixels
!MINIMUM_NUMBER_OF_PIXELS_IN_A_SPOT= 6 ! Used to suppress spurious, isolated 'strong' pixels from entering the spot list
!SPOT_MAXIMUM-CENTROID= 3.0 ! Maximum deviation of spot maximum from spot centroid
!SIGNAL_PIXEL= 3.0 ! Signal pixels must exceed background by more than given esds

! ********** Refinement **********

REFINE(IDXREF)= BEAM AXIS ORIENTATION CELL !POSITION
REFINE(INTEGRATE)= !POSITION BEAM AXIS !ORIENTATION CELL
REFINE(CORRECT)= BEAM AXIS ORIENTATION CELL !POSITION

! ********** Indexing **********

!MINIMUM_FRACTION_OF_INDEXED_SPOTS= 0.25 !0.50 is default.
!MAXIMUM_ERROR_OF_SPOT_POSITION=6.0 ! 3.0 is default
!REFLECTING_RANGE=
!REFLECTING_RANGE_E.S.D.=
!BEAM_DIVERGENCE=
!BEAM_DIVERGENCE_E.S.D.=
"""
pf = PartialFormatter()
XDS_template = pf.format(XDS_template_base, **asdict(xds_preset_base))
XDS_template_DM = pf.format(XDS_template_base, **asdict(xds_preset_dm))
XDS_template_TPX = XDS_template
XDS_template_TVIPS = pf.format(XDS_template_base, **asdict(xds_preset_tvips))
118 changes: 0 additions & 118 deletions src/instamatic/processing/XDS_templateTPX.py

This file was deleted.

Loading