concatenate Numeric

Sheldon shejo284 at gmail.com
Sun Jul 9 10:29:31 EDT 2006


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_arrays):
            if ind == 0:
                bias_down1 = array(bias)
                ppslon1    = array(ppslon)

                ppslat1    = array(ppslat)

             elif ind > 0 and <= 3:
                bias_down1 = concatenate((bias_down1,bias),0)

                ppslon1    = concatenate((ppslon1,ppslon),0)

                ppslat1    = concatenate((ppslat1,ppslat),0)
            elif ind == 4:
                bias_down2 = array(bias)
                ppslon2    = array(ppslon)
                ppslat2    = array(ppslat)
            elif ind > 4 and ind <= 7:
                bias_down2 = concatenate((bias_down2,bias),0)

                ppslon2    = concatenate((ppslon2,ppslon),0)

                ppslat2    = concatenate((ppslat2,ppslat),0)

            elif ind == 8:
                bias_down3 = array(bias)

                ppslon3    = array(ppslon)

                ppslat3    = array(ppslat)

            elif ind > 8:
                bias_down3 = concatenate((bias_down3,bias),0)
                ppslon3    = concatenate((ppslon3,ppslon),0)
                ppslat3    = concatenate((ppslat3,ppslat),0)

bias_a   = concatenate((bias_down1,bias_down2),1) # joining the arrays
side by side
bias_all = concatenate((bias_a,bias_down3),1)

ppslat_a   = concatenate((ppslat1,ppslat2),1)
ppslat_all = concatenate((ppslat_a,ppslat3),1)

ppslon_a   = concatenate((ppslon1,ppslon2),1)
ppslon_all = concatenate((ppslon_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




More information about the Python-list mailing list