0

It's hard to articulate the question I have exactly. I want to subscript all values in the array, but I want the order to be different. The code is below:

# import numpy
import numpy as np

# variables
y = np.zeros([30,120,1440])
composite_events = np.zeros([30,120,1440])

# longitude array
lon = np.linspace(-179.25,179.25,1440)

# index for the starting point
center_lon_index = np.int(500)  

# index for shifting the longitude array
lonindex = (np.arange(start=0,stop=np.size(lon),step=1) + center_lon_index) % np.size(lon)

# set the composite events to be the same as the data, but centering a particular point
composite_events[0,:,:] = y[0,:,lonindex]

The code returns the following error.

ValueError: could not broadcast input array from shape (1440,120) into shape (120,1440)

I understand the error, but as far as I can tell, the shape of y should be the same as the shape of composite_events. This type of code works in other languages I've used. What is python doing here? Thanks!

Joe
  • 19
  • 3

0 Answers0