Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Y
YAC
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
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
dkrz-sw
YAC
Commits
4b5755c8
Commit
4b5755c8
authored
8 months ago
by
Nils-Arne Dreier
Browse files
Options
Downloads
Patches
Plain Diff
add python bindings for compute_grid_cell_areas
parent
44ccc1f3
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
doc/src/reference.dox
+3
-0
3 additions, 0 deletions
doc/src/reference.dox
python/yac.pyx
+11
-0
11 additions, 0 deletions
python/yac.pyx
tests/python/test_interface.py
+1
-0
1 addition, 0 deletions
tests/python/test_interface.py
with
15 additions
and
0 deletions
doc/src/reference.dox
+
3
−
0
View file @
4b5755c8
...
...
@@ -756,6 +756,9 @@
<td style="vertical-align:top;width:33%">
<ul style="margin:0px">
<li> \ref yac::yac_fcompute_grid_cell_areas "yac_fcompute_grid_cell_areas (*)"
<td style="vertical-align:top;width:33%">
<ul style="margin:0px">
<li> \ref yac.YAC.Grid.compute_gril_cell_areas
<tr>
<td style="vertical-align:top;width:33%">
<ul style="margin:0px">
...
...
This diff is collapsed.
Click to expand it.
python/yac.pyx
+
11
−
0
View file @
4b5755c8
...
...
@@ -366,6 +366,7 @@ cdef extern from "yac.h":
const
char
*
filename
,
int
fileformat
,
int
sync_location
);
void
yac_ccompute_grid_cell_areas
(
int
grid_id
,
double
*
cell_areas
);
# helper functions for py interface (not in yac_interface.h)
cdef
extern
void
yac_cget_comp_size_c2py
(
int
comp_id
,
int
*
size
)
...
...
@@ -1034,6 +1035,16 @@ class Grid:
&
mask_id
)
return
Mask
(
mask_id
)
def
compute_grid_cell_areas
(
self
,
cell_areas
=
None
):
"""
@see yac_ccompute_grid_cell_areas
"""
if
cell_areas
is
None
:
cell_areas
=
_np
.
empty
(
self
.
nbr_cells
)
cdef
double
[::
1
]
np_cell_areas
=
_np
.
ascontiguousarray
(
cell_areas
,
dtype
=
_np
.
double
)
yac_ccompute_grid_cell_areas
(
self
.
grid_id
,
&
np_cell_areas
[
0
])
return
cell_areas
class
Points
:
"""
Stores the points_id and provides further functionality
...
...
This diff is collapsed.
Click to expand it.
tests/python/test_interface.py
+
1
−
0
View file @
4b5755c8
...
...
@@ -60,6 +60,7 @@ x.setflags(write=0) # require a const memoryview in Reg2d
grid1
=
yac
.
Reg2dGrid
(
"
grid1
"
,
x
,
x
)
grid1
.
set_global_index
(
range
(
9
),
yac
.
Location
.
CORNER
)
grid1
.
set_global_index
(
np
.
arange
(
4
,
dtype
=
np
.
intc
),
yac
.
Location
.
CELL
)
print
(
f
"
{
grid1
.
compute_grid_cell_areas
()
=
}
"
)
assert
grid1
.
nbr_cells
==
4
assert
grid1
.
nbr_corners
==
9
assert
grid1
.
nbr_edges
==
12
...
...
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