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
Aaron Spring
pyicon
Commits
224764fa
Commit
224764fa
authored
4 years ago
by
Nils Brüggemann
Browse files
Options
Downloads
Patches
Plain Diff
pyicon/pyicon_plotting.py: Added option in hplot_base and vplot_base to save the plotted data.
parent
c9bdc44c
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
+29
-0
29 additions, 0 deletions
pyicon/pyicon_plotting.py
with
29 additions
and
0 deletions
pyicon/pyicon_plotting.py
+
29
−
0
View file @
224764fa
...
...
@@ -19,6 +19,7 @@ import cmocean
# --- debugging
from
ipdb
import
set_trace
as
mybreak
from
importlib
import
reload
from
.pyicon_tb
import
write_dataarray_to_nc
def
hplot_base
(
IcD
,
IaV
,
clim
=
'
auto
'
,
cmap
=
'
viridis
'
,
cincr
=-
1.
,
clevs
=
None
,
...
...
@@ -39,6 +40,8 @@ def hplot_base(IcD, IaV, clim='auto', cmap='viridis', cincr=-1.,
do_plot_settings
=
True
,
land_facecolor
=
'
0.7
'
,
do_write_data_range
=
False
,
save_data
=
False
,
path_nc
=
''
,
):
"""
IaV variable needs the following attributes
...
...
@@ -163,6 +166,19 @@ def hplot_base(IcD, IaV, clim='auto', cmap='viridis', cincr=-1.,
info_str
=
'
min: %.4g; mean: %.4g; std: %.4g; max: %.4g
'
%
(
IaV
.
data
.
min
(),
IaV
.
data
.
mean
(),
IaV
.
data
.
std
(),
IaV
.
data
.
max
())
ax
.
text
(
0.5
,
-
0.18
,
info_str
,
ha
=
'
center
'
,
va
=
'
top
'
,
transform
=
ax
.
transAxes
)
# --- saving data to netcdf
if
save_data
:
if
use_tgrid
:
print
(
'
::: Warning: saving variable on tripolar grid is not supported yet in hplot_base! :::
'
)
ds
=
write_dataarray_to_nc
(
fpath
=
path_nc
+
IaV
.
name
+
'
.nc
'
,
data
=
IaV
.
data
,
coords
=
{
'
lat
'
:
IcD
.
lat
,
'
lon
'
:
IcD
.
lon
},
name
=
IaV
.
name
,
long_name
=
IaV
.
long_name
,
units
=
IaV
.
units
,
long_name_coords
=
[
'
latitude
'
,
'
longitude
'
],
#time_bnds=IaV.bnds,
)
#if (projection!='none') and (crs_features):
##if projection=='PlateCarree':
##if False:
...
...
@@ -198,6 +214,8 @@ def vplot_base(IcD, IaV, clim='auto', cmap='viridis', cincr=-1.,
fig_size_fac
=
2.0
,
do_plot_settings
=
True
,
do_write_data_range
=
False
,
save_data
=
False
,
path_nc
=
''
,
):
"""
IaV variable needs the following attributes
...
...
@@ -328,6 +346,17 @@ def vplot_base(IcD, IaV, clim='auto', cmap='viridis', cincr=-1.,
info_str
=
'
min: %.4g; mean: %.4g; std: %.4g; max: %.4g
'
%
(
IaV
.
data
.
min
(),
IaV
.
data
.
mean
(),
IaV
.
data
.
std
(),
IaV
.
data
.
max
())
ax
.
text
(
0.5
,
-
0.18
,
info_str
,
ha
=
'
center
'
,
va
=
'
top
'
,
transform
=
ax
.
transAxes
)
# --- saving data to netcdf
if
save_data
:
ds
=
write_dataarray_to_nc
(
fpath
=
path_nc
+
IaV
.
name
+
'
.nc
'
,
data
=
IaV
.
data
,
coords
=
{
'
vert_coord
'
:
z
,
'
hor_coord
'
:
x
},
name
=
IaV
.
name
,
long_name
=
IaV
.
long_name
,
units
=
IaV
.
units
,
long_name_coords
=
[
ylabel
,
xstr
],
#time_bnds=IaV.bnds,
)
return
ax
,
cax
,
mappable
,
Dstr
def
calc_conts
(
conts
,
clim
,
cincr
,
nclev
):
...
...
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