Hi,
I am trying to build a large array using concatenate function in
python.
So as I loop over the number of arrays, of which there are 12 (4 down
and 3 across), I create 3 long arrays by concatenating them at the
bottom and then concatenating them side by side:
for ind in range(num_array s):
if ind == 0:
bias_down1 = array(bias)
ppslon1 = array(ppslon)
ppslat1 = array(ppslat)
elif ind 0 and <= 3:
bias_down1 = concatenate((bi as_down1,bias), 0)
ppslon1 = concatenate((pp slon1,ppslon),0 )
ppslat1 = concatenate((pp slat1,ppslat),0 )
elif ind == 4:
bias_down2 = array(bias)
ppslon2 = array(ppslon)
ppslat2 = array(ppslat)
elif ind 4 and ind <= 7:
bias_down2 = concatenate((bi as_down2,bias), 0)
ppslon2 = concatenate((pp slon2,ppslon),0 )
ppslat2 = concatenate((pp slat2,ppslat),0 )
elif ind == 8:
bias_down3 = array(bias)
ppslon3 = array(ppslon)
ppslat3 = array(ppslat)
elif ind 8:
bias_down3 = concatenate((bi as_down3,bias), 0)
ppslon3 = concatenate((pp slon3,ppslon),0 )
ppslat3 = concatenate((pp slat3,ppslat),0 )
bias_a = concatenate((bi as_down1,bias_d own2),1) # joining the arrays
side by side
bias_all = concatenate((bi as_a,bias_down3 ),1)
ppslat_a = concatenate((pp slat1,ppslat2), 1)
ppslat_all = concatenate((pp slat_a,ppslat3) ,1)
ppslon_a = concatenate((pp slon1,ppslon2), 1)
ppslon_all = concatenate((pp slon_a,ppslon3) ,1)
print 'Max lat', max(max(ppslat_ all)), '\t','Min lat',
min(min(ppslat_ all))
print 'Max lon', max(max(ppslon_ all)), '\t','Min lon',
min(min(ppslon_ all))
*************** **
Now this works, the array size is correct but the longitude values
given for max and min are wrong. What is even stranger to me is that
when I write the array in binary format to a file and read it with
Matlab, the max and min are correct but when I read it back with python
the max and min are again incorrect for only the longitude data. I
saved the max and min for the longitude for each array and then check
it in the python program and they are correct at the end but the
max(max(ppslon) ) values is incorrect. Does anyone knows why this is
so?
If I was doing something wrong then Matlab would not have returned
correct values.
Any help is appreciated!
/Sheldon
I am trying to build a large array using concatenate function in
python.
So as I loop over the number of arrays, of which there are 12 (4 down
and 3 across), I create 3 long arrays by concatenating them at the
bottom and then concatenating them side by side:
for ind in range(num_array s):
if ind == 0:
bias_down1 = array(bias)
ppslon1 = array(ppslon)
ppslat1 = array(ppslat)
elif ind 0 and <= 3:
bias_down1 = concatenate((bi as_down1,bias), 0)
ppslon1 = concatenate((pp slon1,ppslon),0 )
ppslat1 = concatenate((pp slat1,ppslat),0 )
elif ind == 4:
bias_down2 = array(bias)
ppslon2 = array(ppslon)
ppslat2 = array(ppslat)
elif ind 4 and ind <= 7:
bias_down2 = concatenate((bi as_down2,bias), 0)
ppslon2 = concatenate((pp slon2,ppslon),0 )
ppslat2 = concatenate((pp slat2,ppslat),0 )
elif ind == 8:
bias_down3 = array(bias)
ppslon3 = array(ppslon)
ppslat3 = array(ppslat)
elif ind 8:
bias_down3 = concatenate((bi as_down3,bias), 0)
ppslon3 = concatenate((pp slon3,ppslon),0 )
ppslat3 = concatenate((pp slat3,ppslat),0 )
bias_a = concatenate((bi as_down1,bias_d own2),1) # joining the arrays
side by side
bias_all = concatenate((bi as_a,bias_down3 ),1)
ppslat_a = concatenate((pp slat1,ppslat2), 1)
ppslat_all = concatenate((pp slat_a,ppslat3) ,1)
ppslon_a = concatenate((pp slon1,ppslon2), 1)
ppslon_all = concatenate((pp slon_a,ppslon3) ,1)
print 'Max lat', max(max(ppslat_ all)), '\t','Min lat',
min(min(ppslat_ all))
print 'Max lon', max(max(ppslon_ all)), '\t','Min lon',
min(min(ppslon_ all))
*************** **
Now this works, the array size is correct but the longitude values
given for max and min are wrong. What is even stranger to me is that
when I write the array in binary format to a file and read it with
Matlab, the max and min are correct but when I read it back with python
the max and min are again incorrect for only the longitude data. I
saved the max and min for the longitude for each array and then check
it in the python program and they are correct at the end but the
max(max(ppslon) ) values is incorrect. Does anyone knows why this is
so?
If I was doing something wrong then Matlab would not have returned
correct values.
Any help is appreciated!
/Sheldon
Comment