Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cdo
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Contributor 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
mpim-sw
cdo
Commits
96f4d71d
Commit
96f4d71d
authored
2 years ago
by
Uwe Schulzweida
Browse files
Options
Downloads
Patches
Plain Diff
Add function hp_index_to_lonlat() and hp_interpolate_weights().
parent
7cb8de20
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/mpim_grid/grid_healpix.cc
+32
-0
32 additions, 0 deletions
src/mpim_grid/grid_healpix.cc
src/mpim_grid/grid_healpix.h
+2
-0
2 additions, 0 deletions
src/mpim_grid/grid_healpix.h
with
34 additions
and
0 deletions
src/mpim_grid/grid_healpix.cc
+
32
−
0
View file @
96f4d71d
...
...
@@ -3,6 +3,7 @@ extern "C"
{
#endif
#include
"lib/healpix/healpix.h"
#include
"lib/healpix/interpolation.h"
#ifdef __cplusplus
}
#endif
...
...
@@ -71,3 +72,34 @@ hp_generate_coords(HpOrder order, int nside, int64_t nvals, double *xvals, doubl
}
}
}
void
hp_index_to_lonlat
(
HpOrder
order
,
int
nside
,
int64_t
ipix
,
double
*
xval
,
double
*
yval
)
{
int64_t
(
*
convert_order
)(
int64_t
ipix
,
int
nside
);
// clang-format off
convert_order
=
(
order
==
HpOrder
::
Ring
)
?
&
healpixl_ring_to_xy
:
(
order
==
HpOrder
::
Nest
)
?
&
healpixl_nested_to_xy
:
&
hp_xy_to_xy
;
// clang-format on
auto
cpix
=
convert_order
(
ipix
,
nside
);
healpixl_to_radec
(
cpix
,
nside
,
0.5
,
0.5
,
xval
,
yval
);
}
void
hp_interpolate_weights
(
double
lon
,
double
lat
,
size_t
*
indices
,
double
*
weights
,
int
nside
,
HpOrder
order
)
{
int64_t
(
*
convert_order
)(
int64_t
ipix
,
int
nside
);
// clang-format off
convert_order
=
(
order
==
HpOrder
::
Ring
)
?
&
healpixl_xy_to_ring
:
(
order
==
HpOrder
::
Nest
)
?
&
healpixl_xy_to_nested
:
&
hp_xy_to_xy
;
// clang-format on
int64_t
ringIndices
[
4
];
interpolate_weights
(
lon
,
lat
,
ringIndices
,
weights
,
nside
);
if
(
order
==
HpOrder
::
Ring
)
for
(
int
i
=
0
;
i
<
4
;
++
i
)
indices
[
i
]
=
ringIndices
[
i
];
else
for
(
int
i
=
0
;
i
<
4
;
++
i
)
indices
[
i
]
=
convert_order
(
healpixl_ring_to_xy
(
ringIndices
[
i
],
nside
),
nside
);
}
This diff is collapsed.
Click to expand it.
src/mpim_grid/grid_healpix.h
+
2
−
0
View file @
96f4d71d
...
...
@@ -15,5 +15,7 @@ HpOrder hp_get_order(const char *orderName);
int64_t
hp_lonlat_to_healpixl
(
HpOrder
order
,
int
nside
,
double
xval
,
double
yval
);
void
hp_generate_coords
(
HpOrder
order
,
int
nside
,
int64_t
nvals
,
double
*
xvals
,
double
*
yvals
,
bool
withBounds
,
double
*
xbounds
,
double
*
ybounds
);
void
hp_index_to_lonlat
(
HpOrder
order
,
int
nside
,
int64_t
ipix
,
double
*
xval
,
double
*
yval
);
void
hp_interpolate_weights
(
double
lon
,
double
lat
,
size_t
*
indices
,
double
*
weights
,
int
nside
,
HpOrder
order
);
#endif
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