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
e2c022e3
Commit
e2c022e3
authored
2 years ago
by
Uwe Schulzweida
Browse files
Options
Downloads
Patches
Plain Diff
Add function hp_lonlat_to_healpixl().
parent
8294717d
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
+24
-10
24 additions, 10 deletions
src/mpim_grid/grid_healpix.cc
src/mpim_grid/grid_healpix.h
+1
-0
1 addition, 0 deletions
src/mpim_grid/grid_healpix.h
with
25 additions
and
10 deletions
src/mpim_grid/grid_healpix.cc
+
24
−
10
View file @
e2c022e3
...
...
@@ -29,14 +29,29 @@ hp_xy_to_xy(int64_t ipix, int nside)
return
ipix
;
}
int64_t
hp_lonlat_to_healpixl
(
HpOrder
order
,
int
nside
,
double
xval
,
double
yval
)
{
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
auto
ipix
=
radec_to_healpixl
(
xval
,
yval
,
nside
);
auto
cpix
=
convert_order
(
ipix
,
nside
);
return
cpix
;
}
void
hp_generate_coords
(
HpOrder
hpO
rder
,
int
nside
,
int64_t
nvals
,
double
*
xvals
,
double
*
yvals
,
bool
withBounds
,
double
*
xbounds
,
hp_generate_coords
(
HpOrder
o
rder
,
int
nside
,
int64_t
nvals
,
double
*
xvals
,
double
*
yvals
,
bool
withBounds
,
double
*
xbounds
,
double
*
ybounds
)
{
int64_t
(
*
convert_order
)(
int64_t
ipix
,
int
nside
);
// clang-format off
convert_order
=
(
hpO
rder
==
HpOrder
::
Ring
)
?
&
healpixl_ring_to_xy
:
(
hpO
rder
==
HpOrder
::
Nest
)
?
&
healpixl_nested_to_xy
:
&
hp_xy_to_xy
;
convert_order
=
(
o
rder
==
HpOrder
::
Ring
)
?
&
healpixl_ring_to_xy
:
(
o
rder
==
HpOrder
::
Nest
)
?
&
healpixl_nested_to_xy
:
&
hp_xy_to_xy
;
// clang-format on
#ifdef _OPENMP
...
...
@@ -44,16 +59,15 @@ hp_generate_coords(HpOrder hpOrder, int nside, int64_t nvals, double *xvals, dou
#endif
for
(
int64_t
ipix
=
0
;
ipix
<
nvals
;
ipix
++
)
{
const
auto
order
=
convert_order
(
ipix
,
nside
);
healpixl_to_radec
(
order
,
nside
,
0.5
,
0.5
,
&
xvals
[
ipix
],
&
yvals
[
ipix
]);
auto
cpix
=
convert_order
(
ipix
,
nside
);
healpixl_to_radec
(
cpix
,
nside
,
0.5
,
0.5
,
&
xvals
[
ipix
],
&
yvals
[
ipix
]);
if
(
withBounds
)
{
healpixl_to_radec
(
order
,
nside
,
0.0
,
0.0
,
&
xbounds
[
ipix
*
4
+
0
],
&
ybounds
[
ipix
*
4
+
0
]);
healpixl_to_radec
(
order
,
nside
,
1.0
,
0.0
,
&
xbounds
[
ipix
*
4
+
1
],
&
ybounds
[
ipix
*
4
+
1
]);
healpixl_to_radec
(
order
,
nside
,
1.0
,
1.0
,
&
xbounds
[
ipix
*
4
+
2
],
&
ybounds
[
ipix
*
4
+
2
]);
healpixl_to_radec
(
order
,
nside
,
0.0
,
1.0
,
&
xbounds
[
ipix
*
4
+
3
],
&
ybounds
[
ipix
*
4
+
3
]);
healpixl_to_radec
(
cpix
,
nside
,
0.0
,
0.0
,
&
xbounds
[
ipix
*
4
+
0
],
&
ybounds
[
ipix
*
4
+
0
]);
healpixl_to_radec
(
cpix
,
nside
,
1.0
,
0.0
,
&
xbounds
[
ipix
*
4
+
1
],
&
ybounds
[
ipix
*
4
+
1
]);
healpixl_to_radec
(
cpix
,
nside
,
1.0
,
1.0
,
&
xbounds
[
ipix
*
4
+
2
],
&
ybounds
[
ipix
*
4
+
2
]);
healpixl_to_radec
(
cpix
,
nside
,
0.0
,
1.0
,
&
xbounds
[
ipix
*
4
+
3
],
&
ybounds
[
ipix
*
4
+
3
]);
}
}
}
This diff is collapsed.
Click to expand it.
src/mpim_grid/grid_healpix.h
+
1
−
0
View file @
e2c022e3
...
...
@@ -12,6 +12,7 @@ enum class HpOrder
};
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
);
...
...
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