Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update pars_conversion to account for the new version of parameters file in DCT #449

Merged
merged 1 commit into from
Mar 12, 2025
Merged
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
16 changes: 12 additions & 4 deletions ImageD11/forward_model/pars_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import ImageD11.transformer
import pyFAI
from datetime import datetime
from ImageD11.forward_model.io import read_matlab_file
from ImageD11.forward_model.io import read_matlab_file, read_h5_file
from scipy.optimize import minimize
import logging

Expand Down Expand Up @@ -95,8 +95,16 @@ def convert_DCTpars2p(par_path, Binning = None, verbose = 1):
a dictionary of p, which has keys of rawfile, Lsam2det, tilt_xyz, RotDet, dety0, detz0, dety00, detz00, wedge, pixelysize, pixelzsize,
detysize, detzsize, BeamStopY, BeamStopZ, S, flip_lr_flag, flip_ud_flag, wavelength, Energy etc.
"""
mat_data = read_matlab_file(par_path)
parameters = mat_data['parameters']
if par_path.endswith('.mat'):
mat_data = read_matlab_file(par_path)
if 'parameters' in mat_data.keys():
parameters = mat_data['parameters'] # old parameters file version: parameters saved as a one single struct
else:
parameters = mat_data.copy() # new parameters file version: parameters saved as multiple structs, i.e. acq, labgeo, detgeo, rec, index etc.
elif par_path.endswith('.h5'):
parameters = read_h5_file(par_path)
else:
raise Exception('At present, the input parameters file must be in .h5 or .mat format')

p = {}
p['rawfile'] = par_path
Expand Down Expand Up @@ -210,7 +218,7 @@ def convert_DCTpars2p(par_path, Binning = None, verbose = 1):
p['BeamStopZ'][0] = np.floor(p['BeamStopZ'][0]/Binning)
p['BeamStopZ'][1] = np.ceil(p['BeamStopZ'][1]/Binning)
if verbose >= 1:
logging.info('Detector images are binned to {:.1f} * {:.1f}'.format(Binning, Binning))
logging.info('Detector images are binned to {:.1f} * {:.1f}'.format(Binning, Binning))
return p


Expand Down