pose bone drivers through python Background: I am trying to do a animation of the deformation of a thin sheet, that has its motion at each point that is modeled as a sin wave (something like z = A*sin(freq*t + phi), where A and phi are the amplitude and phase offset of each point, and t is time.  Much like water wave simulation, but I do need to be able to set each point amplitude and phase precisely.  I modelled the surface as your standard grid, but with two planes so it is a sheet.  I then added an armature with a bone for each point ( I tried shapekeys, but bones seemed to be easier), and also added a driver for each pose bone. I can access the drivers through Python with code like the following

obj = bpy.data.objects['Armature']   # the armature my model is 
drivers = obj.animation_data.drivers    
for d in drivers:
    d.driver.expression = "%f *sin(frame / %f + %f)" % (amp, frame_div, phi)


However, then problem I have no idea which driver applies to which pose bone. The driver data structure seems to give no indication which bone it is driving.  I assumed the order in which I added the drivers is the same as the order of the bones, and this cam close but some seemed off.  

So, the basic problem is, how do you know which driver applies to which pose bone, in Python?

Alternatively, is there a better way to do what I am trying to accomplish, without using bones/drivers?
You might try this:

import bpy

obj = bpy.data.objects['Armature']

#get pose_bone
pb = obj.pose.bones['Bone']
#add drivers
driver_loc = pb.driver_add('location')
driver_rot = pb.driver_add('rotation_quaternion')

#search for a driver
for d in obj.animation_data.drivers:
    if d.data_path.startswith('pose.bones'):
        id = d.data_path.split('"')[1]
        prop = d.data_path.rsplit('.', 1)[1]
        if id == pb.name and prop == 'location':
            break
else:
   d = None

if d:
    #... settings
    d.driver.expression = your_expr