Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pyicon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Fraser William Goldsworth
pyicon
Commits
0e95d940
Commit
0e95d940
authored
2 months ago
by
Nils Brüggemann
Committed by
Fraser William Goldsworth
2 months ago
Browse files
Options
Downloads
Patches
Plain Diff
pyic_view: Allow to toggle grid lines.
parent
763d0400
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/pyic_view.py
+72
-1
72 additions, 1 deletion
scripts/pyic_view.py
with
72 additions
and
1 deletion
scripts/pyic_view.py
+
72
−
1
View file @
0e95d940
...
...
@@ -205,7 +205,8 @@ class view(object):
res_menu
.
bind
(
"
<<ComboboxSelected>>
"
,
self
.
make_new_axis
)
# Button to activate zoom mode
self
.
zoom_button
=
ttk
.
Button
(
root
,
text
=
"
Enable Zoom
"
,
command
=
self
.
activate_zoom
)
self
.
zoom_button
=
ttk
.
Button
(
root
,
text
=
"
Enable Zoom
"
,
command
=
self
.
activate_zoom
)
self
.
zoom_button
.
grid
(
row
=
3
,
column
=
2
)
# Variables to store zoom area
...
...
@@ -223,6 +224,12 @@ class view(object):
res_menu
.
grid
(
row
=
3
,
column
=
3
)
res_menu
.
bind
(
"
<<ComboboxSelected>>
"
,
self
.
make_new_axis
)
# checkbox for grid display
self
.
do_grid
=
tk
.
BooleanVar
()
self
.
checkbox
=
tk
.
Checkbutton
(
root
,
text
=
"
Show grid
"
,
variable
=
self
.
do_grid
,
command
=
self
.
toggle_grid
)
self
.
checkbox
.
grid
(
row
=
2
,
column
=
3
)
# initial plot
self
.
plot_data
()
self
.
canvas
.
draw
()
...
...
@@ -268,6 +275,7 @@ class view(object):
# Ensure correct ordering of coordinates
self
.
ax
.
set_xlim
(
min
(
x0
,
x1
),
max
(
x0
,
x1
))
self
.
ax
.
set_ylim
(
min
(
y0
,
y1
),
max
(
y0
,
y1
))
#self.toggle_grid()
# Remove the rectangle and redraw
self
.
rect
.
remove
()
...
...
@@ -330,6 +338,7 @@ class view(object):
#self.X[valid], self.Y[valid], self.dai.data[valid],
self
.
X
,
self
.
Y
,
self
.
dai
.
data
,
ax
=
self
.
ax
,
cax
=
self
.
cax
)
# set ax limits
if
self
.
proj
==
"
+proj=stere +lat_0=90 +lon_0=0
"
:
self
.
ax
.
set_xlim
([
-
4660515.349812048
,
4660515.349812048
])
self
.
ax
.
set_ylim
([
-
4658959.2511977535
,
4658959.2511977535
])
...
...
@@ -339,6 +348,14 @@ class view(object):
else
:
self
.
ax
.
set_xlim
(
self
.
X
.
min
(),
self
.
X
.
max
())
self
.
ax
.
set_ylim
(
self
.
Y
.
min
(),
self
.
Y
.
max
())
# set ax labels
if
self
.
proj
==
"
None
"
or
self
.
proj
==
"
+proj=latlong
"
:
#self.ax.set_xticks(np.arange(-180.,180.,45.))
#self.ax.set_yticks(np.arange(-90,90,45.))
pass
else
:
self
.
ax
.
set_xticks
([])
self
.
ax
.
set_yticks
([])
self
.
ax
.
set_facecolor
(
'
0.7
'
)
self
.
update_cmap
()
# set titles
...
...
@@ -475,6 +492,60 @@ class view(object):
clim
[
1
]
=
data
.
max
().
data
return
clim
def
toggle_grid
(
self
):
if
self
.
do_grid
.
get
():
print
(
'
Adding grid lines
'
)
color
=
'
k
'
linewidth
=
0.5
if
self
.
proj
==
"
+proj=stere +lat_0=90 +lon_0=0
"
:
lon_c_vals
=
np
.
arange
(
-
180.
,
180.
,
45.
)
lat_c_vals
=
[
40
,
50
,
60
,
70
,
80
]
elif
self
.
proj
==
"
+proj=stere +lat_0=-90 +lon_0=0
"
:
lon_c_vals
=
np
.
arange
(
-
180.
,
180.
,
45.
)
lat_c_vals
=
[
-
30
,
-
40
,
-
50
,
-
60
,
-
70
,
-
80
]
if
self
.
proj
==
"
None
"
or
self
.
proj
==
"
+proj=latlong
"
:
lon_c_vals
=
self
.
ax
.
get_xticks
()
lat_c_vals
=
self
.
ax
.
get_yticks
()
else
:
lon_c_vals
=
np
.
arange
(
-
180.
,
180.
,
45.
)
lat_c_vals
=
np
.
arange
(
-
90.
,
90.
,
45.
)
#transformer = Proj.from_pipeline(self.proj)
nc
=
51
X_c
=
np
.
empty
((
1
,
nc
))
Y_c
=
np
.
empty
((
1
,
nc
))
for
nn
,
lat_c_val
in
enumerate
(
lat_c_vals
):
lon_c
=
np
.
linspace
(
-
180
,
180
,
nc
)
lat_c
=
lat_c_val
*
np
.
ones
(
nc
)
if
self
.
proj
!=
"
None
"
:
x_c
,
y_c
=
self
.
transformer
.
transform
(
lon_c
,
lat_c
,
direction
=
'
FORWARD
'
)
else
:
x_c
,
y_c
=
lon_c
,
lat_c
X_c
=
np
.
concatenate
([
X_c
,
x_c
[
np
.
newaxis
,:]],
axis
=
0
)
Y_c
=
np
.
concatenate
([
Y_c
,
y_c
[
np
.
newaxis
,:]],
axis
=
0
)
for
nn
,
lon_c_val
in
enumerate
(
lon_c_vals
):
lon_c
=
lon_c_val
*
np
.
ones
(
nc
)
lat_c
=
np
.
linspace
(
-
90
,
90
,
nc
)
if
self
.
proj
!=
"
None
"
:
x_c
,
y_c
=
self
.
transformer
.
transform
(
lon_c
,
lat_c
,
direction
=
'
FORWARD
'
)
else
:
x_c
,
y_c
=
lon_c
,
lat_c
X_c
=
np
.
concatenate
([
X_c
,
x_c
[
np
.
newaxis
,:]],
axis
=
0
)
Y_c
=
np
.
concatenate
([
Y_c
,
y_c
[
np
.
newaxis
,:]],
axis
=
0
)
self
.
hgs
=
[]
for
nn
in
range
(
X_c
.
shape
[
0
]):
hg
,
=
self
.
ax
.
plot
(
X_c
[
nn
,:],
Y_c
[
nn
,:],
color
=
color
,
linewidth
=
linewidth
)
self
.
hgs
.
append
(
hg
)
#print(f'nn = {nn}, {self.hgs}')
else
:
print
(
'
Removing grid lines
'
)
for
hg
in
self
.
hgs
:
hg
.
remove
()
self
.
canvas
.
draw
()
# capture mouse click, print coordinates and data
def
on_click
(
self
,
event
):
# Avoid clicking outside the axes
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment