[SciPy-user] Units in SciPy

Robert Kern rkern at ucsd.edu
Fri Apr 1 18:11:59 CST 2005


Duncan Child wrote:

> 3) Map Projections
> 
> Describing lat lon data is harder because if you don't also specify the 
> datum (effectively where you are assuming the center of the Earth is) 
> your position can be miscontrued by 100s of meters. To convert from lat 
> lon to xy you have to specify a bunch of parameters so this is trickier 
> than converting something like meters to km. So I am not sure where this 
> type of data fits in relation to the more usual conversions.

It's just an example of the most general kind of conversions: ones that 
you have to code yourself. You would have two measurement systems 
reified as smart objects, not just dumb tags. You can parameterize all 
you like.

class LatLon(MeasurementSystem):
     ...

latlon = LatLon()

class MapProjection(MeasurementSystem):
     ...

class DatumShifted(MapProjection):
     def __init__(self, datum):
     ...

nad83 = DatumShifted('NAD83')
nad27 = DatumShifted('NAD27')

x1 = quantity([35.94, -120.43], latlon)
x2 = quantity([35.31, -120.66], latlon)

y1 = convert(x2, nad83)
y2 = convert(x2, nad83)

In short, it's the same code you'd have to write anyways (and, in fact, 
I've already written), but it fits into a framework that reduces the 
amount of *interfaces* I have to write and think about and litter around 
my code.

And with DatumShifted suitably implemented, you could do

   y2 - y1

and get

   quantity([-69880.73534289,-20899.29905468], meters)

-- 
Robert Kern
rkern at ucsd.edu

"In the fields of hell where the grass grows high
  Are the graves of dreams allowed to die."
   -- Richard Harter



More information about the SciPy-user mailing list