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
9dc47df9
Commit
9dc47df9
authored
2 years ago
by
fraserwg
Browse files
Options
Downloads
Patches
Plain Diff
updated conversion of lat lon to degrees and added test
parent
7f0ea446
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pyicon/pyicon_calc_xr.py
+5
-14
5 additions, 14 deletions
pyicon/pyicon_calc_xr.py
pyicon/tests/test_pyicon_calc_xr.py
+5
-0
5 additions, 0 deletions
pyicon/tests/test_pyicon_calc_xr.py
with
10 additions
and
14 deletions
pyicon/pyicon_calc_xr.py
+
5
−
14
View file @
9dc47df9
print
(
'
sys glob os
'
)
import
sys
import
glob
,
os
#import datetime
print
(
'
numpy
'
)
import
numpy
as
np
print
(
'
netcdf
'
)
from
netCDF4
import
Dataset
,
num2date
#print('ipdb')
#from ipdb import set_trace as mybreak
print
(
'
xarray
'
)
import
xarray
as
xr
from
itertools
import
product
print
(
'
Done modules calc.
'
)
def
convert_tgrid_data
(
ds_tg
,
check_previous_conversion
=
True
,
set_dim_order
=
True
):
...
...
@@ -123,12 +116,10 @@ def convert_tgrid_data(ds_tg, check_previous_conversion=True, set_dim_order=True
ds_tg
[
'
edge_primal_normal_cartesian_z
'
],
],
dim
=
'
cart
'
).
transpose
()
ds_IcD
[
'
clon
'
]
*=
180.
/
np
.
pi
ds_IcD
[
'
clat
'
]
*=
180.
/
np
.
pi
ds_IcD
[
'
elon
'
]
*=
180.
/
np
.
pi
ds_IcD
[
'
elat
'
]
*=
180.
/
np
.
pi
ds_IcD
[
'
vlon
'
]
*=
180.
/
np
.
pi
ds_IcD
[
'
vlat
'
]
*=
180.
/
np
.
pi
for
point
,
dim
in
product
(
"
ecv
"
,
(
"
lat
"
,
"
lon
"
)):
coord
=
point
+
dim
ds_IcD
[
coord
]
*=
180.
/
np
.
pi
ds_IcD
[
coord
].
attrs
[
"
units
"
]
=
"
degrees
"
ds_IcD
[
'
fc
'
]
=
2.
*
ds_IcD
.
earth_angular_velocity
*
np
.
sin
(
ds_IcD
.
clat
*
np
.
pi
/
180.
)
ds_IcD
[
'
fe
'
]
=
2.
*
ds_IcD
.
earth_angular_velocity
*
np
.
sin
(
ds_IcD
.
elat
*
np
.
pi
/
180.
)
...
...
This diff is collapsed.
Click to expand it.
pyicon/tests/test_pyicon_calc_xr.py
+
5
−
0
View file @
9dc47df9
...
...
@@ -31,6 +31,11 @@ def test_convert_tgrid_data(raw_grid):
assert
converted_tgrid
[
info
].
max
().
values
==
\
converted_tgrid
.
dims
[
"
cell
"
]
-
1
# Conversion of ecv lat and lon to degrees
for
point
,
dim
in
product
(
"
ecv
"
,
(
"
lat
"
,
"
lon
"
)):
coord
=
point
+
dim
assert
converted_tgrid
[
coord
].
attrs
[
"
units
"
]
==
"
degrees
"
# Converted tgrid attribute is there
assert
converted_tgrid
.
attrs
[
"
converted_tgrid
"
]
...
...
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