<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta content="text/html; charset=utf-8">
</head>
<body>
<p dir="ltr">Replace</p>
<p dir="ltr">data = data.byteswap()</p>
<p dir="ltr">By</p>
<p dir="ltr">data = data.byteswap()[::-1]</p>
<p dir="ltr">  Nadav</p>
<div class="quote">On 23 Aug 2014 09:15, Cleo Drakos <cleo21drakos@gmail.com> wrote:<br type="attribution">
</div>
<div>
<div dir="ltr">
<p style="margin:0px 0px 1em; padding:0px; border:0px; font-size:14px; vertical-align:baseline; clear:both; color:rgb(0,0,0); font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif; line-height:17.804800033569336px">
Hello numpy users:</p>
<p style="margin:0px 0px 1em; padding:0px; border:0px; font-size:14px; vertical-align:baseline; clear:both; color:rgb(0,0,0); font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif; line-height:17.804800033569336px">
I have 2d numpy array of 480 rows and 1440 columns as named by 'data' below:</p>
<pre class="" style="margin-top:0px; margin-bottom:10px; padding:5px; border:0px; font-size:14px; vertical-align:baseline; font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; overflow:auto; width:auto; max-height:600px; word-wrap:normal; color:rgb(0,0,0); line-height:17.804800033569336px; background:rgb(238,238,238)">

<code style="margin:0px; padding:0px; border:0px; vertical-align:baseline; font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space:inherit"><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; color:rgb(43,145,175); background:transparent">The</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent"> first element belongs to </span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">(</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; color:rgb(128,0,0); background:transparent">49.875S</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">,</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; color:rgb(128,0,0); background:transparent">179.875W</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">),</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">
the second element belongs to </span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">(</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; color:rgb(128,0,0); background:transparent">49.625S</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">,</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; color:rgb(128,0,0); background:transparent">179.625W</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">),</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">
</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; color:rgb(0,0,139); background:transparent">and</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent"> the last element belongs to </span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">(</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; color:rgb(128,0,0); background:transparent">49.875N</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">,</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; color:rgb(128,0,0); background:transparent">179.875E</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">).</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">

</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; color:rgb(0,0,139); background:transparent">import</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent"> os</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">,</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent"> glob</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">,</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent"> gdal</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">,</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent"> numpy </span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; color:rgb(0,0,139); background:transparent">as</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent"> np

fname </span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">=</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent"> </span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; color:rgb(128,0,0); background:transparent">'3B42RT.2014010606.7.bin'</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">

</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; color:rgb(0,0,139); background:transparent">with</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent"> open</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">(</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">fname</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">,</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent"> </span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; color:rgb(128,0,0); background:transparent">'rb'</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">)</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent"> </span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; color:rgb(0,0,139); background:transparent">as</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent"> fi</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">:</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">
    fi</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">.</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">seek</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">(</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; color:rgb(128,0,0); background:transparent">2880</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">,</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; color:rgb(128,0,0); background:transparent">0</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">)</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">
    data </span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">=</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent"> np</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">.</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">fromfile</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">(</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">fi</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">,</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">dtype</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">=</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">np</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">.</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">uint16</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">,</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">count</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">=</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; color:rgb(128,0,0); background:transparent">480</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">*</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; color:rgb(128,0,0); background:transparent">1440</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">)</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">
    data </span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">=</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent"> data</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">.</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">byteswap</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">()</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">
    data </span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">=</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent"> data</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">.</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">reshape</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">(</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; color:rgb(128,0,0); background:transparent">1440</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">,</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; color:rgb(128,0,0); background:transparent">480</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">)</span></code></pre>
<p style="margin:0px 0px 1em; padding:0px; border:0px; font-size:14px; vertical-align:baseline; clear:both; color:rgb(0,0,0); font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif; line-height:17.804800033569336px">
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.</p>
<p style="margin:0px 0px 1em; padding:0px; border:0px; font-size:14px; vertical-align:baseline; clear:both; color:rgb(0,0,0); font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif; line-height:17.804800033569336px">
I tried to rotate it, but I do not think it is correct.</p>
<pre class="" style="margin-top:0px; margin-bottom:10px; padding:5px; border:0px; font-size:14px; vertical-align:baseline; font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; overflow:auto; width:auto; max-height:600px; word-wrap:normal; color:rgb(0,0,0); line-height:17.804800033569336px; background:rgb(238,238,238)">

<code style="margin:0px; padding:0px; border:0px; vertical-align:baseline; font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif; white-space:inherit"><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent"> data </span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">=</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent"> np</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">.</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">rot90</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">(</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">data</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">,</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; color:rgb(128,0,0); background:transparent">1</span><span class="" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; background:transparent">)</span></code></pre>
<p style="margin:0px 0px 1em; padding:0px; border:0px; font-size:14px; vertical-align:baseline; clear:both; color:rgb(0,0,0); font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif; line-height:17.804800033569336px">
Have some of you experienced with this type of problem? The binary file I am using is here:<a href="ftp://trmmopen.gsfc.nasa.gov/pub/merged/3B42RT/3B42RT.2014010606.7.bin.gz" rel="nofollow" style="margin:0px; padding:0px; border:0px; vertical-align:baseline; color:rgb(74,107,130); text-decoration:none; background:transparent">ftp://trmmopen.gsfc.nasa.gov/pub/merged/3B42RT/3B42RT.2014010606.7.bin.gz</a></p>
<p style="margin:0px 0px 1em; padding:0px; border:0px; font-size:14px; vertical-align:baseline; clear:both; color:rgb(0,0,0); font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif; line-height:17.804800033569336px">
<br>
</p>
<div>
<div dir="ltr">cleo</div>
</div>
</div>
</div>
</body>
</html>