def  __init__(self, inputname=None, initfilename=None,
                startsol=-1, endsol=-1, initpriorsols=False, 
                shotnoisefilt=0):
    """LIBSData(inputname="", sol=-1)

    Read in LIBS (ChemCam) data in CSV format from inputname.
    If inputname ends in .csv, treat it as a CSV file.
    If inputname ends in .pkl, treat it as a pickled file.
    Otherwise, treat it as a directory and look for a .pkl file inside;
    if not found, generate it with contents from all .csv files present.

    If present, also read in data from initfilename (must be .csv).
    This data will be used to initialize the DEMUD model.

    Optionally, specify a sol range (startsol-endsol) for data to analyze.
    Optionally, use data prior to startsol to initialize the model.
    Optionally, specify the width of a median filter to apply.
    """

    input_type = inputname[-3:]

    if input_type == 'csv':
      filename = inputname
      expname  = 'libs-' + \
          os.path.splitext(os.path.basename(filename))[0]
      #filename[filename.rfind('/')+1:filename.find('.')]
    elif input_type == 'pkl':
      if shotnoisefilt > 0:
        #filename = inputname[:-4] + ('-snf%d.pkl' % shotnoisefilt)
        filename = os.path.splitext(inputname)[0] + \
            ('-snf%d.pkl' % shotnoisefilt)
      else:
        filename = inputname
      expname  = 'libs-' + \
          os.path.splitext(os.path.basename(filename))[0]
      #filename[filename.rfind('/')+1:filename.find('.')]
    else:  # assume directory
      input_type = 'dir'
      #filename = inputname + '/libs-mean-norm.pkl'
      filename = os.path.join(inputname, 'libs-mean-norm.pkl')
      if shotnoisefilt > 0:
        #filename = filename[:-4] + ('-snf%d.pkl' % shotnoisefilt)
        filename = os.path.splitext(inputname)[0] + \
            ('-snf%d.pkl' % shotnoisefilt)
        #expname  = 'libs-' + inputname[inputname.rfind('/')+1:]
      expname  = 'libs-' + os.path.basename(inputname)

    Dataset.__init__(self, filename, expname, initfilename)

    printt('Reading %s data from %s.' % (input_type, self.filename))

    if input_type == 'dir' and not os.path.exists(filename):
      LIBSData.read_dir(inputname, filename, shotnoisefilt)