Skip to content
Draft
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
13 changes: 10 additions & 3 deletions ptypy/core/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,9 @@ def reformat(self, newID=None, update=True):
if update:
self.update()

# Keep track if we need to update views again at the end (which can be costly)
requires_update = False

# List of views on this storage
views = self.views

Expand Down Expand Up @@ -692,6 +695,7 @@ def reformat(self, newID=None, update=True):
% (str(self.ID), str(self.owner.ID), _misfit_str))

if needtocrop_or_pad:
requires_update = True
if self.padonly:
misfit[negmisfit] = 0

Expand Down Expand Up @@ -729,6 +733,7 @@ def reformat(self, newID=None, update=True):

# Deal with layermap
if self.layermap != new_layermap:
requires_update = True
relaid_data = []
for i in new_layermap:
if i in self.layermap:
Expand All @@ -755,6 +760,8 @@ def reformat(self, newID=None, update=True):
self.data = new_data
self.shape = new_shape
self.center = new_center
if requires_update:
self.update()

def _to_pix(self, coord):
"""
Expand Down Expand Up @@ -825,7 +832,7 @@ def center(self, v):
"""
self._center = u.expectN(v, self.ndim)
self._origin = - self._center * self._psize
self.update()
#self.update()

@property
def views(self):
Expand Down Expand Up @@ -1812,7 +1819,7 @@ def new_storage(self, ID=None, **kwargs):
# Return new storage
return s

def reformat(self, also_in_copies=False):
def reformat(self, also_in_copies=False, update=True):
"""
Reformats all storages in this container.

Expand All @@ -1822,7 +1829,7 @@ def reformat(self, also_in_copies=False):
If True, also reformat associated copies of this container
"""
for ID, s in self.storages.items():
s.reformat()
s.reformat(update=update)
if also_in_copies:
for c in self.copies:
c.S[ID].reformat()
Expand Down
25 changes: 13 additions & 12 deletions ptypy/core/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -1673,12 +1673,13 @@ def new_data(self):

# Attempt to get new data
new_data = []
prb_ids, obj_ids, pod_ids = dict(), dict(), set()
for label, scan in self.scans.items():
if not scan.data_available:
continue
else:
ilog_streamer('%s: loading data for scan %s' %(type(scan).__name__,label))
prb_ids, obj_ids, pod_ids = dict(), dict(), set()

nd = scan.new_data(_nframes)
while nd:
new_data.append((label, nd[0]))
Expand All @@ -1690,16 +1691,16 @@ def new_data(self):
nd = scan.new_data(_nframes)
ilog_newline()

# Reformatting
ilog_message('%s: loading data for scan %s (reformatting probe/obj/exit)' %(type(scan).__name__,label))
self.ptycho.probe.reformat(True)
self.ptycho.obj.reformat(True)
self.ptycho.exit.reformat(True)

# Initialize probe/object/exit
ilog_message('%s: loading data for scan %s (initializing probe/obj/exit)' %(type(scan).__name__,label))
scan._initialize_probe(prb_ids)
scan._initialize_object(obj_ids)
scan._initialize_exit(list(pod_ids))
# Reformatting
ilog_message('Reformatting probe/obj/exit)')
self.ptycho.probe.reformat(True, update=True)
self.ptycho.obj.reformat(True, update=True)
self.ptycho.exit.reformat(True, update=True)

# Initialize probe/object/exit
ilog_message('%Initializing probe/obj/exit)')
scan._initialize_probe(prb_ids)
scan._initialize_object(obj_ids)
scan._initialize_exit(list(pod_ids))

return new_data