indexing 'all' 2d array python different from single indexing

Viewed 24

I have a meshgrid array of latitudes and longitudes and if I do the following:

print(new_lats[:][0]

I get an array with all different latitude values. Great. Now for the longitudes:

print(new_lons[0][0])
print(new_lons[1][0])

I get the results

-81.53
-81.52

Therefore, it would appear that the first index controls the different longitude values. However, If I do:

print(new_lons[:][0])

I get an array all of the value of -81.53. So it would seem that the 2nd index might actually alter longitude values:

print(new_lons[0][0])
print(new_lons[0][1])

I get the results

-81.53
-81.53

Getting the min and max from the array:

np.amin(new_lons)
np.amax(new_lons)

will yield

-81.53
-78.52

How can I get a single line of longitude values similar to how I indexed the latitudes, and why wouldn't it be similar?

0 Answers
Related