Skip to content

Conversation

@ColeFMeldorf
Copy link
Collaborator

@ColeFMeldorf ColeFMeldorf commented Oct 7, 2025

Blank images were being generated with large (4088x4088) arrays of zeros that were a waste of memory.

  • To somewhat fix this issue, I've made it such that the blank arrays are created, the cutout performed, and then immediately deleted. This way, the memory usage is reduced by a factor of the number of simulated images. I can't make the arrays smaller or nonexistent because then the cutout will fail.
  • While touching these lines of code, I also removed /dev/null s and replaced them with Nones as I was able to make those changes in snappl simultaneously.

This PR is dependent on snappl PR 81

@ColeFMeldorf ColeFMeldorf linked an issue Oct 7, 2025 that may be closed by this pull request
@ColeFMeldorf ColeFMeldorf marked this pull request as ready for review October 7, 2025 20:13
@ColeFMeldorf ColeFMeldorf requested review from Copilot, rknop and wmwv and removed request for Copilot October 7, 2025 20:13
Copy link
Contributor

@wmwv wmwv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update changelog message to be more correct in its description in the updated context.

@@ -0,0 +1 @@
Reduced memory for blank images No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update changelog message.

input_header["BAND"] = image_object.band
input_header["POINTING"] = image_object.pointing
input_header["SCA"] = image_object.sca
image_object.data = np.zeros((4088, 4088))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes to simulation.py will trigger a merge conflict.


image_object.data = None
image_object.noise = None
image_object.flags = None # These are meaningless, delete to save memory.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this comment apply only to flags, or to data, noise, and flags?

input_header["BAND"] = image_object.band
input_header["POINTING"] = image_object.pointing
input_header["SCA"] = image_object.sca
image_object.data = np.zeros((4088, 4088))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Define 4088 somewhere as a variable and use that consistently.

Possibly something like

nx, ny = 4088, 4088

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unnecessary memory allocation when making blank images.

2 participants