tclose figures in order to avoid large memory requirements when looped - sphere - GPU-based 3D discrete element method algorithm with optional fluid coupling
(HTM) git clone git://src.adamsgaard.dk/sphere
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) LICENSE
---
(DIR) commit 14c2ecf26eaf02a9d5d96de31afef8a6ff0a1b3a
(DIR) parent b52f4b15ae61b113931003f1b0941ee404d779ca
(HTM) Author: Anders Damsgaard <anders.damsgaard@geo.au.dk>
Date: Thu, 9 Apr 2015 11:15:00 +0200
close figures in order to avoid large memory requirements when looped
Diffstat:
M python/sphere.py | 24 +++++++++++++++++++-----
1 file changed, 19 insertions(+), 5 deletions(-)
---
(DIR) diff --git a/python/sphere.py b/python/sphere.py
t@@ -5218,7 +5218,8 @@ class sim:
def plotContacts(self, graphics_format = 'png', figsize=[6,6], title=None,
lower_limit = 0.0, upper_limit = 1.0, alpha=1.0, return_data=False,
- outfolder='.'):
+ outfolder='.',
+ f_min = None, f_max = None):
'''
Plot current contact orientations on polar plot
t@@ -5246,6 +5247,11 @@ class sim:
# specify the lower limit of force chains to do statistics on
f_n_lim = lower_limit * f_n_max
+ if f_min:
+ f_n_lim = f_min
+ if f_max:
+ f_n_max = f_max
+
# find the indexes of these contacts
I = numpy.nonzero(data[:,6] >= f_n_lim)
t@@ -5285,7 +5291,7 @@ class sim:
else :
strikelist.append(2.0*numpy.pi - numpy.arccos(dx/dhoriz))
- plt.figure(figsize=figsize)
+ fig = plt.figure(figsize=figsize)
ax = plt.subplot(111, polar=True, axisbg='white')
cs = ax.scatter(strikelist, diplist, marker='o',
c=forcemagnitude,
t@@ -5324,6 +5330,9 @@ class sim:
subprocess.call('rm contacts-tmp.txt', shell=True)
+ fig.clf()
+ plt.close()
+
if return_data:
return data
t@@ -5977,7 +5986,7 @@ class sim:
def visualize(self, method='energy', savefig=True, outformat='png',
- pickle=False, xlim=False, firststep=0):
+ pickle=False, xlim=False, firststep=0, f_min=None, f_max=None):
'''
Visualize output from the simulation, where the temporal progress is
of interest. The output will be saved in the current folder with a name
t@@ -6855,8 +6864,13 @@ class sim:
fn = "../output/{0}.output{1:0=5}.bin".format(self.sid, i)
sb.sid = self.sid + ".{:0=5}".format(i)
sb.readbin(fn, verbose=True)
- sb.plotContacts(lower_limit=0.25, upper_limit=0.75,
- outfolder = '../img_out/')
+ if f_min and f_max:
+ sb.plotContacts(lower_limit=0.25, upper_limit=0.75,
+ outfolder = '../img_out/',
+ f_min = f_min, f_max = f_max)
+ else:
+ sb.plotContacts(lower_limit=0.25, upper_limit=0.75,
+ outfolder = '../img_out/')
subprocess.call('cd ../img_out/ && ' +
'convert -quality 100 {}.*.png {}-contacts.avi'.format(