spacetelescope / cubeviz

Data analysis package for cubes. https://cubeviz.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
15 stars 25 forks source link

Memory usage #440

Closed saimn closed 3 years ago

saimn commented 6 years ago

When working with (relatively) big data cubes, taking care of memory usage is important. Currently it seems clear that I cannot use cubeviz with a MUSE cube on my laptop (with 8Gb of RAM), and even on a more powerful laptop (having 16Gb is pretty common now, at least for Macbooks) I'm not sure it will work. If I can make a few suggestions:

astrofrog commented 6 years ago

Glue should normally make use of memory mapping to avoid using too much memory - I think the issue here is indeed the conversion to float64 in cubeviz. We should avoid this and keep the memory-mapped arrays.

Even if we fix the memory mapping there may be a temporary memory increase when collapsing the cube to the spectrum, but I recently added some functionality in glue to make this more efficient and can check whether we can use it here.

saimn commented 6 years ago

Yes, the float conversion is the main issue here. I realized after writing this that the displayed image is a slice at the central wavelength, so the only reason why the cube is fully loaded is to compute the mean spectrum. For wide cubes this spectrum does not make sense, so it would be great to have a way to choose another initial spectrum (an aperture at the center of the cube could make sense for many cubes as often the main object is at the center). Other than that, I found the memory usage to be quite stable while playing with several features, around ~9Gb for a 3Gb cube (stored as float32), so this is actually pretty good!