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
df38697b
Commit
df38697b
authored
2 months ago
by
Moritz Hanke
Browse files
Options
Downloads
Patches
Plain Diff
some refactoring of test_compute_overlap_area.c
parent
49278381
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/core/test_compute_overlap_area.c
+48
-50
48 additions, 50 deletions
tests/core/test_compute_overlap_area.c
with
48 additions
and
50 deletions
tests/core/test_compute_overlap_area.c
+
48
−
50
View file @
df38697b
...
...
@@ -18,11 +18,16 @@ static enum yac_edge_type gc_edges[] =
YAC_GREAT_CIRCLE_EDGE
,
YAC_GREAT_CIRCLE_EDGE
,
YAC_GREAT_CIRCLE_EDGE
,
YAC_GREAT_CIRCLE_EDGE
,
YAC_GREAT_CIRCLE_EDGE
,
YAC_GREAT_CIRCLE_EDGE
};
static
enum
yac_edge_type
latlon_edges
[
4
]
=
{
YAC_LAT_CIRCLE_EDGE
,
YAC_LON_CIRCLE_EDGE
,
YAC_LAT_CIRCLE_EDGE
,
YAC_LON_CIRCLE_EDGE
};
static
void
check_overlap
(
double
*
lon_a
,
double
*
lat_a
,
int
count_a
,
double
*
lon_b
,
double
*
lat_b
,
int
count_b
,
double
ref_area
,
double
const
*
ref_barycenter
);
double
*
lon_a
,
double
*
lat_a
,
enum
yac_edge_type
*
edges_a
,
int
count_a
,
double
*
lon_b
,
double
*
lat_b
,
enum
yac_edge_type
*
edges_b
,
int
count_b
,
double
ref_area
,
double
const
*
ref_barycenter
);
static
void
check_overlap_polygons
(
struct
yac_grid_cell
*
Polygons
,
double
ref_area
,
double
const
*
ref_barycenter
);
...
...
@@ -85,9 +90,9 @@ int main (void) {
check_overlap
(
(
double
[]){
10
.
0
,
11
.
0
,
11
.
5
,
10
.
5
,
9
.
5
},
(
double
[]){
32
.
0
,
32
.
0
,
30
.
0
,
31
.
0
,
30
.
0
},
5
,
(
double
[]){
32
.
0
,
32
.
0
,
30
.
0
,
31
.
0
,
30
.
0
},
gc_edges
,
5
,
(
double
[]){
10
.
5
,
11
.
0
,
10
.
0
},
(
double
[]){
31
.
5
,
29
.
5
,
29
.
5
},
3
,
(
double
[]){
31
.
5
,
29
.
5
,
29
.
5
},
gc_edges
,
3
,
ref_area
,
ref_barycenter
);
}
...
...
@@ -139,8 +144,8 @@ int main (void) {
}
check_overlap
(
(
double
[]){
-
5
,
5
,
5
,
-
5
},
(
double
[]){
-
5
,
-
5
,
5
,
5
},
4
,
(
double
[]){
-
4
,
4
,
0
},
(
double
[]){
-
4
,
-
4
,
6
},
3
,
(
double
[]){
-
5
,
5
,
5
,
-
5
},
(
double
[]){
-
5
,
-
5
,
5
,
5
},
gc_edges
,
4
,
(
double
[]){
-
4
,
4
,
0
},
(
double
[]){
-
4
,
-
4
,
6
},
gc_edges
,
3
,
ref_area
,
ref_barycenter
);
}
...
...
@@ -180,8 +185,8 @@ int main (void) {
normalise_vector
(
ref_barycenter
);
check_overlap
(
(
double
[]){
0
,
0
,
90
,
180
,
270
},
(
double
[]){
90
,
88
,
88
,
88
,
88
},
5
,
(
double
[]){
0
,
90
,
180
,
270
},
(
double
[]){
89
,
89
,
89
,
89
},
4
,
(
double
[]){
0
,
0
,
90
,
180
,
270
},
(
double
[]){
90
,
88
,
88
,
88
,
88
},
gc_edges
,
5
,
(
double
[]){
0
,
90
,
180
,
270
},
(
double
[]){
89
,
89
,
89
,
89
},
gc_edges
,
4
,
ref_area
,
ref_barycenter
);
}
...
...
@@ -205,8 +210,10 @@ int main (void) {
double
*
ref_barycenter
=
NULL
;
check_overlap
(
(
double
[]){
2
,
3
,
3
,
-
3
,
-
3
,
-
2
,
-
2
,
2
},
(
double
[]){
3
,
3
,
-
3
,
-
3
,
3
,
3
,
-
2
,
-
2
},
8
,
(
double
[]){
1
,
1
,
-
1
,
-
1
},
(
double
[]){
1
,
-
1
,
-
1
,
1
},
4
,
(
double
[]){
2
,
3
,
3
,
-
3
,
-
3
,
-
2
,
-
2
,
2
},
(
double
[]){
3
,
3
,
-
3
,
-
3
,
3
,
3
,
-
2
,
-
2
},
gc_edges
,
8
,
(
double
[]){
1
,
1
,
-
1
,
-
1
},
(
double
[]){
1
,
-
1
,
-
1
,
1
},
gc_edges
,
4
,
ref_area
,
ref_barycenter
);
}
...
...
@@ -233,8 +240,8 @@ int main (void) {
check_overlap
(
(
double
[]){
0
,
3
,
3
,
-
3
,
-
3
,
0
,
0
,
-
2
,
-
2
,
2
,
2
,
0
},
(
double
[]){
3
,
3
,
-
3
,
-
3
,
3
,
3
,
2
,
2
,
-
2
,
-
2
,
2
,
2
},
12
,
(
double
[]){
1
,
1
,
-
1
,
-
1
},
(
double
[]){
1
,
-
1
,
-
1
,
1
},
4
,
(
double
[]){
3
,
3
,
-
3
,
-
3
,
3
,
3
,
2
,
2
,
-
2
,
-
2
,
2
,
2
},
gc_edges
,
12
,
(
double
[]){
1
,
1
,
-
1
,
-
1
},
(
double
[]){
1
,
-
1
,
-
1
,
1
},
gc_edges
,
4
,
ref_area
,
ref_barycenter
);
}
...
...
@@ -284,9 +291,9 @@ int main (void) {
check_overlap
(
(
double
[]){
0
,
90
,
180
,
270
,
270
,
180
,
90
,
0
},
(
double
[]){
88
,
88
,
88
,
88
,
87
,
87
,
87
,
87
},
8
,
(
double
[]){
88
,
88
,
88
,
88
,
87
,
87
,
87
,
87
},
gc_edges
,
8
,
(
double
[]){
90
,
180
,
90
},
(
double
[]){
90
,
87
.
5
,
87
.
5
},
3
,
(
double
[]){
90
,
87
.
5
,
87
.
5
},
gc_edges
,
3
,
ref_area
,
ref_barycenter
);
}
...
...
@@ -326,9 +333,9 @@ int main (void) {
(
double
[]){
315
,
270
,
180
,
90
,
0
,
315
,
315
,
0
,
90
,
180
,
270
,
315
},
(
double
[]){
89
,
89
,
89
,
89
,
89
,
89
,
86
,
86
,
86
,
86
,
86
,
86
},
12
,
86
,
86
,
86
,
86
,
86
,
86
},
gc_edges
,
12
,
(
double
[]){
90
,
90
,
180
},
(
double
[]){
90
,
87
.
5
,
87
.
5
},
3
,
(
double
[]){
90
,
87
.
5
,
87
.
5
},
gc_edges
,
3
,
ref_area
,
ref_barycenter
);
}
...
...
@@ -374,9 +381,9 @@ int main (void) {
(
double
[]){
315
,
270
,
225
,
180
,
135
,
90
,
45
,
0
,
315
,
315
,
0
,
45
,
90
,
135
,
180
,
225
,
270
,
315
},
(
double
[]){
89
,
89
,
89
,
89
,
89
,
89
,
89
,
89
,
89
,
86
,
86
,
86
,
86
,
86
,
86
,
86
,
86
,
86
},
18
,
86
,
86
,
86
,
86
,
86
,
86
,
86
,
86
,
86
},
gc_edges
,
18
,
(
double
[]){
0
+
tri_rotation
,
90
+
tri_rotation
,
180
+
tri_rotation
},
(
double
[]){
87
.
5
,
87
.
5
,
87
.
5
},
3
,
(
double
[]){
87
.
5
,
87
.
5
,
87
.
5
},
gc_edges
,
3
,
ref_area
,
ref_barycenter
);
}
}
...
...
@@ -422,9 +429,9 @@ int main (void) {
(
double
[]){
315
,
270
,
225
,
180
,
135
,
90
,
45
,
0
,
315
,
315
,
0
,
45
,
90
,
135
,
180
,
225
,
270
,
315
},
(
double
[]){
89
,
89
,
89
,
89
,
89
,
89
,
89
,
89
,
89
,
86
,
86
,
86
,
86
,
86
,
86
,
86
,
86
,
86
},
18
,
86
,
86
,
86
,
86
,
86
,
86
,
86
,
86
,
86
},
gc_edges
,
18
,
(
double
[]){
0
,
90
,
180
,
270
},
(
double
[]){
87
.
5
,
87
.
5
,
87
.
5
,
87
.
5
},
4
,
(
double
[]){
87
.
5
,
87
.
5
,
87
.
5
,
87
.
5
},
gc_edges
,
4
,
ref_area
,
ref_barycenter
);
}
...
...
@@ -476,11 +483,11 @@ int main (void) {
(
double
[]){
135
,
90
,
45
,
0
,
315
,
270
,
225
,
180
,
135
,
135
,
180
,
225
,
270
,
315
,
0
,
45
,
90
,
135
},
(
double
[]){
88
,
88
,
88
,
88
,
88
,
88
,
88
,
88
,
88
,
86
,
86
,
86
,
86
,
86
,
86
,
86
,
86
,
86
},
18
,
86
,
86
,
86
,
86
,
86
,
86
,
86
,
86
,
86
},
gc_edges
,
18
,
(
double
[]){
315
,
270
,
225
,
180
,
135
,
90
,
45
,
0
,
315
,
315
,
0
,
45
,
90
,
135
,
180
,
225
,
270
,
315
},
(
double
[]){
89
,
89
,
89
,
89
,
89
,
89
,
89
,
89
,
89
,
87
,
87
,
87
,
87
,
87
,
87
,
87
,
87
,
87
},
18
,
87
,
87
,
87
,
87
,
87
,
87
,
87
,
87
,
87
},
gc_edges
,
18
,
ref_area
,
ref_barycenter
);
}
...
...
@@ -518,12 +525,7 @@ int main (void) {
{
-
0
.
12381864923052141
,
0
.
11788515390505606
,
-
0
.
98527764238894122
}},
.
edge_type
=
(
enum
yac_edge_type
[
4
])
{
YAC_LAT_CIRCLE_EDGE
,
YAC_LON_CIRCLE_EDGE
,
YAC_LAT_CIRCLE_EDGE
,
YAC_LON_CIRCLE_EDGE
},
.
edge_type
=
latlon_edges
,
.
num_corners
=
4
,
.
array_size
=
4
}};
struct
yac_grid_cell
overlap_buffer
=
...
...
@@ -554,12 +556,7 @@ int main (void) {
{
0
.
097899074391390048
,
0
.
004
8094731201957178
,
0
.
99518472667219682
}},
.
edge_type
=
(
enum
yac_edge_type
[
4
])
{
YAC_LAT_CIRCLE_EDGE
,
YAC_LON_CIRCLE_EDGE
,
YAC_LAT_CIRCLE_EDGE
,
YAC_LON_CIRCLE_EDGE
},
.
edge_type
=
latlon_edges
,
.
num_corners
=
4
,
.
array_size
=
4
},
{.
coordinates_xyz
=
...
...
@@ -612,12 +609,7 @@ int main (void) {
{
-
0
.
66183555116521386
,
-
0
.
33314002067992043
,
0
.
67155895484701855
}},
.
edge_type
=
(
enum
yac_edge_type
[
4
])
{
YAC_LAT_CIRCLE_EDGE
,
YAC_LON_CIRCLE_EDGE
,
YAC_LAT_CIRCLE_EDGE
,
YAC_LON_CIRCLE_EDGE
},
.
edge_type
=
latlon_edges
,
.
num_corners
=
4
,
.
array_size
=
4
},
{.
coordinates_xyz
=
...
...
@@ -685,9 +677,9 @@ int main (void) {
}
check_overlap
(
(
double
[]){
0
.
0
,
0
.
5
,
2
.
0
,
0
.
5
,
0
.
0
,
-
0
.
5
,
-
2
.
0
,
-
0
.
5
},
(
double
[]){
2
.
0
,
0
.
5
,
0
.
0
,
-
0
.
5
,
-
2
.
0
,
-
0
.
5
,
0
.
0
,
0
.
5
},
8
,
(
double
[]){
2
.
0
,
0
.
5
,
0
.
0
,
-
0
.
5
,
-
2
.
0
,
-
0
.
5
,
0
.
0
,
0
.
5
},
gc_edges
,
8
,
(
double
[]){
-
3
.
0
,
3
.
0
,
3
.
0
,
-
3
.
0
},
(
double
[]){
3
.
0
,
3
.
0
,
-
3
.
0
,
-
3
.
0
},
4
,
(
double
[]){
3
.
0
,
3
.
0
,
-
3
.
0
,
-
3
.
0
},
gc_edges
,
4
,
ref_area
,
ref_barycenter
);
}
...
...
@@ -722,9 +714,9 @@ int main (void) {
}
check_overlap
(
(
double
[]){
0
.
0
,
0
.
5
,
2
.
0
,
0
.
5
,
0
.
0
,
-
0
.
5
,
-
2
.
0
,
-
0
.
5
},
(
double
[]){
2
.
0
,
0
.
5
,
0
.
0
,
-
0
.
5
,
-
2
.
0
,
-
0
.
5
,
0
.
0
,
0
.
5
},
8
,
(
double
[]){
2
.
0
,
0
.
5
,
0
.
0
,
-
0
.
5
,
-
2
.
0
,
-
0
.
5
,
0
.
0
,
0
.
5
},
gc_edges
,
8
,
(
double
[]){
-
0
.
5
,
0
.
5
,
0
.
5
,
-
0
.
5
},
(
double
[]){
0
.
5
,
0
.
5
,
-
0
.
5
,
-
0
.
5
},
4
,
(
double
[]){
0
.
5
,
0
.
5
,
-
0
.
5
,
-
0
.
5
},
gc_edges
,
4
,
ref_area
,
ref_barycenter
);
}
...
...
@@ -828,9 +820,9 @@ static void check_overlap_polygons(
}
static
void
check_overlap
(
double
*
lon_a
,
double
*
lat_a
,
int
count_a
,
double
*
lon_b
,
double
*
lat_b
,
int
count_b
,
double
ref_area
,
double
const
*
ref_barycenter
)
{
double
*
lon_a
,
double
*
lat_a
,
enum
yac_edge_type
*
edges_a
,
int
count_a
,
double
*
lon_b
,
double
*
lat_b
,
enum
yac_edge_type
*
edges_b
,
int
count_b
,
double
ref_area
,
double
const
*
ref_barycenter
)
{
for
(
int
order_a
=
-
1
;
order_a
<=
1
;
order_a
+=
2
)
{
for
(
int
order_b
=
-
1
;
order_b
<=
1
;
order_b
+=
2
)
{
...
...
@@ -839,21 +831,27 @@ static void check_overlap(
double
curr_lon_a
[
count_a
],
curr_lat_a
[
count_a
];
double
curr_lon_b
[
count_b
],
curr_lat_b
[
count_b
];
enum
yac_edge_type
curr_edges_a
[
count_a
];
enum
yac_edge_type
curr_edges_b
[
count_b
];
for
(
int
i
=
0
;
i
<
count_a
;
++
i
)
{
int
idx
=
(
start_idx_a
+
order_a
*
i
+
count_a
)
%
count_a
;
curr_lon_a
[
i
]
=
lon_a
[
idx
];
curr_lat_a
[
i
]
=
lat_a
[
idx
];
idx
=
(
idx
-
(
order_a
<
0
)
+
count_a
)
%
count_a
;
curr_edges_a
[
i
]
=
edges_a
[
idx
];
}
for
(
int
i
=
0
;
i
<
count_b
;
++
i
)
{
int
idx
=
(
start_idx_b
+
order_b
*
i
+
count_b
)
%
count_b
;
curr_lon_b
[
i
]
=
lon_b
[
idx
];
curr_lat_b
[
i
]
=
lat_b
[
idx
];
idx
=
(
idx
-
(
order_b
<
0
)
+
count_b
)
%
count_b
;
curr_edges_b
[
i
]
=
edges_b
[
idx
];
}
struct
yac_grid_cell
Polygons
[
2
]
=
{
generate_cell_deg
(
curr_lon_a
,
curr_lat_a
,
g
c_edges
,
count_a
),
generate_cell_deg
(
curr_lon_b
,
curr_lat_b
,
g
c_edges
,
count_b
)};
generate_cell_deg
(
curr_lon_a
,
curr_lat_a
,
c
urr
_edges
_a
,
count_a
),
generate_cell_deg
(
curr_lon_b
,
curr_lat_b
,
c
urr
_edges
_b
,
count_b
)};
check_overlap_polygons
(
Polygons
,
ref_area
,
ref_barycenter
);
...
...
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