Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
more enhancements, working fairly stably
Browse files Browse the repository at this point in the history
  • Loading branch information
kwinkunks committed Dec 8, 2016
1 parent d08ff60 commit 91f7151
Show file tree
Hide file tree
Showing 6 changed files with 184 additions and 82 deletions.
40 changes: 30 additions & 10 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Configuration file for seisplot.py

# Dimensions. Overriden by command line option -d.
ndim: 2
ndim: 3

# 3D inline or xline or both, ignored for 2D data
# Fractions, eg 0.3, are interpreted as fraction of volume in that direction.
Expand All @@ -15,20 +15,26 @@ number:
# Side label side
sidelabel: left

# Plot title, use _filename for filename, use false for no title.
# Plot title, use _filename for filename, comment out or use false for no title.
title: My plot of _filename

# Plot date
subtitle: _date
# Plot subtitle, use _date for today's date, comment out or use false for no subtitle.
subtitle: Made on _date

# Plot credit
credit: true

# Traces per inch (less -> wider plot)
tpi: 36
# Plot width... (treated as max, overrides traces per inch)
plot_width: 17

# Inches per second (more -> taller plot)
ips: 3
# ... OR traces per inch (less -> wider plot)
# tpi: 36

# Plot height... (treated as max, overrides inches per second)
plot_height: 11

# ...OR Inches per second (more -> taller plot)
# ips: 3

# Max time in seconds. 0 for max time in file.
tmax: 2
Expand All @@ -55,19 +61,33 @@ opacity: 0.67
# Wiggle plot lineweight
lineweight: 0.2

# Grid on the seismic panels.
grid_traces: true
grid_time: false
grid_alpha: 0.15 # Twice this value used for timing lines, else hard to see.
grid_colour:
- 0
- 0
- 0

# Colormap for variable density
# e.g. matplotlib colourbars: Greys (black to white), RdBu, RdGy, RdYlBu, seismic, etc.
# See more at http://matplotlib.org/examples/color/colormaps_reference.html
cmap: Greys

# Interpolate variable density display. Acceptable values are ‘none’, ‘nearest’,
# ‘bilinear’, ‘bicubic’, ‘spline16’, ‘spline36’, ‘hanning’, ‘hamming’, ‘hermite’,
# ‘kaiser’, ‘quadric’, ‘catrom’, ‘gaussian’, ‘bessel’, ‘mitchell’, ‘sinc’, ‘lanczos’.
interpolation: 'bicubic'

# Fill colour for the spectrum, the histogram, and the title. RGB, 0-255.
highlight_colour:
- 0
- 20
- 80

# Fontsize
fontsize: 10
# Fontsize, set to 0 for automatic
fontsize: 0

# Watermark
#watermark_text: © A Seismic Company
Expand Down
Binary file modified data/31_81_PR.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
76 changes: 46 additions & 30 deletions plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,56 +106,72 @@ def plot_trace_info(trhead_ax, blurb, fs=10):
return trhead_ax


def plot_histogram(hist_ax, data, tickfmt, cfg, fs=10):
def plot_histogram(ax, data, tickfmt, cfg):
"""
Plot a histogram of amplitude values.
"""
fs = cfg['fontsize']
percentile = cfg['percentile']
data = np.array(data)
datamax = np.amax(data)
datamin = np.amin(data)
largest = max(datamax, abs(datamin))
clip_val = np.percentile(data, percentile)
hist_ax.patch.set_alpha(0.0)
ax.patch.set_alpha(0.0)
color = utils.rgb_to_hex(cfg['highlight_colour'])
y, x, _ = hist_ax.hist(np.ravel(data), bins=int(100.0 / (clip_val / largest)),
alpha=0.6, color=color, lw=0)

hist_ax.set_xlim(-clip_val, clip_val)
hist_ax.set_xticklabels(hist_ax.get_xticks(), fontsize=fs - 4)
hist_ax.set_xlabel('amplitude', fontsize=fs - 4)
hist_ax.xaxis.set_label_coords(0.5, -0.12)
hist_ax.set_ylim([0, y.max()])
hist_ax.set_yticks(np.linspace(0, y.max(), 6))
hist_ax.set_ylabel('percentage of samples', fontsize=fs - 4)
hist_ax.tick_params(axis='x', pad=25)
hist_ax.xaxis.labelpad = 25

ticks = hist_ax.get_yticks().tolist() # ytick labels

y, x, _ = ax.hist(np.ravel(data), bins=int(100.0 / (clip_val / largest)),
alpha=0.6, color=color, lw=0)

