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
8e08808c
Commit
8e08808c
authored
1 month ago
by
Nils Brüggemann
Committed by
Fraser William Goldsworth
1 month ago
Browse files
Options
Downloads
Patches
Plain Diff
pyic_view: Allows different projections.
parent
3ee1d349
No related branches found
Branches containing commit
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
+66
-8
66 additions, 8 deletions
scripts/pyic_view.py
with
66 additions
and
8 deletions
scripts/pyic_view.py
+
66
−
8
View file @
8e08808c
...
...
@@ -120,10 +120,21 @@ class view(object):
"
cmo.thermal
"
,
"
cmo.haline
"
,
"
cmo.curl
"
,
]
self
.
res_all
=
[
1.
,
0.3
,
0.1
,
0.02
]
self
.
proj_all
=
[
"
None
"
,
"
+proj=latlong
"
,
"
+proj=stere +lat_0=90 +lon_0=0
"
,
"
+proj=stere +lat_0=-90 +lon_0=0
"
,
"
+proj=eqearth
"
,
"
+proj=moll
"
,
]
self
.
font_size
=
6
*
self
.
fig_size_fac
self
.
res
=
0.3
self
.
it
=
0
self
.
iz
=
0
self
.
proj
=
self
.
proj_all
[
0
]
if
self
.
proj
!=
"
None
"
:
self
.
transformer
=
Proj
.
from_pipeline
(
self
.
proj
)
# Opean data set
self
.
load_data
()
...
...
@@ -134,6 +145,7 @@ class view(object):
self
.
color_limits
=
tk
.
StringVar
(
value
=
"
auto
"
)
# Default color limits
self
.
lon_lat_reg_tk
=
tk
.
StringVar
(
value
=
"
-180,180,-90,90
"
)
self
.
selected_res
=
tk
.
StringVar
(
value
=
"
0.3
"
)
self
.
selected_proj
=
tk
.
StringVar
(
value
=
"
None
"
)
# Create figure and axis
self
.
fig
,
self
.
ax
,
self
.
cax
=
generate_axes
(
asp
=
0.5
)
...
...
@@ -167,11 +179,11 @@ class view(object):
print
(
'
Setup sliders
'
)
self
.
slider_t
=
tk
.
Scale
(
root
,
from_
=
0
,
to
=
len
(
self
.
ds
.
time
)
-
1
,
orient
=
"
horizontal
"
,
label
=
"
time
"
,
command
=
self
.
update_plot
)
self
.
slider_t
.
grid
(
row
=
1
,
column
=
0
,
sticky
=
"
ew
"
)
self
.
slider_t
.
grid
(
row
=
1
,
column
=
0
,
columnspan
=
2
,
sticky
=
"
ew
"
)
self
.
slider_d
=
tk
.
Scale
(
root
,
from_
=
0
,
to
=
len
(
self
.
ds
.
depth
)
-
1
,
orient
=
"
horizontal
"
,
label
=
"
depth
"
,
command
=
self
.
update_plot
)
self
.
slider_d
.
grid
(
row
=
1
,
column
=
1
,
sticky
=
"
ew
"
)
self
.
slider_d
.
grid
(
row
=
1
,
column
=
2
,
columnspan
=
2
,
sticky
=
"
ew
"
)
# Create dropdown menus
print
(
'
Setup var dropdown
'
)
...
...
@@ -331,9 +343,27 @@ class view(object):
self
.
fpath_ckdtree
,
self
.
lon_reg
,
self
.
lat_reg
)
self
.
Lon
,
self
.
Lat
=
np
.
meshgrid
(
self
.
dai
.
lon
.
data
,
self
.
dai
.
lat
.
data
)
if
self
.
proj
==
"
None
"
:
self
.
X
,
self
.
Y
=
self
.
Lon
,
self
.
Lat
else
:
self
.
X
,
self
.
Y
=
self
.
transformer
.
transform
(
self
.
Lon
,
self
.
Lat
,
direction
=
'
FORWARD
'
)
#valid = np.isfinite(self.X) & np.isfinite(self.Y)
#self.dai[valid==False] = np.nan
# make plot
self
.
hm
=
pyic
.
shade
(
self
.
dai
.
lon
,
self
.
dai
.
lat
,
self
.
dai
,
valid
=
np
.
isfinite
(
self
.
X
)
&
np
.
isfinite
(
self
.
Y
)
self
.
hm
=
pyic
.
shade
(
#self.X[valid], self.Y[valid], self.dai.data[valid],
self
.
X
,
self
.
Y
,
self
.
dai
.
data
,
ax
=
self
.
ax
,
cax
=
self
.
cax
)
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
])
elif
self
.
proj
==
"
+proj=stere +lat_0=-90 +lon_0=0
"
:
self
.
ax
.
set_xlim
([
-
5965970.154575175
,
5965970.154575175
])
self
.
ax
.
set_ylim
([
-
5963978.177895851
,
5963978.177895851
])
else
:
self
.
ax
.
set_xlim
(
self
.
X
.
min
(),
self
.
X
.
max
())
self
.
ax
.
set_ylim
(
self
.
Y
.
min
(),
self
.
Y
.
max
())
#pyic.plot_settings(self.ax, xlim=self.lon_reg, ylim=self.lat_reg)
self
.
ax
.
set_facecolor
(
'
0.7
'
)
self
.
update_cmap
()
...
...
@@ -346,7 +376,12 @@ class view(object):
self
.
update_title
()
def
make_new_axis
(
self
,
*
args
):
self
.
res
=
float
(
self
.
selected_res
.
get
())
self
.
proj
=
self
.
selected_proj
.
get
()
if
self
.
proj
!=
"
None
"
:
self
.
transformer
=
Proj
.
from_pipeline
(
self
.
proj
)
try
:
self
.
ax
.
remove
()
...
...
@@ -355,8 +390,21 @@ class view(object):
pass
self
.
update_lon_lat_reg
()
#proj = ccrs.PlateCarree()
proj
=
None
if
self
.
proj
==
"
+proj=stere +lat_0=90 +lon_0=0
"
:
asp
=
1.0
elif
self
.
proj
==
"
+proj=stere +lat_0=-90 +lon_0=0
"
:
asp
=
1.0
elif
self
.
proj
==
"
+proj=eqearth
"
:
asp
=
0.4867169753874043
elif
self
.
proj
==
"
+proj=moll
"
:
asp
=
0.5
else
:
asp
=
(
self
.
lat_reg
[
1
]
-
self
.
lat_reg
[
0
])
/
(
self
.
lon_reg
[
1
]
-
self
.
lon_reg
[
0
])
self
.
fig
,
self
.
ax
,
self
.
cax
=
generate_axes
(
asp
,
generate_figure
=
False
)
##proj = ccrs.PlateCarree()
#proj = None
self
.
ax
=
self
.
fig
.
add_subplot
(
position
=
self
.
pos_ax
,
projection
=
proj
)
...
...
@@ -465,12 +513,22 @@ class view(object):
def
on_click
(
self
,
event
):
# Avoid clicking outside the axes
if
event
.
xdata
is
not
None
and
event
.
ydata
is
not
None
:
lon0
,
lat0
=
event
.
xdata
,
event
.
ydata
if
self
.
proj
!=
"
None
"
:
lon_click
,
lat_click
=
self
.
transformer
.
transform
(
event
.
xdata
,
event
.
ydata
,
direction
=
'
INVERSE
'
,
)
else
:
lon_click
,
lat_click
=
event
.
xdata
,
event
.
ydata
ind
=
np
.
argmin
(
(
self
.
Lon
.
flatten
()
-
lon
0
)
**
2
+
(
self
.
Lat
.
flatten
()
-
lat
0
)
**
2
(
self
.
Lon
.
flatten
()
-
lon
_click
)
**
2
+
(
self
.
Lat
.
flatten
()
-
lat
_click
)
**
2
)
data_click
=
self
.
dai
.
data
.
flatten
()[
ind
]
print
(
f
"
lon:
{
event
.
xdata
:
.
2
f
}
, lat:
{
event
.
ydata
:
.
2
f
}
, data:
{
data_click
:
.
4
f
}
"
)
txt
=
f
"
lon:
{
lon_click
:
.
2
f
}
, lat:
{
lat_click
:
.
2
f
}
, data:
{
data_click
:
.
4
f
}
"
self
.
ht_point
.
set_text
(
txt
)
print
(
txt
)
self
.
canvas
.
draw
()
def
main
():
import
argparse
...
...
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