0

I'm having trouble using the numpy.repeat fuction. It is giving me a MemoryError.

    def __calculate_lon_data(self):
        lon_data = np.arange(self.min_lon, (self.max_lon + self.resolution),
                             self.resolution)
        lon_data = [unextend_lon(lon) for lon in lon_data]
        lon_data = np.float32(lon_data)
        lon_data = np.repeat(lon_data, self.y_dims)
        return lon_data

The resulting array is 18000 x 6501.

I'm successfully able to take the 6501 Latitude array and repeat it 18000 times, to fill out the full grid. But when I try to take the 18000 Longitude array and repeat it 6501 times, that's when I get the MemoryError.

     File "scripts/rain_file.py", line 712, in __calculate_lon_data
    lon_data = np.repeat(lon_data, self.y_dims)
  File "miniconda3/lib/python3.7/site-packages/numpy/core/fromnumeric.py", line 471, in repeat
    return _wrapfunc(a, 'repeat', repeats, axis=axis)
  File "miniconda3/lib/python3.7/site-packages/numpy/core/fromnumeric.py", line 56, in _wrapfunc
    return getattr(obj, method)(*args, **kwds)
MemoryError

I've tried searching for this error, but I haven't yet found a solution. TIA

1 Answer 1

1

I found my issue. My y_dims was getting changed without me realizing it to a much much larger number. Now to fix that and I should be good.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.