Skip to content

Commit

Permalink
Merge pull request #102 from pycroscopy/switch2dict
Browse files Browse the repository at this point in the history
Switch2dict
  • Loading branch information
gduscher authored Sep 30, 2023
2 parents ad2b691 + 673a4ab commit 54aa00b
Show file tree
Hide file tree
Showing 11 changed files with 194 additions and 1,070 deletions.
12 changes: 7 additions & 5 deletions SciFiReaders/readers/microscopy/em/tem/dm_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ def read(self):
if '1' in self.__stored_tags['ImageList']:
start=1
for image_number in self.__stored_tags['ImageList'].keys():
print(image_number, start)
if int(image_number) >= start:
dataset = self.get_dataset(self.__stored_tags['ImageList'][image_number])
if isinstance(dataset, sidpy.Dataset):
Expand Down Expand Up @@ -214,16 +215,17 @@ def read(self):
dataset.source = 'SciFiReaders.DMReader'
dataset.original_metadata['DM']['full_file_name'] = self.__filename

key = f'Channel_{int(image_number):03d}'
key = f"Channel_{int(image_number)-start:03d}"
self.datasets[key] = dataset
self.extract_crucial_metadata(key)

del self.__stored_tags['ImageList']
main_dataset_number = 0
for index, dataset in self.datasets.items():
if 'urvey' in dataset.title:
main_dataset_number = index
main_dataset_key = list(self.datasets.keys())[0]
for key, dataset in self.datasets.items():
print(key, dataset)
if 'urvey' in dataset.title:
main_dataset_key = key
print(main_dataset_key)
self.datasets[main_dataset_key].original_metadata.update(self.__stored_tags)
self.close()
return self.datasets
Expand Down
15 changes: 6 additions & 9 deletions SciFiReaders/readers/microscopy/em/tem/emd_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,15 +215,12 @@ def get_eds_spectrum(self):
if 'Scan' in self.metadata:
scan = self.metadata['Scan']
if 'ScanArea' in scan:
size_x = float(scan['ScanSize']['width'])
size_y = float(scan['ScanSize']['height'])
size_x *= (float(scan['ScanArea']['right']) - float(scan['ScanArea']['left']))
size_y *= (float(scan['ScanArea']['bottom']) - float(scan['ScanArea']['top']))
size_x = int(size_x)
size_y = int(size_y)
elif 'RasterScanDefinition' in acquisition:
size_x = int(acquisition['RasterScanDefinition']['Width'])
size_y = int(acquisition['RasterScanDefinition']['Height'])
size_x = int(float(scan['ScanSize']['width']) * float(scan['ScanArea']['right'])-float(scan['ScanSize']['width']) * float(scan['ScanArea']['left']))
size_y = int(float(scan['ScanSize']['height']) * float(scan['ScanArea']['bottom'])-float(scan['ScanSize']['height']) * float(scan['ScanArea']['top']))

if 'RasterScanDefinition' in acquisition:
size_x = int(acquisition['RasterScanDefinition']['Width'])
size_y = int(acquisition['RasterScanDefinition']['Height'])
spectrum_size = int(acquisition['bincount'])

self.number_of_frames = int(np.ceil((self.data_array[:, 0] == 65535).sum() / (size_x * size_y)))
Expand Down
Loading

0 comments on commit 54aa00b

Please sign in to comment.