Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
Progress Bar on Main Interface
Reprojecting bug fix for datasets with negative values.
  • Loading branch information
Patrick-Cole committed Apr 9, 2015
1 parent b37b9f9 commit 38a7357
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 46 deletions.
5 changes: 3 additions & 2 deletions pygmi/clust/crisp_clust.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def __init__(self, parent=None):
self.indata = {}
self.outdata = {}
self.parent = parent
self.pbar = parent.pbar

self.spinbox_maxclusters = QtGui.QSpinBox()
self.combobox_alg = QtGui.QComboBox()
Expand Down Expand Up @@ -183,7 +184,7 @@ def settings(self):
self.parent.process_is_active()
self.run()
self.parent.process_is_active(False)

self.pbar.to_max()
return True

def update_vars(self):
Expand Down Expand Up @@ -545,7 +546,7 @@ def crisp_means(self, data, no_clust, cent, centfix, maxit, term_thresh,
obj_fcn_prev = obj_fcn_initial
obj_fcn = np.zeros(maxit) # This is new - we must initialize this.

for i in range(maxit): # =1:maxit. loop over all iterations
for i in self.pbar.iter(range(maxit)): # =1:maxit. loop over all iterations
cent_prev = cent # store result of last iteration
idx_prev = idx
dist_prev = edist
Expand Down
5 changes: 4 additions & 1 deletion pygmi/clust/fuzzy_clust.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def __init__(self, parent=None):
self.indata = {}
self.outdata = {}
self.parent = parent
self.pbar = parent.pbar

self.combobox_alg = QtGui.QComboBox()
self.doublespinbox_maxerror = QtGui.QDoubleSpinBox()
Expand Down Expand Up @@ -191,6 +192,8 @@ def settings(self):
self.parent.process_is_active()
self.run()
self.parent.process_is_active(False)

self.pbar.to_max()
return True

def update_vars(self):
Expand Down Expand Up @@ -624,7 +627,7 @@ def fuzzy_means(self, data, no_clust, init, centfix, maxit, term_thresh,
# num2unicode(info(1)),'/[',num2unicode(info(2)),
# ' ',num2unicode(info(3)),'] Run: ',num2unicode(info(4)),'/',
# num2unicode(info(5))])
for i in range(maxit): # loop over all iterations
for i in self.pbar.iter(range(maxit)): # loop over all iterations
# waitbar(i/maxit,hh)
cent_prev = cent # store result of last iteration
uprev = uuu
Expand Down
6 changes: 6 additions & 0 deletions pygmi/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import math
import pkgutil
import os
import pygmi.misc as misc


class Arrow(QtGui.QGraphicsLineItem):
Expand Down Expand Up @@ -320,6 +321,7 @@ def mouseDoubleClickEvent(self, event):
item to reflect whether it is busy working.
"""
self.setBrush(QtGui.QColor(255, 0, 0, 127))

temp = self.settings()
if temp is True:
self.setBrush(QtGui.QColor(0, 255, 0, 127))
Expand Down Expand Up @@ -512,6 +514,7 @@ def __init__(self, parent=None):
self.graphics_view = QtGui.QGraphicsView()
self.textbrowser_datainfo = QtGui.QTextBrowser()
self.textbrowser_processlog = QtGui.QTextBrowser()
self.pbar = misc.ProgressBar()

self.action_help = QtGui.QAction(self)
self.action_delete = QtGui.QAction(self)
Expand Down Expand Up @@ -599,6 +602,7 @@ def setupui(self):
self.grid_layout.addWidget(self.graphics_view, 0, 0, 4, 2)
self.grid_layout.addWidget(self.textbrowser_datainfo, 1, 2, 1, 1)
self.grid_layout.addWidget(self.textbrowser_processlog, 3, 2, 1, 1)
self.grid_layout.addWidget(self.pbar, 5, 0, 1, 3)

label = QtGui.QLabel()
label_2 = QtGui.QLabel()
Expand Down Expand Up @@ -866,9 +870,11 @@ def process_is_active(self, isactive=True):
isactive : bool, optional
boolean variable indicating if a process is active.
"""

if isactive:
self.textbrowser_processlog.setStyleSheet(
"* { background-color: rgba(255, 0, 0, 127); }")
self.pbar.setValue(0)
else:
self.textbrowser_processlog.setStyleSheet(
"* { background-color: rgb(255, 255, 255); }")
Expand Down
8 changes: 4 additions & 4 deletions pygmi/menu_default.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ def __init__(self, parent):
self.menufile.setTitle("File")
parent.menubar.addAction(self.menufile.menuAction())

self.action_open_project = QtGui.QAction(parent)
self.action_open_project.setText("Open Project")
# self.action_open_project = QtGui.QAction(parent)
# self.action_open_project.setText("Open Project")
# self.menufile.addAction(self.action_open_project)

self.action_save_project = QtGui.QAction(parent)
self.action_save_project.setText("Save Project")
# self.action_save_project = QtGui.QAction(parent)
# self.action_save_project.setText("Save Project")
# self.menufile.addAction(self.action_save_project)

self.action_exit = QtGui.QAction(parent)
Expand Down
9 changes: 8 additions & 1 deletion pygmi/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
ptimer is utility module used to simplify checking how much time has passed
in a program. It also outputs a message at the point when called. """

from PyQt4 import QtGui, QtCore
from PyQt4 import QtGui
import time


Expand Down Expand Up @@ -131,3 +131,10 @@ def iter(self, iterable):

self.setFormat('%p%')
self.setValue(total)

def to_max(self):
""" Set PBar to Maximum """
self.setMaximum(1)
self.setMinimum(0)
self.setValue(1)
QtGui.QApplication.processEvents()
24 changes: 14 additions & 10 deletions pygmi/raster/cooper.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import scipy.signal as si
import copy
import pygmi.menu_default as menu_default
from numba import jit

# data = np.array([ [1, 2, 3, 4, 5, 6, 7, 8, 9],
# [1, 2, 3, 4, 5, 7, 6, 8, 9],
Expand Down Expand Up @@ -74,6 +75,7 @@ def __init__(self, parent):
self.azi = 45.
self.elev = 45.
self.order = 1
self.pbar = self.parent.pbar

self.sb_order = QtGui.QSpinBox()
self.sb_azi = QtGui.QSpinBox()
Expand Down Expand Up @@ -124,7 +126,7 @@ def settings(self):

data = copy.deepcopy(self.indata['Raster'])

for i in range(len(data)):
for i in self.pbar.iter(range(len(data))):
data[i].data = gradients(data[i].data, self.azi, 0., self.order)

self.outdata['Raster'] = data
Expand Down Expand Up @@ -199,6 +201,7 @@ def __init__(self, parent):
self.outdata = {}
self.wsize = 11
self.dh = 10
self.pbar = self.parent.pbar

self.sb_dh = QtGui.QSpinBox()
self.sb_wsize = QtGui.QSpinBox()
Expand Down Expand Up @@ -255,7 +258,8 @@ def settings(self):
self.parent.showprocesslog(data[i].dataid+':')

vtot, vstd, vsum = visibility2d(data[i].data, self.wsize,
self.dh*data[i].data.std()/100.)
self.dh*data[i].data.std()/100.,
self.pbar.iter)
# data[i].data = vtot
data2.append(copy.deepcopy(data[i]))
data2.append(copy.deepcopy(data[i]))
Expand All @@ -273,7 +277,7 @@ def settings(self):
return True


def visibility2d(data, wsize, dh):
def visibility2d(data, wsize, dh, piter=iter):
"""
Compute visibility as a textural measure
Expand Down Expand Up @@ -314,21 +318,21 @@ def visibility2d(data, wsize, dh):
data[mask] = mean

# self.parent.showprocesslog('NS')
for j in range(nc): # Columns
for j in piter(range(nc)): # Columns
for i in range(w2, nr-w2):
dtmp = data[i-w2:i+w2+1, j]
vn[i, j] = __visible1(dtmp, wsize, w2+1, dh)
vs[i, j] = __visible2(dtmp, wsize, w2+1, dh)

# self.parent.showprocesslog('EW')
for j in range(w2, nc-w2): # Rows
for j in piter(range(w2, nc-w2)): # Rows
for i in range(nr):
dtmp = data[i, j-w2:j+w2+1]
ve[i, j] = __visible1(dtmp, wsize, w2+1, dh)
vw[i, j] = __visible2(dtmp, wsize, w2+1, dh)

# self.parent.showprocesslog('Diag')
for j in range(w2, nc-w2):
for j in piter(range(w2, nc-w2)):
for i in range(w2, nr-w2):
dtmp = np.zeros(wsize)
for k in range(wsize):
Expand All @@ -345,7 +349,7 @@ def visibility2d(data, wsize, dh):
vtot = vn+vs+ve+vw+vd1+vd2+vd3+vd4
vtot = vtot[w2:nr-w2, w2:nc-w2]

for j in range(nc):
for j in piter(range(nc)):
for i in range(nr):
vstd[i, j] = np.std([vn[i, j], vs[i, j], ve[i, j], vw[i, j],
vd1[i, j], vd2[i, j], vd3[i, j],
Expand Down Expand Up @@ -430,6 +434,7 @@ def __init__(self, parent):
self.outdata = {}
self.azi = 75
self.smooth = 0
self.pbar = self.parent.pbar

self.sb_azi = QtGui.QSpinBox()
self.sb_s = QtGui.QSpinBox()
Expand Down Expand Up @@ -483,7 +488,7 @@ def settings(self):
data = copy.deepcopy(self.indata['Raster'])
data2 = []

for i in range(len(data)):
for i in self.pbar.iter(range(len(data))):
t1, th, t2, ta, tdx = tilt1(data[i].data, self.azi, self.smooth)
data2.append(copy.deepcopy(data[i]))
data2.append(copy.deepcopy(data[i]))
Expand Down Expand Up @@ -599,7 +604,7 @@ def __nextpow2(n):
m_i = np.ceil(np.log2(n))
return m_i


@jit
def vertical(data, npts=None, xint=1):
""" Vertical """

Expand All @@ -614,7 +619,6 @@ def vertical(data, npts=None, xint=1):
data1 = __taper2d(data, npts, nc, nr, cdiff, rdiff)
# data1 = np.pad(data, ((rdiff, cdiff), (rdiff,cdiff)), 'edge')


f = np.fft.fft2(data1)
fz = f
wn = 2.0*np.pi/(xint*(npts-1))
Expand Down
Loading

0 comments on commit 38a7357

Please sign in to comment.