[Numpy-discussion] Changing the numpy array into required shape

Nadav Horesh nadavh at visionsense.com
Sat Aug 23 03:30:55 EDT 2014


data = data.byteswap()


data = data.byteswap()[::-1]


On 23 Aug 2014 09:15, Cleo Drakos <cleo21drakos at gmail.com> wrote:

Hello numpy users:

I have 2d numpy array of 480 rows and 1440 columns as named by 'data' below:

The first element belongs to (49.875S,179.875W),
the second element belongs to (49.625S,179.625W),
and the last element belongs to (49.875N,179.875E).

import os, glob, gdal, numpy as np

fname = '3B42RT.2014010606.7.bin'

with open(fname, 'rb') as fi:
    data = np.fromfile(fi,dtype=np.uint16,count=480*1440)
    data = data.byteswap()
    data = data.reshape(1440,480)

How can I convert this numpy array so that its first element belongs to (49.875N,179.625W), i.e., upper left latitude and longitude respectively; and the last element belong to (49.625S,179.875E), i.e., lower right latitute and longitude respectively.

I tried to rotate it, but I do not think it is correct.

 data = np.rot90(data,1)

Have some of you experienced with this type of problem? The binary file I am using is here:ftp://trmmopen.gsfc.nasa.gov/pub/merged/3B42RT/3B42RT.2014010606.7.bin.gz

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20140823/b1849f2d/attachment.html>

More information about the NumPy-Discussion mailing list