In a message of Thu, 26 Nov 2015 15:15:43 -0200, jorge.conr...@cptec.inpe.br wr ites: >Hi, > > >I'm startig in Python and I have a 4D binary data. The dimension of my >data is: > >67 ----> longitude points >41 ----> latitude points >10 ----> pressure levels points >33 ----> time points > > >How can I read this data and what can I do to get a 2D array >(longitude,latitude) for a specific pressure and time dimension. > > >Conrado
If your binary data is all of the same type -- these are all floats, or all ints -- you can use the python array module to read it. https://docs.python.org/3/library/array.html If they are heterogenous then you cannot use array, but can use struct https://docs.python.org/3.5/library/struct.html If I were you, I would want to get my data into pandas, which is the best tool for data analysis http://pandas.pydata.org/ And I would do this pretty much exactly as Albert Jan outlines in this stackoverflow question. http://stackoverflow.com/questions/16573089/reading-binary-data-into-pandas though, as I said, if your data is homogeneous you can use the array module instead of using the struct one. But struct will work on homogenous data as well -- it is just slower. You may not care. Note that Albert Jan's answer is the one on the bottom, i.e. not the one that got the checkmark from the original poster. Laura -- https://mail.python.org/mailman/listinfo/python-list