Skip to content

Commit

Permalink
add exit buffer to copied state (#530)
Browse files Browse the repository at this point in the history
  • Loading branch information
daurer authored Feb 1, 2024
1 parent f8f9750 commit e3075c1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ptypy/core/ptycho.py
Original file line number Diff line number Diff line change
Expand Up @@ -1119,7 +1119,7 @@ def plot_overview(self, fignum=100):

def copy_state(self, name="baseline", overwrite=False):
"""
Store a copy of the current state of object/probe
Store a copy of the current state of object/probe and exit
Warning: This feature is under development and syntax might change!
"""
Expand All @@ -1133,12 +1133,14 @@ def copy_state(self, name="baseline", overwrite=False):
self.state_dict[name] = {}
self.state_dict[name]["ob"] = self.obj.copy()
self.state_dict[name]["pr"] = self.probe.copy()
self.state_dict[name]["ex"] = self.exit.copy()
self.state_dict[name]["runtime"] = self.runtime.copy(depth=99)
logger.info("Saved a copy of object and probe as the {:s} state".format(name))

def restore_state(self, name="baseline", reformat_exit=True):
"""
Restore object/probe based on a previously saved copy
The exit buffer can be reformatted or loaded from the state
Warning: This feature is under development and syntax might change!
"""
Expand All @@ -1147,6 +1149,8 @@ def restore_state(self, name="baseline", reformat_exit=True):
S.data[:] = self.state_dict[name]["pr"].storages[ID].data
for ID,S in self.obj.storages.items():
S.data[:] = self.state_dict[name]["ob"].storages[ID].data
for ID,S in self.exit.storages.items():
S.data[:] = self.state_dict[name]["ex"].storages[ID].data
self.runtime = self.state_dict[name]["runtime"]

# Reformat/Recalculate exit waves
Expand Down

0 comments on commit e3075c1

Please sign in to comment.