Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
spherelib
Spherelib
Commits
c8d1a865
Commit
c8d1a865
authored
Jun 09, 2010
by
Maude Le Jeune
Browse files
+ cat2mask
parent
d4422eea
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
40 additions
and
27 deletions
+40
-27
python/spherelib/__init__.py
python/spherelib/__init__.py
+1
-1
python/spherelib/spherelib_map.cpp
python/spherelib/spherelib_map.cpp
+22
-7
python/spherelib/spherelib_map.h
python/spherelib/spherelib_map.h
+3
-3
python/spherelib/spherelib_map.i
python/spherelib/spherelib_map.i
+9
-16
python/spherelib/test.py
python/spherelib/test.py
+5
-0
No files found.
python/spherelib/__init__.py
View file @
c8d1a865
...
...
@@ -23,6 +23,6 @@
"""
import
map
from
spherelib_map
import
regress
from
spherelib_map
import
regress
,
fastfill
,
cat2mask
from
fitsfunc2
import
*
from
bin
import
*
python/spherelib/spherelib_map.cpp
View file @
c8d1a865
#include "mask.h"
#include "healpix_base.h"
#include "fastfiller.h"
#include "Python.h"
void
regress
(
double
*
tabmap
,
double
*
tabmask
,
int
npix
,
int
order
=
1
)
void
regress
(
double
*
tabmap
,
int
npix
,
double
*
tabmask
,
int
npix
2
,
int
order
=
1
)
{
if
(
npix2
!=
npix
)
PyErr_Format
(
PyExc_ValueError
,
"Arrays of different lengths (%d %d)"
,
npix2
,
npix
);
arr
<
double
>
arrmap
(
tabmap
,
npix
);
arr
<
double
>
arrmask
(
tabmask
,
npix
);
MapExt
<
double
>
map
(
arrmap
,
RING
);
...
...
@@ -25,12 +28,24 @@ void fastfill(double *tabmap, int npix,double eps=1e-6, int niter=-1, int starts
}
void
inplace
(
double
*
invec
,
int
n
)
void
cat2mask
(
double
*
tabmask
,
int
npix
,
double
*
theta
,
int
ncat
,
double
*
phi
,
int
ncat2
,
double
radius
=
20
)
{
int
i
;
for
(
i
=
0
;
i
<
n
;
i
++
)
{
invec
[
i
]
=
2
*
invec
[
i
];
arr
<
double
>
arrmask
(
tabmask
,
npix
);
MapExt
<
double
>
mask
(
arrmask
,
RING
);
if
(
ncat2
!=
ncat
)
PyErr_Format
(
PyExc_ValueError
,
"Arrays of different lengths (%d %d)"
,
ncat2
,
ncat
);
radius
=
radius
/
60.0
*
degr2rad
;
// arcmin to degree
mask
.
fill
(
1.0
);
vector
<
int
>
listpix
;
vector
<
int
>::
iterator
it
;
for
(
int
i
=
0
;
i
<
ncat
;
i
++
){
listpix
.
clear
();
pointing
p
(
theta
[
i
],
phi
[
i
]);
mask
.
query_disc
(
p
,
radius
,
listpix
);
for
(
it
=
listpix
.
begin
();
it
!=
listpix
.
end
();
it
++
){
mask
[
*
it
]
=
0
;
}
}
arrmask
=
mask
.
Map
();
}
python/spherelib/spherelib_map.h
View file @
c8d1a865
...
...
@@ -11,8 +11,8 @@
#ifndef _SPHERELIB_MAP_H_
# define _SPHERELIB_MAP_H_
void
regress
(
double
*
map
reg
,
double
*
ma
skreg
,
int
n
reg
,
int
order
=
1
);
void
fastfill
(
double
*
map
fill
,
int
n
fill
,
double
eps
=
1e-6
,
int
niter
=-
1
,
int
startscale
=
0
);
//
void
inplace (double *invec, int n
);
void
regress
(
double
*
map
1
,
int
npix1
,
double
*
ma
p2
,
int
n
pix2
,
int
order
=
1
);
void
fastfill
(
double
*
map
,
int
n
pix
,
double
eps
=
1e-6
,
int
niter
=-
1
,
int
startscale
=
0
);
void
cat2mask
(
double
*
map
,
int
npix
,
double
*
theta
,
int
ntheta
,
double
*
phi
,
int
nphi
,
double
radius
=
20
);
#endif
/* !_SPHERELIB_MAP_H_ */
python/spherelib/spherelib_map.i
View file @
c8d1a865
...
...
@@ -12,27 +12,20 @@
%
}
// map regression
%
apply
(
double
*
INPLACE_ARRAY1
,
int
DIM1
)
{
(
double
*
map
reg
,
int
n
reg
1
),
(
double
*
ma
skreg
,
int
n
reg
2
)
}
;
%
apply
(
double
*
INPLACE_ARRAY1
,
int
DIM1
)
{
(
double
*
map
1
,
int
n
pix
1
),
(
double
*
ma
p2
,
int
n
pix
2
)
}
;
%
rename
(
regress
)
my_regress
;
%
feature
(
"docstring"
,
"Remove multipole of HEALPix masked map up to order (1 or 2)"
)
my_regress
;
%
feature
(
"autodoc"
,
0
)
my_regress
;
%
inline
%
{
void
my_regress
(
double
*
mapreg
,
int
nreg1
,
double
*
maskreg
,
int
nreg2
,
int
order
=
1
)
{
if
(
nreg1
!=
nreg2
)
{
PyErr_Format
(
PyExc_ValueError
,
"Arrays of different lengths"
)
;
}
regress
(
mapreg
,
maskreg
,
nreg1
,
order
)
;
}
%
}
%
ignore
regress
;
%
feature
(
"docstring"
,
"Remove multipole of HEALPix masked map up to order (1 or 2)"
)
regress
;
%
feature
(
"autodoc"
,
0
)
regress
;
// gap filling
%
apply
(
double
*
INPLACE_ARRAY1
,
int
DIM1
)
{
(
double
*
map
fill
,
int
n
fill
)
}
;
%
feature
(
"docstring"
,
"Iteratively fills holes in an HEALPix map by putting in null and undef pixels the mean value of its neighbors"
)
my_regress
;
%
apply
(
double
*
INPLACE_ARRAY1
,
int
DIM1
)
{
(
double
*
map
,
int
n
pix
)
}
;
%
feature
(
"docstring"
,
"Iteratively fills holes in an HEALPix map by putting in null and undef pixels the mean value of its neighbors"
)
fastfill
;
%
feature
(
"autodoc"
,
0
)
fastfill
;
// cat2 mask
%
apply
(
double
*
IN_ARRAY1
,
int
DIM1
)
{
(
double
*
theta
,
int
ntheta
),
(
double
*
phi
,
int
nphi
)
}
;
%
feature
(
"docstring"
,
"Compute an Healpix map with null values around the sources. (input catalog should contain theta and phi coordinates (radian) as first and second column)"
)
cat2mask
;
%
feature
(
"autodoc"
,
0
)
cat2mask
;
...
...
python/spherelib/test.py
View file @
c8d1a865
...
...
@@ -18,3 +18,8 @@ alm = healpy.map2alm(squeeze(map), 200)
spherelib
.
write_alm
(
'alm.fits'
,
alm
)
theta
=
array
([
0
,
0.2
])
phi
=
array
([
0.2
,
0
])
nside
=
256
mask
=
ones
((
nside
*
nside
*
12
,))
mask
=
spherelib
.
cat2mask
(
mask
,
theta
,
phi
,
radius
=
50
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment