enthought / mayavi

3D visualization of scientific data in Python
http://docs.enthought.com/mayavi/mayavi/
Other
1.3k stars 284 forks source link

Huge temp file on hard drive? #1099

Open dbukenberger opened 2 years ago

dbukenberger commented 2 years ago

Hey,

I've noticed that some visualizations seem to occupy space on my system drive. My setup: Win10, Python 3.8.0, and just upgraded to the latest versions: NumPy 1.21.3, Mayavi 4.7.3

The following code creates 100x100x100 axis-aligned positions in a -1:1 cube and displays them as spheres in a quiver3d plot.

import numpy as np
from mayavi import mlab

gridRes = 100
rng = np.linspace(-1, 1, gridRes, endpoint=False) + 1/gridRes
grid = np.float32(np.vstack(np.vstack(np.transpose(np.meshgrid(rng, rng, rng), axes=[3,2,1,0]))))

x,y,z = grid.T
s = np.ones_like(z) * (1/gridRes)**(1/3)
mlab.quiver3d(x, y, z, s, s, s, mode = 'sphere')

The problem:

By running the code I can reproduce the situation that around 7 GB of storage become occupied on my system-drive (C:) as long as the script runs and is freed again afterwards.

What is strange:

In the Explorer I cannot track down any files, created on C: during the runtime of the script, neither does the Task-Manager show any drive activity during the runtime. I can only see the difference in remaining disc-space in the Drive-Overview of the Windows Explorer. However, the situation seems to be somewhat real, because if there is not enough space available on C:, lets say 5 GB, it gets filled until there are actually 0 bytes left and the Explorer complains about missing space on the system drive. The Python installation, all packages and the executed scripts are actually located on drive E: (C: and E: are partitions, both on the same physical SSD.)

My experiments:

I have played around with the resolution parameter of quiver3d to reduce the amount of displayed geometry, which also actually reduces the amount of occupied disc space. When my assumption is correct, that the resolution in theta and phi apply the same way as the subdivisions of a UV-Sphere in Blender, I get 58 vertices per sphere for the default resolution of 8. With 100x100x100 spheres with 58 vertices of 3 dimensions with 4 bytes each, this gives 100*3 58 3 4 = 696000000 byte, so 6.96 GB ... roughly the space, occupied on my drive. (However, I am not sure if this is a lucky guess as it does not fit my measurements with other resolutions. o_O) Creating the same plot with points3d also occupies several GBs, but less than quiver3d.

My question:

Is this behavior normal, known or maybe even intended? If so, can I change the location where this space is occupied?

Cheers, Dennis

rahulporuri commented 2 years ago

Is this behavior normal, known or maybe even intended?

I don't have an answer to that question at the moment

If so, can I change the location where this space is occupied?

Can you tell us what you see when you add the following to your script -

from traits.etsconfig.api import ETSConfig
print(ETSConfig.application_home)
print(ETSConfig.application_data)

It is possible that ETSConfig.application_home is sitting in C:\ and we should be able to set it to somewhere in E:\, which should alleviate your problem.

dbukenberger commented 2 years ago

Thanks for the reply.

Yes, these two paths point to the C: drive. With the script above, located and executed in E:\projects\mayaviTest\mtest.py, the output is:

C:\Users\Dennis\AppData\Roaming\Enthought\mayaviTest
C:\Users\Dennis\AppData\Roaming\Enthought

Although, these paths do not actually exist - I then naively tried to set them to a folder on E:

ETSConfig.application_home = 'E:\data\mayaviTest'
ETSConfig.application_data = 'E:\data'
ETSConfig.user_data = 'E:\data'

But that does not seem to have any effect, the space still gets filled up on C:. (And it also does not make a difference if mayavi is imported before or after the new paths are set.)

Cheers, Dennis

rahulporuri commented 2 years ago

(And it also does not make a difference if mayavi is imported before or after the new paths are set.)

Can you import mayavi after setting the new paths?

dbukenberger commented 2 years ago

Yes, but it does not make a difference if I do this:

from mayavi import mlab
from traits.etsconfig.api import ETSConfig
ETSConfig.application_home = 'E:\data\mayaviTest'
ETSConfig.application_data = 'E:\data'
ETSConfig.user_data = 'E:\data'

or this:

from traits.etsconfig.api import ETSConfig
ETSConfig.application_home = 'E:\data\mayaviTest'
ETSConfig.application_data = 'E:\data'
ETSConfig.user_data = 'E:\data'
from mayavi import mlab