code: def read(fname,**kw):
      '''
      Reads an lsp output file and returns a raw dump of data,
      sectioned into quantities either as an dictionary or a typed numpy array.
      Parameters:
      -----------
      fname -- filename of thing to read
      Keyword Arguments:
      ------------------
      vprint   --  Verbose printer. Used in scripts
      override --  (type, start) => A tuple of a dump type and a place to start
                   in the passed file, useful to attempting to read semicorrupted
                   files.
      gzip     --  Read as a gzip file.
      flds/sclr Specific Arguments:
      -----------------------------
      var          -- list of quantities to be read. For fields, this can consist
                      of strings that include vector components, e.g., 'Ex'. If 
                      None (default), read all quantities.
      keep_edges   -- If set to truthy, then don't remove the edges from domains before
                      concatenation and don't reshape the flds data.
      sort         -- If not None, sort using these indices, useful for avoiding
                      resorting. If True and not an ndarray, just sort.
      first_sort   -- If truthy, sort, and return the sort data for future flds
                      that should have the same shape.
      keep_xs      -- Keep the xs's, that is, the grid information. Usually redundant
                      with x,y,z returned.
      return_array -- If set to truthy, then try to return a numpy array with a dtype.
                      Requires of course that the quantities have the same shape.
      '''
      if test(kw,'gzip') and kw['gzip'] == 'guess':
          kw['gzip'] = re.search(r'\.gz$', fname) is not None;
      openf = gzip.open if test(kw, 'gzip') else open;
      with openf(fname,'rb') as file:
          if test(kw,'override'):
              dump, start = kw['override'];
              file.seek(start);
              header = {'dump_type': dump};
              if not test(kw, 'var') and 2 <= header['dump_type'] <= 3 :
                  raise ValueError(
                      "If you want to force to read as a scalar, you need to supply the quantities"
                  );
          else:
              header = get_header(file);
          vprint = kw['vprint'] if test(kw, 'vprint') else lambda s: None;
          if 2 <= header['dump_type'] <= 3 :
              if not test(kw, 'var'):
                  var=[i[0] for i in header['quantities']];
              else:
                  var=kw['var'];
              keep_edges = test(kw, 'keep_edges');
              first_sort = test(kw, 'first_sort');
              if test(kw,'sort'):
                  sort = kw['sort']
              else:
                  sort = None;
              keep_xs = test(kw, 'keep_xs');
              return_array = test(kw, 'return_array');
          readers = {
              1: lambda: read_particles(file, header),
              2: lambda: read_flds(
                  file,header,var,vprint,
                  keep_edges=keep_edges,
                  first_sort=first_sort,
                  sort=sort,
                  keep_xs=keep_xs,
                  return_array=return_array),
              3: lambda: read_flds(
                  file,header,var, vprint,
                  keep_edges=keep_edges,
                  first_sort=first_sort,
                  sort=sort,
                  keep_xs=keep_xs,
                  return_array=return_array,
                  vector=False),
              6: lambda: read_movie(file, header),
              10:lambda: read_pext(file,header)
          };
          try:
              d = readers[header['dump_type']]();
          except KeyError:
              raise NotImplementedError("Other file types not implemented yet!");
      return d;