Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
thopri
PyNEMO
Commits
ca637fde
Commit
ca637fde
authored
5 years ago
by
James Harle
Browse files
Options
Download
Email Patches
Plain Diff
2to3 in gui
parent
67505f90
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
152 additions
and
151 deletions
+152
-151
pynemo/gui/nemo_bdy_mask.py
pynemo/gui/nemo_bdy_mask.py
+2
-2
pynemo/gui/nemo_bdy_mask_gui.py
pynemo/gui/nemo_bdy_mask_gui.py
+3
-3
pynemo/gui/nemo_bdy_namelist_edit.py
pynemo/gui/nemo_bdy_namelist_edit.py
+3
-3
pynemo/gui/nemo_ncml_generator.py
pynemo/gui/nemo_ncml_generator.py
+57
-56
pynemo/gui/nemo_ncml_tab_widget.py
pynemo/gui/nemo_ncml_tab_widget.py
+84
-84
pynemo/gui/selection_editor.py
pynemo/gui/selection_editor.py
+3
-3
No files found.
pynemo/gui/nemo_bdy_mask.py
View file @
ca637fde
...
...
@@ -199,7 +199,7 @@ class Mask(object):
mask_data
[
index
]
=
self
.
data
[
index
]
#connected components
label_mask
,
num_labels
=
ndimage
.
label
(
mask_data
)
mean_values
=
ndimage
.
sum
(
np
.
ones
(
self
.
data
.
shape
),
label_mask
,
range
(
1
,
num_labels
+
1
))
mean_values
=
ndimage
.
sum
(
np
.
ones
(
self
.
data
.
shape
),
label_mask
,
list
(
range
(
1
,
num_labels
+
1
))
)
max_area_mask
=
None
if
mean_values
.
size
!=
0
:
max_area_index
=
np
.
argmax
(
mean_values
)
+
1
...
...
@@ -228,7 +228,7 @@ class Mask(object):
label_mask
,
num_labels
=
ndimage
.
label
(
mask_data
)
if
num_labels
==
0
:
#if mask is empty/clear
return
mean_values
=
ndimage
.
sum
(
np
.
ones
(
self
.
data
.
shape
),
label_mask
,
range
(
1
,
num_labels
+
1
))
mean_values
=
ndimage
.
sum
(
np
.
ones
(
self
.
data
.
shape
),
label_mask
,
list
(
range
(
1
,
num_labels
+
1
))
)
max_area_mask
=
None
if
mean_values
.
size
!=
0
:
max_area_index
=
np
.
argmax
(
mean_values
)
+
1
...
...
This diff is collapsed.
Click to expand it.
pynemo/gui/nemo_bdy_mask_gui.py
View file @
ca637fde
...
...
@@ -11,7 +11,7 @@ import numpy as np
from
.selection_editor
import
PolygonEditor
,
BoxEditor
import
os.path
from
PyQt4.QtCore
import
pyqtSignal
,
pyqtSlot
,
Qt
from
nemo_bdy_mask
import
Mask
from
.
nemo_bdy_mask
import
Mask
import
logging
from
PyQt4.QtGui
import
QSizePolicy
from
matplotlib.colors
import
Normalize
...
...
@@ -126,7 +126,7 @@ class MatplotlibWidget(QtGui.QWidget):
x
=
np
.
arange
(
0
,
self
.
mask
.
lon
.
shape
[
0
])
y
=
np
.
arange
(
0
,
self
.
mask
.
lon
.
shape
[
1
])
x_vals
,
y_vals
=
np
.
meshgrid
(
y
,
x
)
grid
=
zip
(
x_vals
.
ravel
(),
y_vals
.
ravel
())
grid
=
list
(
zip
(
x_vals
.
ravel
(),
y_vals
.
ravel
())
)
self
.
_drawing_tool
.
polygon
.
set_linewidth
(
1.0
)
p_path
=
Path
(
self
.
_drawing_tool
.
polygon
.
xy
)
...
...
@@ -146,7 +146,7 @@ class MatplotlibWidget(QtGui.QWidget):
x
=
np
.
arange
(
0
,
self
.
mask
.
lon
.
shape
[
0
])
y
=
np
.
arange
(
0
,
self
.
mask
.
lon
.
shape
[
1
])
x_vals
,
y_vals
=
np
.
meshgrid
(
y
,
x
)
grid
=
zip
(
x_vals
.
ravel
(),
y_vals
.
ravel
())
#check for the index
grid
=
list
(
zip
(
x_vals
.
ravel
(),
y_vals
.
ravel
())
)
#check for the index
self
.
_drawing_tool
.
polygon
.
set_linewidth
(
1.0
)
p_path
=
Path
(
self
.
_drawing_tool
.
polygon
.
xy
)
...
...
This diff is collapsed.
Click to expand it.
pynemo/gui/nemo_bdy_namelist_edit.py
View file @
ca637fde
...
...
@@ -51,7 +51,7 @@ class NameListEditor(QtGui.QWidget):
text
.
setText
(
str
(
self
.
settings
[
setting
]))
text
.
textChanged
.
connect
(
lambda
value
=
setting
,
\
var_name
=
setting
:
self
.
label_changed
(
value
,
var_name
))
if
self
.
bool_settings
.
has_key
(
setting
)
:
if
setting
in
self
.
bool_settings
:
chkbox
=
QtGui
.
QCheckBox
(
self
)
chkbox
.
setChecked
(
self
.
bool_settings
[
setting
])
chkbox
.
stateChanged
.
connect
(
lambda
value
=
setting
,
\
...
...
@@ -109,7 +109,7 @@ class NameListEditor(QtGui.QWidget):
def
label_changed
(
self
,
value
,
name
):
""" callback when the text is changed in the text box"""
self
.
new_settings
[
name
]
=
unicode
(
value
).
encode
(
'utf_8'
)
self
.
new_settings
[
name
]
=
str
(
value
).
encode
(
'utf_8'
)
def
combo_index_changed
(
self
,
value
,
name
):
""" callback when the True/False drop down for the settings which has boolean value
...
...
@@ -153,7 +153,7 @@ class NameListEditor(QtGui.QWidget):
try
:
self
.
mask_settings_update
.
emit
(
float
(
self
.
settings
[
'mask_max_depth'
]),
float
(
self
.
settings
[
'mask_shelfbreak_dist'
]))
except
KeyError
:
print
'Set the mask setting mask_max_depth and mask_shelfbreak_dist'
print
(
'Set the mask setting mask_max_depth and mask_shelfbreak_dist'
)
if
self
.
bool_settings
[
'mask_file'
]:
self
.
bathymetry_update
.
emit
(
self
.
settings
[
'bathy'
],
self
.
settings
[
'mask_file'
])
...
...
This diff is collapsed.
Click to expand it.
pynemo/gui/nemo_ncml_generator.py
View file @
ca637fde
This diff is collapsed.
Click to expand it.
pynemo/gui/nemo_ncml_tab_widget.py
View file @
ca637fde
This diff is collapsed.
Click to expand it.
pynemo/gui/selection_editor.py
View file @
ca637fde
...
...
@@ -58,12 +58,12 @@ class PolygonEditor(object):
self
.
reset_line
()
self
.
reset_polygon
()
elif
self
.
xy_values
.
shape
[
0
]
<=
2
:
# point or line for 1 or 2 points
xval
,
yval
=
zip
(
*
self
.
xy_values
)
xval
,
yval
=
list
(
zip
(
*
self
.
xy_values
)
)
if
self
.
line
==
None
:
self
.
line
=
Line2D
(
xval
,
yval
,
marker
=
'o'
,
markerfacecolor
=
'r'
,
animated
=
True
)
self
.
axis
.
add_line
(
self
.
line
)
else
:
self
.
line
.
set_data
(
zip
(
*
self
.
xy_values
))
self
.
line
.
set_data
(
list
(
zip
(
*
self
.
xy_values
))
)
self
.
reset_polygon
()
else
:
# more than 2 points if polygon is not created then creates one and draws
if
self
.
polygon
==
None
:
...
...
@@ -72,7 +72,7 @@ class PolygonEditor(object):
self
.
axis
.
add_patch
(
self
.
polygon
)
else
:
self
.
polygon
.
xy
=
self
.
xy_values
self
.
line
.
set_data
(
zip
(
*
self
.
xy_values
))
self
.
line
.
set_data
(
list
(
zip
(
*
self
.
xy_values
))
)
self
.
draw_callback
(
None
)
self
.
canvas
.
draw
()
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment