public class PixTools
extends java.lang.Object
All methods are thread safe. This class can be used as a singleton,
the singleton instance being available from the getInstance()
method.
For compatibility with previous versions however it is possible to
construct new instances using the default constructor.
Modifier and Type | Field and Description |
---|---|
private static double |
HALFPI |
private static int |
ns_max |
private static double |
PI |
private static long[] |
pix2x |
private static long[] |
pix2y |
private static int |
pixmax |
private static PixTools |
pixTools
Singleton instance.
|
private static double |
TWOPI |
private static double |
twothird |
private static long[] |
x2pix |
private static int |
xmax |
private static int |
xmid |
private static long[] |
y2pix |
Constructor and Description |
---|
PixTools()
default constructor
|
Modifier and Type | Method and Description |
---|---|
long |
ang2pix_nest(long nside,
double theta,
double phi)
renders the pixel number pix (NESTED scheme) for a pixel which contains a
point on a sphere at coordinates theta and phi, given map resolution
parameter nside.
|
long |
ang2pix_ring(long nside,
double theta,
double phi)
renders the pixel number ipix (RING scheme) for a pixel which contains a
point with coordinates theta and phi, given the map resolution parameter
nside.
|
javax.vecmath.Vector3d |
Ang2Vec(double theta,
double phi)
calculates vector corresponding to angles theta (co-latitude
measured from North pole, in [0,pi] radians) phi (longitude measured
eastward in [0,2pi] radians) North pole is (x,y,z) = (0, 0, 1)
|
double |
AngDist(javax.vecmath.Vector3d v1,
javax.vecmath.Vector3d v2)
calculates angular distance (in radians) between 2 Vectors
v1 and v2 In general dist = acos(v1.v2) except if the vectors are almost
aligned
|
java.lang.Object[] |
convert_inplace_long(java.lang.String subcall,
java.lang.Object[] map)
converts a 8 byte Object map from RING to NESTED and vice versa in place,
ie without allocation a temporary map (Has no reason for Java).
|
java.lang.Object[] |
convert_nest2ring(long nside,
java.lang.Object[] map)
make the conversion NEST to RING
|
java.lang.Object[] |
convert_ring2nest(long nside,
java.lang.Object[] map)
makes the conversion RING to NEST
|
javax.vecmath.Vector3d |
crossProduct(javax.vecmath.Vector3d v1,
javax.vecmath.Vector3d v2)
calculate cross product of two vectors
|
double |
dotProduct(javax.vecmath.Vector3d v1,
javax.vecmath.Vector3d v2)
calculates a dot product (inner product) of two 3D vectors
the result is double
|
java.util.ArrayList |
getDisc_ring(long nside,
javax.vecmath.Vector3d vector0,
double radius)
an obsolete method.
|
static PixTools |
getInstance()
Returns singleton instance.
|
long |
GetNSide(double pixsize)
calculate requared nside given pixel size in arcsec
|
java.util.ArrayList |
InRing(long nside,
long iz,
double phi0,
double dphi,
boolean nest)
returns the list of pixels in RING or NEST scheme with latitude in [phi0 -
dpi, phi0 + dphi] on the ring iz in [1, 4*nside -1 ] The pixel id numbers
are in [0, 12*nside^2 - 1] the indexing is in RING, unless nest is set to
1
|
double[] |
intrs_intrv(double[] d1,
double[] d2)
computes the intersection di of 2 intervals d1 (= [a1,b1])
and d2 (= [a2,b2]) on the periodic domain (=[A,B] where A and B
arbitrary) ni is the resulting number of intervals (0,1, or 2) if a1
|
private PixInfo |
makePix2Vect_Nest(long nside,
long ipix)
renders vector (x,y,z) coordinates of the nominal pixel center for the
pixel ipix (NESTED scheme ) given the map resolution parameter nside.
|
private PixInfo |
makePix2Vect_ring(long nside,
long ipix)
renders vector (x,y,z) coordinates of the nominal pixel center for pixel
ipix (RING scheme) given the map resolution parameter nside.
|
private void |
mk_pix2xy()
creates an array of pixel numbers pix2x from x and y coordinates in the
face.
|
private static void |
mk_xy2pix()
fills arrays x2pix and y2pix giving the number of the pixel laying in
(x,y).
|
java.util.ArrayList |
neighbours_nest(long nside,
long ipix)
returns 7 or 8 neighbours of any pixel in the nested scheme The neighbours
are ordered in the following way: First pixel is the one to the south (
the one west of the south direction is taken for pixels that don't have a
southern neighbour).
|
long |
nest2ring(long nside,
long ipnest)
converts from NESTED to RING pixel numbering
|
long |
next_in_line_nest(long nside,
long ipix)
calculates the pixel that lies on the East side (and the same
latitude) as the given NESTED pixel number - ipix
|
long |
Npix2Nside(long npix)
returns nside such that npix = 12*nside^2, nside should be
power of 2 and smaller than ns_max if not return -1
|
long |
Nside2Npix(long nside)
calculates npix such that npix = 12*nside^2 ,nside should be
a power of 2, and smaller than ns_max otherwise return -1
|
double[] |
pix2ang_nest(long nside,
long ipix)
Renders theta and phi coordinates of the normal pixel center for the
pixel number ipix (NESTED scheme) given the map resolution parameter
nside.
|
double[] |
pix2ang_ring(long nside,
long ipix)
renders theta and phi coordinates of the nominal pixel center for the
pixel number ipix (RING scheme) given the map resolution parameter nside
|
javax.vecmath.Vector3d |
pix2vect_nest(long nside,
long ipix)
renders vector (x,y,z) coordinates of the nominal pixel center for the
pixel ipix (NESTED scheme ) given the map resolution parameter nside.
|
javax.vecmath.Vector3d |
pix2vect_ring(long nside,
long ipix)
returns the vector pointing in the center of the pixel ipix.
|
double[][] |
pix2vertex_nest(long nside,
long ipix)
renders vector (x,y,z) coordinates of the nominal pixel center for the
pixel ipix (NESTED scheme ) given the map resolution parameter nside.
|
double[][] |
pix2vertex_ring(long nside,
long ipix)
returns double [][] with coordinates of the pixel corners.
|
private long[] |
pix2xy_nest(long nside,
long ipf)
gives the x,y coordinates in a face from pixel number within the face
(NESTED) schema.
|
double |
PixRes(long nside)
calculates angular resolution of the pixel map
in arc seconds.
|
double[] |
PolarToRaDec(double[] polar)
returns ra, dec in degrees given polar coordinates in radians
|
java.util.ArrayList |
query_disc(long nside,
javax.vecmath.Vector3d vector,
double radius,
int nest,
int inclusive)
generates in the RING or NESTED scheme all pixels that lays within an
angular distance Radius of the center.
|
java.util.ArrayList |
query_polygon(long nside,
java.util.ArrayList vlist,
long nest,
long inclusive)
finds pixels that lay within a CONVEX polygon defined by its vertex on
sphere
|
java.util.ArrayList |
query_strip(long nside,
double theta1,
double theta2,
long nest)
finds pixels having a colatitude (measured from North pole) :
theta1 < colatitude < theta2 with 0 <= theta1 < theta2 <= Pi
if theta2 < theta1
then pixels with 0 <= colatitude < theta2 or theta1 < colatitude < Pi are
returned
|
java.util.ArrayList |
query_triangle(long nside,
javax.vecmath.Vector3d v1,
javax.vecmath.Vector3d v2,
javax.vecmath.Vector3d v3,
long nest,
long inclusive)
generates a list of pixels that lay inside a triangle defined by
the three vertex vectors
|
double[] |
RaDecToPolar(double[] radec)
returns polar coordinates in radians given ra, dec in degrees
|
long |
ring2nest(long nside,
long ipring)
converts pixel number from ring numbering schema to the nested one
|
long |
RingNum(long nside,
double z)
returns the ring number in {1, 4*nside - 1} calculated from z coordinate
|
double |
SurfaceTriangle(javax.vecmath.Vector3d v1,
javax.vecmath.Vector3d v2,
javax.vecmath.Vector3d v3)
calculates the surface of spherical triangle defined by
vertices v1,v2,v3 Algorithm: finds triangle sides and uses l'Huilier
formula to compute "spherical excess" = surface area of triangle on a
sphere of radius one see, eg Bronshtein, Semendyayev Eq 2.86 half
perimeter hp = 0.5*(side1+side2+side3) l'Huilier formula x0 = tan( hp/2.)
x1 = tan((hp - side1)/2.) x2 = tan((hp - side2)/2.) x3 = tan((hp -
side3)/2.)
|
double[] |
Vect2Ang(javax.vecmath.Vector3d v)
converts a Vector3d in a tuple of angles tup[0] = theta
co-latitude measured from North pole, in [0,PI] radians, tup[1] = phi
longitude measured eastward, in [0,2PI] radians
|
long |
vect2pix_nest(long nside,
javax.vecmath.Vector3d vector)
renders the pixel number pix (NESTED scheme) for a pixel which contains a
point on a sphere at coordinate vector (x,y,z), given the map resolution
parameter nside.
|
long |
vect2pix_ring(long nside,
javax.vecmath.Vector3d vector)
renders the pixel number ipix (RING scheme) for a pixel which contains a
point on a sphere at coordinate vector (x,y,z), given the map resolution
parameter nside
|
java.util.Vector |
VectProd(java.util.Vector v1,
java.util.Vector v2)
calculates a vector production of two vectors.
|
private long |
xy2pix_nest(long nside,
long ix,
long iy,
long face_num)
gives the pixel number ipix (NESTED) corresponding to ix, iy and face_num
|
double[] |
xyzToPolar(double x,
double y,
double z)
returns polar coordinates of a point on unit sphere given Cartesian coordinates
|
private static final double twothird
private static final double PI
private static final double TWOPI
private static final double HALFPI
private static final int ns_max
private static final int xmax
private static final int pixmax
private static final int xmid
private static final long[] x2pix
private static final long[] y2pix
private static final long[] pix2x
private static final long[] pix2y
private static final PixTools pixTools
public java.util.ArrayList query_strip(long nside, double theta1, double theta2, long nest) throws java.lang.Exception
nside
- long the map resolution parametertheta1
- lower edge of the colatitudetheta2
- upper edge of the colatitudenest
- long if = 1 result is in NESTED schemejava.lang.Exception
java.lang.IllegalArgumentException
public java.util.ArrayList query_polygon(long nside, java.util.ArrayList vlist, long nest, long inclusive) throws java.lang.Exception
nside
- the map resolutionvlist
- ArrayList of vectors defining the polygon verticesnest
- if set to 1 use NESTED schemeinclusive
- if set 1 returns all pixels crossed by polygon boundariesjava.lang.Exception
java.lang.IllegalArgumentException
public java.util.ArrayList query_triangle(long nside, javax.vecmath.Vector3d v1, javax.vecmath.Vector3d v2, javax.vecmath.Vector3d v3, long nest, long inclusive) throws java.lang.Exception
nside
- long map resolution parameterv1
- Vector3d defines one vertex of the trianglev2
- Vector3d another vertexv3
- Vector3d yet another onenest
- long 0 (default) RING numbering scheme, if set to 1 the NESTED
scheme will be used.inclusive
- long 0 (default) only pixels whose centers are inside the
triangle will be listed, if set to 1 all pixels overlaping the
triangle will be listedjava.lang.Exception
java.lang.IllegalArgumentException
public double[] intrs_intrv(double[] d1, double[] d2)
d1
- double[] first intervald2
- double[] second intervalpublic java.util.ArrayList getDisc_ring(long nside, javax.vecmath.Vector3d vector0, double radius)
nside
- vector0
- radius
- public java.util.ArrayList query_disc(long nside, javax.vecmath.Vector3d vector, double radius, int nest, int inclusive)
nside
- long map resolutionvector
- Vector3d pointing to the disc centerradius
- double angular radius of the disc (in RADIAN )nest
- int 0 (default) if output is in RING scheme, if set to 1
output is in NESTEDinclusive
- int 0 (default) only pixels whose centers lay in the disc
are listed, if set to 1, all pixels overlapping the disc
are listed. In the inclusive mode the radius is increased by half the pixel size.
In this case most probably all neighbor pixels will be listed even with very small
radius.
In case of exclusive search and very small radius when the disc lays completely
inside a pixel the pixel number is returned using vector2pix method.public double[] pix2ang_ring(long nside, long ipix)
nside
- long map resolutionipix
- long pixel numberpublic javax.vecmath.Vector3d pix2vect_ring(long nside, long ipix)
nside
- map resolutionipix
- pixel numberpublic double[][] pix2vertex_ring(long nside, long ipix)
nside
- map resolutionipix
- pixel numberprivate PixInfo makePix2Vect_ring(long nside, long ipix)
nside
- long map resolutionipix
- pixel numberpublic long ang2pix_ring(long nside, double theta, double phi)
nside
- long map resolution parametertheta
- double thetaphi
- -
double phipublic long vect2pix_ring(long nside, javax.vecmath.Vector3d vector)
nside
- long map resolutionvector
- Vector3d of the point coordinatesjava.lang.IllegalArgumentException
public double[] pix2ang_nest(long nside, long ipix)
nside
- map resolution parameter - longipix
- long pixel numberjava.lang.IllegalArgumentException
public javax.vecmath.Vector3d pix2vect_nest(long nside, long ipix)
nside
- the map resolutionipix
- long pixel numberjava.lang.IllegalArgumentException
public double[][] pix2vertex_nest(long nside, long ipix)
nside
- the map resolutionipix
- long pixel numberjava.lang.IllegalArgumentException
private PixInfo makePix2Vect_Nest(long nside, long ipix)
nside
- long the map resolutionipix
- long pixel numberpublic long ang2pix_nest(long nside, double theta, double phi)
nside
- the map resolution parametertheta
- double theta coordinate in radiansphi
- double phi coordinate in radiansjava.lang.IllegalArgumentException
public java.lang.Object[] convert_nest2ring(long nside, java.lang.Object[] map)
nside
- the map resolution parametermap
- Object[] the map in NESTED schemejava.lang.IllegalArgumentException
public java.lang.Object[] convert_ring2nest(long nside, java.lang.Object[] map)
nside
- long resolutionmap
- map in RINGjava.lang.IllegalArgumentException
public java.lang.Object[] convert_inplace_long(java.lang.String subcall, java.lang.Object[] map)
subcall
- String name of the method to use.map
- Object[] mapjava.lang.IllegalArgumentException
public java.util.ArrayList neighbours_nest(long nside, long ipix)
nside
- the map resolutionipix
- long pixel numberjava.lang.IllegalArgumentException
public java.util.ArrayList InRing(long nside, long iz, double phi0, double dphi, boolean nest)
nside
- long the map resolutioniz
- long ring numberphi0
- doubledphi
- doublenest
- boolean format flagjava.lang.IllegalArgumentException
- Modified by N. Kuropatkin 07/09/2008 Corrected several bugs and make test of all cases.public long next_in_line_nest(long nside, long ipix)
nside
- long resolutionipix
- long pixel numberjava.lang.IllegalArgumentException
public long vect2pix_nest(long nside, javax.vecmath.Vector3d vector)
nside
- long the map resolutionvector
- Vewctor3d the input vectorjava.lang.IllegalArgumentException
private long xy2pix_nest(long nside, long ix, long iy, long face_num)
nside
- the map resolution parameterix
- Integer x coordinateiy
- Integer y coordinateface_num
- long face numberjava.lang.IllegalArgumentException
private long[] pix2xy_nest(long nside, long ipf)
nside
- long resolution parameteripf
- long pixel numberjava.lang.IllegalArgumentException
private void mk_pix2xy()
public long ring2nest(long nside, long ipring)
nside
- long resolutionipring
- long pixel number in ring schemajava.lang.IllegalArgumentException
public long nest2ring(long nside, long ipnest)
nside
- long resolutionipnest
- long NEST pixel numberjava.lang.IllegalArgumentException
private static void mk_xy2pix()
public long RingNum(long nside, double z)
nside
- long resolutionz
- double z coordinatepublic javax.vecmath.Vector3d Ang2Vec(double theta, double phi)
theta
- doublephi
- doublejava.lang.IllegalArgumentException
public double[] Vect2Ang(javax.vecmath.Vector3d v)
v
- Vector3dpublic long Npix2Nside(long npix)
npix
- long the number of pixels in the mappublic long Nside2Npix(long nside)
nside
- long the map resolutionpublic double SurfaceTriangle(javax.vecmath.Vector3d v1, javax.vecmath.Vector3d v2, javax.vecmath.Vector3d v3) throws java.lang.Exception
v1
- Vector3dv2
- Vector3dv3
- Vector3d vertices of the trianglejava.lang.Exception
public double AngDist(javax.vecmath.Vector3d v1, javax.vecmath.Vector3d v2) throws java.lang.Exception
v1
- Vector3dv2
- Vector3djava.lang.Exception
public java.util.Vector VectProd(java.util.Vector v1, java.util.Vector v2) throws java.lang.Exception
v1
- Vectror containing 3 elements of Number typev2
- Vector containing 3 elements of Number typejava.lang.Exception
public double dotProduct(javax.vecmath.Vector3d v1, javax.vecmath.Vector3d v2) throws java.lang.Exception
v1
- 3d Vector of Number Objects (Double, long .. )v2
- 3d Vectorjava.lang.Exception
public javax.vecmath.Vector3d crossProduct(javax.vecmath.Vector3d v1, javax.vecmath.Vector3d v2)
v1
- Vector3dv2
- Vector3dpublic double PixRes(long nside)
nside
- public long GetNSide(double pixsize)
pixsize
- in arcsecpublic double[] RaDecToPolar(double[] radec)
radec
- double array containing ra,dec in degreespublic double[] PolarToRaDec(double[] polar)
polar
- double array polar[0] = phi in radians
polar[1] = theta in radianspublic double[] xyzToPolar(double x, double y, double z)
x
- - Cartesian coordinate x of a point on unit spherey
- - y coordinatez
- - z coordinatepublic static PixTools getInstance()