Q:

Numpy change elements based on threshold and then do element by element addition

I have 3247 197x10 dimension matrices. I need to scan through them, and if a value is above 1, set it equal to 1. If a value is less than or equal to 1, I want to set it to zero. Then, I have to take this modified matrix and add it to the modified matrices of the other 3246 sets. Here is what I have so far:
for i in range(LOWER, UPPER + 1):
    fname = file_name+str(i)+".txt"
    cur_resfile = np.genfromtxt(fname, delimiter = ",", skiprows = 1)
    m_cur = cur_resfile

    m_cur[m_cur <= 1] = 0
    m_cur[m_cur > 1 ] = 1

    m_ongoing = m_ongoing + m_cur

I want m_ongoing to hold the ongoing running sums so that I can save this to a file. However, it's not working and seems to just be writing the last m_cur in the loop. If I run the loop a total of 3 times, there are some cells that all mutually have 1s, so I would expect a few threes. I definitely expect a lot of 2s but I'm only seeing 1s and 0s.
What is the best way to do what I'm trying to do?
-Change values based on condition
-Take a lot of matrices and add all element by element to create running sums      for each cell.

A:

You could use numpy.clip()
for i in range(LOWER, UPPER + 1):
    fname = file_name+str(i)+".txt"

    cur_resfile = np.genfromtxt(fname, delimiter = ",", skiprows = 1)

    m_ongoing += cur_resfile.clip(0,1)

EDIT Answering the question that was asked:
m_ongoing = np.zeros((197,10))

for i in range(LOWER, UPPER + 1):
    fname = file_name+str(i)+".txt"
    cur_resfile = np.genfromtxt(fname, delimiter = ",", skiprows = 1)

    # add one to the places where cur_file > 1
    m_ongoing[cur_resfile > 1] += 1

