Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pyicon-fraser
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Fraser William Goldsworth
pyicon-fraser
Commits
91fd969b
Commit
91fd969b
authored
2 years ago
by
fraserwg
Browse files
Options
Downloads
Patches
Plain Diff
added converted_tgrid check which prevents double conversion of a tgrid file
parent
dd69e7c5
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
+32
-7
32 additions, 7 deletions
pyicon/pyicon_calc_xr.py
with
32 additions
and
7 deletions
pyicon/pyicon_calc_xr.py
+
32
−
7
View file @
91fd969b
...
...
@@ -12,18 +12,43 @@ print('xarray')
import
xarray
as
xr
print
(
'
Done modules calc.
'
)
def
convert_tgrid_data
(
ds_tg
):
def
convert_tgrid_data
(
ds_tg
,
check_previous_conversion
=
True
,
set_dim_order
=
True
):
"""
Convert xarray grid file to grid file compatible with pyicon function.
Open classical ICON grid file by:
ds_tg = xr.open_dataset(fpath_tg, chunks=dict())
Parameters
----------
ds_tg : xr.Dataset
raw, unprocessed tgrid
check_previous_conversion : bool
check whether the dataset has already been converted and raise an error
if so
set_dim_order : bool or list
Transpose the dataset so dimensions appear in the standard pyicon
order, or the order listed
Then convert by:
ds_IcD = pyic.convert_tgrid_data(ds_tg)
Returns
-------
ds_icd : xr.Dataset
A tgrid dataset compatible with pyicon functions
ds_tg and ds_IcD are both lazy xarray data sets containing dask arrays.
Notes
-----
Open classical ICON grid file by:
ds_tg = xr.open_dataset(fpath_tg, chunks=dict())
Then convert by:
ds_IcD = pyic.convert_tgrid_data(ds_tg)
"""
if
check_previous_conversion
:
if
"
converted_tgrid
"
in
ds_tg
.
attrs
:
raise
ValueError
(
"
ds_tg has previously been converted by this function,
\
applying the function again will lead to undocumented
\
behaviour. To proceed, set
'
check_previous_conversion=False
'"
)
ds_IcD
=
xr
.
Dataset
()
# --- constants (from src/shared/mo_physical_constants.f90)
...
...
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