[triangle-zpug] Refactoring of lightning talk code
Chris Calloway
cbc at unc.edu
Fri Jul 27 01:43:11 CEST 2007
For those of you interested in the code from my lightning talk on
parsing sodar data at the last meeting, I did a serious refactoring
today on a couple of the classes. Here's the diff:
http://trac.nccoos.org/datamgmt/changeset/63
I eliminated named group re pattern matches in both classes. Didn't need
'em. The lines of data are just tokens and white space, so split() works
fine.
And I eliminated some convoluted for loops and list comprehensions by
just using dict(zip()).
As you can see, the resulting code is many times more compact, readable,
and simpler.
I credit David Goodger for the nudge. He released the slides for his
PyCon 2007 presentation today and it had some reminders in it:
http://python.net/~goodger/projects/pycon/2007/idiomatic/presentation.html
We went over about 80% of those idioms in Pycamp. But it never hurts to
remind yourself again.
I'll probably refactor some more as I have time. If you want to follow
along, you can just treat the changesets as a blog:
http://trac.nccoos.org/datamgmt/timeline
For those following along with my undersea glider mission, we're coming
up on our Gulf Stream hinge-point. We're making about 1km/hr progress,
variable by tidal gyration, and should be at the "home" point to start
making incursions into the stream by the weekend:
http://nccoos.org/platforms/gliders
The hinge-point is the westernmost pin on the map and varies from 10km
to 50km from the stream according to many factors. We will make ever
widening arcs into the stream from that hinge-point and return to it
upon exiting from the stream after being dragged to the north by the
current. Click on the vizualization link below the map to see the
salinity and density profiles as we look for evidence of Antarctic water
intrusions and other fun end times data.
Many of you have met my cow-orker Jesse at PyCamp or Plone Boot Camp.
There's another more sophisticated MapServer viz Jesse is preparing with
real time HF radar current measurements superimposed on the glider path.
I'll send that along for your viewing enjoyment once Jesse does a couple
of tweaks. In the meantime, you can make more sense of the meanders of
the glider path by comparing it with the radar imaging of the sea
surface current speed and direction from our good friends and partners
at Skidaway:
http://www.skio.peachnet.edu/research/sabsoon/WERA/
--
Sincerely,
Chris Calloway
http://www.seacoos.org
office: 332 Chapman Hall phone: (919) 962-4323
mail: Campus Box #3300, UNC-CH, Chapel Hill, NC 27599
More information about the TriZPUG
mailing list