import pickle


def get_splines(filename):
  """
  Get the spline interpolators and ranges of validity

  Spline interpolator foles are of the form::
    ( ( {'R1-18-E': <scipy.interpolate.interpolate.interp1d at 0xc1de90>,
         'R1-18-H': <scipy.interpolate.interpolate.interp1d at 0xc1d990>,
         ...
         'R2-26-E': <scipy.interpolate.interpolate.interp1d at 0xc1db90>,
         'R2-26-H': <scipy.interpolate.interpolate.interp1d at 0xc1d890>},
        {'R1-18-E': (-10.0, 0.8, 0.1),
         'R1-18-H': (-10.0, 0.8, 0.1),
          ...
         'R2-26-E': (-10.0, 0.8, 0.1),
         'R2-26-H': (-10.0, 0.8, 0.1)} ),
     ( {'R1-18-E': <scipy.interpolate.interpolate.interp1d at 0xc7d030>,
        'R1-18-H': <scipy.interpolate.interpolate.interp1d at 0xc74b90>,
        ...
        'R2-26-E': <scipy.interpolate.interpolate.interp1d at 0xc74d50>,
        'R2-26-H': <scipy.interpolate.interpolate.interp1d at 0xc74ab0>},
       {'R1-18-E': (-27.5, -8.1, 0.1),
        'R1-18-H': (-27.400000000000002, -7.800000000000001, 0.1),
        ...
        'R2-26-E': (-27.6, -9.200000000000001, 0.1),
        'R2-26-H': (-27.400000000000002, -9.200000000000001, 0.1) } ) )
  Each tuple has a dict of splines and a dict of valid ranges for the
  independent variable, which is control voltage in the first and attenuation
  in the second.

  @param filename : full path to dill pickle file
  @type  filename : str

  @return: tuple of tuples of dicts
  """
  fd = open(filename,'rb')
  splines = pickle.load(fd)
  return splines