ax.set_xlim(-clip_val, clip_val)
ax.set_xticklabels(ax.get_xticks(), fontsize=fs-4)
ax.set_xlabel('amplitude', fontsize=fs - 4)
ax.xaxis.set_label_coords(0.5, -0.12)
ax.set_ylim([0, y.max()])
ax.set_yticks(np.linspace(0, y.max(), 6))
ax.set_ylabel('percentage of samples', fontsize=fs-4)
ax.tick_params(axis='x', pad=25)
ax.xaxis.labelpad = 25

ticks = ax.get_yticks().tolist() # ytick labels
percentages = 100*np.array(ticks)/data.size
labels = []
for label in percentages:
labels.append("{:.2f}".format(label))
hist_ax.set_yticklabels(labels, fontsize=fs - 4)
hist_ax.xaxis.set_major_formatter(tickfmt)
ax.set_yticklabels(labels, fontsize=fs - 4)
ax.xaxis.set_major_formatter(tickfmt)
if datamax < 1:
statstring = "\nMinimum: {:.4f}\nMaximum: {:.4f}".format(datamin, datamax)
statstring += "\n{:.1f} percentile: {:.4f}".format(percentile, clip_val)
elif datamax < 10:
statstring = "\nMinimum: {:.2f}\nMaximum: {:.4f}".format(datamin, datamax)
statstring = "\nMinimum: {:.2f}\nMaximum: {:.2f}".format(datamin, datamax)
statstring += "\n{:.1f} percentile: {:.2f}".format(percentile, clip_val)
elif datamax < 100:
statstring = "\nMinimum: {:.1f}\nMaximum: {:.4f}".format(datamin, datamax)
statstring = "\nMinimum: {:.1f}\nMaximum: {:.1f}".format(datamin, datamax)
statstring += "\n{:.1f} percentile: {:.1f}".format(percentile, clip_val)
else:
statstring = "\nMinimum: {:.0f}\nMaximum: {:.4f}".format(datamin, datamax)
statstring = "\nMinimum: {:.0f}\nMaximum: {:.0f}".format(datamin, datamax)
statstring += "\n{:.1f} percentile: ±{:.0f}".format(percentile, clip_val)

ax.text(.98, .95, 'AMPLITUDE HISTOGRAM',
horizontalalignment='right',
verticalalignment='top',
fontweight='bold',
color=utils.rgb_to_hex(cfg['highlight_colour']),
transform=ax.transAxes, fontsize=fs-3)
ax.text(.98, .95, statstring,
horizontalalignment='right',
verticalalignment='top',
transform=ax.transAxes, fontsize=fs-3)
ax.set_alpha(0)

ax.grid()
gridlines = ax.get_xgridlines() + ax.get_ygridlines()
for line in gridlines:
line.set_linestyle('-')
line.set_alpha(0.2)

statstring += "\nClip percentile: {:.1f}".format(percentile)

hist_ax.text(.98, .95, 'AMPLITUDE HISTOGRAM'+statstring,
horizontalalignment='right',
verticalalignment='top',
transform=hist_ax.transAxes, fontsize=fs - 3)
hist_ax.set_alpha(0)
hist_ax.grid()
return hist_ax
return ax


def plot_colourbar(clr_ax, cmap, data=None, mima=False, plusminus=False, zorder=1):
Expand Down
16 changes: 14 additions & 2 deletions seismic.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def plot_spectrum(self,
f_min = np.amin(mis)
f_max = np.amax(mas)

statstring = "\nMin: {:.2f} Hz\nPeak: {:.2f} Hz\nMax: {:.2f}"
statstring = "\nMin: {:.1f} Hz\nPeak: {:.1f} Hz\nMax: {:.1f} Hz"
stats = statstring.format(f_min, f_peak, f_max)

ax.plot(f, db, lw=0) # Plot invisible line to get the min
Expand All @@ -301,13 +301,25 @@ def plot_spectrum(self,
ax.set_xticklabels(ax.get_xticks(), fontsize=fontsize - 4)
ax.set_yticklabels(ax.get_yticks(), fontsize=fontsize - 4)
ax.set_ylabel('power [dB]', fontsize=fontsize - 4)
ax.text(.98, .95, 'AMPLITUDE SPECTRUM'+stats,
ax.text(.98, .95, 'AMPLITUDE SPECTRUM',
horizontalalignment='right',
verticalalignment='top',
fontweight='bold',
color=colour,
transform=ax.transAxes, fontsize=fontsize - 3)
ax.text(.98, .95, stats,
horizontalalignment='right',
verticalalignment='top',
transform=ax.transAxes, fontsize=fontsize - 3)
ax.yaxis.set_major_formatter(tickfmt)
ax.xaxis.set_major_formatter(tickfmt)

ax.grid('on')
gridlines = ax.get_xgridlines() + ax.get_ygridlines()
for line in gridlines:
line.set_linestyle('-')
line.set_alpha(0.2)

return ax

def get_data(self, l=1, direction=None):
Expand Down
Loading

0 comments on commit 91f7151

Please sign in to comment.