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
6583c3f9
Commit
6583c3f9
authored
1 year ago
by
Nils Brüggemann
Browse files
Options
Downloads
Patches
Plain Diff
pyicon_calc_xr.py: Fixed a bug where input grid dataset ds_tg was modified by convert_tgrid_data.
parent
45f9530a
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_calc_xr.py
+7
-4
7 additions, 4 deletions
pyicon/pyicon_calc_xr.py
with
7 additions
and
4 deletions
pyicon/pyicon_calc_xr.py
+
7
−
4
View file @
6583c3f9
...
...
@@ -5,13 +5,13 @@ from itertools import product
def
convert_tgrid_data
(
ds_tg
,
check_previous_conversion
=
True
,
set_dim_order
=
None
,
old_dim_behaviour
=
None
ds_tg
_in
,
check_previous_conversion
=
True
,
set_dim_order
=
None
,
old_dim_behaviour
=
None
):
"""
Convert xarray grid file to grid file compatible with pyicon function.
Parameters
----------
ds_tg : xr.Dataset
ds_tg
_in
: xr.Dataset
raw, unprocessed tgrid
check_previous_conversion : bool
...
...
@@ -44,6 +44,10 @@ def convert_tgrid_data(
Then convert by:
ds_IcD = pyic.convert_tgrid_data(ds_tg)
"""
# make deep copy of ds_tg_in to avoid glaobal modifications if during this function call
ds_tg
=
ds_tg_in
.
copy
(
deep
=
True
)
if
old_dim_behaviour
is
None
:
warnings
.
warn
(
"
The default behaviour for convert_tgrid has recently
\
...
...
@@ -195,6 +199,7 @@ def convert_tgrid_data(
ds_IcD
[
variable
]
=
ds_IcD
[
variable
].
rename
(
dim_name_remappings
[
variable
])
ds_IcD
.
attrs
[
"
converted_tgrid
"
]
=
True
ds_tg
.
attrs
[
"
converted_tgrid
"
]
=
True
if
set_dim_order
is
None
:
standard_order
=
[
"
cell
"
,
"
vertex
"
,
"
edge
"
,
"
nc
"
,
"
nv
"
,
"
ne
"
,
"
cart
"
,
...]
...
...
@@ -400,8 +405,6 @@ def xr_calc_2dlocal_from_3d(ds_IcD, p_vn_c):
uo
=
u2
*
cosLon
-
u1
*
sinLon
vo
=
-
(
u1
*
cosLon
+
u2
*
sinLon
)
*
sinLat
+
u3
*
cosLat
uo
=
u2
*
cosLon
-
u1
*
sinLon
vo
=
-
(
u1
*
cosLon
+
u2
*
sinLon
)
*
sinLat
+
u3
*
cosLat
return
uo
,
vo
...
...
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