Python Forum
Looping in a 3D matrix - desperate for assistance!
Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Looping in a 3D matrix - desperate for assistance!
#9
It is nice that is working, but remember that it is really limited, you will need to adapt it to your case.

The np.empty function creates a numpy array without initialising the memory. I do it in this way because in the loop I will write every element, so filling it with 0 will be just a waste of cycles.
In that line I am creating an array of N_years x N_lat x N_lon dimensions, and to do this I need to pass np.empty the tuple (n_year, n_lat, n_lon) Remember that Quantity has dimension (n_days, n_lat, n_lon), so I just need to use the 2nd and 3rd dimensions of that array... and that is what Quantity.shape[1:3] does (remember that in python slices, the upper value is not reached, so 1:4 means 1, 2, 3)

About the NetCDF, yes, for sure you can store this amount of data. I personally used HDF5 to store several Gb of data without any issue and there are nice bindings in python.
If you need to perform this kind of analysis you might like to see pandas, that is designed to work with these kind of massive data arrays.
Reply


Messages In This Thread
RE: Looping in a 3D matrix - desperate for assistance! - by killerrex - May-17-2018, 12:18 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Need desperate help needHelpp 2 3,357 Aug-06-2017, 06:02 PM
Last Post: eyn2k

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020