def  read_dir(cls, dirname, outfile, shotnoisefilt=0):
    """read_dir(dirname, outfile)

    Read in raw LIBS data from .csv files in dirname.
    Pickle the result and save it to outfile.
    Note: does NOT update object fields.
    Follow this with a call to readin().
    """

    # First read in the target names and sol numbers.
    targets = {}
    sols    = {}
    # Location of this file is hard-coded!
    # My latest version goes through sol 707.
    metafile = 'msl_ccam_obs.csv'
    with open(os.path.join(dirname, metafile)) as f:
      datareader = csv.reader(f)
      # Index targets, sols by spacecraft clock value
      for row in datareader:
        [sol, edr_type, sclk, target] = [row[i] for i in [0,1,2,5]]
        if edr_type != 'CL5':
          continue
        prior_targets = [t for t in targets.values() if target in t]
        n_prior = len(prior_targets)
        # Add 1 so shots are indexed from 1, not 0
        targets[sclk] = target + ':%d' % (n_prior + 1)
        sols[sclk]    = sol
    print 'Read %d target names from %s.' % (len(targets), metafile)

    print 'Now reading LIBS data from %s.' % dirname

    data        = []
    labels      = []
    wavelengths = []

    files = os.listdir(dirname)
    f_ind = 0