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
43006f24
Commit
43006f24
authored
8 months ago
by
Fraser William Goldsworth
Browse files
Options
Downloads
Patches
Plain Diff
added new error messages
parent
98929e95
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
pyicon/pyicon_plotting.py
+50
-7
50 additions, 7 deletions
pyicon/pyicon_plotting.py
with
50 additions
and
7 deletions
pyicon/pyicon_plotting.py
+
50
−
7
View file @
43006f24
import
sys
,
glob
,
os
import
warnings
import
json
from
pathlib
import
Path
# --- calculations
...
...
@@ -1901,7 +1902,7 @@ def plot(data,
grid_type
=
'
auto
'
,
# --- ckdtree interpolation
res
=
0.3
,
fpath_ckdtree
=
'
auto
'
,
coordinates
=
'
clat cl
on
'
,
coordinates
=
N
on
e
,
antialias
=
1
,
mask_to_zero
=
False
,
# --- original grid
...
...
@@ -2128,12 +2129,54 @@ def plot(data,
f
"
Unable to find file `fpath_ckdtree=
{
fpath_ckdtree
}
`.
\
Try setting `fpath_ckdtree` explicitly.
"
)
datai
=
interp_to_rectgrid_xr
(
data
.
compute
(),
fpath_ckdtree
,
lon_reg
=
lon_reg
,
lat_reg
=
lat_reg
,
coordinates
=
coordinates
,
antialias
=
antialias
,
mask_to_zero
=
mask_to_zero
,
)
if
coordinates
is
None
:
# Infer the coordinates
if
'
cell
'
in
data
.
dims
:
data
=
data
.
rename
(
cell
=
'
ncells
'
)
coordinates
=
'
clat clon
'
elif
'
vertex
'
in
data
.
dims
:
data
=
data
.
rename
(
vertex
=
'
ncells
'
)
coordinates
=
'
vlat vlon
'
else
:
warnings
.
warn
(
"
Coordinates are being inferred. If the resulting plot looks
\n
"
"
unreasonable try setting `coordinates` kwarg explicitly.
"
)
if
'
ncells
'
in
data
.
dims
:
coordinates
=
'
clat clon
'
elif
'
ncells_2
'
in
data
.
dims
:
data
=
data
.
rename
(
ncells_2
=
'
ncells
'
)
coordinates
=
'
vlat vlon
'
else
:
raise
RuntimeError
(
"
Unable to infer coordinates. Please try setting the
\n
"
"
`coordinates` key word argument explicitly.
"
)
try
:
datai
=
interp_to_rectgrid_xr
(
data
.
compute
(),
fpath_ckdtree
,
lon_reg
=
lon_reg
,
lat_reg
=
lat_reg
,
coordinates
=
coordinates
,
antialias
=
antialias
,
mask_to_zero
=
mask_to_zero
,
)
except
IndexError
:
raise
ValueError
(
"
A problem was encountered attempting to interpolate the data to a
\n
"
"
regular grid before plotting. This was *almost certainly* caused by
\n
"
"
the incorrect specification of the `coordinates` keyword argument.
\n
"
"
If the quantity you wish to plot is on cells it should be
\n
"
"
`
'
clon clat
'
`, if on vertices `
'
vlon vlat
'
`.
"
)
except
AttributeError
:
raise
AttributeError
(
"
The ckdtree used for interpolating this object doesn
'
t support
\n
"
f
"
interpolation from
{
coordinates
}
to
'
lat lon
'
. You may need to
\n
"
f
"
recreate the ckdtree stored in
{
fpath_ckdtree
}
or specify a
\n
"
"
different ckdtree.
"
)
lon
=
datai
.
lon
lat
=
datai
.
lat
...
...
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