Skip to content

Commit

Permalink
Merge branch 'gamaanderson-master'
Browse files Browse the repository at this point in the history
BUG: Fix Nyquist and changes loss on advancement.
  • Loading branch information
nguy committed May 24, 2016
2 parents 961e995 + c9f9d26 commit c72ed25
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 3 deletions.
24 changes: 24 additions & 0 deletions artview/components/menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def __init__(self, pathDir=None, filename=None, Vradar=None, Vgrid=None,
for m in mode:
self.mode.append(m.lower())
self.Vradar = Vradar
self.current_container = self.Vradar
self.Vgrid = Vgrid
self.Vfilelist = Vfilelist
self.sharedVariables = {"Vradar": None,
Expand Down Expand Up @@ -99,9 +100,22 @@ def keyPressEvent(self, event):
'''Change data file with left and right arrow keys.'''
if event.key() == QtCore.Qt.Key_Right:
# Menu control the file and open the radar
resp = True
if hasattr(self.current_container.value, 'changed') and self.current_container.value.changed:
resp = common.ShowQuestionYesNo("Save changes before moving to next File?")
if resp == QtGui.QMessageBox.Yes:
self.saveCurrent()
elif resp != QtGui.QMessageBox.No:
return
self.AdvanceFileSelect(self.fileindex + 1)
elif event.key() == QtCore.Qt.Key_Left:
# Menu control the file and open the radar
if hasattr(self.current_container.value, 'changed') and self.current_container.value.changed:
resp = common.ShowQuestionYesNo("Save changes before moving to next File?")
if resp == QtGui.QMessageBox.Yes:
self.saveCurrent()
elif resp != QtGui.QMessageBox.No:
return
self.AdvanceFileSelect(self.fileindex - 1)
else:
QtGui.QWidget.keyPressEvent(self, event)
Expand Down Expand Up @@ -150,6 +164,12 @@ def showFileDialog(self):
self.filename = filename
self._openfile()

def saveCurrent(self):
if self.current_container == self.Vradar:
self.saveRadar()
elif self.current_container == self.Vgrid:
self.saveGrid()

def saveRadar(self):
'''
Open a dialog box to save radar file.
Expand Down Expand Up @@ -612,13 +632,15 @@ def _openfile(self, filename=None):
# Add the filename for Display
radar.filename = self.filename
self.Vradar.change(radar)
self.current_container = self.Vradar
return
except:
try:
radar = pyart.io.read(self.filename)
# Add the filename for Display
radar.filename = self.filename
self.Vradar.change(radar)
self.current_container = self.Vradar
return
except:
import traceback
Expand All @@ -629,11 +651,13 @@ def _openfile(self, filename=None):
grid = pyart.io.read_grid(
self.filename, delay_field_loading=True)
self.Vgrid.change(grid)
self.current_container = self.Vgrid
return
except:
try:
grid = pyart.io.read_grid(self.filename)
self.Vgrid.change(grid)
self.current_container = self.Vgrid
return
except:
import traceback
Expand Down
17 changes: 17 additions & 0 deletions artview/core/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,23 @@ def ShowQuestion(msg):

return response

def ShowQuestionYesNo(msg):
'''
Show a Question message with yes no.
Parameters::
----------
msg - string
Message to display in MessageBox.
'''
Dialog = QtGui.QDialog()
response = QtGui.QMessageBox.question(
Dialog, "Question", msg,
QtGui.QMessageBox.Yes, QtGui.QMessageBox.No,
QtGui.QMessageBox.Cancel)

return response


def ShowLongText(msg, modal=True, set_html=False):
'''
Expand Down
1 change: 1 addition & 0 deletions artview/plugins/dealias_region_based.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ def dealias_region_based(self):

# add fields and update
self.Vradar.value.add_field(name, field, True)
self.Vradar.value.changed = True
self.Vradar.update(strong_update)
print("Correction took %fs" % (t1-t0))

Expand Down
1 change: 1 addition & 0 deletions artview/plugins/dealias_unwrap_phase.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ def dealias_unwrap_phase(self):

# add fields and update
self.Vradar.value.add_field(name, field, True)
self.Vradar.value.changed = True
self.Vradar.update(strong_update)
print("Correction took %fs" % (t1-t0))

Expand Down
2 changes: 2 additions & 0 deletions artview/plugins/manual_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ def removeFromField(self):
data.mask[mask_ray, mask_range] = True
self.Vradar.value.fields[self.Vfield.value]['data'] = data

self.Vradar.value.changed = True
self.Vradar.update()

def removeFromRadar(self):
Expand All @@ -180,6 +181,7 @@ def removeFromRadar(self):
data.mask[mask_ray, mask_range] = True
self.Vradar.value.fields[field]['data'] = data

self.Vradar.value.changed = True
self.Vradar.update()

def reset(self):
Expand Down
13 changes: 10 additions & 3 deletions artview/plugins/manual_unfold.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def __init__(self, Vradar=None, Vpoints=None, name=" ManualUnfold",
instance.
'''
super(ManualUnfold, self).__init__(name=name, parent=parent)
self.lockNyquist = False

if Vradar is None:
self.Vradar = Variable(None)
Expand Down Expand Up @@ -179,6 +180,8 @@ def unfold(self, side):
radar.fields[corrVel]['valid_min'] = - 1.5 * nyquist
if 'valid_max' not in radar.fields[corrVel]:
radar.fields[corrVel]['valid_max'] = 1.5 * nyquist
self.lockNyquist = True
self.Vradar.value.changed = True
self.Vradar.update(strong_update)

# save for undoing
Expand All @@ -202,6 +205,8 @@ def foldBack(self):
data = radar.fields[corrVel]['data']
data = data - 2 * unfold * nyquist
radar.fields[corrVel]['data'] = data
self.lockNyquist = True
self.Vradar.value.changed = True
self.Vradar.update()

def _displayHelp(self):
Expand Down Expand Up @@ -235,9 +240,11 @@ def NewRadar(self, variable, strong):
if self.Vradar.value is None:
return

if strong:
if strong and not self.lockNyquist:
nyquist_vel = self.Vradar.value.get_nyquist_vel(0, True)
self.nyquistVelocity.setValue(nyquist_vel)

if nyquist_vel > 0:
self.nyquistVelocity.setValue(nyquist_vel)
elif self.lockNyquist:
self.lockNyquist = False

_plugins = [ManualUnfold]
1 change: 1 addition & 0 deletions artview/plugins/phase_proc_lp.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ def phase_proc_lp(self):
# add fields and update
self.Vradar.value.add_field(reproc_phase_name, reproc_phase, True)
self.Vradar.value.add_field(sob_kdp_name, sob_kdp, True)
self.Vradar.value.changed = True
self.Vradar.update(strong_update)
print("Correction took %fs" % (t1-t0))

Expand Down

0 comments on commit c72ed25

Please sign in to comment.