Skip to content

Commit

Permalink
Add new kind to save all used params into .ptyr (#501)
Browse files Browse the repository at this point in the history
  • Loading branch information
daurer authored Oct 27, 2023
1 parent c544fef commit 4b88db0
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions ptypy/core/ptycho.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ class Ptycho(Base):
doc = Choose a reconstruction file format for after engine completion.
- ``'minimal'``: Bare minimum of information
- ``'dls'``: Custom format for Diamond Light Source
choices = 'minimal','dls'
- ``'used_params'``: Same as minimal but including all used parameters
choices = 'minimal','dls','used_params'
[io.interaction]
default = None
Expand Down Expand Up @@ -991,7 +992,7 @@ def save_run(self, alt_file=None, kind='minimal', force_overwrite=True):

content = dump

elif kind == 'minimal' or kind == 'dls':
elif kind in ('minimal', 'dls', 'used_params'):
# if self.interactor is not None:
# self.interactor.stop()
logger.info('Generating shallow copies of probe, object and '
Expand All @@ -1006,7 +1007,7 @@ def save_run(self, alt_file=None, kind='minimal', force_overwrite=True):
defaults_tree['ptycho'].validate(self.p) # check the parameters are actually able to be read back in
except RuntimeError:
logger.warning("The parameters we are saving won't pass a validator check!")
minimal.pars = self.p.copy() # _to_dict(Recursive=True)
minimal.pars = self.p.copy(depth=99) # _to_dict(Recursive=True)
minimal.runtime = self.runtime.copy()

content = minimal
Expand All @@ -1020,6 +1021,13 @@ def save_run(self, alt_file=None, kind='minimal', force_overwrite=True):
for ID, S in self.obj.storages.items():
content.obj[ID]['grids'] = S.grids()

if kind == 'used_params':
for name, engine in self.engines.items():
content.pars.engines[name] = engine.p
for name, scan in self.model.scans.items():
content.pars.scans[name] = scan.p
content.pars.scans[name].data = scan.ptyscan.p

if kind in ['minimal', 'dls'] and self.record_positions:
content.positions = {}
for ID, S in self.obj.storages.items():
Expand Down

0 comments on commit 4b88db0

Please sign in to comment.