Skip to content

Commit bb3e84d

Browse files
committed
Override Write
Override LASFile write to use version 2, no wrapping by default. This helps with code flow when using the Log class. Also removed write function from viewer. Log object can be referenced from LogViewer.log and saved with method from log object.
1 parent e5c401b commit bb3e84d

File tree

2 files changed

+38
-40
lines changed

2 files changed

+38
-40
lines changed

petropy/graphs.py

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -630,12 +630,8 @@ def show(self):
630630
>>> log = ptr.log_data('WFMP') # sample Wolfcamp log
631631
>>> viewer = ptr.LogViewer(log, edit_mode = True) # allow edits when viewing
632632
>>> viewer.show() # display graphs with editing option
633-
>>> viewer.write('wfmp_updated.las') # writes changed data to new las file
634-
635-
See Also
636-
--------
637-
write
638-
LogViewer method to write the updated log to a new las file.
633+
>>> s = 'path/to/new_file.las'
634+
>>> viewer.log.write(f) # writes changed data to new las file
639635
640636
"""
641637
if self.edit_mode:
@@ -667,38 +663,6 @@ def show(self):
667663

668664
plt.show()
669665

670-
def write(self, file_object, version = None, wrap = None, STRT = None, STOP = None, STEP = None, fmt = '%10.5g'):
671-
"""
672-
Writes log stored in viewer to file.
673-
674-
Parameters
675-
----------
676-
file_object : file
677-
a file_like object opening for writing.
678-
version : float (default None)
679-
las version either 1.2 or 2
680-
wrap : bool
681-
Boolean to write a wrapped las file. If not provided, will default to WRAP item in Log object
682-
STRT : float
683-
Optional override to automatic calculation using the first index curve value.
684-
STEP : float
685-
Optional override to automatic calculation using the first step size in the index curve.
686-
fmt : str
687-
Format string for numerical data being written to data section.
688-
689-
Example
690-
-------
691-
>>> import petropy as ptr
692-
>>> log = ptr.log_data('WFMP') # sample Wolfcamp log
693-
>>> viewer = ptr.LogViewer(log, edit_mode = True) # allow edits when viewing
694-
>>> viewer.show() # display and graphically edit log
695-
>>> with open('new_file.las', 'w') as f:
696-
... viewer.write('new_file_name.las') # save edits to new las file
697-
698-
"""
699-
700-
self.log.write(file_object, version = None, wrap = None, STRT = None, STOP = None, STEP = None, fmt = '%10.5g')
701-
702666
def _curve_pick(self, event):
703667
"""
704668
Event handler for selecting a curve to edit. Results in self._edit_curve being set to matplotlib

petropy/log.py

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def tops_from_csv(self, csv_path = None):
117117
>>> log.tops_from_csv() # loads default tops for included datasets
118118
119119
>>> import petropy as ptr
120-
>>> log = ptr.Las('path/to/well.las') # loads specified las file
120+
>>> log = ptr.Log('path/to/well.las') # loads specified las file
121121
>>> log.tops_from_csv('path/to/tops.csv') # loads specified tops csv
122122
123123
"""
@@ -1734,7 +1734,6 @@ def formation_multimineral_model(self, formations = [], parameter = 'default'):
17341734
Examples
17351735
--------
17361736
>>> import petropy as ptr
1737-
>>> from petropy import datasets
17381737
>>> log = ptr.log_data('WFMP') # reads sample Wolfcamp Log from las file
17391738
>>> f = ['WFMPA', 'WFMPB', 'WFMPC']
17401739
>>> # calculates fluid properties for formations WFMPA, WFMPB, and WFMPC with default settings
@@ -2122,3 +2121,38 @@ def to_csv(self, *args, **kwargs):
21222121
df = self.df()
21232122
df.fillna(value = self.well['NULL'].value, inplace = True)
21242123
df.to_csv(*args, **kwargs)
2124+
2125+
def write(self, file_path, version = 2.0, wrap = False, STRT = None, STOP = None, STEP = None, fmt = '%10.5g'):
2126+
"""
2127+
Writes to las file, and overwrites if file exisits. Uses parent class LASFile.write method
2128+
with specified defaults
2129+
2130+
Paramters
2131+
---------
2132+
file_path : str
2133+
path to new las file.
2134+
version : {1.2 or 2} (default 2)
2135+
Version for las file
2136+
wrap : {True, Flase, None} (default False)
2137+
Specify to wrap data. If None, uses setting from when file was read.
2138+
STRT : float (default None)
2139+
Optional override to automatic calculation using the first index curve value.
2140+
STOP : float (default None)
2141+
Optional override to automatic calculation using the last index curve value.
2142+
STEP : float (default None)
2143+
Optional override to automatic calculation using the first step size in the index curve.
2144+
fmt : str (default '%10.5g')
2145+
Format string for numerical data being written to data section.
2146+
2147+
Example
2148+
-------
2149+
>>> import petropy as ptr
2150+
>>> log = ptr.log_data('WFMP') # reads sample Wolfcamp Log from las file
2151+
>>> p = 'path/to/new_file.las' # create file path to save log
2152+
>>> log.write(p)
2153+
2154+
"""
2155+
2156+
with open(file_path, 'w') as f:
2157+
super(Log, self).write(f, version = version, wrap = wrap,
2158+
STRT = STRT, STOP = STOP, STEP = None, fmt = fmt)

0 commit comments

Comments
 (0)