Пример #1
0
def process_record(filename, record):
  if '~' not in record: return 'No proper start of record'
  if '~A' not in record: return 'No delimited data block'

  halves = record[record.index('~'):].strip().split('~A')
  metadata = las.parse_metadata(\
    las.sanitize(line.strip('.').strip()) for line in las.filter_lines(halves[0], ['-'])\
  )
  if len(metadata['curveAliases']) < 1: return 'bad format in metadata block'

  try:
    halves[1] = halves[1][halves[1].index('\n'):]
    #filter blank and lines starting with #, split resulting text into tokens
    tokens = '\t'.join(las.filter_lines(halves[1], ['#'])).split()
  except: return 'bad separation between metadata and curve data'

  if len(tokens) % len(metadata['curveAliases']) != 0: return 'mismatched reading count'

  null_vals = get_nulls(metadata)
  curve_aliases = metadata['curveAliases']
  step_type = curve_aliases[0]
  for idx in xrange(0, len(tokens), len(curve_aliases)): # idx is index of first reading on a step
    step_values = tokens[idx : idx + len(curve_aliases)] # get all readings for the next step
    try:
      for idy, reading in enumerate(filter(lambda x: float(x) not in null_vals, step_values)[1:]):
        helper.emit('\t'.join([filename, step_type, step_values[0], curve_aliases[idy], metadata['C'][curve_aliases[idy]].get('UOM', ''), reading]))
    except ValueError: pass
Пример #2
0
def process_record(filename, record):
    if '~' not in record: return 'No proper start of record'
    if '~A' not in record: return 'No delimited data block'

    halves = record[record.index('~'):].strip().split('~A')
    metadata = las.parse_metadata(\
      las.sanitize(line.strip('.').strip()) for line in las.filter_lines(halves[0], ['-'])\
    )
    if len(metadata['curveAliases']) < 1: return 'bad format in metadata block'

    try:
        halves[1] = halves[1][halves[1].index('\n'):]
        #filter blank and lines starting with #, split resulting text into tokens
        tokens = '\t'.join(las.filter_lines(halves[1], ['#'])).split()
    except:
        return 'bad separation between metadata and curve data'

    if len(tokens) % len(metadata['curveAliases']) != 0:
        return 'mismatched reading count'

    null_vals = get_nulls(metadata)
    curve_aliases = metadata['curveAliases']
    step_type = curve_aliases[0]
    for idx in xrange(
            0, len(tokens),
            len(curve_aliases)):  # idx is index of first reading on a step
        step_values = tokens[
            idx:idx + len(curve_aliases)]  # get all readings for the next step
        try:
            for idy, reading in enumerate(
                    filter(lambda x: float(x) not in null_vals,
                           step_values)[1:]):
                helper.emit('\t'.join([
                    filename, step_type, step_values[0], curve_aliases[idy],
                    metadata['C'][curve_aliases[idy]].get('UOM', ''), reading
                ]))
        except ValueError:
            pass
Пример #3
0
def process_record(filename, record):
  if '~' not in record: return 'No proper start of record'
  halves = record[record.index('~'):].strip().split('~A')
  if len(halves) < 2: return 'Improperly separated metadata & data blocks'

  metadata = las.parse_metadata(\
    las.sanitize(line.strip('.').strip()) for line in las.filter_lines(halves[0], ['-'])\
  )
  if len(metadata['curveAliases']) < 1: return 'Improperly formatted metadata block'

  for block in ['V', 'W', 'C']:
    if block in metadata:
      for mnemonic, val in metadata[block].iteritems():
        helper.emit('%s\t%s\t%s\t%s\t%s' % \
          (filename, block, mnemonic, val.get('UOM', ''), val.get('description', '')))
Пример #4
0
def process_record(filename, record):
    if '~' not in record: return 'No proper start of record'
    halves = record[record.index('~'):].strip().split('~A')
    if len(halves) < 2: return 'Improperly separated metadata & data blocks'

    metadata = las.parse_metadata(\
      las.sanitize(line.strip('.').strip()) for line in las.filter_lines(halves[0], ['-'])\
    )
    if len(metadata['curveAliases']) < 1:
        return 'Improperly formatted metadata block'

    for block in ['V', 'W', 'C']:
        if block in metadata:
            for mnemonic, val in metadata[block].iteritems():
                helper.emit('%s\t%s\t%s\t%s\t%s' % \
                  (filename, block, mnemonic, val.get('UOM', ''), val.get('description', '')))