Monday, 15 August 2011

python - Processing different data through same equation -



python - Processing different data through same equation -

i have array looks this:

a=[ id. r d ] [[ 47. 223.25190261 58.0551391 ] [ 49. 223.25102751 58.05662719] [ 57. 223.25013049 58.05139459]]

the first column isnt important. next 2 though, coordinates.

i have compare each set of coordinates (column 2 , 3 together) against these coordinates: (223.251, 58.05) using equation: b=sin(d)sin(d) + cos(d)cos(d)cos(r-r).

where (r,d) original coordinates (223.251, 58.05) , (r,d) coordinates in array. how do each set of coordinates in array without having input numbers myself or having define each number , replace them next set of coordinates? want programme maintain (r,d) consistent , alter (r,d) each row , create calculations. after it's done making calculation each row want have them output. have no thought how this, i'm thinking maybe loop. i'm lost. end of code this:

b=(((sin(dec0))*(sin(dec1)) + (cos(dec0)*cos(dec1))*(cos(ra0-ra1)))) print b 0.540302302454

but first row of coordinates, want done manually

i'm not sure if formula right , info representative, because values close each other. anyway, print b value each item in data, can use:

from math import radians, sin, cos orig = (223.251, 58.05) r = radians(orig[0]) d = radians(orig[1]) = [[ 47., 223.25190261, 58.0551391 ], [ 49., 223.25102751, 58.05662719], [ 57., 223.25013049, 58.05139459]] item in a: r = radians(item[1]) d = radians(item[2]) b = sin(d)*sin(d) + cos(d)*cos(d)*cos(r-r) print(b)

if you've got numpy array input, utilize numpy module instead of math of course.

python arrays loops numpy sin

No comments:

Post a Comment