The way I'm doing this now seems really clunky. Is there a better way to index this array?
This is the code that works:
DEM = np.empty((number_of_DEM_files, DEMfile.shape[0], DEMfile.shape[1]), 'float')
for t in range(number_of_DEM_files):
DEM[t] = np.load(DEM_filename_list[t])
I tried doing it with list comprehensions like this:
DEM = np.load([DEM_filename_list[t] for t in range(number_of_DEM_files)])
but I get a syntax error. Is this possible? Is there even a reason to do this or is it just as slow as what I've already got? Is there a better way?
EDIT:
DEM_filename_list looks like this:
DEM_filename_list = (D:/Documents/Data/grand_canyon_2015/03-11/dem1.npy,
D:/Documents/Data/grand_canyon_2015/03-11/dem2.npy,
D:/Documents/Data/grand_canyon_2015/03-11/dem3.npy,
etc)
The first line creates an empty 3d array. Ultimately, I'm trying to load and store a time series of arrays in one 3d array, so that you can index it with DEM[t,i,j]
where t is the time, i is row number, and j is the column number.