Examples

itohnobue edited this page Apr 1, 2011 · 1 revision
  1. Examples

Sorry, for now it's the only documentaion on pyLASDev. I'll try to improve it later. In addition, you can use test scripts from the source file archive as examples.

# print all readed mnemonics and values from ~VERSION section
for key in las_info['version'].keys():
        value = las_info['version'][key]
        print key, value

# ===============================
# 2. ~WELL Section
# ==============================

# print all keys (readed mnemonics) from the well section dictionary
print las_info['well'].keys()

# print 'EXAMS' mnemonic value from the well section
print las_info['well']['EXAMS']

# print all readed mnemonics and values from the ~WELLS section
for key in las_info['well'].keys():
        value = las_info['well'][key]
        print key, value

# ==============================
# 3. ~PARAMETERS Section
# ==============================

# print all keys (readed mnemonics) from the parameters section dictionary
print las_info['parameters'].keys()

# print 'WING' mnemonic value from the parameters section
print las_info['parameters']['WING']

# print all readed mnemonics and values from the ~PARAMETERS section
for key in las_info['parameters'].keys():
        value = las_info['parameters'][key]
        print key, value

# =============================
# 4. ~CURVE Section
# =============================

# print name of the first curve
print las_info['curves_order'][0]

# print all curves names in the right order
for k in xrange(len(las_info['curves_order'])):
        curve_name = las_info['curves_order'][k]
        print k, curve_name

# =============================
# 5. ~ASCII Logs Section
# =============================

# Logs dictionary contains NumPy arrays, named as Curves from ~CURVE section

# print DEPTH log from the Logs Section
print las_info['logs']['DEPTH']


# print all arrays and curves names from the Logs Section
for curve_name in las_info['curves_order']:
        log_values = las_info['logs'][key_ordered]
        print curve_name, log_values

# =============================
# Editing LAS File
# =============================

# To edit a LAS File just edit the dictionaries elements as you want, for example:

# add 1 to all elements of the PERM log from the Logs Section
las_info['logs']['PERM'] += 1

# delete the PORO log from the Logs Section
del las_info['logs']['PORO']

# rename the DEPTH to DEPTH_XXX in Logs Section
las_info['logs']['DEPTH_XXX'] = las_info['logs']['DEPTH']
del las_info['logs']['DEPTH']

# also we need to delete this log from the curves list:
las_info['curves_order'].remove('DEPTH')

# etc, enjoy :)

# =============================
# Writing LAS File
# =============================

filename = "somefile_changed.las"

write_las_file(filename, las_info)
Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.