Last active
October 24, 2022 19:22
-
-
Save gwbischof/82416612d729db04827f9bf6b41b1982 to your computer and use it in GitHub Desktop.
Multifile Density
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import matplotlib.pyplot as plt | |
| from pathlib import Path | |
| from export_draft import Multifile | |
| DATA_DIRECTORY = Path("/nsls2/data/chx/legacy/Compressed_Data") | |
| densities = [] | |
| def multifile_density(multifile): | |
| total_pixels = 0 | |
| frame_size = multifile.md['nrows'] * multifile.md['ncols'] | |
| for frame_num in range(20, 30): | |
| pixel_count = multifile.rdrawframe(frame_num)[0].shape[0] | |
| total_pixels += pixel_count | |
| print(multifile.filename.name, total_pixels/(frame_size*10)) | |
| return total_pixels/(frame_size*10) | |
| for file in os.listdir(DATA_DIRECTORY): | |
| if file.endswith(".cmp"): | |
| try: | |
| multifile = Multifile(DATA_DIRECTORY / file, 0 ,200) | |
| density = multifile_density(multifile) | |
| except Exception as e: | |
| pass | |
| else: | |
| densities.append(density) | |
| len(densities) | |
| plt.hist(densities, bins=20) | |
| plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment