Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
NIFTy
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
Container registry
Model registry
Monitor
Service Desk
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
ift
NIFTy
Commits
858b96e6
Commit
858b96e6
authored
2 years ago
by
Lukas Platz
Committed by
Lukas Platz
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
refactor HPSpace/GLSpace plotting, add exportable helper for 2d projection
parent
fe020fdc
Branches
Branches containing commit
No related tags found
1 merge request
!847
Draft: Multi-Frequency and `HPSpace` Plotting refactor
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/plot.py
+32
-32
32 additions, 32 deletions
src/plot.py
with
32 additions
and
32 deletions
src/plot.py
+
32
−
32
View file @
858b96e6
...
...
@@ -87,11 +87,39 @@ def _hammer_helper(xsize):
return
res
,
mask
,
theta
,
phi
sphere_projection_helpers
=
{
_
sphere_projection_helpers
=
{
'
mollweide
'
:
_mollweide_helper
,
'
hammer
'
:
_hammer_helper
,
}
"""
Dictionary of projection helpers for spherical projections
"""
def
project_spherical_field_to_2d
(
val
,
dom
,
projection
=
'
mollweide
'
,
xsize
=
800
,
have_rgb
=
False
):
"""
Project spherical data onto a two-dimensional plane
"""
if
projection
not
in
_sphere_projection_helpers
.
keys
():
raise
ValueError
(
f
"
Projection
'
{
projection
}
'
unsupported!
"
)
res
,
mask
,
theta
,
phi
=
_sphere_projection_helpers
[
projection
](
xsize
)
if
have_rgb
:
res
=
np
.
full
(
shape
=
res
.
shape
+
(
3
,),
fill_value
=
1.
,
dtype
=
np
.
float64
)
if
isinstance
(
dom
,
HPSpace
):
from
ducc0.healpix
import
Healpix_Base
ptg
=
np
.
empty
((
phi
.
size
,
2
),
dtype
=
np
.
float64
)
ptg
[:,
0
]
=
theta
ptg
[:,
1
]
=
phi
base
=
Healpix_Base
(
int
(
np
.
sqrt
(
dom
.
size
//
12
)),
"
RING
"
)
res
[
mask
]
=
val
[
base
.
ang2pix
(
ptg
)]
else
:
from
ducc0.misc
import
GL_thetas
ra
=
np
.
linspace
(
0
,
2
*
np
.
pi
,
dom
.
nlon
+
1
)
dec
=
GL_thetas
(
dom
.
nlat
)
ilat
=
_find_closest
(
dec
,
theta
)
ilon
=
_find_closest
(
ra
,
phi
)
ilon
=
np
.
where
(
ilon
==
dom
.
nlon
,
0
,
ilon
)
res
[
mask
]
=
val
[
ilat
*
dom
.
nlon
+
ilon
]
return
res
class
MultiFrequencyToRGBProjector
:
...
...
@@ -616,38 +644,10 @@ def _plot2D(f, ax, **kwargs):
_limit_xy
(
**
kwargs
)
return
elif
isinstance
(
dom
,
(
HPSpace
,
GLSpace
)):
from
ducc0.healpix
import
Healpix_Base
from
ducc0.misc
import
GL_thetas
xsize
=
kwargs
.
pop
(
'
xsize
'
,
800
)
projection
=
kwargs
.
pop
(
'
projection
'
,
'
mollweide
'
)
if
projection
not
in
sphere_projection_helpers
.
keys
():
raise
ValueError
(
f
"
Projection
'
{
projection
}
'
unsupported!
"
)
res
,
mask
,
theta
,
phi
=
sphere_projection_helpers
[
projection
](
xsize
)
if
have_rgb
:
res
=
np
.
full
(
shape
=
res
.
shape
+
(
3
,),
fill_value
=
1.
,
dtype
=
np
.
float64
)
if
isinstance
(
dom
,
HPSpace
):
ptg
=
np
.
empty
((
phi
.
size
,
2
),
dtype
=
np
.
float64
)
ptg
[:,
0
]
=
theta
ptg
[:,
1
]
=
phi
base
=
Healpix_Base
(
int
(
np
.
sqrt
(
dom
.
size
//
12
)),
"
RING
"
)
if
have_rgb
:
res
[
mask
]
=
rgb
[
base
.
ang2pix
(
ptg
)]
else
:
res
[
mask
]
=
f
.
val
[
base
.
ang2pix
(
ptg
)]
else
:
ra
=
np
.
linspace
(
0
,
2
*
np
.
pi
,
dom
.
nlon
+
1
)
dec
=
GL_thetas
(
dom
.
nlat
)
ilat
=
_find_closest
(
dec
,
theta
)
ilon
=
_find_closest
(
ra
,
phi
)
ilon
=
np
.
where
(
ilon
==
dom
.
nlon
,
0
,
ilon
)
if
have_rgb
:
res
[
mask
]
=
rgb
[
ilat
*
dom
[
0
].
nlon
+
ilon
]
else
:
res
[
mask
]
=
f
.
val
[
ilat
*
dom
.
nlon
+
ilon
]
val
=
rgb
if
have_rgb
else
f
.
val
res
=
project_spherical_field_to_2d
(
val
,
dom
,
projection
,
xsize
,
have_rgb
)
plt
.
axis
(
'
off
'
)
if
have_rgb
:
plt
.
imshow
(
res
,
origin
=
"
lower
"
)
...
...
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