Permalink
Browse files

Cleanup and started to use numpy.sum instead of .flat

  • Loading branch information...
1 parent 90dcabd commit 746f2a33761d24793373d4b0c5a65f281f888673 @uniomni uniomni committed Feb 14, 2012
@@ -94,43 +94,6 @@ def run(self, layers):
I_male = I - I_female
# Generate text with result for this study
- print 'Sums'
- print 'Total:', numpy.sum(P)
- print 'Impac:', numpy.sum(I)
-
- #import cPickle
- #fid = open('test_arrays_zoom.pck', 'wb')
- #cPickle.dump((D, P), fid)
- #fid.close()
-
-
- #print 'P isnan: %i' % numpy.isnan(P).sum()
- #print 'D isnan: %i' % numpy.isnan(D).sum()
-
- print 'Number of deep cells: %i' % numpy.sum(D > threshold)
- print 'Number of shallow cells: %i' % numpy.sum(D <= threshold)
- print 'Sum: %i' % (numpy.sum(D > threshold) + numpy.sum(D <= threshold))
- print 'Total: %i' % numpy.sum(D >= 0)
- print
-
- imp = numpy.sum(P[D > threshold])
- safe = numpy.sum(P[D <= threshold])
- tot1 = numpy.sum(P[D >= 0])
- tot2 = numpy.sum(P)
- #print 'Count imp cells: %i' % numpy.sum(P[D > threshold] >= 0)
- #print 'Count safe cells: %i' % numpy.sum(P[D <= threshold] >= 0)
- #print 'Sum: %i' % (numpy.sum(P[D > threshold] >= 0) + numpy.sum(P[D <= threshold] >= 0))
- #print 'Total1: %i' % numpy.sum(P >= 0)
- #print 'Total2: %i' % numpy.sum(P[D >= 0] >= 0)
- #print
-
- print 'Impacted %i' % imp
- print 'Not imp %i' % safe
- print 'Sum: %i' % (safe + imp)
- print 'Tot1: %i' % tot1
- #print 'Tot2: %i' % tot2
- print 'Sum-Tot1 %i' % (safe + imp - tot1)
-
total = str(int(numpy.sum(P) / 1000))
count = str(int(numpy.sum(I) / 1000))
@@ -94,8 +94,8 @@ def run(self, layers):
I_male = I - I_female
# Generate text with result for this study
- total = str(int(sum(P.flat) / 1000))
- count = str(int(sum(I.flat) / 1000))
+ total = str(int(numpy.sum(P) / 1000))
+ count = str(int(numpy.sum(I) / 1000))
# Create report
iname = inundation.get_name()
@@ -124,8 +124,8 @@ def run(self, layers):
% ('Meninggal (x 1000)', count))
if gender_ratio is not None:
- affected_female = str(int(sum(I_female.flat) / 1000))
- affected_male = str(int(sum(I_male.flat) / 1000))
+ affected_female = str(int(numpy.sum(I_female) / 1000))
+ affected_male = str(int(numpy.sum(I_male) / 1000))
caption += (' <tr><td>%s&#58;</td>'
'<td align="right">%s</td></tr>'
@@ -94,8 +94,8 @@ def run(self, layers):
I_male = I - I_female
# Generate text with result for this study
- total = str(int(sum(P.flat) / 1000))
- count = str(int(sum(I.flat) / 1000))
+ total = str(int(numpy.sum(P) / 1000))
+ count = str(int(numpy.sum(I) / 1000))
# Create report
iname = inundation.get_name()
@@ -124,8 +124,8 @@ def run(self, layers):
% ('Terdampak (x 1000)', count))
if gender_ratio is not None:
- affected_female = str(int(sum(I_female.flat) / 1000))
- affected_male = str(int(sum(I_male.flat) / 1000))
+ affected_female = str(int(numpy.sum(I_female) / 1000))
+ affected_male = str(int(numpy.sum(I_male) / 1000))
caption += (' <tr><td>%s&#58;</td>'
'<td align="right">%s</td></tr>'

0 comments on commit 746f2a3

Please sign in to comment.