pax_global_header00006660000000000000000000000064131540061520014507gustar00rootroot0000000000000052 comment=447a7be073876dba32d1c6be811eebc48255c844 eag-HEALPix-master/000077500000000000000000000000001315400615200142705ustar00rootroot00000000000000eag-HEALPix-master/.classpath000066400000000000000000000003341315400615200162530ustar00rootroot00000000000000 eag-HEALPix-master/.project000066400000000000000000000005621315400615200157420ustar00rootroot00000000000000 eag-HEALPIX org.eclipse.jdt.core.javabuilder org.eclipse.jdt.core.javanature eag-HEALPix-master/Licence.txt000066400000000000000000000245271315400615200164050ustar00rootroot00000000000000GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below. 0. Additional Definitions. As used herein, “this License” refers to version 3 of the GNU Lesser General Public License, and the “GNU GPL” refers to version 3 of the GNU General Public License. The Library refers to a covered work governed by this License, other than an Application or a Combined Work as defined below. An Application is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library. A Combined Work is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the Linked Version. The Minimal Corresponding Source for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version. The Corresponding Application Codefor a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work. 1. Exception to Section 3 of the GNU GPL. You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL. 2. Conveying Modified Versions. If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version: a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy. 3. Object Code Incorporating Material from Library Header Files. The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following: a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License b) Accompany the object code with a copy of the GNU GPL and this license document. 4. Combined Works. You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following: a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the Combined Work with a copy of the GNU GPL and this license document. c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document. d) Do one of the following: 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source. 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version. e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.) 5. Combined Libraries. You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License. b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 6. Revised Versions of the GNU Lesser General Public License. The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation. If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library. GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. eag-HEALPix-master/Readme.txt000066400000000000000000000004061315400615200162260ustar00rootroot00000000000000 Provides source code of java tools compatible with HEALPIX methods to work with sky pixelization. AUTHOR: Nikolay Kuropatkin kuropat@fnal.gov Java docs of all included classes are in doc subdirectory eag-HEALPix-master/doc/000077500000000000000000000000001315400615200150355ustar00rootroot00000000000000eag-HEALPix-master/doc/PixTools.html000066400000000000000000000115131315400615200175050ustar00rootroot00000000000000 PixTools

EAG logo

HEALPix PixTools.java

The package gov.fnal.eag.healpix contains four classes - PixTools.java , Region.java, service classes BitManipulation.java, and PixInfo.java

These classes in general are translation of the corresponding HEALPix FORTRAN90 programs to Java.

The translation is not straight forward, but included junit tests have validated the package.

The Package Overview.

The package creates sky pixelization to a specified resolution. The original FORTRAN version has natural limit imposed by HEALPix to the number of pixels Npix = 12 x N^2, where N the number of sides is an integer power of 2 and <= 8192 (Npix ~ 8.0E8)

The presented Java version overcomes this limitation boosting the resolution to about 0.2 arcsec (Npix ~ 1.3E13) which seems to be sufficient for modern experiments like SNAP

These tools permit creation of HEALPix maps as well as use of existing maps. There are tools to translate sky coordinates (Ra, Dec) to a pixel number, and to generate a list of neighboring pixels within some specified radius. More complicated queries are also supported.

The new class Region was added to the package. The class permits to define a rectangular area on the sphere providing standard ra,dec (Right ascension and Declination) limits of the area. Provided methods permits to pixelize the area with specified size of pixels.

Package API.

For API description see Java docs.

To download the self-installing jar file click here.

To install these jar files and the package documentation use command:

java -jar eag-HEALPix.jar

This will create in the installation directory two jar files (vecmath.jar, PixTools.jar) and the "doc" subdirectory.

Optimization.

Working with highest resolution is time consuming and can be prohibitive. There is an optimized version of this package giving significant improvement in some cases. This version was developed by Jan Kotek, and can be found here.

06/14/2005 Nikolay Kuropatkin.

12/19/2007 Nikolay Kuropatkin.

04/11/2008 Nikolay Kuropatkin.

07/09/2008 Nikolay Kuropatkin. Bug fixed in inRing method

02/09/2010 Nikolay Kuropatkin. Bug was found by Jan Kotek in Query-disc with search radius smaller than the pixel size. Fixed.

11 Jan 2012 Nikolay Kuropatkin. Make the BitManipulation a static class.

11 Jan 2012 modifications were proposed and implemented by Mark Taylor to make the package thread safe.

All methods are thread safe now. 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.

Unit tests showing various methods of using the class are provided.

28 Jul 2012 Nikolay Kuropatkin. To address some silly test of QuertyDisc method when two close points over the pole are missing each other in inclusive search the radius modification for inclusive search was changed. As the pixel shape is changing toward the pole from almost square to triangular the radius modifier should grow. In normal case close to equator the modifier is chosen to be half of the angular size of the pixel. Now the modifier is a function of the z component of unit vector pointing in the center of disc. The modifier value M=a+abs(z)*a, where a is half pixel size. In this case no changes in the QueryDisc behavior in the equatorial area is expected, while in the polar area one can expect increased number of pixels returned in the inclusive search. The maximum number of additional pixels can be estimated as 2*PI*(radius + M)/(2*a).

eag-HEALPix-master/doc/allclasses-frame.html000066400000000000000000000053401315400615200211430ustar00rootroot00000000000000 All Classes (javadoc for PixTools)

All Classes

eag-HEALPix-master/doc/allclasses-noframe.html000066400000000000000000000046401315400615200215020ustar00rootroot00000000000000 All Classes (javadoc for PixTools)

All Classes

eag-HEALPix-master/doc/constant-values.html000066400000000000000000000230011315400615200210450ustar00rootroot00000000000000 Constant Field Values (javadoc for PixTools)

Constant Field Values

Contents

gov.fnal.*

  • gov.fnal.eag.healpix.HealpixException 
    Modifier and Type Constant Field Value
    private static final long serialVersionUID 1L
  • gov.fnal.eag.healpix.PixTools 
    Modifier and Type Constant Field Value
    private static final double HALFPI 1.5707963267948966
    private static final int ns_max 1048576
    private static final double PI 3.141592653589793
    private static final int pixmax 262144
    private static final double TWOPI 6.283185307179586
    private static final double twothird 0.6666666666666666
    private static final int xmax 4096
    private static final int xmid 512
  • gov.fnal.eag.healpix.Region 
    Modifier and Type Constant Field Value
    private static final double epsilon 1.0E-10
    private static final double TWOPI 6.283185307179586
  • gov.fnal.eag.healpix.test.RegionTest 
    Modifier and Type Constant Field Value
    private static final double epsilon 1.0E-10
    private static final double TWOPI 6.283185307179586
eag-HEALPix-master/doc/deprecated-list.html000066400000000000000000000064221315400615200210000ustar00rootroot00000000000000 Deprecated List (javadoc for PixTools)

Deprecated API

Contents

eag-HEALPix-master/doc/gov/000077500000000000000000000000001315400615200156305ustar00rootroot00000000000000eag-HEALPix-master/doc/gov/fnal/000077500000000000000000000000001315400615200165505ustar00rootroot00000000000000eag-HEALPix-master/doc/gov/fnal/eag/000077500000000000000000000000001315400615200173045ustar00rootroot00000000000000eag-HEALPix-master/doc/gov/fnal/eag/healpix/000077500000000000000000000000001315400615200207365ustar00rootroot00000000000000eag-HEALPix-master/doc/gov/fnal/eag/healpix/BitManipulation.html000066400000000000000000000332731315400615200247330ustar00rootroot00000000000000 BitManipulation (javadoc for PixTools)
gov.fnal.eag.healpix

Class BitManipulation

  • java.lang.Object
    • gov.fnal.eag.healpix.BitManipulation


  • public final class BitManipulation
    extends java.lang.Object
    bit manipulation class derived from Healpix fortran90 program.
    Author:
    N Kuropatkin
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      private static long magic1
      magic1 odd bits set constant
      private static long magic2
      magic2 - even bits set constant
    • Constructor Summary

      Constructors 
      Constructor and Description
      BitManipulation() 
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      static long invLSB(long i)
      returns i with even bits inverted
      static long invMSB(long i)
      returns i with odd bits inverted
      static long invswapLSBMSB(long i)
      returns NOT i with even and odd bit positions interchanged
      static void main(java.lang.String[] pars)
      the main program for simple test
      static double MODULO(double a, double b)
      simulates behaviour of fortran90 MODULO function
      static long swapLSBMSB(long i)
      swaps low and high bits in the word i
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • magic1

        private static long magic1
        magic1 odd bits set constant
      • magic2

        private static long magic2
        magic2 - even bits set constant
    • Constructor Detail

      • BitManipulation

        public BitManipulation()
    • Method Detail

      • swapLSBMSB

        public static long swapLSBMSB(long i)
        swaps low and high bits in the word i
        Parameters:
        i - integer input word
        Returns:
        int a word with odd and even bits interchanged
      • invswapLSBMSB

        public static long invswapLSBMSB(long i)
        returns NOT i with even and odd bit positions interchanged
        Parameters:
        i - int input word
        Returns:
        int NOT (i with LSBMSB)
      • invLSB

        public static long invLSB(long i)
        returns i with even bits inverted
        Parameters:
        i - int input word
        Returns:
        int word with modified bits
      • invMSB

        public static long invMSB(long i)
        returns i with odd bits inverted
        Parameters:
        i - int input word
        Returns:
        int word with modified bits
      • MODULO

        public static double MODULO(double a,
                    double b)
        simulates behaviour of fortran90 MODULO function
        Parameters:
        a - double
        b - double
        Returns:
        double MODULO
      • main

        public static void main(java.lang.String[] pars)
        the main program for simple test
        Parameters:
        pars -
eag-HEALPix-master/doc/gov/fnal/eag/healpix/HealpixException.html000066400000000000000000000234571315400615200251100ustar00rootroot00000000000000 HealpixException (javadoc for PixTools)
gov.fnal.eag.healpix

Class HealpixException

  • java.lang.Object
    • java.lang.Throwable
      • java.lang.Exception
        • gov.fnal.eag.healpix.HealpixException
  • All Implemented Interfaces:
    java.io.Serializable


    public class HealpixException
    extends java.lang.Exception
    handles exceptions from this package
    Author:
    N. Kuropatkin
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      private static long serialVersionUID 
    • Constructor Summary

      Constructors 
      Constructor and Description
      HealpixException(java.lang.String message)
      message - String to be printed in case of exception
    • Method Summary

      • Methods inherited from class java.lang.Throwable

        addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • HealpixException

        public HealpixException(java.lang.String message)
        message - String to be printed in case of exception
        Parameters:
        message -
eag-HEALPix-master/doc/gov/fnal/eag/healpix/PixInfo.html000066400000000000000000000216321315400615200232040ustar00rootroot00000000000000 PixInfo (javadoc for PixTools)
gov.fnal.eag.healpix

Class PixInfo

  • java.lang.Object
    • gov.fnal.eag.healpix.PixInfo


  •  class PixInfo
    extends java.lang.Object
    Aggregates a vector and double[3][4] array which are the results of a pixel center calculation.
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      (package private) javax.vecmath.Vector3d pixVect 
      (package private) double[][] pixVertex 
    • Constructor Summary

      Constructors 
      Constructor and Description
      PixInfo(javax.vecmath.Vector3d pixVect, double[][] pixVertex) 
    • Method Summary

      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • pixVect

        final javax.vecmath.Vector3d pixVect
      • pixVertex

        final double[][] pixVertex
    • Constructor Detail

      • PixInfo

        PixInfo(javax.vecmath.Vector3d pixVect,
               double[][] pixVertex)
eag-HEALPix-master/doc/gov/fnal/eag/healpix/PixTools.html000066400000000000000000002162751315400615200234220ustar00rootroot00000000000000 PixTools (javadoc for PixTools)
gov.fnal.eag.healpix

Class PixTools

  • java.lang.Object
    • gov.fnal.eag.healpix.PixTools


  • public class PixTools
    extends java.lang.Object
    contains methods translated from HEALPix Fortran90 with increased map resolution in comparison to original Fortran code.
    Author:
    N Kuropatkin Created on Mar 10, 2005 Modified on December 18 2007 Corrected arithmetic and mistyping April 20 2008, Mark Taylor made modifications to make the class thread safe 11-Jan-2012

    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.

    • Field Summary

      Fields 
      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 Summary

      Constructors 
      Constructor and Description
      PixTools()
      default constructor
    • Method Summary

      Methods 
      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 b1 then d1 = {x | a1 <=x <= B U A <=x <=b1}
      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
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PixTools

        public PixTools()
        default constructor
    • Method Detail

      • query_strip

        public java.util.ArrayList query_strip(long nside,
                                      double theta1,
                                      double theta2,
                                      long nest)
                                        throws java.lang.Exception
        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
        Parameters:
        nside - long the map resolution parameter
        theta1 - lower edge of the colatitude
        theta2 - upper edge of the colatitude
        nest - long if = 1 result is in NESTED scheme
        Returns:
        ArrayList of pixel numbers (long)
        Throws:
        java.lang.Exception
        java.lang.IllegalArgumentException
      • query_polygon

        public java.util.ArrayList query_polygon(long nside,
                                        java.util.ArrayList vlist,
                                        long nest,
                                        long inclusive)
                                          throws java.lang.Exception
        finds pixels that lay within a CONVEX polygon defined by its vertex on sphere
        Parameters:
        nside - the map resolution
        vlist - ArrayList of vectors defining the polygon vertices
        nest - if set to 1 use NESTED scheme
        inclusive - if set 1 returns all pixels crossed by polygon boundaries
        Returns:
        ArrayList of pixels algorithm: the polygon is divided into triangles vertex 0 belongs to all triangles
        Throws:
        java.lang.Exception
        java.lang.IllegalArgumentException
      • query_triangle

        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
        generates a list of pixels that lay inside a triangle defined by the three vertex vectors
        Parameters:
        nside - long map resolution parameter
        v1 - Vector3d defines one vertex of the triangle
        v2 - Vector3d another vertex
        v3 - Vector3d yet another one
        nest - 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 listed
        Returns:
        ArrayList with pixel numbers
        Throws:
        java.lang.Exception
        java.lang.IllegalArgumentException
      • intrs_intrv

        public 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 b1 then d1 = {x | a1 <=x <= B U A <=x <=b1}
        Parameters:
        d1 - double[] first interval
        d2 - double[] second interval
        Returns:
        double[] one or two intervals intersections
      • getDisc_ring

        public java.util.ArrayList getDisc_ring(long nside,
                                       javax.vecmath.Vector3d vector0,
                                       double radius)
        an obsolete method. Use query_disc instead.
        Parameters:
        nside -
        vector0 -
        radius -
        Returns:
        - ArrayList of long
      • query_disc

        public 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.
        Parameters:
        nside - long map resolution
        vector - Vector3d pointing to the disc center
        radius - 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 NESTED
        inclusive - 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.
        Returns:
        ArrayList of pixel numbers calls: RingNum(nside, ir) InRing(nside, iz, phi0, dphi,nest) vector2pix(nside,ipix)
      • pix2ang_ring

        public 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
        Parameters:
        nside - long map resolution
        ipix - long pixel number
        Returns:
        double[] theta,phi
      • pix2vect_ring

        public javax.vecmath.Vector3d pix2vect_ring(long nside,
                                           long ipix)
        returns the vector pointing in the center of the pixel ipix. The vector is calculated by makePix2Vect_ring method
        Parameters:
        nside - map resolution
        ipix - pixel number
        Returns:
        Vector3d
      • pix2vertex_ring

        public double[][] pix2vertex_ring(long nside,
                                 long ipix)
        returns double [][] with coordinates of the pixel corners. The array is calculated by makePix2Vect_ring method
        Parameters:
        nside - map resolution
        ipix - pixel number
        Returns:
        double[][] list of vertex coordinates
      • makePix2Vect_ring

        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. It also calculates (x,y,z) positions of the four vertices in order N,W,S,E. These results are returned in a PixInfo object. Those can be used using pix2Vect_ring and pix2vert_ring methods
        Parameters:
        nside - long map resolution
        ipix - pixel number
        Returns:
        result object
      • ang2pix_ring

        public 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.
        Parameters:
        nside - long map resolution parameter
        theta - double theta
        phi - - double phi
        Returns:
        long ipix
      • vect2pix_ring

        public 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
        Parameters:
        nside - long map resolution
        vector - Vector3d of the point coordinates
        Returns:
        long pixel number
        Throws:
        java.lang.IllegalArgumentException
      • pix2ang_nest

        public 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.
        Parameters:
        nside - map resolution parameter - long
        ipix - long pixel number
        Returns:
        double[] (theta, phi)
        Throws:
        java.lang.IllegalArgumentException
      • pix2vect_nest

        public 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. Also calculates the (x,y,z) positions of 4 pixel vertices (corners) in the order N,W,S,E. These can be get using method pix2vertex_nest.
        Parameters:
        nside - the map resolution
        ipix - long pixel number
        Returns:
        Vector3d
        Throws:
        java.lang.IllegalArgumentException
      • pix2vertex_nest

        public 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. Also calculates the (x,y,z) positions of 4 pixel vertices (corners) in the order N,W,S,E.
        Parameters:
        nside - the map resolution
        ipix - long pixel number
        Returns:
        double[3][4] 4 sets of vector components
        Throws:
        java.lang.IllegalArgumentException
      • makePix2Vect_Nest

        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. Tis can be get using method pix2vect_nest Also calculates the (x,y,z) positions of 4 pixel vertices (corners) in the order N,W,S,E. The result can be used using method pix2vertex_nest.
        Parameters:
        nside - long the map resolution
        ipix - long pixel number
        Returns:
        result
      • ang2pix_nest

        public 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. The computation is made to the highest resolution available and then degraded to required resolution by integer division. It makes sure that the treatment of round-off will be consistent for every resolution.
        Parameters:
        nside - the map resolution parameter
        theta - double theta coordinate in radians
        phi - double phi coordinate in radians
        Returns:
        pixel number long
        Throws:
        java.lang.IllegalArgumentException
      • convert_nest2ring

        public java.lang.Object[] convert_nest2ring(long nside,
                                           java.lang.Object[] map)
        make the conversion NEST to RING
        Parameters:
        nside - the map resolution parameter
        map - Object[] the map in NESTED scheme
        Returns:
        - Object[] a map in RING scheme
        Throws:
        java.lang.IllegalArgumentException
      • convert_ring2nest

        public java.lang.Object[] convert_ring2nest(long nside,
                                           java.lang.Object[] map)
        makes the conversion RING to NEST
        Parameters:
        nside - long resolution
        map - map in RING
        Returns:
        map in NEST
        Throws:
        java.lang.IllegalArgumentException
      • convert_inplace_long

        public 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). This method is more general but slower than convert_nest2ring. This method is a wrapper for functions ring2nest and nest2ring. Their names are supplied in the subcall argument.
        Parameters:
        subcall - String name of the method to use.
        map - Object[] map
        Returns:
        resulting Object[] map.
        Throws:
        java.lang.IllegalArgumentException
      • neighbours_nest

        public 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). From then on the neighbors are ordered in the clockwise direction.
        Parameters:
        nside - the map resolution
        ipix - long pixel number
        Returns:
        ArrayList
        Throws:
        java.lang.IllegalArgumentException
      • InRing

        public 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
        Parameters:
        nside - long the map resolution
        iz - long ring number
        phi0 - double
        dphi - double
        nest - boolean format flag
        Returns:
        ArrayList of pixels
        Throws:
        java.lang.IllegalArgumentException - Modified by N. Kuropatkin 07/09/2008 Corrected several bugs and make test of all cases.
      • next_in_line_nest

        public 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
        Parameters:
        nside - long resolution
        ipix - long pixel number
        Returns:
        long next pixel in line
        Throws:
        java.lang.IllegalArgumentException
      • vect2pix_nest

        public 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. The computation is made to the highest resolution available (nside=ns_max) and then degraded to that requared (by Integer division) this doesn't cost much, and it makes sure that the treatment of round-off will be consistent for every resolution
        Parameters:
        nside - long the map resolution
        vector - Vewctor3d the input vector
        Returns:
        pixel long
        Throws:
        java.lang.IllegalArgumentException
      • xy2pix_nest

        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
        Parameters:
        nside - the map resolution parameter
        ix - Integer x coordinate
        iy - Integer y coordinate
        face_num - long face number
        Returns:
        long pixel number ipix
        Throws:
        java.lang.IllegalArgumentException
      • pix2xy_nest

        private long[] pix2xy_nest(long nside,
                         long ipf)
        gives the x,y coordinates in a face from pixel number within the face (NESTED) schema.
        Parameters:
        nside - long resolution parameter
        ipf - long pixel number
        Returns:
        ixiy long[] contains x and y coordinates
        Throws:
        java.lang.IllegalArgumentException
      • mk_pix2xy

        private void mk_pix2xy()
        creates an array of pixel numbers pix2x from x and y coordinates in the face. Suppose NESTED scheme of pixel ordering Bits corresponding to x and y are interleaved in the pixel number in even and odd bits.
      • ring2nest

        public long ring2nest(long nside,
                     long ipring)
        converts pixel number from ring numbering schema to the nested one
        Parameters:
        nside - long resolution
        ipring - long pixel number in ring schema
        Returns:
        long pixel number in nest schema
        Throws:
        java.lang.IllegalArgumentException
      • nest2ring

        public long nest2ring(long nside,
                     long ipnest)
        converts from NESTED to RING pixel numbering
        Parameters:
        nside - long resolution
        ipnest - long NEST pixel number
        Returns:
        ipring long RING pixel number
        Throws:
        java.lang.IllegalArgumentException
      • mk_xy2pix

        private static void mk_xy2pix()
        fills arrays x2pix and y2pix giving the number of the pixel laying in (x,y). x and y are in [1,512] the pixel number is in [0, 512**2 -1] if i-1 = sum_p=0 b_p*2^p then ix = sum+p=0 b_p*4^p iy = 2*ix ix + iy in [0,512**2 -1]
      • RingNum

        public long RingNum(long nside,
                   double z)
        returns the ring number in {1, 4*nside - 1} calculated from z coordinate
        Parameters:
        nside - long resolution
        z - double z coordinate
        Returns:
        long ring number
      • Ang2Vec

        public 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)
        Parameters:
        theta - double
        phi - double
        Returns:
        Vector3d
        Throws:
        java.lang.IllegalArgumentException
      • Vect2Ang

        public 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
        Parameters:
        v - Vector3d
        Returns:
        double[] out_tup out_tup[0] = theta out_tup[1] = phi
      • Npix2Nside

        public 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
        Parameters:
        npix - long the number of pixels in the map
        Returns:
        long nside the map resolution parameter
      • Nside2Npix

        public 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
        Parameters:
        nside - long the map resolution
        Returns:
        npix long the number of pixels in the map
      • SurfaceTriangle

        public double SurfaceTriangle(javax.vecmath.Vector3d v1,
                             javax.vecmath.Vector3d v2,
                             javax.vecmath.Vector3d v3)
                               throws java.lang.Exception
        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.)
        Parameters:
        v1 - Vector3d
        v2 - Vector3d
        v3 - Vector3d vertices of the triangle
        Returns:
        double the triangle surface
        Throws:
        java.lang.Exception
      • AngDist

        public double AngDist(javax.vecmath.Vector3d v1,
                     javax.vecmath.Vector3d v2)
                       throws java.lang.Exception
        calculates angular distance (in radians) between 2 Vectors v1 and v2 In general dist = acos(v1.v2) except if the vectors are almost aligned
        Parameters:
        v1 - Vector3d
        v2 - Vector3d
        Returns:
        double dist
        Throws:
        java.lang.Exception
      • VectProd

        public java.util.Vector VectProd(java.util.Vector v1,
                                java.util.Vector v2)
                                  throws java.lang.Exception
        calculates a vector production of two vectors.
        Parameters:
        v1 - Vectror containing 3 elements of Number type
        v2 - Vector containing 3 elements of Number type
        Returns:
        Vector of 3 Objects of Double type
        Throws:
        java.lang.Exception
      • dotProduct

        public double dotProduct(javax.vecmath.Vector3d v1,
                        javax.vecmath.Vector3d v2)
                          throws java.lang.Exception
        calculates a dot product (inner product) of two 3D vectors the result is double
        Parameters:
        v1 - 3d Vector of Number Objects (Double, long .. )
        v2 - 3d Vector
        Returns:
        double
        Throws:
        java.lang.Exception
      • crossProduct

        public javax.vecmath.Vector3d crossProduct(javax.vecmath.Vector3d v1,
                                          javax.vecmath.Vector3d v2)
        calculate cross product of two vectors
        Parameters:
        v1 - Vector3d
        v2 - Vector3d
        Returns:
        Vector3d result of the product
      • PixRes

        public double PixRes(long nside)
        calculates angular resolution of the pixel map in arc seconds.
        Parameters:
        nside -
        Returns:
        double resolution in arcsec
      • GetNSide

        public long GetNSide(double pixsize)
        calculate requared nside given pixel size in arcsec
        Parameters:
        pixsize - in arcsec
        Returns:
        long nside parameter
      • RaDecToPolar

        public double[] RaDecToPolar(double[] radec)
        returns polar coordinates in radians given ra, dec in degrees
        Parameters:
        radec - double array containing ra,dec in degrees
        Returns:
        res double array containing theta and phi in radians res[0] = theta res[1] = phi
      • PolarToRaDec

        public double[] PolarToRaDec(double[] polar)
        returns ra, dec in degrees given polar coordinates in radians
        Parameters:
        polar - double array polar[0] = phi in radians polar[1] = theta in radians
        Returns:
        double array radec radec[0] = ra in degrees radec[1] = dec in degrees
      • xyzToPolar

        public double[] xyzToPolar(double x,
                          double y,
                          double z)
        returns polar coordinates of a point on unit sphere given Cartesian coordinates
        Parameters:
        x - - Cartesian coordinate x of a point on unit sphere
        y - - y coordinate
        z - - z coordinate
        Returns:
        double [] theta,phi
      • getInstance

        public static PixTools getInstance()
        Returns singleton instance.
eag-HEALPix-master/doc/gov/fnal/eag/healpix/Region.html000066400000000000000000000437341315400615200230620ustar00rootroot00000000000000 Region (javadoc for PixTools)
gov.fnal.eag.healpix

Class Region

  • java.lang.Object
    • gov.fnal.eag.healpix.Region


  • public class Region
    extends java.lang.Object
    Author:
    kuropat The class represents square region on a sphere defined by raMin, raMax decMin,decMax in degrees. The dec varies from Pi/2 to -Pi/2. The ra varies from 0. inclusive to 2Pi exclusive. Negative value of ra will be corrected by adding 2Pi
    • Constructor Summary

      Constructors 
      Constructor and Description
      Region(double xMin, double xMax, double yMin, double yMax)
      default constructor
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      double[][] getPolReg()
      provides polar coordinates of the region vertices
      java.util.ArrayList getVertices() 
      boolean inReg(double ra, double dec)
      return true if the point ra,dec is inside region
      boolean inRegPol(double phi, double theta)
      return true if point phi, theta is inside region
      java.util.ArrayList pixelize(double precision)
      divides region on HealPix pixels of given size including pixels that only partly inside the region
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • raMin

        private double raMin
      • raMax

        private double raMax
      • decMin

        private double decMin
      • decMax

        private double decMax
      • tetMin

        private double tetMin
      • tetMax

        private double tetMax
      • phiMin

        private double phiMin
      • phiMax

        private double phiMax
      • vertices

        private java.util.ArrayList vertices
      • PI

        private double PI
    • Constructor Detail

      • Region

        public Region(double xMin,
              double xMax,
              double yMin,
              double yMax)
        default constructor
        Parameters:
        xMin - ra min in degrees
        xMax - ra max in degrees
        yMin - dec min in degrees
        yMax - dec max in degrees
    • Method Detail

      • inReg

        public boolean inReg(double ra,
                    double dec)
        return true if the point ra,dec is inside region
        Parameters:
        ra - in degrees
        dec - in degrees
        Returns:
        boolean true if inside the region
      • inRegPol

        public boolean inRegPol(double phi,
                       double theta)
        return true if point phi, theta is inside region
        Parameters:
        phi - in radians
        theta - in radians
        Returns:
        boolean true if in region
      • getVertices

        public java.util.ArrayList getVertices()
        Returns:
        ArrayList of 3d vectors of vertices of the region
      • pixelize

        public java.util.ArrayList pixelize(double precision)
                                     throws java.lang.Exception
        divides region on HealPix pixels of given size including pixels that only partly inside the region
        Parameters:
        precision - - angular size of the division element in arcsec
        Returns:
        ArrayList of pixel numbers in ring schema for specifyed resolution
        Throws:
        java.lang.Exception
      • getPolReg

        public double[][] getPolReg()
        provides polar coordinates of the region vertices
        Returns:
        array of corner coordinates in form of polar thete,phi angles.
eag-HEALPix-master/doc/gov/fnal/eag/healpix/class-use/000077500000000000000000000000001315400615200226355ustar00rootroot00000000000000eag-HEALPix-master/doc/gov/fnal/eag/healpix/class-use/BitManipulation.html000066400000000000000000000166471315400615200266400ustar00rootroot00000000000000 Uses of Class gov.fnal.eag.healpix.BitManipulation (javadoc for PixTools)

Uses of Class
gov.fnal.eag.healpix.BitManipulation

eag-HEALPix-master/doc/gov/fnal/eag/healpix/class-use/HealpixException.html000066400000000000000000000101221315400615200267700ustar00rootroot00000000000000 Uses of Class gov.fnal.eag.healpix.HealpixException (javadoc for PixTools)

Uses of Class
gov.fnal.eag.healpix.HealpixException

No usage of gov.fnal.eag.healpix.HealpixException
eag-HEALPix-master/doc/gov/fnal/eag/healpix/class-use/PixInfo.html000066400000000000000000000152431315400615200251040ustar00rootroot00000000000000 Uses of Class gov.fnal.eag.healpix.PixInfo (javadoc for PixTools)

Uses of Class
gov.fnal.eag.healpix.PixInfo

eag-HEALPix-master/doc/gov/fnal/eag/healpix/class-use/PixTools.html000066400000000000000000000220651315400615200253110ustar00rootroot00000000000000 Uses of Class gov.fnal.eag.healpix.PixTools (javadoc for PixTools)

Uses of Class
gov.fnal.eag.healpix.PixTools

eag-HEALPix-master/doc/gov/fnal/eag/healpix/class-use/Region.html000066400000000000000000000077441315400615200247620ustar00rootroot00000000000000 Uses of Class gov.fnal.eag.healpix.Region (javadoc for PixTools)

Uses of Class
gov.fnal.eag.healpix.Region

No usage of gov.fnal.eag.healpix.Region
eag-HEALPix-master/doc/gov/fnal/eag/healpix/package-frame.html000066400000000000000000000024021315400615200243050ustar00rootroot00000000000000 gov.fnal.eag.healpix (javadoc for PixTools)

gov.fnal.eag.healpix

eag-HEALPix-master/doc/gov/fnal/eag/healpix/package-summary.html000066400000000000000000000157571315400615200247310ustar00rootroot00000000000000 gov.fnal.eag.healpix (javadoc for PixTools)

Package gov.fnal.eag.healpix

EAG HEALPix

See: Description

  • Class Summary 
    Class Description
    BitManipulation
    bit manipulation class derived from Healpix fortran90 program.
    PixInfo
    Aggregates a vector and double[3][4] array which are the results of a pixel center calculation.
    PixTools
    contains methods translated from HEALPix Fortran90 with increased map resolution in comparison to original Fortran code.
    Region  
  • Exception Summary 
    Exception Description
    HealpixException
    handles exceptions from this package

Package gov.fnal.eag.healpix Description

EAG HEALPix

The package contains conversion of basic utilities used for pixel manipulation

in the HEALPix from FORTRAN90 to Java. The package consists of one class PixTools and supporting methods and the vecmath.jar library. The package permits to create HEALPix maps, query existing maps providing a list of neighboring pixels selected by various requarements.

All methods of the class 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.

eag-HEALPix-master/doc/gov/fnal/eag/healpix/package-tree.html000066400000000000000000000120021315400615200241470ustar00rootroot00000000000000 gov.fnal.eag.healpix Class Hierarchy (javadoc for PixTools)

Hierarchy For Package gov.fnal.eag.healpix

Package Hierarchies:

Class Hierarchy

eag-HEALPix-master/doc/gov/fnal/eag/healpix/package-use.html000066400000000000000000000157141315400615200240210ustar00rootroot00000000000000 Uses of Package gov.fnal.eag.healpix (javadoc for PixTools)

Uses of Package
gov.fnal.eag.healpix

eag-HEALPix-master/doc/gov/fnal/eag/healpix/package.html000066400000000000000000000022461315400615200232230ustar00rootroot00000000000000 No title

EAG HEALPix

The package contains conversion of basic utilities used for pixel manipulation

in the HEALPix from FORTRAN90 to Java. The package consists of one class PixTools and supporting methods and the vecmath.jar library. The package permits to create HEALPix maps, query existing maps providing a list of neighboring pixels selected by various requarements.

All methods of the class are thread safe. This class can be used as a singleton, the singleton instance being available from the {@link #getInstance} method. For compatibility with previous versions however it is possible to construct new instances using the default constructor.

eag-HEALPix-master/doc/gov/fnal/eag/healpix/test/000077500000000000000000000000001315400615200217155ustar00rootroot00000000000000eag-HEALPix-master/doc/gov/fnal/eag/healpix/test/BitManipulationTest.html000066400000000000000000000213261315400615200265460ustar00rootroot00000000000000 BitManipulationTest (javadoc for PixTools)
gov.fnal.eag.healpix.test

Class BitManipulationTest

  • java.lang.Object
    • TestCase
      • gov.fnal.eag.healpix.test.BitManipulationTest


  • public class BitManipulationTest
    extends TestCase
    Author:
    N Kuropatkin
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      void testBitManipulation()
      tests bit manipulation methods
      void testMODULO()
      test Modulo
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • BitManipulationTest

        public BitManipulationTest()
    • Method Detail

      • testBitManipulation

        public void testBitManipulation()
        tests bit manipulation methods
      • testMODULO

        public void testMODULO()
        test Modulo
eag-HEALPix-master/doc/gov/fnal/eag/healpix/test/DiscTest.html000066400000000000000000000352761315400615200243420ustar00rootroot00000000000000 DiscTest (javadoc for PixTools)
gov.fnal.eag.healpix.test

Class DiscTest

  • java.lang.Object
    • gov.fnal.eag.healpix.test.DiscTest


  • public class DiscTest
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      private int nCheck 
      private int nFail 
    • Constructor Summary

      Constructors 
      Constructor and Description
      DiscTest() 
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      void checkOverlap(int order, double raDeg1, double decDeg1, double raDeg2, double decDeg2) 
      (package private) static double haversineSeparationFormula(double ra1, double dec1, double ra2, double dec2)
      Haversine formula for spherical trigonometry.
      (package private) static java.util.Collection intersection(java.util.Collection c1, java.util.Collection c2) 
      static void main(java.lang.String[] args) 
      (package private) static long orderToNside(int order) 
      java.util.Collection queryDisc(int order, double ra, double dec, double radius) 
      java.lang.String report() 
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • nCheck

        private int nCheck
      • nFail

        private int nFail
    • Constructor Detail

      • DiscTest

        public DiscTest()
    • Method Detail

      • checkOverlap

        public void checkOverlap(int order,
                        double raDeg1,
                        double decDeg1,
                        double raDeg2,
                        double decDeg2)
                          throws java.lang.Exception
        Throws:
        java.lang.Exception
      • queryDisc

        public java.util.Collection queryDisc(int order,
                                     double ra,
                                     double dec,
                                     double radius)
      • report

        public java.lang.String report()
      • orderToNside

        static long orderToNside(int order)
      • intersection

        static java.util.Collection intersection(java.util.Collection c1,
                                        java.util.Collection c2)
      • haversineSeparationFormula

        static double haversineSeparationFormula(double ra1,
                                        double dec1,
                                        double ra2,
                                        double dec2)
        Haversine formula for spherical trigonometry. This does not have the numerical instabilities of the cosine formula at small angles.

        This implementation derives from Bob Chamberlain's contribution to the comp.infosystems.gis FAQ; he cites R.W.Sinnott, "Virtues of the Haversine", Sky and Telescope vol.68, no.2, 1984, p159.

        Parameters:
        ra1 - right ascension of point 1 in radians
        dec1 - declination of point 1 in radians
        ra2 - right ascension of point 2 in radians
        dec2 - declination of point 2 in radians
        Returns:
        angular separation of point 1 and point 2 in radians
        See Also:
      • main

        public static void main(java.lang.String[] args)
                         throws java.lang.Exception
        Throws:
        java.lang.Exception
eag-HEALPix-master/doc/gov/fnal/eag/healpix/test/PixToolTest1.RaDePoint.html000066400000000000000000000235641315400615200267600ustar00rootroot00000000000000 PixToolTest1.RaDePoint (javadoc for PixTools)
gov.fnal.eag.healpix.test

Class PixToolTest1.RaDePoint

  • java.lang.Object
    • gov.fnal.eag.healpix.test.PixToolTest1.RaDePoint
  • Enclosing class:
    PixToolTest1


    public static class PixToolTest1.RaDePoint
    extends java.lang.Object
    Simple point on sky. Used as return value of functions

    • Field Summary

      Fields 
      Modifier and Type Field and Description
      double de
      coordinates in degrees
      double ra
      coordinates in degrees
    • Method Summary

      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • ra

        public double ra
        coordinates in degrees
      • de

        public double de
        coordinates in degrees
    • Constructor Detail

      • PixToolTest1.RaDePoint

        public PixToolTest1.RaDePoint()
      • PixToolTest1.RaDePoint

        public PixToolTest1.RaDePoint(double ra,
                              double de)
eag-HEALPix-master/doc/gov/fnal/eag/healpix/test/PixToolTest1.html000066400000000000000000000377751315400615200251450ustar00rootroot00000000000000 PixToolTest1 (javadoc for PixTools)
gov.fnal.eag.healpix.test

Class PixToolTest1

  • java.lang.Object
    • TestCase
      • gov.fnal.eag.healpix.test.PixToolTest1


  • public class PixToolTest1
    extends TestCase
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class and Description
      static class  PixToolTest1.RaDePoint
      Simple point on sky.
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      (package private) long NSIDE1 
      (package private) long NSIDE2 
      (package private) static PixTools tools 
    • Constructor Summary

      Constructors 
      Constructor and Description
      PixToolTest1() 
    • Field Detail

      • NSIDE1

        long NSIDE1
      • NSIDE2

        long NSIDE2
    • Constructor Detail

      • PixToolTest1

        public PixToolTest1()
    • Method Detail

      • testCircle1

        public void testCircle1()
      • testCircle2

        public void testCircle2()
      • testCircle3

        public void testCircle3()
      • testCircle4

        public void testCircle4()
      • testCircle5

        public void testCircle5()
        with NSIDE 512
      • testVertexes

        public void testVertexes()
        with NSIDE 512
      • testVertexesHR

        public void testVertexesHR()
        with high res.
      • testInverse

        public void testInverse()
      • getHealId

        public long getHealId(double ra,
                     double de,
                     long nsides)
        get position ID for ra,de
        Parameters:
        ra - right ascencion in degrees
        de - declination in degrees
        nsides - - non default number of nsides
      • getRaDe

        public static PixToolTest1.RaDePoint getRaDe(long area,
                                     long nsides)
        inverse method, convert area ID to RaDePoint
eag-HEALPix-master/doc/gov/fnal/eag/healpix/test/PixToolsSingletonTest.html000066400000000000000000000635431315400615200271220ustar00rootroot00000000000000 PixToolsSingletonTest (javadoc for PixTools)
gov.fnal.eag.healpix.test

Class PixToolsSingletonTest

  • java.lang.Object
    • TestCase
      • gov.fnal.eag.healpix.test.PixToolsSingletonTest


  • public class PixToolsSingletonTest
    extends TestCase
    • Constructor Detail

      • PixToolsSingletonTest

        public PixToolsSingletonTest()
    • Method Detail

      • testMODULO

        public void testMODULO()
        test MODULO function
      • testAngDist

        public void testAngDist()
                         throws java.lang.Exception
        tests angular distance calculation
        Throws:
        java.lang.Exception
      • testSurfaceTriangle

        public void testSurfaceTriangle()
                                 throws java.lang.Exception
        Throws:
        java.lang.Exception
      • testNside2Npix

        public void testNside2Npix()
        tests calculation of npixels from nside
      • testNpix2Nside

        public void testNpix2Nside()
        tests calculation of nsides from npixels
      • testVec2Ang

        public void testVec2Ang()
        test of directional angles calculation
      • testAng2Pix

        public void testAng2Pix()
                         throws java.lang.Exception
        tests calculation of pixel from polar angles in ring schema of pixalization
        Throws:
        java.lang.Exception
      • testAng2Vect

        public void testAng2Vect()
                          throws java.lang.Exception
        tests calculation of unit vector from polar angles
        Throws:
        java.lang.Exception
      • testRingNum

        public void testRingNum()
                         throws java.lang.Exception
        tests calculation of ring number from z coordinate
        Throws:
        java.lang.Exception
      • testNest2Ring

        public void testNest2Ring()
                           throws java.lang.Exception
        tests conversion from nest schema pixel to ring schema pixel
        Throws:
        java.lang.Exception
      • testRing2Nest

        public void testRing2Nest()
                           throws java.lang.Exception
        tests conversion from ring schema pixel to nest schema pixel
        Throws:
        java.lang.Exception
      • testNext_In_Line_Nest

        public void testNext_In_Line_Nest()
                                   throws java.lang.Exception
        tests Next_In_Line method for the nest schema
        Throws:
        java.lang.Exception
      • testInRing

        public void testInRing()
                        throws java.lang.Exception
        tests InRing method
        Throws:
        java.lang.Exception
      • testNeighbours_Nest

        public void testNeighbours_Nest()
                                 throws java.lang.Exception
        tests Neighbour's method for nest schema of the pixelization
        Throws:
        java.lang.Exception
      • testIntrs_Intrv

        public void testIntrs_Intrv()
                             throws java.lang.Exception
        tests intrs_intrv method
        Throws:
        java.lang.Exception
      • testPix2Vect_ring

        public void testPix2Vect_ring()
                               throws java.lang.Exception
        tests conversion from pixel number to vector
        Throws:
        java.lang.Exception
      • testPix2Vect_nest

        public void testPix2Vect_nest()
                               throws java.lang.Exception
        tests conversion from pixel number to vector
        Throws:
        java.lang.Exception
      • testVect2Pix_ring

        public void testVect2Pix_ring()
                               throws java.lang.Exception
        tests conversion from vector to pixel number
        Throws:
        java.lang.Exception
      • testVect2Pix_nest

        public void testVect2Pix_nest()
                               throws java.lang.Exception
        tests conversion from vector to pixel number
        Throws:
        java.lang.Exception
      • testQuery_Strip

        public void testQuery_Strip()
                             throws java.lang.Exception
        tests Query_Strip method
        Throws:
        java.lang.Exception
      • testQuery_Disc

        public void testQuery_Disc()
                            throws java.lang.Exception
        tests Query_Disc method
        Throws:
        java.lang.Exception
      • testQuery_Triangle

        public void testQuery_Triangle()
                                throws java.lang.Exception
        tests Query_Triangle method
        Throws:
        java.lang.Exception
      • testQuery_Polygon

        public void testQuery_Polygon()
                               throws java.lang.Exception
        tests Query_Poligon method
        Throws:
        java.lang.Exception
      • testMaxResolution

        public void testMaxResolution()
        tests MaxResolution method
      • testQueryDiscRes

        public void testQueryDiscRes()
                              throws java.lang.Exception
        tests QueryDiscResolution method
        Throws:
        java.lang.Exception
      • testQuery_disk2

        public void testQuery_disk2()
        test Query_disk check for consistency in the query for RING/NESTED
      • testGetNside

        public void testGetNside()
        tests GetNside method
      • testRaDecToPolar

        public void testRaDecToPolar()
        test conversion of Ra Dec to polar coordinates
eag-HEALPix-master/doc/gov/fnal/eag/healpix/test/PixToolsStaticTest.html000066400000000000000000000664061315400615200264100ustar00rootroot00000000000000 PixToolsStaticTest (javadoc for PixTools)
gov.fnal.eag.healpix.test

Class PixToolsStaticTest

  • java.lang.Object
    • TestCase
      • gov.fnal.eag.healpix.test.PixToolsStaticTest


  • public class PixToolsStaticTest
    extends TestCase
    test suit for PixTools using static constructor
    Author:
    N. Kuropatkin
    • Field Detail

      • pixTools

        private static PixTools pixTools
    • Constructor Detail

      • PixToolsStaticTest

        public PixToolsStaticTest()
    • Method Detail

      • testMODULO

        public void testMODULO()
        test MODULO function
      • testAngDist

        public void testAngDist()
                         throws java.lang.Exception
        tests angular distance calculation
        Throws:
        java.lang.Exception
      • testSurfaceTriangle

        public void testSurfaceTriangle()
                                 throws java.lang.Exception
        Throws:
        java.lang.Exception
      • testNside2Npix

        public void testNside2Npix()
        tests calculation of npixels from nside
      • testNpix2Nside

        public void testNpix2Nside()
        tests calculation of nsides from npixels
      • testVec2Ang

        public void testVec2Ang()
        test of directional angles calculation
      • testAng2Pix

        public void testAng2Pix()
                         throws java.lang.Exception
        tests calculation of pixel from polar angles in ring schema of pixalization
        Throws:
        java.lang.Exception
      • testAng2Vect

        public void testAng2Vect()
                          throws java.lang.Exception
        tests calculation of unit vector from polar angles
        Throws:
        java.lang.Exception
      • testRingNum

        public void testRingNum()
                         throws java.lang.Exception
        tests calculation of ring number from z coordinate
        Throws:
        java.lang.Exception
      • testNest2Ring

        public void testNest2Ring()
                           throws java.lang.Exception
        tests conversion from nest schema pixel to ring schema pixel
        Throws:
        java.lang.Exception
      • testRing2Nest

        public void testRing2Nest()
                           throws java.lang.Exception
        tests conversion from ring schema pixel to nest schema pixel
        Throws:
        java.lang.Exception
      • testNext_In_Line_Nest

        public void testNext_In_Line_Nest()
                                   throws java.lang.Exception
        tests Next_In_Line method for the nest schema
        Throws:
        java.lang.Exception
      • testInRing

        public void testInRing()
                        throws java.lang.Exception
        tests InRing method
        Throws:
        java.lang.Exception
      • testNeighbours_Nest

        public void testNeighbours_Nest()
                                 throws java.lang.Exception
        tests Neighbour's method for nest schema of the pixelization
        Throws:
        java.lang.Exception
      • testIntrs_Intrv

        public void testIntrs_Intrv()
                             throws java.lang.Exception
        tests intrs_intrv method
        Throws:
        java.lang.Exception
      • testPix2Vect_ring

        public void testPix2Vect_ring()
                               throws java.lang.Exception
        tests conversion from pixel number to vector
        Throws:
        java.lang.Exception
      • testPix2Vect_nest

        public void testPix2Vect_nest()
                               throws java.lang.Exception
        tests conversion from pixel number to vector
        Throws:
        java.lang.Exception
      • testVect2Pix_ring

        public void testVect2Pix_ring()
                               throws java.lang.Exception
        tests conversion from vector to pixel number
        Throws:
        java.lang.Exception
      • testVect2Pix_nest

        public void testVect2Pix_nest()
                               throws java.lang.Exception
        tests conversion from vector to pixel number
        Throws:
        java.lang.Exception
      • testQuery_Strip

        public void testQuery_Strip()
                             throws java.lang.Exception
        tests Query_Strip method
        Throws:
        java.lang.Exception
      • testQuery_Disc

        public void testQuery_Disc()
                            throws java.lang.Exception
        tests Query_Disc method
        Throws:
        java.lang.Exception
      • testQuery_Triangle

        public void testQuery_Triangle()
                                throws java.lang.Exception
        tests Query_Triangle method
        Throws:
        java.lang.Exception
      • testQuery_Polygon

        public void testQuery_Polygon()
                               throws java.lang.Exception
        tests Query_Poligon method
        Throws:
        java.lang.Exception
      • testMaxResolution

        public void testMaxResolution()
        tests MaxResolution method
      • testQueryDiscRes

        public void testQueryDiscRes()
                              throws java.lang.Exception
        tests QueryDiscResolution method
        Throws:
        java.lang.Exception
      • testQuery_disk2

        public void testQuery_disk2()
        test Query_disk check for consistency in the query for RING/NESTED
      • testGetNside

        public void testGetNside()
        tests GetNside method
      • testRaDecToPolar

        public void testRaDecToPolar()
        test conversion of Ra Dec to polar coordinates
eag-HEALPix-master/doc/gov/fnal/eag/healpix/test/PixToolsTest.html000066400000000000000000000631141315400615200252310ustar00rootroot00000000000000 PixToolsTest (javadoc for PixTools)
gov.fnal.eag.healpix.test

Class PixToolsTest

  • java.lang.Object
    • TestCase
      • gov.fnal.eag.healpix.test.PixToolsTest


  • public class PixToolsTest
    extends TestCase
    test suit for PixTools
    Author:
    N. Kuropatkin
    • Constructor Detail

      • PixToolsTest

        public PixToolsTest()
    • Method Detail

      • testMODULO

        public void testMODULO()
        test MODULO function
      • testAngDist

        public void testAngDist()
                         throws java.lang.Exception
        tests angular distance calculation
        Throws:
        java.lang.Exception
      • testSurfaceTriangle

        public void testSurfaceTriangle()
                                 throws java.lang.Exception
        Throws:
        java.lang.Exception
      • testNside2Npix

        public void testNside2Npix()
        tests calculation of npixels from nside
      • testNpix2Nside

        public void testNpix2Nside()
        tests calculation of nsides from npixels
      • testVec2Ang

        public void testVec2Ang()
        test of directional angles calculation
      • testAng2Pix

        public void testAng2Pix()
                         throws java.lang.Exception
        tests calculation of pixel from polar angles in ring schema of pixalization
        Throws:
        java.lang.Exception
      • testAng2Vect

        public void testAng2Vect()
                          throws java.lang.Exception
        tests calculation of unit vector from polar angles
        Throws:
        java.lang.Exception
      • testRingNum

        public void testRingNum()
                         throws java.lang.Exception
        tests calculation of ring number from z coordinate
        Throws:
        java.lang.Exception
      • testNest2Ring

        public void testNest2Ring()
                           throws java.lang.Exception
        tests conversion from nest schema pixel to ring schema pixel
        Throws:
        java.lang.Exception
      • testRing2Nest

        public void testRing2Nest()
                           throws java.lang.Exception
        tests conversion from ring schema pixel to nest schema pixel
        Throws:
        java.lang.Exception
      • testNext_In_Line_Nest

        public void testNext_In_Line_Nest()
                                   throws java.lang.Exception
        tests Next_In_Line method for the nest schema
        Throws:
        java.lang.Exception
      • testInRing

        public void testInRing()
                        throws java.lang.Exception
        tests InRing method
        Throws:
        java.lang.Exception
      • testNeighbours_Nest

        public void testNeighbours_Nest()
                                 throws java.lang.Exception
        tests Neighbour's method for nest schema of the pixelization
        Throws:
        java.lang.Exception
      • testIntrs_Intrv

        public void testIntrs_Intrv()
                             throws java.lang.Exception
        tests intrs_intrv method
        Throws:
        java.lang.Exception
      • testPix2Vect_ring

        public void testPix2Vect_ring()
                               throws java.lang.Exception
        tests conversion from pixel number to vector
        Throws:
        java.lang.Exception
      • testPix2Vect_nest

        public void testPix2Vect_nest()
                               throws java.lang.Exception
        tests conversion from pixel number to vector
        Throws:
        java.lang.Exception
      • testVect2Pix_ring

        public void testVect2Pix_ring()
                               throws java.lang.Exception
        tests conversion from vector to pixel number
        Throws:
        java.lang.Exception
      • testVect2Pix_nest

        public void testVect2Pix_nest()
                               throws java.lang.Exception
        tests conversion from vector to pixel number
        Throws:
        java.lang.Exception
      • testQuery_Strip

        public void testQuery_Strip()
                             throws java.lang.Exception
        tests Query_Strip method
        Throws:
        java.lang.Exception
      • testQuery_Disc

        public void testQuery_Disc()
                            throws java.lang.Exception
        tests Query_Disc method
        Throws:
        java.lang.Exception
      • testQuery_Triangle

        public void testQuery_Triangle()
                                throws java.lang.Exception
        tests Query_Triangle method
        Throws:
        java.lang.Exception
      • testQuery_Polygon

        public void testQuery_Polygon()
                               throws java.lang.Exception
        tests Query_Poligon method
        Throws:
        java.lang.Exception
      • testMaxResolution

        public void testMaxResolution()
        tests MaxResolution method
      • testQueryDiscRes

        public void testQueryDiscRes()
                              throws java.lang.Exception
        tests QueryDiscResolution method
        Throws:
        java.lang.Exception
      • testQuery_disk2

        public void testQuery_disk2()
        test Query_disk check for consistency in the query for RING/NESTED
      • testGetNside

        public void testGetNside()
        tests GetNside method
      • testRaDecToPolar

        public void testRaDecToPolar()
        test conversion of Ra Dec to polar coordinates
eag-HEALPix-master/doc/gov/fnal/eag/healpix/test/QueryDiscTest.html000066400000000000000000000225101315400615200253530ustar00rootroot00000000000000 QueryDiscTest (javadoc for PixTools)
gov.fnal.eag.healpix.test

Class QueryDiscTest

  • java.lang.Object
    • TestCase
      • gov.fnal.eag.healpix.test.QueryDiscTest


  • public class QueryDiscTest
    extends TestCase
    • Constructor Summary

      Constructors 
      Constructor and Description
      QueryDiscTest() 
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      void testQuery_Disc_1()
      additional tests of Query_Disc method
      void testQueryCircle() 
      void testQueryDisc() 
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • QueryDiscTest

        public QueryDiscTest()
    • Method Detail

      • testQueryDisc

        public void testQueryDisc()
      • testQueryCircle

        public void testQueryCircle()
      • testQuery_Disc_1

        public void testQuery_Disc_1()
                              throws java.lang.Exception
        additional tests of Query_Disc method
        Throws:
        java.lang.Exception
eag-HEALPix-master/doc/gov/fnal/eag/healpix/test/RegionTest.html000066400000000000000000000264571315400615200247040ustar00rootroot00000000000000 RegionTest (javadoc for PixTools)
gov.fnal.eag.healpix.test

Class RegionTest

  • java.lang.Object
    • TestCase
      • gov.fnal.eag.healpix.test.RegionTest


  • public class RegionTest
    extends TestCase
    Author:
    kuropat Junit methods to test Region class
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      private BitManipulation bm 
      private static double epsilon 
      private static double TWOPI 
    • Constructor Summary

      Constructors 
      Constructor and Description
      RegionTest() 
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      void testPixelize()
      test pixelization
      void testRegion()
      test default constructor
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • RegionTest

        public RegionTest()
    • Method Detail

      • testRegion

        public void testRegion()
        test default constructor
      • testPixelize

        public void testPixelize()
        test pixelization
eag-HEALPix-master/doc/gov/fnal/eag/healpix/test/ThreadTest.Worker.html000066400000000000000000000330401315400615200261220ustar00rootroot00000000000000 ThreadTest.Worker (javadoc for PixTools)
gov.fnal.eag.healpix.test

Class ThreadTest.Worker

  • java.lang.Object
    • java.lang.Thread
      • gov.fnal.eag.healpix.test.ThreadTest.Worker
  • All Implemented Interfaces:
    java.lang.Runnable
    Enclosing class:
    ThreadTest


    private static class ThreadTest.Worker
    extends java.lang.Thread
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.lang.Thread

        java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      private int inclusive_ 
      private int nest_ 
      private long nside_ 
      private double radius_ 
      private java.util.List result_ 
      private javax.vecmath.Vector3d vector_ 
      • Fields inherited from class java.lang.Thread

        MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
    • Constructor Summary

      Constructors 
      Constructor and Description
      ThreadTest.Worker(long nside, javax.vecmath.Vector3d vector, double radius, int nest, int inclusive) 
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      void run() 
      • Methods inherited from class java.lang.Thread

        activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • nside_

        private final long nside_
      • vector_

        private final javax.vecmath.Vector3d vector_
      • radius_

        private final double radius_
      • nest_

        private final int nest_
      • inclusive_

        private final int inclusive_
      • result_

        private java.util.List result_
    • Constructor Detail

      • ThreadTest.Worker

        ThreadTest.Worker(long nside,
                         javax.vecmath.Vector3d vector,
                         double radius,
                         int nest,
                         int inclusive)
    • Method Detail

      • run

        public void run()
        Specified by:
        run in interface java.lang.Runnable
        Overrides:
        run in class java.lang.Thread
eag-HEALPix-master/doc/gov/fnal/eag/healpix/test/ThreadTest.html000066400000000000000000000312011315400615200246470ustar00rootroot00000000000000 ThreadTest (javadoc for PixTools)
gov.fnal.eag.healpix.test

Class ThreadTest

  • java.lang.Object
    • gov.fnal.eag.healpix.test.ThreadTest


  • public class ThreadTest
    extends java.lang.Object
    The thread proof test by Mark Teylor
    Author:
    Mark Taylor
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class and Description
      private static class  ThreadTest.Worker 
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      private static PixTools pixTools 
    • Constructor Summary

      Constructors 
      Constructor and Description
      ThreadTest() 
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      private static void assertEquals(java.lang.String msg, java.util.List l1, java.util.List l2) 
      static void main(java.lang.String[] args) 
      void testPixtools() 
      private void workPixtools(boolean useThreads) 
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • pixTools

        private static PixTools pixTools
    • Constructor Detail

      • ThreadTest

        public ThreadTest()
    • Method Detail

      • testPixtools

        public void testPixtools()
                          throws java.lang.InterruptedException
        Throws:
        java.lang.InterruptedException
      • workPixtools

        private void workPixtools(boolean useThreads)
                           throws java.lang.InterruptedException
        Throws:
        java.lang.InterruptedException
      • assertEquals

        private static void assertEquals(java.lang.String msg,
                        java.util.List l1,
                        java.util.List l2)
      • main

        public static void main(java.lang.String[] args)
                         throws java.lang.InterruptedException
        Throws:
        java.lang.InterruptedException
eag-HEALPix-master/doc/gov/fnal/eag/healpix/test/class-use/000077500000000000000000000000001315400615200236145ustar00rootroot00000000000000eag-HEALPix-master/doc/gov/fnal/eag/healpix/test/class-use/BitManipulationTest.html000066400000000000000000000103271315400615200304440ustar00rootroot00000000000000 Uses of Class gov.fnal.eag.healpix.test.BitManipulationTest (javadoc for PixTools)

Uses of Class
gov.fnal.eag.healpix.test.BitManipulationTest

No usage of gov.fnal.eag.healpix.test.BitManipulationTest
eag-HEALPix-master/doc/gov/fnal/eag/healpix/test/class-use/DiscTest.html000066400000000000000000000101361315400615200262250ustar00rootroot00000000000000 Uses of Class gov.fnal.eag.healpix.test.DiscTest (javadoc for PixTools)

Uses of Class
gov.fnal.eag.healpix.test.DiscTest

No usage of gov.fnal.eag.healpix.test.DiscTest
eag-HEALPix-master/doc/gov/fnal/eag/healpix/test/class-use/PixToolTest1.RaDePoint.html000066400000000000000000000146761315400615200306630ustar00rootroot00000000000000 Uses of Class gov.fnal.eag.healpix.test.PixToolTest1.RaDePoint (javadoc for PixTools)

Uses of Class
gov.fnal.eag.healpix.test.PixToolTest1.RaDePoint

eag-HEALPix-master/doc/gov/fnal/eag/healpix/test/class-use/PixToolTest1.html000066400000000000000000000102121315400615200270150ustar00rootroot00000000000000 Uses of Class gov.fnal.eag.healpix.test.PixToolTest1 (javadoc for PixTools)

Uses of Class
gov.fnal.eag.healpix.test.PixToolTest1

No usage of gov.fnal.eag.healpix.test.PixToolTest1
eag-HEALPix-master/doc/gov/fnal/eag/healpix/test/class-use/PixToolsSingletonTest.html000066400000000000000000000103551315400615200310120ustar00rootroot00000000000000 Uses of Class gov.fnal.eag.healpix.test.PixToolsSingletonTest (javadoc for PixTools)

Uses of Class
gov.fnal.eag.healpix.test.PixToolsSingletonTest

No usage of gov.fnal.eag.healpix.test.PixToolsSingletonTest
eag-HEALPix-master/doc/gov/fnal/eag/healpix/test/class-use/PixToolsStaticTest.html000066400000000000000000000103141315400615200302720ustar00rootroot00000000000000 Uses of Class gov.fnal.eag.healpix.test.PixToolsStaticTest (javadoc for PixTools)

Uses of Class
gov.fnal.eag.healpix.test.PixToolsStaticTest

No usage of gov.fnal.eag.healpix.test.PixToolsStaticTest
eag-HEALPix-master/doc/gov/fnal/eag/healpix/test/class-use/PixToolsTest.html000066400000000000000000000102121315400615200271170ustar00rootroot00000000000000 Uses of Class gov.fnal.eag.healpix.test.PixToolsTest (javadoc for PixTools)

Uses of Class
gov.fnal.eag.healpix.test.PixToolsTest

No usage of gov.fnal.eag.healpix.test.PixToolsTest
eag-HEALPix-master/doc/gov/fnal/eag/healpix/test/class-use/QueryDiscTest.html000066400000000000000000000102251315400615200272520ustar00rootroot00000000000000 Uses of Class gov.fnal.eag.healpix.test.QueryDiscTest (javadoc for PixTools)

Uses of Class
gov.fnal.eag.healpix.test.QueryDiscTest

No usage of gov.fnal.eag.healpix.test.QueryDiscTest
eag-HEALPix-master/doc/gov/fnal/eag/healpix/test/class-use/RegionTest.html000066400000000000000000000101641315400615200265670ustar00rootroot00000000000000 Uses of Class gov.fnal.eag.healpix.test.RegionTest (javadoc for PixTools)

Uses of Class
gov.fnal.eag.healpix.test.RegionTest

No usage of gov.fnal.eag.healpix.test.RegionTest
eag-HEALPix-master/doc/gov/fnal/eag/healpix/test/class-use/ThreadTest.Worker.html000066400000000000000000000103011315400615200300140ustar00rootroot00000000000000 Uses of Class gov.fnal.eag.healpix.test.ThreadTest.Worker (javadoc for PixTools)

Uses of Class
gov.fnal.eag.healpix.test.ThreadTest.Worker

No usage of gov.fnal.eag.healpix.test.ThreadTest.Worker
eag-HEALPix-master/doc/gov/fnal/eag/healpix/test/class-use/ThreadTest.html000066400000000000000000000101641315400615200265530ustar00rootroot00000000000000 Uses of Class gov.fnal.eag.healpix.test.ThreadTest (javadoc for PixTools)

Uses of Class
gov.fnal.eag.healpix.test.ThreadTest

No usage of gov.fnal.eag.healpix.test.ThreadTest
eag-HEALPix-master/doc/gov/fnal/eag/healpix/test/package-frame.html000066400000000000000000000037651315400615200253010ustar00rootroot00000000000000 gov.fnal.eag.healpix.test (javadoc for PixTools)

gov.fnal.eag.healpix.test

eag-HEALPix-master/doc/gov/fnal/eag/healpix/test/package-summary.html000066400000000000000000000163031315400615200256740ustar00rootroot00000000000000 gov.fnal.eag.healpix.test (javadoc for PixTools)

Package gov.fnal.eag.healpix.test

Junit tests for EAG HEALPix project

See: Description

Package gov.fnal.eag.healpix.test Description

Junit tests for EAG HEALPix project

eag-HEALPix-master/doc/gov/fnal/eag/healpix/test/package-tree.html000066400000000000000000000152631315400615200251420ustar00rootroot00000000000000 gov.fnal.eag.healpix.test Class Hierarchy (javadoc for PixTools)

Hierarchy For Package gov.fnal.eag.healpix.test

Package Hierarchies:

Class Hierarchy

eag-HEALPix-master/doc/gov/fnal/eag/healpix/test/package-use.html000066400000000000000000000123271315400615200247750ustar00rootroot00000000000000 Uses of Package gov.fnal.eag.healpix.test (javadoc for PixTools)

Uses of Package
gov.fnal.eag.healpix.test

eag-HEALPix-master/doc/gov/fnal/eag/healpix/test/package.html000066400000000000000000000007251315400615200242020ustar00rootroot00000000000000 No title

Junit tests for EAG HEALPix project

eag-HEALPix-master/doc/help-doc.html000066400000000000000000000205771315400615200174310ustar00rootroot00000000000000 API Help (javadoc for PixTools)

How This API Document Is Organized

This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.
  • Overview

    The Overview page is the front page of this API document and provides a list of all packages with a summary for each. This page can also contain an overall description of the set of packages.

  • Package

    Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain six categories:

    • Interfaces (italic)
    • Classes
    • Enums
    • Exceptions
    • Errors
    • Annotation Types
  • Class/Interface

    Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:

    • Class inheritance diagram
    • Direct Subclasses
    • All Known Subinterfaces
    • All Known Implementing Classes
    • Class/interface declaration
    • Class/interface description
    • Nested Class Summary
    • Field Summary
    • Constructor Summary
    • Method Summary
    • Field Detail
    • Constructor Detail
    • Method Detail

    Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.

  • Annotation Type

    Each annotation type has its own separate page with the following sections:

    • Annotation Type declaration
    • Annotation Type description
    • Required Element Summary
    • Optional Element Summary
    • Element Detail
  • Enum

    Each enum has its own separate page with the following sections:

    • Enum declaration
    • Enum description
    • Enum Constant Summary
    • Enum Constant Detail
  • Use

    Each documented package, class and interface has its own Use page. This page describes what packages, classes, methods, constructors and fields use any part of the given class or package. Given a class or interface A, its Use page includes subclasses of A, fields declared as A, methods that return A, and methods and constructors with parameters of type A. You can access this page by first going to the package, class or interface, then clicking on the "Use" link in the navigation bar.

  • Tree (Class Hierarchy)

    There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with java.lang.Object. The interfaces do not inherit from java.lang.Object.

    • When viewing the Overview page, clicking on "Tree" displays the hierarchy for all packages.
    • When viewing a particular package, class or interface page, clicking "Tree" displays the hierarchy for only that package.
  • Deprecated API

    The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.

  • Index

    The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.

  • Prev/Next

    These links take you to the next or previous class, interface, package, or related page.

  • Frames/No Frames

    These links show and hide the HTML frames. All pages are available with or without frames.

  • All Classes

    The All Classes link shows all classes and interfaces except non-static nested types.

  • Serialized Form

    Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description.

  • Constant Field Values

    The Constant Field Values page lists the static final fields and their values.

This help file applies to API documentation generated using the standard doclet.
eag-HEALPix-master/doc/index-all.html000066400000000000000000002740721315400615200176140ustar00rootroot00000000000000 Index (javadoc for PixTools)
A B C D E G H I M N O P Q R S T V W X Y 

A

ang2pix_nest(long, double, double) - Method in class gov.fnal.eag.healpix.PixTools
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.
ang2pix_ring(long, double, double) - Method in class gov.fnal.eag.healpix.PixTools
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.
Ang2Vec(double, double) - Method in class gov.fnal.eag.healpix.PixTools
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)
AngDist(Vector3d, Vector3d) - Method in class gov.fnal.eag.healpix.PixTools
calculates angular distance (in radians) between 2 Vectors v1 and v2 In general dist = acos(v1.v2) except if the vectors are almost aligned
assertEquals(String, List, List) - Static method in class gov.fnal.eag.healpix.test.ThreadTest
 

B

BitManipulation - Class in gov.fnal.eag.healpix
bit manipulation class derived from Healpix fortran90 program.
BitManipulation() - Constructor for class gov.fnal.eag.healpix.BitManipulation
 
BitManipulationTest - Class in gov.fnal.eag.healpix.test
 
BitManipulationTest() - Constructor for class gov.fnal.eag.healpix.test.BitManipulationTest
 
bm - Variable in class gov.fnal.eag.healpix.Region
 
bm - Variable in class gov.fnal.eag.healpix.test.RegionTest
 

C

checkOverlap(int, double, double, double, double) - Method in class gov.fnal.eag.healpix.test.DiscTest
 
convert_inplace_long(String, Object[]) - Method in class gov.fnal.eag.healpix.PixTools
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).
convert_nest2ring(long, Object[]) - Method in class gov.fnal.eag.healpix.PixTools
make the conversion NEST to RING
convert_ring2nest(long, Object[]) - Method in class gov.fnal.eag.healpix.PixTools
makes the conversion RING to NEST
crossProduct(Vector3d, Vector3d) - Method in class gov.fnal.eag.healpix.PixTools
calculate cross product of two vectors

D

de - Variable in class gov.fnal.eag.healpix.test.PixToolTest1.RaDePoint
coordinates in degrees
decMax - Variable in class gov.fnal.eag.healpix.Region
 
decMin - Variable in class gov.fnal.eag.healpix.Region
 
DiscTest - Class in gov.fnal.eag.healpix.test
 
DiscTest() - Constructor for class gov.fnal.eag.healpix.test.DiscTest
 
dotProduct(Vector3d, Vector3d) - Method in class gov.fnal.eag.healpix.PixTools
calculates a dot product (inner product) of two 3D vectors the result is double

E

epsilon - Static variable in class gov.fnal.eag.healpix.Region
 
epsilon - Static variable in class gov.fnal.eag.healpix.test.RegionTest
 

G

getDisc_ring(long, Vector3d, double) - Method in class gov.fnal.eag.healpix.PixTools
an obsolete method.
getHealId(double, double, long) - Method in class gov.fnal.eag.healpix.test.PixToolTest1
get position ID for ra,de
getInstance() - Static method in class gov.fnal.eag.healpix.PixTools
Returns singleton instance.
GetNSide(double) - Method in class gov.fnal.eag.healpix.PixTools
calculate requared nside given pixel size in arcsec
getPolReg() - Method in class gov.fnal.eag.healpix.Region
provides polar coordinates of the region vertices
getRaDe(long, long) - Static method in class gov.fnal.eag.healpix.test.PixToolTest1
inverse method, convert area ID to RaDePoint
getVertices() - Method in class gov.fnal.eag.healpix.Region
 
gov.fnal.eag.healpix - package gov.fnal.eag.healpix
EAG HEALPix
gov.fnal.eag.healpix.test - package gov.fnal.eag.healpix.test
Junit tests for EAG HEALPix project

H

HALFPI - Static variable in class gov.fnal.eag.healpix.PixTools
 
haversineSeparationFormula(double, double, double, double) - Static method in class gov.fnal.eag.healpix.test.DiscTest
Haversine formula for spherical trigonometry.
HealpixException - Exception in gov.fnal.eag.healpix
handles exceptions from this package
HealpixException(String) - Constructor for exception gov.fnal.eag.healpix.HealpixException
message - String to be printed in case of exception

I

inclusive_ - Variable in class gov.fnal.eag.healpix.test.ThreadTest.Worker
 
inReg(double, double) - Method in class gov.fnal.eag.healpix.Region
return true if the point ra,dec is inside region
inRegPol(double, double) - Method in class gov.fnal.eag.healpix.Region
return true if point phi, theta is inside region
InRing(long, long, double, double, boolean) - Method in class gov.fnal.eag.healpix.PixTools
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
intersection(Collection, Collection) - Static method in class gov.fnal.eag.healpix.test.DiscTest
 
intrs_intrv(double[], double[]) - Method in class gov.fnal.eag.healpix.PixTools
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 b1 then d1 = {x | a1 <=x <= B U A <=x <=b1}
invLSB(long) - Static method in class gov.fnal.eag.healpix.BitManipulation
returns i with even bits inverted
invMSB(long) - Static method in class gov.fnal.eag.healpix.BitManipulation
returns i with odd bits inverted
invswapLSBMSB(long) - Static method in class gov.fnal.eag.healpix.BitManipulation
returns NOT i with even and odd bit positions interchanged

M

magic1 - Static variable in class gov.fnal.eag.healpix.BitManipulation
magic1 odd bits set constant
magic2 - Static variable in class gov.fnal.eag.healpix.BitManipulation
magic2 - even bits set constant
main(String[]) - Static method in class gov.fnal.eag.healpix.BitManipulation
the main program for simple test
main(String[]) - Static method in class gov.fnal.eag.healpix.test.DiscTest
 
main(String[]) - Static method in class gov.fnal.eag.healpix.test.ThreadTest
 
makePix2Vect_Nest(long, long) - Method in class gov.fnal.eag.healpix.PixTools
renders vector (x,y,z) coordinates of the nominal pixel center for the pixel ipix (NESTED scheme ) given the map resolution parameter nside.
makePix2Vect_ring(long, long) - Method in class gov.fnal.eag.healpix.PixTools
renders vector (x,y,z) coordinates of the nominal pixel center for pixel ipix (RING scheme) given the map resolution parameter nside.
mk_pix2xy() - Method in class gov.fnal.eag.healpix.PixTools
creates an array of pixel numbers pix2x from x and y coordinates in the face.
mk_xy2pix() - Static method in class gov.fnal.eag.healpix.PixTools
fills arrays x2pix and y2pix giving the number of the pixel laying in (x,y).
MODULO(double, double) - Static method in class gov.fnal.eag.healpix.BitManipulation
simulates behaviour of fortran90 MODULO function

N

nCheck - Variable in class gov.fnal.eag.healpix.test.DiscTest
 
neighbours_nest(long, long) - Method in class gov.fnal.eag.healpix.PixTools
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).
nest2ring(long, long) - Method in class gov.fnal.eag.healpix.PixTools
converts from NESTED to RING pixel numbering
nest_ - Variable in class gov.fnal.eag.healpix.test.ThreadTest.Worker
 
next_in_line_nest(long, long) - Method in class gov.fnal.eag.healpix.PixTools
calculates the pixel that lies on the East side (and the same latitude) as the given NESTED pixel number - ipix
nFail - Variable in class gov.fnal.eag.healpix.test.DiscTest
 
Npix2Nside(long) - Method in class gov.fnal.eag.healpix.PixTools
returns nside such that npix = 12*nside^2, nside should be power of 2 and smaller than ns_max if not return -1
ns_max - Static variable in class gov.fnal.eag.healpix.PixTools
 
NSIDE1 - Variable in class gov.fnal.eag.healpix.test.PixToolTest1
 
NSIDE2 - Variable in class gov.fnal.eag.healpix.test.PixToolTest1
 
Nside2Npix(long) - Method in class gov.fnal.eag.healpix.PixTools
calculates npix such that npix = 12*nside^2 ,nside should be a power of 2, and smaller than ns_max otherwise return -1
nside_ - Variable in class gov.fnal.eag.healpix.test.ThreadTest.Worker
 

O

orderToNside(int) - Static method in class gov.fnal.eag.healpix.test.DiscTest
 

P

phiMax - Variable in class gov.fnal.eag.healpix.Region
 
phiMin - Variable in class gov.fnal.eag.healpix.Region
 
PI - Static variable in class gov.fnal.eag.healpix.PixTools
 
PI - Variable in class gov.fnal.eag.healpix.Region
 
pix2ang_nest(long, long) - Method in class gov.fnal.eag.healpix.PixTools
Renders theta and phi coordinates of the normal pixel center for the pixel number ipix (NESTED scheme) given the map resolution parameter nside.
pix2ang_ring(long, long) - Method in class gov.fnal.eag.healpix.PixTools
renders theta and phi coordinates of the nominal pixel center for the pixel number ipix (RING scheme) given the map resolution parameter nside
pix2vect_nest(long, long) - Method in class gov.fnal.eag.healpix.PixTools
renders vector (x,y,z) coordinates of the nominal pixel center for the pixel ipix (NESTED scheme ) given the map resolution parameter nside.
pix2vect_ring(long, long) - Method in class gov.fnal.eag.healpix.PixTools
returns the vector pointing in the center of the pixel ipix.
pix2vertex_nest(long, long) - Method in class gov.fnal.eag.healpix.PixTools
renders vector (x,y,z) coordinates of the nominal pixel center for the pixel ipix (NESTED scheme ) given the map resolution parameter nside.
pix2vertex_ring(long, long) - Method in class gov.fnal.eag.healpix.PixTools
returns double [][] with coordinates of the pixel corners.
pix2x - Static variable in class gov.fnal.eag.healpix.PixTools
 
pix2xy_nest(long, long) - Method in class gov.fnal.eag.healpix.PixTools
gives the x,y coordinates in a face from pixel number within the face (NESTED) schema.
pix2y - Static variable in class gov.fnal.eag.healpix.PixTools
 
pixelize(double) - Method in class gov.fnal.eag.healpix.Region
divides region on HealPix pixels of given size including pixels that only partly inside the region
PixInfo - Class in gov.fnal.eag.healpix
Aggregates a vector and double[3][4] array which are the results of a pixel center calculation.
PixInfo(Vector3d, double[][]) - Constructor for class gov.fnal.eag.healpix.PixInfo
 
pixmax - Static variable in class gov.fnal.eag.healpix.PixTools
 
PixRes(long) - Method in class gov.fnal.eag.healpix.PixTools
calculates angular resolution of the pixel map in arc seconds.
PixTools - Class in gov.fnal.eag.healpix
contains methods translated from HEALPix Fortran90 with increased map resolution in comparison to original Fortran code.
PixTools() - Constructor for class gov.fnal.eag.healpix.PixTools
default constructor
pixTools - Static variable in class gov.fnal.eag.healpix.PixTools
Singleton instance.
pixTools - Static variable in class gov.fnal.eag.healpix.test.PixToolsStaticTest
 
pixTools - Static variable in class gov.fnal.eag.healpix.test.ThreadTest
 
PixToolsSingletonTest - Class in gov.fnal.eag.healpix.test
 
PixToolsSingletonTest() - Constructor for class gov.fnal.eag.healpix.test.PixToolsSingletonTest
 
PixToolsStaticTest - Class in gov.fnal.eag.healpix.test
test suit for PixTools using static constructor
PixToolsStaticTest() - Constructor for class gov.fnal.eag.healpix.test.PixToolsStaticTest
 
PixToolsTest - Class in gov.fnal.eag.healpix.test
test suit for PixTools
PixToolsTest() - Constructor for class gov.fnal.eag.healpix.test.PixToolsTest
 
PixToolTest1 - Class in gov.fnal.eag.healpix.test
 
PixToolTest1() - Constructor for class gov.fnal.eag.healpix.test.PixToolTest1
 
PixToolTest1.RaDePoint - Class in gov.fnal.eag.healpix.test
Simple point on sky.
PixToolTest1.RaDePoint() - Constructor for class gov.fnal.eag.healpix.test.PixToolTest1.RaDePoint
 
PixToolTest1.RaDePoint(double, double) - Constructor for class gov.fnal.eag.healpix.test.PixToolTest1.RaDePoint
 
pixVect - Variable in class gov.fnal.eag.healpix.PixInfo
 
pixVertex - Variable in class gov.fnal.eag.healpix.PixInfo
 
PolarToRaDec(double[]) - Method in class gov.fnal.eag.healpix.PixTools
returns ra, dec in degrees given polar coordinates in radians

Q

query_disc(long, Vector3d, double, int, int) - Method in class gov.fnal.eag.healpix.PixTools
generates in the RING or NESTED scheme all pixels that lays within an angular distance Radius of the center.
query_polygon(long, ArrayList, long, long) - Method in class gov.fnal.eag.healpix.PixTools
finds pixels that lay within a CONVEX polygon defined by its vertex on sphere
query_strip(long, double, double, long) - Method in class gov.fnal.eag.healpix.PixTools
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
query_triangle(long, Vector3d, Vector3d, Vector3d, long, long) - Method in class gov.fnal.eag.healpix.PixTools
generates a list of pixels that lay inside a triangle defined by the three vertex vectors
queryDisc(int, double, double, double) - Method in class gov.fnal.eag.healpix.test.DiscTest
 
QueryDiscTest - Class in gov.fnal.eag.healpix.test
 
QueryDiscTest() - Constructor for class gov.fnal.eag.healpix.test.QueryDiscTest
 

R

ra - Variable in class gov.fnal.eag.healpix.test.PixToolTest1.RaDePoint
coordinates in degrees
RaDecToPolar(double[]) - Method in class gov.fnal.eag.healpix.PixTools
returns polar coordinates in radians given ra, dec in degrees
radius_ - Variable in class gov.fnal.eag.healpix.test.ThreadTest.Worker
 
raMax - Variable in class gov.fnal.eag.healpix.Region
 
raMin - Variable in class gov.fnal.eag.healpix.Region
 
Region - Class in gov.fnal.eag.healpix
 
Region(double, double, double, double) - Constructor for class gov.fnal.eag.healpix.Region
default constructor
RegionTest - Class in gov.fnal.eag.healpix.test
 
RegionTest() - Constructor for class gov.fnal.eag.healpix.test.RegionTest
 
report() - Method in class gov.fnal.eag.healpix.test.DiscTest
 
result_ - Variable in class gov.fnal.eag.healpix.test.ThreadTest.Worker
 
ring2nest(long, long) - Method in class gov.fnal.eag.healpix.PixTools
converts pixel number from ring numbering schema to the nested one
RingNum(long, double) - Method in class gov.fnal.eag.healpix.PixTools
returns the ring number in {1, 4*nside - 1} calculated from z coordinate
run() - Method in class gov.fnal.eag.healpix.test.ThreadTest.Worker
 

S

serialVersionUID - Static variable in exception gov.fnal.eag.healpix.HealpixException
 
SurfaceTriangle(Vector3d, Vector3d, Vector3d) - Method in class gov.fnal.eag.healpix.PixTools
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.)
swapLSBMSB(long) - Static method in class gov.fnal.eag.healpix.BitManipulation
swaps low and high bits in the word i

T

testAng2Pix() - Method in class gov.fnal.eag.healpix.test.PixToolsSingletonTest
tests calculation of pixel from polar angles in ring schema of pixalization
testAng2Pix() - Method in class gov.fnal.eag.healpix.test.PixToolsStaticTest
tests calculation of pixel from polar angles in ring schema of pixalization
testAng2Pix() - Method in class gov.fnal.eag.healpix.test.PixToolsTest
tests calculation of pixel from polar angles in ring schema of pixalization
testAng2Vect() - Method in class gov.fnal.eag.healpix.test.PixToolsSingletonTest
tests calculation of unit vector from polar angles
testAng2Vect() - Method in class gov.fnal.eag.healpix.test.PixToolsStaticTest
tests calculation of unit vector from polar angles
testAng2Vect() - Method in class gov.fnal.eag.healpix.test.PixToolsTest
tests calculation of unit vector from polar angles
testAngDist() - Method in class gov.fnal.eag.healpix.test.PixToolsSingletonTest
tests angular distance calculation
testAngDist() - Method in class gov.fnal.eag.healpix.test.PixToolsStaticTest
tests angular distance calculation
testAngDist() - Method in class gov.fnal.eag.healpix.test.PixToolsTest
tests angular distance calculation
testBitManipulation() - Method in class gov.fnal.eag.healpix.test.BitManipulationTest
tests bit manipulation methods
testCircle1() - Method in class gov.fnal.eag.healpix.test.PixToolTest1
 
testCircle2() - Method in class gov.fnal.eag.healpix.test.PixToolTest1
 
testCircle3() - Method in class gov.fnal.eag.healpix.test.PixToolTest1
 
testCircle4() - Method in class gov.fnal.eag.healpix.test.PixToolTest1
 
testCircle5() - Method in class gov.fnal.eag.healpix.test.PixToolTest1
with NSIDE 512
testGetNside() - Method in class gov.fnal.eag.healpix.test.PixToolsSingletonTest
tests GetNside method
testGetNside() - Method in class gov.fnal.eag.healpix.test.PixToolsStaticTest
tests GetNside method
testGetNside() - Method in class gov.fnal.eag.healpix.test.PixToolsTest
tests GetNside method
testInRing() - Method in class gov.fnal.eag.healpix.test.PixToolsSingletonTest
tests InRing method
testInRing() - Method in class gov.fnal.eag.healpix.test.PixToolsStaticTest
tests InRing method
testInRing() - Method in class gov.fnal.eag.healpix.test.PixToolsTest
tests InRing method
testIntrs_Intrv() - Method in class gov.fnal.eag.healpix.test.PixToolsSingletonTest
tests intrs_intrv method
testIntrs_Intrv() - Method in class gov.fnal.eag.healpix.test.PixToolsStaticTest
tests intrs_intrv method
testIntrs_Intrv() - Method in class gov.fnal.eag.healpix.test.PixToolsTest
tests intrs_intrv method
testInverse() - Method in class gov.fnal.eag.healpix.test.PixToolTest1
 
testMaxResolution() - Method in class gov.fnal.eag.healpix.test.PixToolsSingletonTest
tests MaxResolution method
testMaxResolution() - Method in class gov.fnal.eag.healpix.test.PixToolsStaticTest
tests MaxResolution method
testMaxResolution() - Method in class gov.fnal.eag.healpix.test.PixToolsTest
tests MaxResolution method
testMODULO() - Method in class gov.fnal.eag.healpix.test.BitManipulationTest
test Modulo
testMODULO() - Method in class gov.fnal.eag.healpix.test.PixToolsSingletonTest
test MODULO function
testMODULO() - Method in class gov.fnal.eag.healpix.test.PixToolsStaticTest
test MODULO function
testMODULO() - Method in class gov.fnal.eag.healpix.test.PixToolsTest
test MODULO function
testNeighbours_Nest() - Method in class gov.fnal.eag.healpix.test.PixToolsSingletonTest
tests Neighbour's method for nest schema of the pixelization
testNeighbours_Nest() - Method in class gov.fnal.eag.healpix.test.PixToolsStaticTest
tests Neighbour's method for nest schema of the pixelization
testNeighbours_Nest() - Method in class gov.fnal.eag.healpix.test.PixToolsTest
tests Neighbour's method for nest schema of the pixelization
testNest2Ring() - Method in class gov.fnal.eag.healpix.test.PixToolsSingletonTest
tests conversion from nest schema pixel to ring schema pixel
testNest2Ring() - Method in class gov.fnal.eag.healpix.test.PixToolsStaticTest
tests conversion from nest schema pixel to ring schema pixel
testNest2Ring() - Method in class gov.fnal.eag.healpix.test.PixToolsTest
tests conversion from nest schema pixel to ring schema pixel
testNext_In_Line_Nest() - Method in class gov.fnal.eag.healpix.test.PixToolsSingletonTest
tests Next_In_Line method for the nest schema
testNext_In_Line_Nest() - Method in class gov.fnal.eag.healpix.test.PixToolsStaticTest
tests Next_In_Line method for the nest schema
testNext_In_Line_Nest() - Method in class gov.fnal.eag.healpix.test.PixToolsTest
tests Next_In_Line method for the nest schema
testNpix2Nside() - Method in class gov.fnal.eag.healpix.test.PixToolsSingletonTest
tests calculation of nsides from npixels
testNpix2Nside() - Method in class gov.fnal.eag.healpix.test.PixToolsStaticTest
tests calculation of nsides from npixels
testNpix2Nside() - Method in class gov.fnal.eag.healpix.test.PixToolsTest
tests calculation of nsides from npixels
testNside2Npix() - Method in class gov.fnal.eag.healpix.test.PixToolsSingletonTest
tests calculation of npixels from nside
testNside2Npix() - Method in class gov.fnal.eag.healpix.test.PixToolsStaticTest
tests calculation of npixels from nside
testNside2Npix() - Method in class gov.fnal.eag.healpix.test.PixToolsTest
tests calculation of npixels from nside
testPix2Vect_nest() - Method in class gov.fnal.eag.healpix.test.PixToolsSingletonTest
tests conversion from pixel number to vector
testPix2Vect_nest() - Method in class gov.fnal.eag.healpix.test.PixToolsStaticTest
tests conversion from pixel number to vector
testPix2Vect_nest() - Method in class gov.fnal.eag.healpix.test.PixToolsTest
tests conversion from pixel number to vector
testPix2Vect_ring() - Method in class gov.fnal.eag.healpix.test.PixToolsSingletonTest
tests conversion from pixel number to vector
testPix2Vect_ring() - Method in class gov.fnal.eag.healpix.test.PixToolsStaticTest
tests conversion from pixel number to vector
testPix2Vect_ring() - Method in class gov.fnal.eag.healpix.test.PixToolsTest
tests conversion from pixel number to vector
testPixelize() - Method in class gov.fnal.eag.healpix.test.RegionTest
test pixelization
testPixtools() - Method in class gov.fnal.eag.healpix.test.ThreadTest
 
testQuery_Disc() - Method in class gov.fnal.eag.healpix.test.PixToolsSingletonTest
tests Query_Disc method
testQuery_Disc() - Method in class gov.fnal.eag.healpix.test.PixToolsStaticTest
tests Query_Disc method
testQuery_Disc() - Method in class gov.fnal.eag.healpix.test.PixToolsTest
tests Query_Disc method
testQuery_Disc_1() - Method in class gov.fnal.eag.healpix.test.QueryDiscTest
additional tests of Query_Disc method
testQuery_disk2() - Method in class gov.fnal.eag.healpix.test.PixToolsSingletonTest
test Query_disk check for consistency in the query for RING/NESTED
testQuery_disk2() - Method in class gov.fnal.eag.healpix.test.PixToolsStaticTest
test Query_disk check for consistency in the query for RING/NESTED
testQuery_disk2() - Method in class gov.fnal.eag.healpix.test.PixToolsTest
test Query_disk check for consistency in the query for RING/NESTED
testQuery_Polygon() - Method in class gov.fnal.eag.healpix.test.PixToolsSingletonTest
tests Query_Poligon method
testQuery_Polygon() - Method in class gov.fnal.eag.healpix.test.PixToolsStaticTest
tests Query_Poligon method
testQuery_Polygon() - Method in class gov.fnal.eag.healpix.test.PixToolsTest
tests Query_Poligon method
testQuery_Strip() - Method in class gov.fnal.eag.healpix.test.PixToolsSingletonTest
tests Query_Strip method
testQuery_Strip() - Method in class gov.fnal.eag.healpix.test.PixToolsStaticTest
tests Query_Strip method
testQuery_Strip() - Method in class gov.fnal.eag.healpix.test.PixToolsTest
tests Query_Strip method
testQuery_Triangle() - Method in class gov.fnal.eag.healpix.test.PixToolsSingletonTest
tests Query_Triangle method
testQuery_Triangle() - Method in class gov.fnal.eag.healpix.test.PixToolsStaticTest
tests Query_Triangle method
testQuery_Triangle() - Method in class gov.fnal.eag.healpix.test.PixToolsTest
tests Query_Triangle method
testQueryCircle() - Method in class gov.fnal.eag.healpix.test.QueryDiscTest
 
testQueryDisc() - Method in class gov.fnal.eag.healpix.test.QueryDiscTest
 
testQueryDiscRes() - Method in class gov.fnal.eag.healpix.test.PixToolsSingletonTest
tests QueryDiscResolution method
testQueryDiscRes() - Method in class gov.fnal.eag.healpix.test.PixToolsStaticTest
tests QueryDiscResolution method
testQueryDiscRes() - Method in class gov.fnal.eag.healpix.test.PixToolsTest
tests QueryDiscResolution method
testRaDecToPolar() - Method in class gov.fnal.eag.healpix.test.PixToolsSingletonTest
test conversion of Ra Dec to polar coordinates
testRaDecToPolar() - Method in class gov.fnal.eag.healpix.test.PixToolsStaticTest
test conversion of Ra Dec to polar coordinates
testRaDecToPolar() - Method in class gov.fnal.eag.healpix.test.PixToolsTest
test conversion of Ra Dec to polar coordinates
testRegion() - Method in class gov.fnal.eag.healpix.test.RegionTest
test default constructor
testRing2Nest() - Method in class gov.fnal.eag.healpix.test.PixToolsSingletonTest
tests conversion from ring schema pixel to nest schema pixel
testRing2Nest() - Method in class gov.fnal.eag.healpix.test.PixToolsStaticTest
tests conversion from ring schema pixel to nest schema pixel
testRing2Nest() - Method in class gov.fnal.eag.healpix.test.PixToolsTest
tests conversion from ring schema pixel to nest schema pixel
testRingNum() - Method in class gov.fnal.eag.healpix.test.PixToolsSingletonTest
tests calculation of ring number from z coordinate
testRingNum() - Method in class gov.fnal.eag.healpix.test.PixToolsStaticTest
tests calculation of ring number from z coordinate
testRingNum() - Method in class gov.fnal.eag.healpix.test.PixToolsTest
tests calculation of ring number from z coordinate
testSurfaceTriangle() - Method in class gov.fnal.eag.healpix.test.PixToolsSingletonTest
 
testSurfaceTriangle() - Method in class gov.fnal.eag.healpix.test.PixToolsStaticTest
 
testSurfaceTriangle() - Method in class gov.fnal.eag.healpix.test.PixToolsTest
 
testVec2Ang() - Method in class gov.fnal.eag.healpix.test.PixToolsSingletonTest
test of directional angles calculation
testVec2Ang() - Method in class gov.fnal.eag.healpix.test.PixToolsStaticTest
test of directional angles calculation
testVec2Ang() - Method in class gov.fnal.eag.healpix.test.PixToolsTest
test of directional angles calculation
testVect2Pix_nest() - Method in class gov.fnal.eag.healpix.test.PixToolsSingletonTest
tests conversion from vector to pixel number
testVect2Pix_nest() - Method in class gov.fnal.eag.healpix.test.PixToolsStaticTest
tests conversion from vector to pixel number
testVect2Pix_nest() - Method in class gov.fnal.eag.healpix.test.PixToolsTest
tests conversion from vector to pixel number
testVect2Pix_ring() - Method in class gov.fnal.eag.healpix.test.PixToolsSingletonTest
tests conversion from vector to pixel number
testVect2Pix_ring() - Method in class gov.fnal.eag.healpix.test.PixToolsStaticTest
tests conversion from vector to pixel number
testVect2Pix_ring() - Method in class gov.fnal.eag.healpix.test.PixToolsTest
tests conversion from vector to pixel number
testVertexes() - Method in class gov.fnal.eag.healpix.test.PixToolTest1
with NSIDE 512
testVertexesHR() - Method in class gov.fnal.eag.healpix.test.PixToolTest1
with high res.
tetMax - Variable in class gov.fnal.eag.healpix.Region
 
tetMin - Variable in class gov.fnal.eag.healpix.Region
 
ThreadTest - Class in gov.fnal.eag.healpix.test
The thread proof test by Mark Teylor
ThreadTest() - Constructor for class gov.fnal.eag.healpix.test.ThreadTest
 
ThreadTest.Worker - Class in gov.fnal.eag.healpix.test
 
ThreadTest.Worker(long, Vector3d, double, int, int) - Constructor for class gov.fnal.eag.healpix.test.ThreadTest.Worker
 
tools - Static variable in class gov.fnal.eag.healpix.test.PixToolTest1
 
TWOPI - Static variable in class gov.fnal.eag.healpix.PixTools
 
TWOPI - Static variable in class gov.fnal.eag.healpix.Region
 
TWOPI - Static variable in class gov.fnal.eag.healpix.test.RegionTest
 
twothird - Static variable in class gov.fnal.eag.healpix.PixTools
 

V

Vect2Ang(Vector3d) - Method in class gov.fnal.eag.healpix.PixTools
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
vect2pix_nest(long, Vector3d) - Method in class gov.fnal.eag.healpix.PixTools
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.
vect2pix_ring(long, Vector3d) - Method in class gov.fnal.eag.healpix.PixTools
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
vector_ - Variable in class gov.fnal.eag.healpix.test.ThreadTest.Worker
 
VectProd(Vector, Vector) - Method in class gov.fnal.eag.healpix.PixTools
calculates a vector production of two vectors.
vertices - Variable in class gov.fnal.eag.healpix.Region
 

W

workPixtools(boolean) - Method in class gov.fnal.eag.healpix.test.ThreadTest
 

X

x2pix - Static variable in class gov.fnal.eag.healpix.PixTools
 
xmax - Static variable in class gov.fnal.eag.healpix.PixTools
 
xmid - Static variable in class gov.fnal.eag.healpix.PixTools
 
xy2pix_nest(long, long, long, long) - Method in class gov.fnal.eag.healpix.PixTools
gives the pixel number ipix (NESTED) corresponding to ix, iy and face_num
xyzToPolar(double, double, double) - Method in class gov.fnal.eag.healpix.PixTools
returns polar coordinates of a point on unit sphere given Cartesian coordinates

Y

y2pix - Static variable in class gov.fnal.eag.healpix.PixTools
 
A B C D E G H I M N O P Q R S T V W X Y 
eag-HEALPix-master/doc/index.html000066400000000000000000000027221315400615200170350ustar00rootroot00000000000000 javadoc for PixTools <noscript> <div>JavaScript is disabled on your browser.</div> </noscript> <h2>Frame Alert</h2> <p>This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. Link to <a href="overview-summary.html">Non-frame version</a>.</p> eag-HEALPix-master/doc/overview-frame.html000066400000000000000000000015341315400615200206640ustar00rootroot00000000000000 Overview List (javadoc for PixTools)

 

eag-HEALPix-master/doc/overview-summary.html000066400000000000000000000076621315400615200212770ustar00rootroot00000000000000 Overview (javadoc for PixTools)
Packages 
Package Description
gov.fnal.eag.healpix
EAG HEALPix
gov.fnal.eag.healpix.test
Junit tests for EAG HEALPix project
eag-HEALPix-master/doc/overview-tree.html000066400000000000000000000161401315400615200205300ustar00rootroot00000000000000 Class Hierarchy (javadoc for PixTools)

Hierarchy For All Packages

Package Hierarchies:

Class Hierarchy

eag-HEALPix-master/doc/package-list000066400000000000000000000000571315400615200173260ustar00rootroot00000000000000gov.fnal.eag.healpix gov.fnal.eag.healpix.test eag-HEALPix-master/doc/packages.html000066400000000000000000000015021315400615200174770ustar00rootroot00000000000000 (javadoc for PixTools)


The front page has been relocated.Please see:
          Frame version
          Non-frame version.
eag-HEALPix-master/doc/resources/000077500000000000000000000000001315400615200170475ustar00rootroot00000000000000eag-HEALPix-master/doc/resources/background.gif000066400000000000000000000044111315400615200216550ustar00rootroot00000000000000GIF89a2p=[q>\r?]sCby@^tDczA_uKmVz<[q=\r<[p>]s=\q;YmBbyAaw?^t>]rXfcIs( gxrIhCN)nB!9_<]x>c|bYi 7`mڪkҚj  kJ˫F{+Z~[l2˭R{{n*n o;-oΫ;̯n+ G;ƽ[q$;l2[/+{˱+r:/65;sq;#3&M̲@ ¼tC\QSV?ݵ^,p mZ7kqL:-KMpށtSvn uH#0wyB. @E1z騗>:驫~:꯷:;Nz޺z»>|N<7_<~'_?O7{~~݋_=ۧ{o@?Տ@0~^7A{TUB;aF ) Ђ" a SHB5Px &b(@jqc7FЇ^DaXQd4nw@# }A @#)H> iπsD'-OxB3ѹP`vդ@P3%I۩ДmH PN~g; Ӑ t'MSt Cg*ΒED*SJjSYJЏ4Kj,GQ4Z=+J_Ւ1jO0$ I+^W~_kWuիaֱ}d#ZlcKY6Eh;v=brVk+Kھ6ejS Z6jWڽV%m6-.t{;ֺՕ-n[i r䅬t]^Ve:udK_0z+YMe[_7px8M{^µ%\651|K7™ pA x;c!=qZ@j AJ$?J!JBڣZ MZVX a*gLʥM7ljڦ[e5*-:i(]|*j vU 2j4:;Jzڦ9A`jApʩکZZJڪꪰ ꪵjj ʫȚ*JjՊ ʬªjJຮzڭʮ뺭گJ蚮:z ۰j њ* k{۫k+,[Z[밚*.0*=K9{;:F{B[:J7Zڴ*R ʳZ ?KjZ-˩A0/"!k ot+vKozs;vx~붂|+ w[{۸u+}K˷ {k{kۺ KK[rK{[빨ۻλ;{;{ K˼ܻ۷ҫ曾뻰۾[ۼ; ;˿+k~; \l[{{kK!, <{̺웿٫ 0-!@#000?\@~k>nN_^mny藾扞N>((?)O( o //O  &O'* /!?)!?,;2O_.?$/%OJF?W6O"?=/_VoUd9^f_hlC?T?n/bC?uJjN[m|_j/op_o7Q<?OlO_//_t?_oxO-+,,,ÓʘӺƹׯȏȠ⥎ı Fm]X <ʡ~2rY&=Jj$ip‹ uxR"~UgǂB Gj) K2iUJJjTVUu,٦`jMm[XԬ\v-[]n{vk޺u`!7ak3eɠ'6qeΑ/?\4^ԟU;Ypڑ^tyᙟ^x݊kj,nǾKv[bԚ+/z쩪* .2@wX܁c1xq"o(|r'L-qӌ13/k= 3<4E"|AoQOP'MuK)Smu>:/KO]lh>@0p T(. @ VpChA z'` %P, _І&$?HRPԡ [(q7Da C&:3$!XDF"A(갃^b(F,0Uh'qjxE&ЍsdF<0["Q:oE@h d!y6񎋄GA IJ&ѓT$(EI4#S9HFNcyIR"D(OJKĠ})S%2[M.ͬ"9MnV \+)gnD'gylR;oiKd̥5?@ π5AЂ6CP'Cщ4G-χT%%iDQzP *(K]Q:43Nszѝ4,}iP+:T)R}jԟ7S:UVݨRUzҨ:դLiQӄtcjVVZuX(ZR>tR\W•c=+Wc ӽ~*DiZV"McKFv^5KYVvl^?R=^;ҺujY [2ֳukl*؅fvmS[vbkWZ6kmUs[ׁ^+_;[]lXW+&wy.tbE)JsvI LsӔg0`S\,g- S{7 Oֻ-rܷ~آ-}RMUlZ֮p maOصa;uvk~F7Ukus;VjZkp;n kw˾7dGF|ߪ|v8O+kێ|%An[($x p.e#ds ]K>.Htr"MNw3hLf΍f`9(9=z2,e9Yl]a_\ab]K4oKΉW:N=f~d3Mvw΁f{їH?y~SvnQ[m>p咵Mrl7o8zuw7ok߇ĥ>仧wOZrW˿}$G5{>gm͆pqFoH~#eo|Wq~qlp~~kHro}+~&ȂQ }6W-h1q&(q.X_sfvsgxW{Ry]C Ԅnwt7fxHdwvZyW'f6{Z&vySsdtWhzz{&wybyq`7VeD{Dž4xsW~8LuQeqc`xyu$zTxs{({xzzfAM(sM]gaCwxuyhvxhCXȇ^7HxwWm(hl(dFhSFt(oƉxouVd茮8YI؍[8y Y?ǎPY`莇W~?Xtzs؋Mh秀X*X|9x8('؀=G]Aj(|FqhqE'䷔(ڷ\ǃ֗rAHXM k: h9헂&%GV6~Q9jiC tYT)Wey]iـWƀ){ W)AGWoyiŋu'0GXyU8#%GdKL) LĹz$9vNǏhəiwH牜Ȉ,ɛyxyXBy}(`cy%ٟɠRvogv9IݙY L4If8陗FR8VIXiZIxGAɔǖ$x:U5*FfYCzȕ9Iǚz闣I>&ꁥ٤L=H7o"P:餌iٗvWEږ\7[9p9;nz0z{R)/ j:@1 [G i "  j y ^&鍠v j J#zڞڙ9:yo(HHj "*|ĮڮĄ鑿M% ,_(բN9n^:4Z2xVm:p J Y{ۥ+iu*}!]}B&ɗtU3{/1@۱$;z/՘@)ڲ)Rjj{00}ob;A{8+`II󕟧:۫*١ȫ˷ʐ cjz۷HFϩuWڎZyJ Gג>Ǻ޺C jc;t;$z{Kp[ iٰlkMVkD[ZKjk[h~ʩۻ`kn6*,[>{=d+;\QiU<֦57o%47kPpa@Ԡ`#E3V 1Ȅ/B 2DI"LN列0Yx9s H@O;uP`ĉ%Pj4i '$@A5 WX;6X +0Lؠ!C p}m 0`A_ymAB<8܁1"SÇ-c "@"BiӡIbr̝7g ZӧUnMYlٱ?:5nޯ1|Boؾ9kn4n㫑^.pEw=o<['^7k7>xDL H ( ;eag-HEALPix-master/doc/serialized-form.html000066400000000000000000000074611315400615200210270ustar00rootroot00000000000000 Serialized Form (javadoc for PixTools)

Serialized Form

eag-HEALPix-master/doc/stylesheet.css000066400000000000000000000025571315400615200177510ustar00rootroot00000000000000/* Javadoc style sheet */ /* Define colors, fonts and other style attributes here to override the defaults */ /* Page background color */ body { background-color: #FFFFFF; color:#000000 } /* Headings */ h1 { font-size: 145% } /* Table colors */ .TableHeadingColor { background: #CCCCFF; color:#000000 } /* Dark mauve */ .TableSubHeadingColor { background: #EEEEFF; color:#000000 } /* Light mauve */ .TableRowColor { background: #FFFFFF; color:#000000 } /* White */ /* Font used in left-hand frame lists */ .FrameTitleFont { font-size: 100%; font-family: Helvetica, Arial, sans-serif; color:#000000 } .FrameHeadingFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif; color:#000000 } .FrameItemFont { font-size: 90%; font-family: Helvetica, Arial, sans-serif; color:#000000 } /* Navigation bar fonts and colors */ .NavBarCell1 { background-color:#EEEEFF; color:#000000} /* Light mauve */ .NavBarCell1Rev { background-color:#00008B; color:#FFFFFF} /* Dark Blue */ .NavBarFont1 { font-family: Arial, Helvetica, sans-serif; color:#000000;color:#000000;} .NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;color:#FFFFFF;} .NavBarCell2 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000} .NavBarCell3 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF; color:#000000} eag-HEALPix-master/gov/000077500000000000000000000000001315400615200150635ustar00rootroot00000000000000eag-HEALPix-master/gov/fnal/000077500000000000000000000000001315400615200160035ustar00rootroot00000000000000eag-HEALPix-master/gov/fnal/eag/000077500000000000000000000000001315400615200165375ustar00rootroot00000000000000eag-HEALPix-master/gov/fnal/eag/healpix/000077500000000000000000000000001315400615200201715ustar00rootroot00000000000000eag-HEALPix-master/gov/fnal/eag/healpix/.gitignore000066400000000000000000000001341315400615200221570ustar00rootroot00000000000000/BitManipulation.class /HealpixException.class /PixInfo.class /PixTools.class /Region.class eag-HEALPix-master/gov/fnal/eag/healpix/BitManipulation.java000066400000000000000000000062201315400615200241330ustar00rootroot00000000000000/* * Created on Mar 15, 2005 * */ package gov.fnal.eag.healpix; /** * * * bit manipulation class derived from Healpix * fortran90 program. * * @author N Kuropatkin */ public final class BitManipulation { /** * magic1 odd bits set constant */ private static long magic1 = 89478485; // 101010101010101010101010101 LSB /** * magic2 - even bits set constant */ private static long magic2 = 178956970; //1010101010101010101010101010 MSB /** * swaps low and high bits in the word i * @param i integer input word * @return int a word with odd and even bits interchanged */ public static long swapLSBMSB(long i) { long res = 0; long lsb = (i & magic1); long msb = (i & magic2); res = msb/2 + lsb*2; return res; } /** * returns NOT i with even and odd bit positions interchanged * @param i int input word * @return int NOT (i with LSBMSB) */ public static long invswapLSBMSB(long i) { long res = 0; long lsb = (i & magic1); long msb = (i & magic2); res = ~(msb/2+lsb*2); return res; } /** * returns i with even bits inverted * @param i int input word * @return int word with modified bits */ public static long invLSB(long i) { long res = 0; res = (i ^ magic1); // returns exclusive OR with odd bits return res; } /** * returns i with odd bits inverted * @param i int input word * @return int word with modified bits */ public static long invMSB(long i) { long res = 0; res = (i ^ magic2); return res; } /** * simulates behaviour of fortran90 MODULO function * @param a double * @param b double * @return double MODULO */ public static double MODULO(double a, double b) { double res = 0.; double c = 0; long k = 0; if (a>0.) { if (b>0.) { k = (long) (a/b); res = a - k*b; return res; } if (b<0.) { k = (long)Math.rint(a/b); res = a - k*b; return res; } } if (a<=0.) { if (b<=0.) { k = (long)(a/b); res = a - k*b; return res; } if (b>0.) { k = (long)Math.rint(a/b); res = a - k*b; return res; } } return res; } /** * the main program for simple test * @param pars */ public static void main(String[] pars) { // BitManipulation bm = new BitManipulation(); int l=0; int k = 1; long lsb; long msb; long mag1=0;; long mag2=0;; for (int i = 0; i<32; i++) { mag1 += Math.pow(2.,l); mag2 += Math.pow(2.,k); System.out.println("l="+l+" mag1="+ mag1+" mag2="+mag2); l +=2; k +=2; } l = 0; k = 1; for (int i=0; i < 21; i++) { lsb = (long)Math.pow(2.,l); msb = (long)Math.pow(2.,k); System.out.println(" l="+l+" 2^l="+lsb+" l="+k+" 2^l="+msb); l +=2; k +=2; } // BitManipulation bm = new BitManipulation(); double a= 6004765143422312.; double b = BitManipulation.MODULO(a, 16.); System.out.println("a="+a+" MODULO(1024)="+b); } } eag-HEALPix-master/gov/fnal/eag/healpix/HealpixException.java000066400000000000000000000006331315400615200243070ustar00rootroot00000000000000/* * Created on Apr 14, 2005 * */ package gov.fnal.eag.healpix; /** * handles exceptions from this package * *@author N. Kuropatkin */ public class HealpixException extends Exception { /** * */ private static final long serialVersionUID = 1L; /** * message - String to be printed in case of exception * @param message */ public HealpixException(String message) { super(message); } } eag-HEALPix-master/gov/fnal/eag/healpix/PixInfo.java000066400000000000000000000005651315400615200224160ustar00rootroot00000000000000package gov.fnal.eag.healpix; import javax.vecmath.Vector3d; /** * Aggregates a vector and double[3][4] array which are the results of a * pixel center calculation. */ class PixInfo { final Vector3d pixVect; final double[][] pixVertex; PixInfo(Vector3d pixVect, double[][] pixVertex) { this.pixVect = pixVect; this.pixVertex = pixVertex; } } eag-HEALPix-master/gov/fnal/eag/healpix/PixTools.java000066400000000000000000003532211315400615200226230ustar00rootroot00000000000000package gov.fnal.eag.healpix; import java.util.ArrayList; import java.util.Arrays; import java.util.Vector; import java.io.FileNotFoundException; import java.io.PrintStream; import java.lang.Number; import javax.vecmath.Vector3d; /** * * contains methods translated from HEALPix Fortran90 * with increased map resolution in comparison to original Fortran code. * * @author N Kuropatkin * * Created on Mar 10, 2005 * Modified on December 18 2007 * Corrected arithmetic and mistyping April 20 2008 * * @author Mark Taylor made modifications to make the class thread safe 11-Jan-2012 * *

* All methods are thread safe. This class can be used as a singleton, * the singleton instance being available from the {@link #getInstance} method. * For compatibility with previous versions however it is possible to * construct new instances using the default constructor. *

* */ public class PixTools { private static final double twothird = 2. / 3.; private static final double PI = Math.PI; private static final double TWOPI = 2. * PI; private static final double HALFPI = PI / 2.0; private static final int ns_max = 1048576; // 2^20 // private static final int xmax = 4096; // private static final int pixmax = 262144; // private static final int xmid = 512; private static final long[] x2pix = new long[xmax+1]; private static final long[] y2pix = new long[xmax+1]; private static final long[] pix2x = new long[pixmax+1]; private static final long[] pix2y = new long[pixmax+1]; static { mk_xy2pix(); } /** Singleton instance. */ private static final PixTools pixTools = new PixTools(); /** * default constructor * * */ public PixTools() { } /** * 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 * * @param nside * long the map resolution parameter * @param theta1 * lower edge of the colatitude * @param theta2 * upper edge of the colatitude * @param nest * long if = 1 result is in NESTED scheme * @return ArrayList of pixel numbers (long) * @throws Exception * @throws IllegalArgumentException */ public ArrayList query_strip(long nside, double theta1, double theta2, long nest) throws Exception { ArrayList res = new ArrayList(); ArrayList listir = new ArrayList(); long npix, nstrip; long iz, irmin, irmax; int is; double phi0, dphi; double[] colrange = new double[4]; boolean nest_flag = false; String SID = " QUERY_STRIP"; /* ---------------------------------------- */ npix = Nside2Npix(nside); if (nest == 1) nest_flag = true; if (npix < 0) { throw new IllegalArgumentException(SID + " Nside should be power of 2"); } if ((theta1 < 0.0 || theta1 > PI) || (theta2 < 0.0 || theta2 > PI)) { throw new IllegalArgumentException(SID + " Illegal value of theta1, theta2"); } if (theta1 <= theta2) { nstrip = 1; colrange[0] = theta1; colrange[1] = theta2; } else { nstrip = 2; colrange[0] = 0.0; colrange[1] = theta2; colrange[2] = theta1; colrange[3] = PI; } /* loops on strips */ for (is = 0; is < nstrip; is++) { irmin = RingNum(nside, Math.cos(colrange[2 * is])); irmax = RingNum(nside, Math.cos(colrange[2 * is + 1])); /* loop on ring number */ for (iz = irmin; iz <= irmax; iz++) { phi0 = 0.; dphi = PI; listir = InRing(nside, iz, phi0, dphi, nest_flag); res.addAll(listir); } } return res; } /** * finds pixels that lay within a CONVEX polygon defined by its vertex on * sphere * * @param nside * the map resolution * @param vlist * ArrayList of vectors defining the polygon vertices * @param nest * if set to 1 use NESTED scheme * @param inclusive * if set 1 returns all pixels crossed by polygon boundaries * @return ArrayList of pixels * * algorithm: the polygon is divided into triangles vertex 0 belongs to all * triangles * @throws Exception * @throws IllegalArgumentException */ public ArrayList query_polygon(long nside, ArrayList vlist, long nest, long inclusive) throws Exception { ArrayList res = new ArrayList(); int nv = vlist.size(); Vector3d vp0, vp1, vp2; Vector3d vo; ArrayList vvlist = new ArrayList(); // double surface, fsky; double hand; double[] ss = new double[nv]; // int n_in_trg, ilist, ntl; long npix; int ix = 0; int n_remain, np, nm, nlow; String SID = "QUERY_POLYGON"; // System.out.println("Start polygon"); for (int k = 0; k < nv; k++) ss[k] = 0.; /* -------------------------------------- */ n_remain = nv; if (n_remain < 3) { throw new IllegalArgumentException(SID + " Number of vertices should be >= 3"); } /*---------------------------------------------------------------- */ /* Check that the poligon is convex or has only one concave vertex */ /*---------------------------------------------------------------- */ int i0 = 0; int i2 = 0; if (n_remain > 3) { // a triangle is always convex for (int i1 = 1; i1 <= n_remain - 1; i1++) { // in [0,n_remain-1] i0 = (int) BitManipulation.MODULO(i1 - 1, n_remain); i2 = (int) BitManipulation.MODULO(i1 + 1, n_remain); vp0 = (Vector3d) vlist.get(i0); // select vertices by 3 // neighbour vp1 = (Vector3d) vlist.get(i1); vp2 = (Vector3d) vlist.get(i2); // computes handedness (v0 x v2) . v1 for each vertex v1 vo = new Vector3d(crossProduct(vp0, vp2)); hand = dotProduct(vo, vp1); if (hand >= 0.) { ss[i1] = 1.0; } else { ss[i1] = -1.0; } } np = 0; // number of vert. with positive handedness for (int i = 0; i < nv; i++) { if (ss[i] > 0.) np++; } nm = n_remain - np; nlow = Math.min(np, nm); if (nlow != 0) { if (nlow == 1) { // only one concave vertex if (np == 1) { // ix index of the vertex in the list for (int k = 0; k < nv - 1; k++) { if (Math.abs(ss[k] - 1.0) <= 1.e-12) { ix = k; break; } } } else { for (int k = 0; k < nv - 1; k++) { if (Math.abs(ss[k] + 1.0) <= 1.e-12) { ix = k; break; } } } // rotate pixel list to put that vertex in #0 int n_rot = vlist.size() - ix; int ilast = vlist.size() - 1; for (int k = 0; k < n_rot; k++) { Vector3d temp = new Vector3d((Vector3d) vlist .get(ilast)); vlist.remove(ilast); vlist.add(0, temp); } } if (nlow > 1) { // more than 1concave vertex System.out .println(" The polygon has more than one concave vertex"); System.out.println(" The result is unpredictable"); } } } /* fill the polygon, one triangle at a time */ npix = (long) Nside2Npix(nside); while (n_remain >= 3) { vp0 = (Vector3d) vlist.get(0); vp1 = (Vector3d) vlist.get(n_remain - 2); vp2 = (Vector3d) vlist.get(n_remain - 1); /* find pixels within the triangle */ ArrayList templist = new ArrayList(); templist = query_triangle(nside, vp0, vp1, vp2, nest, inclusive); vvlist.addAll(templist); n_remain--; } /* make final pixel list */ npix = vvlist.size(); long[] pixels = new long[(int)npix]; for (int i = 0; i < npix; i++) { pixels[i] = ((Long) vvlist.get(i)).longValue(); } Arrays.sort(pixels); int k = 0; res.add(k, new Long(pixels[0])); for (int i = 1; i < pixels.length; i++) { if (pixels[i] > pixels[i - 1]) { k++; res.add(k, new Long(pixels[i])); } } return res; } /** * generates a list of pixels that lay inside a triangle defined by * the three vertex vectors * * @param nside * long map resolution parameter * @param v1 * Vector3d defines one vertex of the triangle * @param v2 * Vector3d another vertex * @param v3 * Vector3d yet another one * @param nest * long 0 (default) RING numbering scheme, if set to 1 the NESTED * scheme will be used. * @param 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 listed * @return ArrayList with pixel numbers * @throws Exception * @throws IllegalArgumentException */ public ArrayList query_triangle(long nside, Vector3d v1, Vector3d v2, Vector3d v3, long nest, long inclusive) throws Exception { ArrayList res; res = new ArrayList(); ArrayList listir; long npix, iz, irmin, irmax, n12, n123a, n123b, ndom = 0; boolean test1, test2, test3; boolean test1a, test1b, test2a, test2b, test3a, test3b; double dth1, dth2, determ, sdet; double zmax, zmin, z1max, z1min, z2max, z2min, z3max, z3min; double z, tgth, st, offset, sin_off; double phi_pos, phi_neg; Vector3d[] vv = new Vector3d[3]; Vector3d[] vo = new Vector3d[3]; double[] sprod = new double[3]; double[] sto = new double[3]; double[] phi0i = new double[3]; double[] tgthi = new double[3]; double[] dc = new double[3]; double[][] dom = new double[3][2]; double[] dom12 = new double[4]; double[] dom123a = new double[4]; double[] dom123b = new double[4]; double[] alldom = new double[6]; double a_i, b_i, phi0, dphiring; long idom; // long nir, ip, status; boolean do_inclusive = false; boolean do_nest = false; String SID = "QUERY_TRIANGLE"; long nsidesq = nside * nside; /* */ // System.out.println("in query_triangle"); npix = Nside2Npix(nside); if (npix < 0) { throw new IllegalArgumentException(SID + " Nside should be power of 2 >0 and < "+ns_max); } if (inclusive == 1) do_inclusive = true; if (nest == 1) do_nest = true; vv[0] = new Vector3d(v1); vv[0].normalize(); vv[1] = new Vector3d(v2); vv[1].normalize(); vv[2] = new Vector3d(v3); vv[2].normalize(); /* */ dth1 = 1.0 / (3.0 * nsidesq); dth2 = 2.0 / (3.0 * nside); /* * determ = (v1 X v2) . v3 determines the left ( <0) or right (>0) * handedness of the triangle */ Vector3d vt = new Vector3d(0., 0., 0.); vt = crossProduct(vv[0], vv[1]); determ = dotProduct(vt, vv[2]); if (Math.abs(determ) < 1.0e-20) { throw new HealpixException( SID + ": the triangle is degenerated - query cannot be performed"); } if (determ >= 0.) { // The sign of determinant sdet = 1.0; } else { sdet = -1.0; } sprod[0] = dotProduct(vv[1], vv[2]); sprod[1] = dotProduct(vv[2], vv[0]); sprod[2] = dotProduct(vv[0], vv[1]); /* vector orthogonal to the great circle containing the vertex doublet */ vo[0] = crossProduct(vv[1], vv[2]); vo[1] = crossProduct(vv[2], vv[0]); vo[2] = crossProduct(vv[0], vv[1]); vo[0].normalize(); vo[1].normalize(); vo[2].normalize(); /* test presence of poles in the triangle */ zmax = -1.0; zmin = 1.0; test1 = (vo[0].z * sdet >= 0.0); // north pole in hemisphere defined by // 2-3 test2 = (vo[1].z * sdet >= 0.0); // north pole in the hemisphere defined // by 1-2 test3 = (vo[2].z * sdet >= 0.0); // north pole in hemisphere defined by // 1-3 if (test1 && test2 && test3) zmax = 1.0; // north pole in the triangle if ((!test1) && (!test2) && (!test3)) zmin = -1.0; // south pole in the triangle /* look for northenest and southernest points in the triangle */ test1a = ((vv[2].z - sprod[0] * vv[1].z) >= 0.0); // segment 2-3 test1b = ((vv[1].z - sprod[0] * vv[2].z) >= 0.0); test2a = ((vv[2].z - sprod[1] * vv[0].z) >= 0.0); // segment 1-3 test2b = ((vv[0].z - sprod[1] * vv[2].z) >= 0.0); test3a = ((vv[1].z - sprod[2] * vv[0].z) >= 0.0); // segment 1-2 test3b = ((vv[0].z - sprod[2] * vv[1].z) >= 0.0); /* sin of theta for orthogonal vector */ for (int i = 0; i < 3; i++) { sto[i] = Math.sqrt((1.0 - vo[i].z) * (1.0 + vo[i].z)); } /* * for each segment ( side of the triangle ) the extrema are either - * -the 2 vertices - one of the vertices and a point within the segment */ // segment 2-3 z1max = vv[1].z; z1min = vv[2].z; // if (test1a == test1b) { // zz = sto[0]; // if (vv[1].z + vv[2].z >= 0.0) { // z1max = zz; // } else { // z1min = -zz; // } // } // segment 1-3 z2max = vv[2].z; z2min = vv[0].z; // if (test2a == test2b) { // zz = sto[1]; // if (vv[0].z + vv[2].z >= 0.0) { // z2max = zz; // } else { // z2min = -zz; // } // } // segment 1-2 z3max = vv[0].z; z3min = vv[1].z; // if (test3a == test3b) { // zz = sto[2]; // if (vv[0].z + vv[1].z >= 0.0) { // z3max = zz; // } else { // z3min = -zz; // } // } zmax = Math.max(Math.max(z1max, z2max), Math.max(z3max, zmax)); zmin = Math.min(Math.min(z1min, z2min), Math.min(z3min, zmin)); /* * if we are inclusive, move upper point up, and lower point down, by a * half pixel size */ offset = 0.0; sin_off = 0.0; if (do_inclusive) { offset = PI / (4.0 * nside); // half pixel size sin_off = Math.sin(offset); zmax = Math.min(1.0, Math.cos(Math.acos(zmax) - offset)); zmin = Math.max(-1.0, Math.cos(Math.acos(zmin) + offset)); } irmin = RingNum(nside, zmax); irmax = RingNum(nside, zmin); // System.out.println("irmin = " + irmin + " irmax =" + irmax); /* loop on the rings */ for (int i = 0; i < 3; i++) { tgthi[i] = -1.0e30 * vo[i].z; phi0i[i] = 0.0; } for (int j = 0; j < 3; j++) { if (sto[j] > 1.0e-10) { tgthi[j] = -vo[j].z / sto[j]; // - cotan(theta_orth) phi0i[j] = Math.atan2(vo[j].y, vo[j].x); // Should make it 0-2pi // ? /* Bring the phi0i to the [0,2pi] domain if need */ if (phi0i[j] < 0.) { phi0i[j] = BitManipulation.MODULO( (Math.atan2(vo[j].y, vo[j].x) + TWOPI), TWOPI); // [0-2pi] } } } /* * the triangle boundaries are geodesics: intersection of the sphere * with plans going through (0,0,0) if we are inclusive, the boundaries * are the intersection of the sphere with plains pushed outward by * sin(offset) */ // double temp = 0.; boolean found = false; for (iz = irmin; iz <= irmax; iz++) { found = false; if (iz <= nside - 1) { // North polar cap z = 1.0 - iz * iz * dth1; } else if (iz <= 3 * nside) { // tropical band + equator z = (2.0 * nside - iz) * dth2; } else { z = -1.0 + (4.0 * nside - iz) * (4.0 * nside - iz) * dth1; } /* computes the 3 intervals described by the 3 great circles */ st = Math.sqrt((1.0 - z) * (1.0 + z)); tgth = z / st; // cotan(theta_ring) for (int j = 0; j < 3; j++) { dc[j] = tgthi[j] * tgth - sdet * sin_off / ((sto[j] + 1.0e-30) * st); } for (int k = 0; k < 3; k++) { if (dc[k] * sdet <= -1.0) { // the whole iso-latitude ring is on // right side of the great circle dom[k][0] = 0.0; dom[k][1] = TWOPI; } else if (dc[k] * sdet >= 1.0) { // all on the wrong side dom[k][0] = -1.000001 * (k + 1); dom[k][1] = -1.0 * (k + 1); } else { // some is good some is bad phi_neg = phi0i[k] - (Math.acos(dc[k]) * sdet); phi_pos = phi0i[k] + (Math.acos(dc[k]) * sdet); // if (phi_pos < 0.) phi_pos += TWOPI; if (phi_neg < 0.) phi_neg += TWOPI; // dom[k][0] = BitManipulation.MODULO(phi_neg, TWOPI); dom[k][1] = BitManipulation.MODULO(phi_pos, TWOPI); } // } /* identify the intersections (0,1,2 or 3) of the 3 intervals */ dom12 = intrs_intrv(dom[0], dom[1]); n12 = dom12.length / 2; if (n12 != 0) { if (n12 == 1) { dom123a = intrs_intrv(dom[2], dom12); n123a = dom123a.length / 2; if (n123a == 0) found = true; if (!found) { for (int l = 0; l < dom123a.length; l++) { alldom[l] = dom123a[l]; } ndom = n123a; // 1 or 2 } } if (!found) { if (n12 == 2) { double[] tmp = { dom12[0], dom12[1] }; dom123a = intrs_intrv(dom[2], tmp); double[] tmp1 = { dom12[2], dom12[3] }; dom123b = intrs_intrv(dom[2], tmp1); n123a = dom123a.length / 2; n123b = dom123b.length / 2; ndom = n123a + n123b; // 0, 1, 2 or 3 if (ndom == 0) found = true; if (!found) { if (n123a != 0) { for (int l = 0; l < 2 * n123a; l++) { alldom[l] = dom123a[l]; } } if (n123b != 0) { for (int l = 0; l < 2 * n123b; l++) { alldom[(int) (l + 2 * n123a)] = dom123b[l]; } } if (ndom > 3) { throw new HealpixException(SID + ": too many intervals found"); } } } } if (!found) { for (idom = 0; idom < ndom; idom++) { a_i = alldom[(int) (2 * idom)]; b_i = alldom[(int) (2 * idom + 1)]; phi0 = (a_i + b_i) / 2.0; dphiring = Math.abs(b_i - a_i) / 2.0; if (dphiring < 0.0) { phi0 += PI; dphiring += PI; } /* finds pixels in the triangle on that ring */ listir = InRing(nside, iz, phi0, dphiring, do_nest); res.addAll(listir); } } } } return res; } /** * 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 b1 then d1 = {x | a1 <=x <= B U A <=x * <=b1} * * @param d1 double[] first interval * @param d2 double[] second interval * @return double[] one or two intervals intersections */ public double[] intrs_intrv(double[] d1, double[] d2) { double[] res; double epsilon = 1.0e-10; // double temp = 0.; // int ni; double[] dk; double[] di = { 0. }; int ik = 0; boolean tr12, tr21, tr34, tr43, tr13, tr31, tr24, tr42, tr14, tr32; /* */ tr12 = (d1[0] < d1[1] + epsilon); tr21 = !tr12; // d1[0] >= d1[1] tr34 = (d2[0] < d2[1] + epsilon); tr43 = !tr34; // d2[0]>d2[1] tr13 = (d1[0] < d2[0] + epsilon); // d2[0] can be in interval tr31 = !tr13; // d1[0] in longerval tr24 = (d1[1] < d2[1] + epsilon); // d1[1] upper limit tr42 = !tr24; // d2[1] upper limit tr14 = (d1[0] < d2[1] + epsilon); // d1[0] in interval tr32 = (d2[0] < d1[1] + epsilon); // d2[0] in interval ik = 0; dk = new double[] { -1.0e9, -1.0e9, -1.0e9, -1.0e9 }; /* d1[0] lower limit case 1 */ if ((tr34 && tr31 && tr14) || (tr43 && (tr31 || tr14))) { ik++; // ik = 1; dk[ik - 1] = d1[0]; // a1 } /* d2[0] lower limit case 1 */ if ((tr12 && tr13 && tr32) || (tr21 && (tr13 || tr32))) { ik++; // ik = 1 dk[ik - 1] = d2[0]; // a2 } /* d1[1] upper limit case 2 */ if ((tr34 && tr32 && tr24) || (tr43 && (tr32 || tr24))) { ik++; // ik = 2 dk[ik - 1] = d1[1]; // b1 } /* d2[1] upper limit case 2 */ if ((tr12 && tr14 && tr42) || (tr21 && (tr14 || tr42))) { ik++; // ik = 2 dk[ik - 1] = d2[1]; // b2 } di = new double[1]; di[0] = 0.; switch (ik) { case 2: di = new double[2]; di[0] = dk[0] - epsilon; di[1] = dk[1] + epsilon; break; case 4: di = new double[4]; di[0] = dk[0] - epsilon; di[1] = dk[3] + epsilon; di[2] = dk[1] - epsilon; di[3] = dk[2] + epsilon; break; } res = di; return res; } /** * an obsolete method. Use query_disc instead. * * @param nside * @param vector0 * @param radius * @return - ArrayList of long */ public ArrayList getDisc_ring(long nside, Vector3d vector0, double radius) { ArrayList res; int nest = 0; int inclusive = 0; res = query_disc(nside, vector0, radius, nest, inclusive); return res; } /** * generates in the RING or NESTED scheme all pixels that lays within an * angular distance Radius of the center. * * @param nside * long map resolution * @param vector * Vector3d pointing to the disc center * @param radius * double angular radius of the disc (in RADIAN ) * @param nest * int 0 (default) if output is in RING scheme, if set to 1 * output is in NESTED * @param inclusive * 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. * @return ArrayList of pixel numbers * * calls: RingNum(nside, ir) InRing(nside, iz, phi0, dphi,nest) vector2pix(nside,ipix) */ public ArrayList query_disc(long nside, Vector3d vector, double radius, int nest, int inclusive) { ArrayList res = new ArrayList(); long irmin, irmax, iz, ip, nir, npix, ilist; // double norm_vect0; double x0, y0, z0, radius_eff; double a, b, c, cosang; double dth1, dth2; double phi0, cosphi0, cosdphi, dphi; double rlat0, rlat1, rlat2, zmin, zmax, z; // long status, list_size, nlost; boolean do_inclusive = false; boolean do_nest = false; String SID = "QUERY_DISC"; /* */ long nsidesq = nside * nside; npix = 12 * nsidesq; double pixres = PixRes(nside); // in arc seconds // double halfPix = 0.5*Math.toRadians(pixres/3600.); // in radians double halfPix = PI / (4.0 * nside); // System.out.println("0.5 pixel size ="+halfPix); if (radius < 0.0 || radius > PI) { throw new IllegalArgumentException(SID + ": angular radius is in RADIAN and should be in [0,pi]"); } if (inclusive == 1) do_inclusive = true; if (nest == 1) do_nest = true; dth1 = 1.0 / (3.0 * nside * nside); dth2 = 2.0 / (3.0 * nside); radius_eff = radius; // if (radius_eff <= halfPix) radius_eff = halfPix; /* disc center */ vector.normalize(); x0 = vector.x; // norm_vect0; y0 = vector.y; // norm_vect0; z0 = vector.z; // norm_vect0; // System.out.println("x0="+x0+" y0="+y0+" z0="+z0); // // NK make radius increase a function of altitude // if (do_inclusive) { radius_eff += (halfPix + Math.abs(z0)*halfPix);} // increase radius for incluzive search // System.out.println("effective radius="+radius_eff); // if (do_inclusive) { radius_eff += halfPix;} cosang = Math.cos(radius_eff); phi0 = 0.0; dphi = 0.0; if (x0 != 0. || y0 != 0.) phi0 = BitManipulation.MODULO(Math.atan2(y0, x0) + TWOPI, TWOPI); // in [0, 2pi] cosphi0 = Math.cos(phi0); // System.out.println("phi0="+phi0+" cosphi0="+cosphi0); a = x0 * x0 + y0 * y0; /* coordinate z of highest and lowest points in the disc */ rlat0 = Math.asin(z0); // latitude in RAD of the center rlat1 = rlat0 + radius_eff; rlat2 = rlat0 - radius_eff; // System.out.println("rlat0="+rlat0+" rlat1="+rlat1+" rlat2="+rlat2); // if (rlat1 >= HALFPI) { zmax = 1.0; } else { zmax = Math.sin(rlat1); } irmin = RingNum(nside, zmax); irmin = Math.max(1, irmin - 1); // start from a higher point to be safe if (rlat2 <= -HALFPI) { zmin = -1.0; } else { zmin = Math.sin(rlat2); } irmax = RingNum(nside, zmin); irmax = Math.min(4 * nside - 1, irmax + 1); // go down to a lower point // System.out.println(" irmax="+irmax+" irmin="+irmin); ilist = -1; // /* loop on ring number */ for (iz = irmin; iz <= irmax; iz++) { if (iz <= nside - 1) { // north polar cap z = 1.0 - iz * iz * dth1; } else if (iz <= 3 * nside) { // tropical band + equator z = (2.0 * nside - iz) * dth2; } else { z = -1.0 + (4.0 * nside - iz) * (4.0 * nside - iz) * dth1; } /* find phi range in the disc for each z */ b = cosang - z * z0; c = 1.0 - z * z; cosdphi = b / Math.sqrt(a * c); long done = 0; if (Math.abs(x0) <= 1.0e-12 && Math.abs(y0) <= 1.0e-12) { cosdphi = -1.0; dphi = PI; done = 1; } if (done == 0) { if (Math.abs(cosdphi) <= 1.0) { dphi = Math.acos(cosdphi); // in [0,pi] } else { if (cosphi0 >= cosdphi) { dphi = PI; // all the pixels at this elevation are in // the disc } else { done = 2; // out of the disc } } } if (done < 2) { // pixels in disc /* find pixels in the disc */ // System.out.println("iz="+iz+" phi="+phi0+" dphi="+dphi); ArrayList listir = InRing(nside, iz, phi0, dphi, do_nest); // System.out.println("ir"+iz); res.addAll(listir); } } // // if radius less than pixel size check that the pixel number is in the list // and add one if it is missing. // long pixel = 0; if ( pixres > Math.toDegrees(radius)/3600. ) { // System.out.println("case with r < pix. size"); if (do_nest) { pixel = vect2pix_nest(nside,vector); } else { pixel = vect2pix_ring(nside,vector); } if (!res.contains(new Long(pixel))) res.add(new Long(pixel)); } return res; } /** * generates in the RING or NESTED scheme all pixels that lays at an * angular distance Radius of the center. * * @param nside * long map resolution * @param vector * Vector3d pointing to the ring center * @param radius * double angular radius of the ring (in RADIAN ) * @param nest * int 0 (default) if output is in RING scheme, if set to 1 * output is in NESTED * @param inclusive * int 0 (default) only pixels whose centers are crossed by the ring * are listed, if set to 1, all pixels crossed or touched by the ring * 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 ring lays completely * inside a pixel the pixel number is returned using vector2pix method. * @return ArrayList of pixel numbers * * calls: RingNum(nside, ir) InRing(nside, iz, phi0, dphi,nest) vector2pix(nside,ipix) */ public ArrayList query_ring(long nside, Vector3d vector, double radius, int nest, int inclusive) { ArrayList res = new ArrayList(); long irmin, irmax, iz, ip, nir, npix, ilist; // double norm_vect0; double x0, y0, z0, radius_eff; double a, b, c, cosang; double dth1, dth2; double phi0, cosphi0, cosdphi, dphi; double rlat0, rlat1, rlat2, zmin, zmax, z; // long status, list_size, nlost; boolean do_inclusive = false; boolean do_nest = false; String SID = "QUERY_RING"; /* */ long nsidesq = nside * nside; npix = 12 * nsidesq; double pixres = PixRes(nside); // in arc seconds // double halfPix = 0.5*Math.sqrt(PI / (3.0*npix)); // in radians double dr = 2.0*halfPix; // interval in phi // System.out.println("0.5 pixel size ="+halfPix); if (radius < 0.0 || radius > PI) { throw new IllegalArgumentException(SID + ": angular radius is in RADIAN and should be in [0,pi]"); } if (inclusive == 1) do_inclusive = true; if (nest == 1) do_nest = true; dth1 = 1.0 / (3.0 * nside * nside); dth2 = 2.0 / (3.0 * nside); radius_eff = radius; // if (radius_eff <= halfPix) radius_eff = halfPix; /* disc center */ vector.normalize(); x0 = vector.x; // norm_vect0; y0 = vector.y; // norm_vect0; z0 = vector.z; // norm_vect0; // System.out.println("x0="+x0+" y0="+y0+" z0="+z0); // // NK make radius increase a function of altitude // if (do_inclusive) { radius_eff += (halfPix + Math.abs(z0)*halfPix);} // increase radius for incluzive search // System.out.println("effective radius="+radius_eff); // if (do_inclusive) { radius_eff += halfPix;} cosang = Math.cos(radius_eff); phi0 = 0.0; dphi = 0.0; if (x0 != 0. || y0 != 0.) phi0 = BitManipulation.MODULO(Math.atan2(y0, x0) + TWOPI, TWOPI); // in [0, 2pi] cosphi0 = Math.cos(phi0); // System.out.println("phi0="+phi0+" cosphi0="+cosphi0); a = x0 * x0 + y0 * y0; /* coordinate z of highest and lowest points in the disc */ rlat0 = Math.asin(z0); // latitude in RAD of the center rlat1 = rlat0 + radius_eff; rlat2 = rlat0 - radius_eff; // System.out.println("rlat0="+rlat0+" rlat1="+rlat1+" rlat2="+rlat2); // if (rlat1 >= HALFPI) { zmax = 1.0; } else { zmax = Math.sin(rlat1); } irmin = RingNum(nside, zmax); irmin = Math.max(1, irmin - 1); // start from a higher point to be safe if (rlat2 <= -HALFPI) { zmin = -1.0; } else { zmin = Math.sin(rlat2); } irmax = RingNum(nside, zmin); irmax = Math.min(4 * nside - 1, irmax + 1); // go down to a lower point System.out.println(" irmax="+irmax+" irmin="+irmin); ilist = -1; // /* loop on ring number */ for (iz = irmin; iz <= irmax; iz++) { if (iz <= nside - 1) { // north polar cap z = 1.0 - iz * iz * dth1; } else if (iz <= 3 * nside) { // tropical band + equator z = (2.0 * nside - iz) * dth2; } else { z = -1.0 + (4.0 * nside - iz) * (4.0 * nside - iz) * dth1; } /* find phi range in the disc for each z */ b = cosang - z * z0; c = 1.0 - z * z; cosdphi = b / Math.sqrt(a * c); int done = 0; if (Math.abs(x0) <= 1.0e-12 && Math.abs(y0) <= 1.0e-12) { cosdphi = -1.0; dphi = PI; done = 1; } if (done == 0) { if (Math.abs(cosdphi) <= 1.0) { dphi = Math.acos(cosdphi); // in [0,pi] } else { if (cosphi0 >= cosdphi) { dphi = PI; // } else { done = 2; // out of the ring } } } System.out.println(" done="+done); if (done < 2) { // pixels in ring /* find pixels in the ring */ System.out.println("iz="+iz+" phi="+phi0+" dphi="+dphi); double phi01 = phi0 - 0.5*dphi; double phi02 = phi0 + 0.5*dphi; ArrayList listir = null; // System.out.println("iz="+iz +" phi01="+phi01+" phi02="+phi02+" dr="+dr); listir = InRing(nside, iz, phi0, dphi, do_nest); if (listir.size()<=1) { res.addAll(listir); } else { res.add(listir.get(0)); res.add(listir.get(listir.size()-1)); } // System.out.println("ir"+iz); // listir = InRing(nside, iz, phi02, dr, do_nest); // res.addAll(listir); } } // return res; } /** * renders theta and phi coordinates of the nominal pixel center for the * pixel number ipix (RING scheme) given the map resolution parameter nside * * @param nside * long map resolution * @param ipix * long pixel number * @return double[] theta,phi */ public double[] pix2ang_ring(long nside, long ipix) { double[] res = { 0., 0. }; long nl2, nl4, npix, ncap, iring, iphi, ip, ipix1; double fodd, hip, fihip, theta, phi; String SID = "pix2ang_ring:"; /* */ if (nside < 1 || nside > ns_max) { throw new IllegalArgumentException(SID + " Nside should be power of 2 >0 and < "+ns_max); } long nsidesq = nside * nside; npix = 12 * nsidesq; // total number of pixels if (ipix < 0 || ipix > npix - 1) { throw new IllegalArgumentException(SID + " ipix out of range calculated from nside"); } ipix1 = ipix + 1; // in [1, npix] nl2 = 2 * nside; nl4 = 4 * nside; ncap = 2 * nside * (nside - 1); // points in each polar cap, =0 for // nside =1 if (ipix1 <= ncap) { // North polar cap hip = ipix1 / 2.0; fihip = (long) hip; // get integer part of hip iring = (long) (Math.sqrt(hip - Math.sqrt(fihip))) + 1; // counted from north // pole iphi = ipix1 - 2 * iring * (iring - 1); theta = Math.acos(1.0 - iring * iring / (3.0 * nsidesq)); phi = ((double)iphi - 0.5) * PI / (2.0 * iring); } else if (ipix1 <= nl2 * (5 * nside + 1)) { // equatorial region ip = ipix1 - ncap - 1; iring = (long) (ip / nl4) + nside; // counted from North pole iphi = (long) BitManipulation.MODULO(ip, nl4) + 1; fodd = 0.5 * (1. + BitManipulation.MODULO(iring + nside, 2)); // 1 if iring+nside // is odd, 1/2 otherwise theta = Math.acos((nl2 - iring) / (1.5 * nside)); phi = ((double)iphi - fodd) * PI / (2.0 * nside); } else { // South pole cap ip = npix - ipix1 + 1; hip = ip / 2.0; fihip = (long) hip; iring = (long) (Math.sqrt(hip - Math.sqrt(fihip))) + 1; // counted from South // pole iphi = 4 * iring + 1 - (ip - 2 * iring * (iring - 1)); theta = Math.acos(-1.0 + iring * iring / (3.0 * nsidesq)); phi = ((double)iphi - 0.5) * PI / (2.0 * iring); } res[0] = theta; res[1] = phi; return res; } /** * returns the vector pointing in the center of the pixel ipix. The vector * is calculated by makePix2Vect_ring method * * @param nside map resolution * @param ipix pixel number * @return Vector3d */ public Vector3d pix2vect_ring(long nside, long ipix) { PixInfo pixInfo = makePix2Vect_ring(nside, ipix); Vector3d res = new Vector3d(pixInfo.pixVect); return res; } /** * returns double [][] with coordinates of the pixel corners. The array is * calculated by makePix2Vect_ring method * * @param nside map resolution * @param ipix pixel number * @return double[][] list of vertex coordinates */ public double[][] pix2vertex_ring(long nside, long ipix) { double[][] res; PixInfo pixinfo = makePix2Vect_ring(nside, ipix); res = pixinfo.pixVertex; return res; } /** * renders vector (x,y,z) coordinates of the nominal pixel center for pixel * ipix (RING scheme) given the map resolution parameter nside. It also * calculates (x,y,z) positions of the four vertices in order N,W,S,E. * These results are returned in a PixInfo object. * Those can be used using pix2Vect_ring and pix2vert_ring methods * * @param nside * long map resolution * @param ipix * pixel number * @return result object */ private PixInfo makePix2Vect_ring(long nside, long ipix) { long nl2; Vector3d pixVect = new Vector3d(0., 0., 0.); double[][] pixVertex = new double[3][4]; long nl4; long iring, iphi, ip, ipix1; long npix,ncap; double phi_nv, phi_wv, phi_sv, phi_ev; double z_nv, z_sv, sth_nv, sth_sv, hdelta_phi; double fact1, fact2, fodd, hip, fihip, z, sth, phi; long iphi_mod; long iphi_rat; // boolean do_vertex = true; long nsidesq = nside * nside; String SID = " Pix2Vect_ring:"; /* */ if (nside < 1 || nside > ns_max) { throw new IllegalArgumentException(SID + " Nside should be power of 2 >0 and < "+ns_max); } npix = 12 * nsidesq; if (ipix < 0 || ipix > npix - 1) { throw new IllegalArgumentException(SID + " ipix out of range calculated from nside"); } ipix1 = ipix + 1; // in [1, npix] nl2 = 2 * nside; nl4 = 4 * nside; ncap = 2 * nside * (nside - 1); // points in each polar cap fact1 = 1.5 * nside; fact2 = 3.0 * nsidesq; phi_nv = 0.0; phi_sv = 0.0; if (ipix1 <= ncap) { // north polar cap hip = ipix1 / 2.0; fihip = (long) hip; iring = (long) (Math.sqrt(hip - Math.sqrt(fihip))) + 1; // counted from north // pole iphi = ipix1 - 2 * iring * (iring - 1); z = 1.0 - iring * iring / fact2; phi = (iphi - 0.5) * PI / (2.0 * iring); hdelta_phi = PI / (4.0 * iring); // half pixel width z_nv = 1.0 - (iring - 1) * (iring - 1) / fact2; z_sv = 1.0 - (iring + 1) * (iring + 1) / fact2; iphi_mod = (long) BitManipulation.MODULO(iphi - 1, iring); // in [0,1,...,iring-1] iphi_rat = (iphi - 1) / iring; // in [0,1,2,3] if (iring > 1) phi_nv = HALFPI * (iphi_rat + iphi_mod / (iring - 1.0)); phi_sv = HALFPI * (iphi_rat + (iphi_mod + 1.0) / (iring + 1.0)); } else if (ipix1 <= nl2 * (5 * nside + 1)) { // equatorial region ip = (ipix1 - ncap - 1); iring = (long) (ip / nl4) + nside; // counted from North pole iphi = (long) BitManipulation.MODULO(ip, nl4) + 1; fodd = 0.5 * (1. + BitManipulation.MODULO(iring + nside, 2)); // 1 if iring+nside // is odd or 1/2 z = (nl2 - iring) / fact1; phi = (iphi - fodd) * PI / (2.0 * nside); hdelta_phi = PI / (4.0 * nside); // half pixel width phi_nv = phi; phi_sv = phi; z_nv = (nl2 - iring + 1) / fact1; z_sv = (nl2 - iring - 1) / fact1; if (iring == nside) { // nothern transition z_nv = 1.0 - (nside - 1) * (nside - 1) / fact2; iphi_mod = (long) BitManipulation.MODULO(iphi - 1, nside); // in [0,1,...,nside-1] iphi_rat = (iphi - 1) / nside; // in [0,1,2,3] if (nside > 1) phi_nv = HALFPI * (iphi_rat + iphi_mod / (nside - 1.)); } else if (iring == 3 * nside) { // southern transition z_sv = -1.0 + (nside - 1) * (nside - 1) / fact2; iphi_mod = (long) BitManipulation.MODULO(iphi - 1, nside); // in [0,1,... iring-1] iphi_rat = (iphi - 1) / nside; // in [0,1,2,3] if (nside > 1) phi_sv = HALFPI * (iphi_rat + iphi_mod / (nside - 1.0)); } } else { // South polar cap ip = npix - ipix1 + 1; hip = ip / 2.0; fihip = (long) hip; iring = (long) (Math.sqrt(hip - Math.sqrt(fihip))) + 1; // counted from South // pole iphi = 4 * iring + 1 - (ip - 2 * iring * (iring - 1)); z = -1.0 + iring * iring / fact2; phi = (iphi - 0.5) * PI / (2.0 * iring); hdelta_phi = PI / (4.0 * iring); // half pixel width z_nv = -1.0 + (iring + 1) * (iring + 1) / fact2; z_sv = -1.0 + (iring - 1) * (iring - 1) / fact2; iphi_mod = (long) BitManipulation.MODULO(iphi - 1, iring); // in [0,1,...,iring-1] iphi_rat = (iphi - 1) / iring; // in [0,1,2,3] phi_nv = HALFPI * (iphi_rat + (iphi_mod + 1) / (iring + 1.0)); if (iring > 1) phi_sv = HALFPI * (iphi_rat + iphi_mod / (iring - 1.0)); } /* pixel center */ sth = Math.sqrt((1.0 - z) * (1.0 + z)); pixVect.x = sth * Math.cos(phi); pixVect.y = sth * Math.sin(phi); pixVect.z = z; pixVect = new Vector3d(sth * Math.cos(phi), sth * Math.sin(phi), z); /* west vertex */ phi_wv = phi - hdelta_phi; pixVertex[0][1] = sth * Math.cos(phi_wv); pixVertex[1][1] = sth * Math.sin(phi_wv); pixVertex[2][1] = z; /* east vertex */ phi_ev = phi + hdelta_phi; pixVertex[0][3] = sth * Math.cos(phi_ev); pixVertex[1][3] = sth * Math.sin(phi_ev); pixVertex[2][3] = z; /* north vertex */ sth_nv = Math.sqrt((1.0 - z_nv) * (1.0 + z_nv)); pixVertex[0][0] = sth_nv * Math.cos(phi_nv); pixVertex[1][0] = sth_nv * Math.sin(phi_nv); pixVertex[2][0] = z_nv; /* south vertex */ sth_sv = Math.sqrt((1.0 - z_sv) * (1.0 + z_sv)); pixVertex[0][2] = sth_sv * Math.cos(phi_sv); pixVertex[1][2] = sth_sv * Math.sin(phi_sv); pixVertex[2][2] = z_sv; return new PixInfo(pixVect, pixVertex); } /** * 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. * * @param nside * long map resolution parameter * @param theta * double theta * @param phi - * double phi * @return long ipix */ public long ang2pix_ring(long nside, double theta, double phi) { long nl4; long jp, jm, kshift; long ip; long ir; double z, za, tt, tp, tmp; long pix = 0; long ipix1; long nl2, ncap, npix; String SID = "ang2pix_ring:"; /* */ if (nside < 1 || nside > ns_max) { throw new IllegalArgumentException(SID + " Nside should be power of 2 >0 and < "+ns_max); } if (theta < 0.0 || theta > PI) { throw new IllegalArgumentException(SID + " Theta out of range [0,pi]"); } z = Math.cos(theta); za = Math.abs(z); if (phi >= TWOPI) phi = phi -TWOPI ; if (phi < 0.) phi =phi + TWOPI; // phi in [0, 2pi] tt = phi / HALFPI; // in [0,4] // tt = BitManipulation.MODULO(phi, TWOPI) / HALFPI; // in [0,4] nl2 = 2 * nside; nl4 = 4 * nside; ncap = nl2 * (nside - 1); // number of pixels in the north polar cap npix = 12 * nside * nside; if (za < twothird) { // equatorial region jp = (long) (nside * (0.5 + tt - 0.75 * z)); // index of ascending // edge line jm = (long) (nside * (0.5 + tt + 0.75 * z)); // index of descending // edge line ir = nside + 1 + jp - jm; // in [1,2n+1] kshift = 0; if ((long) BitManipulation.MODULO(ir, 2) == 0) kshift = 1; // 1 if ir even, 0 otherwise ip = (long) ((jp + jm - nside + kshift + 1) / 2) + 1; // in [1,4n] if (ip > nl4) ip = ip - nl4; ipix1 = ncap + nl4 * (ir - 1) + ip; } else { // North and South polar caps tp = tt - (long) tt; tmp = Math.sqrt(3.0 * (1.0 - za)); jp = (long) (nside * tp * tmp); // increasing edge line index jm = (long) (nside * (1.0 - tp) * tmp); // decreasing edge index ir = jp + jm + 1; // ring number counted from closest pole ip = (long) (tt * ir) + 1; // in [1,4*ir] if (ip > 4 * ir) ip = ip - 4 * ir; ipix1 = 2 * ir * (ir - 1) + ip; if (z <= 0.0) ipix1 = npix - 2 * ir * (ir + 1) + ip; } pix = ipix1 - 1; // in [0, npix-1] return pix; } /** * 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 * * @param nside * long map resolution * @param vector * Vector3d of the point coordinates * @return long pixel number * @throws IllegalArgumentException */ public long vect2pix_ring(long nside, Vector3d vector) { long res = 0; long nl2, nl4, ncap, npix, jp, jm, ipix1; double z, za, tt, tp, tmp, dnorm, phi; long ir, ip, kshift; String SID = " vect2pix_ring:"; /* */ if (nside < 1 || nside > ns_max) { throw new IllegalArgumentException(SID + " Nside should be power of 2 >0 and < "+ns_max); } dnorm = vector.length(); z = vector.z / dnorm; phi = 0.; if (vector.x != 0. || vector.y != 0.) phi = Math.atan2(vector.y, vector.x); // phi in [-pi,pi] za = Math.abs(z); if (phi < 0.) phi += TWOPI; // phi in [0, 2pi] tt = phi / HALFPI; // in [0,4] nl2 = 2 * nside; nl4 = 4 * nside; ncap = nl2 * (nside - 1); // number of pixels in the north polar cap npix = 12 * nside * nside; if (za < twothird) { // equatorial region jp = (long) (nside * (0.5 + tt - 0.75 * z)); // index of ascending // edge line jm = (long) (nside * (0.5 + tt + 0.75 * z)); // index of descending // edge line ir = nside + 1 + jp - jm; // in [1,2n+1] kshift = 0; if ((long) BitManipulation.MODULO(ir, 2) == 0) kshift = 1; // 1 if ir even, 0 otherwise ip = (long) ((jp + jm - nside + kshift + 1) / 2) + 1; // in [1,4n] if (ip > nl4) ip = ip - nl4; ipix1 = ncap + nl4 * (ir - 1) + ip; } else { // North and South polar caps tp = tt - (long) tt; tmp = Math.sqrt(3.0 * (1.0 - za)); jp = (long) (nside * tp * tmp); // increasing edge line index jm = (long) (nside * (1.0 - tp) * tmp); // decreasing edge index ir = jp + jm + 1; // ring number counted from closest pole ip = (long) (tt * ir) + 1; // in [1,4*ir] if (ip > 4 * ir) ip = ip - 4 * ir; ipix1 = 2 * ir * (ir - 1) + ip; if (z <= 0.0) ipix1 = npix - 2 * ir * (ir + 1) + ip; } res = ipix1 - 1; // in [0, npix-1] return res; } /** * * Renders theta and phi coordinates of the normal pixel center for the * pixel number ipix (NESTED scheme) given the map resolution parameter * nside. * * @param nside * map resolution parameter - long * @param ipix * long pixel number * @return double[] (theta, phi) * @throws IllegalArgumentException */ public double[] pix2ang_nest(long nside, long ipix) { double[] res = new double[2]; double theta = 0.; double phi = 0.; long npix, npface, ipf, ip_low, ip_trunc, ip_med, ip_hi; long jrt, jr, nr, jpt, jp, kshift, nl4, ix, iy, face_num; double z, fn, fact1, fact2; String SID = "pix2ang_nest:"; // coordinate of the lowest corner of each face long[] jrll = { 0, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4 }; // in units of // nside long[] jpll = { 0, 1, 3, 5, 7, 0, 2, 4, 6, 1, 3, 5, 7 }; // in units of // nside/2 /* */ if (nside < 1 || nside > ns_max) { throw new IllegalArgumentException(SID + " Nside should be power of 2 >0 and < "+ns_max); } long nsidesq = nside * nside; npix = 12 * nsidesq; if (ipix < 0 || ipix > npix - 1) { throw new IllegalArgumentException(SID + " ipix out of range calculated from nside"); } if (pix2x[xmax-1] <= 0) mk_pix2xy(); fn = 1.*nside; fact1 = 1.0 / (3.0 * fn * fn); fact2 = 2.0 / (3.0 * fn); nl4 = 4 * nside; /* findes the face, and the number in the face */ npface = nside * nside; face_num = ipix / npface; // face number [0,11] ipf = (long) BitManipulation.MODULO(ipix, npface); // pixel in the face [0, npface-1] /* * finds x,y on the face (starting from the lowest corner) from pixel * number */ ip_low = (long) BitManipulation.MODULO(ipf, pixmax); // content of the last 18 bits ip_trunc = ipf / pixmax; // trancation of the last 18 bits ip_med = (long) BitManipulation.MODULO(ip_trunc, pixmax); // content of the next 18 bits ip_hi = ip_trunc / pixmax; // content of the high wait 18 bits ix = pixmax * pix2x[(int)ip_hi] + xmid * pix2x[(int)ip_med] + pix2x[(int) ip_low]; iy = pixmax * pix2y[(int)ip_hi] + xmid * pix2y[(int)ip_med] + pix2y[(int)ip_low]; /* transform these in (horizontal, vertical) coordinates */ jrt = ix + iy; // [0,2*(nside-1)] jpt = ix - iy; // [ -nside+1, nside -1] /* computes the z coordinate on the sphere */ jr = jrll[(int) (face_num + 1)] * nside - jrt - 1; // ring number in [1, // 4*nside-1] nr = nside; // equatorial region (the most frequent ) z = (2 * nside - jr) * fact2; kshift = (long) BitManipulation.MODULO(jr - nside, 2); if (jr < nside) { // north pole region nr = jr; z = 1.0 - nr * nr * fact1; kshift = 0; } else if (jr > 3 * nside) { // south pole region nr = nl4 - jr; z = -1.0 + nr * nr * fact1; kshift = 0; } theta = Math.acos(z); /* computes phi coordinate on the sphere, in [0,2pi] */ jp = (jpll[(int) (face_num + 1)] * nr + jpt + 1 + kshift) / 2; if (jp > nl4) jp = jp - nl4; if (jp < 1) jp = jp + nl4; phi = (jp - (kshift + 1) * 0.5) * (HALFPI / nr); res[0] = theta; res[1] = phi; return res; } /** * renders vector (x,y,z) coordinates of the nominal pixel center for the * pixel ipix (NESTED scheme ) given the map resolution parameter nside. * Also calculates the (x,y,z) positions of 4 pixel vertices (corners) in * the order N,W,S,E. These can be get using method pix2vertex_nest. * * @param nside the map resolution * @param ipix long pixel number * @return Vector3d * @throws IllegalArgumentException */ public Vector3d pix2vect_nest(long nside, long ipix) { PixInfo pixinfo = makePix2Vect_Nest(nside, ipix); return pixinfo.pixVect; } /** * renders vector (x,y,z) coordinates of the nominal pixel center for the * pixel ipix (NESTED scheme ) given the map resolution parameter nside. * Also calculates the (x,y,z) positions of 4 pixel vertices (corners) in * the order N,W,S,E. * * @param nside the map resolution * @param ipix long pixel number * @return double[3][4] 4 sets of vector components * @throws IllegalArgumentException */ public double[][] pix2vertex_nest(long nside, long ipix) { double[][] res = new double[3][4]; PixInfo pixinfo = makePix2Vect_Nest(nside, ipix); double[][] pixVertex = pixinfo.pixVertex; for (int i = 0; i < 3; i++) { for (int j = 0; j < 4; j++) { res[i][j] = pixVertex[i][j]; } } return res; } /** * renders vector (x,y,z) coordinates of the nominal pixel center for the * pixel ipix (NESTED scheme ) given the map resolution parameter nside. Tis * can be get using method pix2vect_nest Also calculates the (x,y,z) * positions of 4 pixel vertices (corners) in the order N,W,S,E. * The result can be used using method pix2vertex_nest. * @param nside long the map resolution * @param ipix long pixel number * @return result */ private PixInfo makePix2Vect_Nest(long nside, long ipix) { Vector3d pixVect = new Vector3d(0., 0., 0.); double[][] pixVertex = new double[3][4]; long npix, npface, ipf, ip_low, ip_trunc, ip_med, ip_hi; long jrt, jr, nr, jpt, jp, kshift, nl4; double z, fn, fact1, fact2, sth, phi; long ix, iy, face_num; int[] jrll = { 0, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4 }; int[] jpll = { 0, 1, 3, 5, 7, 0, 2, 4, 6, 1, 3, 5, 7 }; double phi_nv, phi_wv, phi_sv, phi_ev, phi_up, phi_dn; double z_nv, z_sv, sth_nv, sth_sv; double hdelta_phi; long iphi_mod, iphi_rat; // boolean do_vertex = true; String SID = "Pix2Vect_Nest:"; z_nv = 0.; z_sv = 0.; /* */ if (nside < 1 || nside > ns_max) { throw new IllegalArgumentException(SID + " Nside should be power of 2 >0 and < "+ns_max); } long nsidesq = nside * nside; npix = 12 * nsidesq; if (ipix < 0 || ipix > npix - 1) { throw new IllegalArgumentException(SID + " ipix out of range calculated from nside"); } /* initiates the array for the pixel number -> (x,y) mapping */ if (pix2x[pixmax-1] <= 0) mk_pix2xy(); fn = nside; fact1 = 1.0 / (3.0 * fn * fn); fact2 = 2.0 / (3.0 * fn); nl4 = 4 * nside; /* finds the face and the number in the face */ npface = nsidesq; // System.out.println("ipix="+ipix+" npface="+npface); face_num = ipix / npface; // face number in [0, 11] ipf = (long) BitManipulation.MODULO(ipix, npface); // pixel number in the face [0,npface-1] /* * finds the x,y on the face (starting from the lowest corner) from the * pixel number */ ip_low = (long) BitManipulation.MODULO(ipf, pixmax); // last 18 bits ip_trunc = ipf / pixmax; // trancateion of the last 18 bits ip_med = (long) BitManipulation.MODULO(ip_trunc, pixmax); // next 18 bits ip_hi = ip_trunc / pixmax; // high 18 bits ix = pixmax * pix2x[(int)ip_hi] + xmid * pix2x[(int)ip_med] + pix2x[(int)ip_low]; iy = pixmax * pix2y[(int)ip_hi] + xmid * pix2y[(int)ip_med] + pix2y[(int)ip_low]; /* transform this in (vertical, horizontal) coordinates */ jrt = ix + iy; // vertical in [0,2*(nside-1)] jpt = ix - iy; // horizontal in [ -nside+1, nside-1] /* computes the z coordinate on the sphere */ jr = jrll[(int) (face_num + 1)] * nside - jrt - 1; // ring number in // [1,4*nside-1] nr = nside; // equatorial region (the most frequent ) z = (2.0 * nside - jr) * fact2; kshift = (long) BitManipulation.MODULO(jr - nside, 2); z_nv = (2.0 * nside - jr + 1.0) * fact2; z_sv = (2.0 * nside - jr - 1.0) * fact2; if (jr == nside) { // northen transition z_nv = 1.0 - (nside - 1.0) * (nside - 1.0) * fact1; } else if (jr == 3 * nside) { // southern transition z_sv = -1.0 + (nside - 1.0) * (nside - 1.0) * fact1; } if (jr < nside) { // north pole region nr = jr; z = 1.0 - nr * nr * fact1; kshift = 0; z_nv = 1.0 - (nr - 1) * (nr - 1) * fact1; z_sv = 1.0 - (nr + 1) * (nr + 1) * fact1; } else if (jr > 3 * nside) { // south pole region nr = nl4 - jr; z = -1.0 + nr * nr * fact1; kshift = 0; z_nv = -1.0 + (nr + 1) * (nr + 1) * fact1; z_sv = -1.0 + (nr - 1) * (nr - 1) * fact1; } /* computes the phi coordinate on the sphere, in [0,2pi] */ jp = (jpll[(int) (face_num + 1)] * nr + jpt + 1 + kshift) / 2; // phi in the ring in // [1,4*nr] if (jp > nl4) jp = jp - nl4; if (jp < 1) jp = jp + nl4; phi = (jp - (kshift + 1) / 2.) * (HALFPI / nr); sth = Math.sqrt((1.0 - z) * (1.0 + z)); pixVect.x = sth * Math.cos(phi); pixVect.y = sth * Math.sin(phi); pixVect.z = z; phi_nv = phi; phi_sv = phi; phi_up = 0.0; iphi_mod = (long) BitManipulation.MODULO(jp - 1, nr); // in [0,1,...,nr-1] iphi_rat = (jp - 1) / nr; // in [0,1,2,3] if (nr > 1) phi_up = HALFPI * (iphi_rat + iphi_mod / (nr - 1.)); phi_dn = HALFPI * (iphi_rat + (iphi_mod + 1) / (nr + 1.)); if (jr < nside) { // north polar cap phi_nv = phi_up; phi_sv = phi_dn; } else if (jr > 3 * nside) { // south polar cap phi_nv = phi_dn; phi_sv = phi_up; } else if (jr == nside) { // north transition phi_nv = phi_up; } else if (jr == 3 * nside) { // south transition phi_sv = phi_up; } hdelta_phi = PI / (4.0 * nr); /* west vertex */ // phi_wv = phi = hdelta_phi; phi_wv = phi - hdelta_phi; pixVertex[0][1] = sth * Math.cos(phi_wv); pixVertex[1][1] = sth * Math.sin(phi_wv); pixVertex[2][1] = z; /* east vertex */ phi_ev = phi + hdelta_phi; pixVertex[0][3] = sth * Math.cos(phi_ev); pixVertex[1][3] = sth * Math.sin(phi_ev); pixVertex[2][3] = z; /* north vertex */ sth_nv = Math.sqrt((1.0 - z_nv) * (1.0 + z_nv)); pixVertex[0][0] = sth_nv * Math.cos(phi_nv); pixVertex[1][0] = sth_nv * Math.sin(phi_nv); pixVertex[2][0] = z_nv; /* south vertex */ sth_sv = Math.sqrt((1.0 - z_sv) * (1.0 + z_sv)); pixVertex[0][2] = sth_sv * Math.cos(phi_sv); pixVertex[1][2] = sth_sv * Math.sin(phi_sv); pixVertex[2][2] = z_sv; return new PixInfo(pixVect, pixVertex); } /** * 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. * * The computation is made to the highest resolution available and then * degraded to required resolution by integer division. It makes sure that * the treatment of round-off will be consistent for every resolution. * * @param nside the map resolution parameter * @param theta double theta coordinate in radians * @param phi double phi coordinate in radians * @return pixel number long * @throws IllegalArgumentException */ public long ang2pix_nest(long nside, double theta, double phi) { long pix = 0; // long ipix1; double z, za, tt, tp, tmp; long jp, jm, ifp, ifm, face_num, ix, iy, ix_low, ix_hi; long iy_low, iy_hi, ipf, ntt; // long nl2, nl4, ncap, npix, kshift, ir, ip; String SID = "ang2pix_nest:"; /* */ if (nside < 1 || nside > ns_max) { throw new IllegalArgumentException(SID + " Nside should be power of 2 >0 and < "+ns_max); } if (theta < 0.0 || theta > PI) { throw new IllegalArgumentException(SID + " theta is out of range [0.,PI]"); } if (x2pix[xmax-1] <= 0) mk_xy2pix(); z = Math.cos(theta); za = Math.abs(z); if (phi < 0.) phi += TWOPI; // phi in [0,2pi] if (phi >= TWOPI ) phi -= TWOPI; tt = BitManipulation.MODULO(phi, TWOPI) / HALFPI; // in [0,4] // tt = 2. * phi / PI; // in [0,4] if (za <= twothird) { // Equatorial region /* * the index of edge lines increases when the longitude = phi goes * up */ jp = (long) (ns_max * (0.5 + tt - z * 0.75)); // ascending edge line // index jm = (long) (ns_max * (0.5 + tt + z * 0.75)); // descending edge line // index /* find the face */ ifp = jp / ns_max; // in [0,4] ifm = jm / ns_max; if (ifp == ifm) { // faces 4 to 7 face_num = (long) BitManipulation.MODULO(ifp, 4) + 4; } else if (ifp < ifm) { // (half-) faces 0 to 3 face_num = (long) BitManipulation.MODULO(ifp, 4); } else { // (half-) faces 8 to 11 face_num = (long) BitManipulation.MODULO(ifm, 4) + 8; } ix = (long) BitManipulation.MODULO(jm, ns_max); iy = ns_max - (long) BitManipulation.MODULO(jp, ns_max) - 1; } else { // polar region, za > 2/3 ntt = (long) tt; if (ntt >= 4) ntt = 3; tp = tt - ntt; tmp = Math.sqrt(3.0 * (1.0 - za)); // in [0,1] /* * the index of edge lines increases when distance from the closest * pole goes up */ jp = (long) (ns_max * tp * tmp); // line going toward the pole has // phi increases jm = (long) (ns_max * (1.0 - tp) * tmp); // that one goes away of the // closest pole jp = (long) Math.min(ns_max - 1, jp); // for pointss too close to the // boundary jm = (long) Math.min(ns_max - 1, jm); /* finds the face and pixel's (x,y) */ if (z >= 0) { face_num = ntt; // in [0,3] ix = ns_max - jm - 1; iy = ns_max - jp - 1; } else { face_num = ntt + 8; // in [8,11] ix = jp; iy = jm; } } ix_low = (long) BitManipulation.MODULO(ix, xmax); ix_hi = ix / xmax; iy_low = (long) BitManipulation.MODULO(iy, xmax); iy_hi = iy / xmax; ipf = (x2pix[(int) (ix_hi + 1)] + y2pix[(int) (iy_hi + 1)]) * (xmax * xmax) + (x2pix[(int) (ix_low + 1)] + y2pix[(int) (iy_low + 1)]); ipf = ipf / ((ns_max / nside) * (ns_max / nside)); // in [0, nside**2 // -1] pix = ipf + face_num * nside * nside; // in [0, 12*nside**2 -1] return pix; } /** * make the conversion NEST to RING * * @param nside the map resolution parameter * @param map Object[] the map in NESTED scheme * @return - Object[] a map in RING scheme * @throws IllegalArgumentException */ public Object[] convert_nest2ring(long nside, Object[] map) { Object[] res; long npix, ipn; int ipr; npix = 12 * nside * nside; res = new Object[(int) npix]; for (ipn = 0; ipn < npix; ipn++) { ipr = (int) nest2ring(nside, ipn); res[ipr] = map[(int) ipn]; } return res; } /** * makes the conversion RING to NEST * * @param nside * long resolution * @param map * map in RING * @return map in NEST * @throws IllegalArgumentException */ public Object[] convert_ring2nest(long nside, Object[] map) { Object[] res; long npix, ipn, ipr; npix = 12 * nside * nside; res = new Object[(int) npix]; for (ipr = 0; ipr < npix; ipr++) { ipn = ring2nest(nside, ipr); res[(int) ipn] = map[(int)ipr]; } return res; } /** * 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). This * method is more general but slower than convert_nest2ring. * * This method is a wrapper for functions ring2nest and nest2ring. Their * names are supplied in the subcall argument. * * @param subcall * String name of the method to use. * @param map * Object[] map * @return resulting Object[] map. * @throws IllegalArgumentException */ public Object[] convert_inplace_long(String subcall, Object[] map) { Object[] res; long npix, nside; boolean[] check; long ilast, i1, i2; String SID = "convert_in_place:"; Object pixbuf1, pixbuf2; npix = map.length; nside = (long) Math.sqrt(npix / 12.); if (nside > ns_max) { throw new IllegalArgumentException(SID + " Map is too big"); } check = new boolean[(int) npix]; for (int i = 0; i < npix; i++) check[i] = false; ilast = 0; // start from first pixel for (int i = 0; i < npix; i++) { pixbuf2 = map[(int) ilast]; i1 = ilast; if (subcall.equalsIgnoreCase("ring2nest")) { i2 = ring2nest(nside, i1); } else { i2 = nest2ring(nside, i1); } while (!check[(int) i2]) { pixbuf1 = map[(int) i2]; map[(int) i2] = pixbuf2; pixbuf2 = pixbuf1; i1 = i2; if (subcall.equalsIgnoreCase("ring2nest")) { i2 = ring2nest(nside, i1); } else { i2 = nest2ring(nside, i1); } } while (!(check[(int) ilast] && (ilast < npix - 1))) { ilast++; } } res = map; return res; } /** * 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). From then on the neighbors are ordered in the * clockwise direction. * * @param nside the map resolution * @param ipix long pixel number * @return ArrayList * @throws IllegalArgumentException */ public ArrayList neighbours_nest(long nside, long ipix) { ArrayList res = new ArrayList(); long npix, ipf, ipo, ix, ixm, ixp, iy, iym, iyp, ixo, iyo; long face_num, other_face; long ia, ib, ibp, ibm, ib2, nsidesq; int icase; long local_magic1, local_magic2; long arb_const = 0; long[] ixiy = new long[2]; long[] ixoiyo = new long[2]; String SID = "neighbours_nest:"; /* fill the pixel list with 0 */ res.add(0, new Long(0)); res.add(1, new Long(0)); res.add(2, new Long(0)); res.add(3, new Long(0)); res.add(4, new Long(0)); res.add(5, new Long(0)); res.add(6, new Long(0)); res.add(7, new Long(0)); icase = 0; /* */ if ((nside < 1) || (nside > ns_max)) { throw new IllegalArgumentException(SID + " Nside should be power of 2 >0 and < "+ns_max); } nsidesq = nside * nside; npix = 12 * nsidesq; // total number of pixels if ((ipix < 0) || (ipix > npix - 1)) { throw new IllegalArgumentException(SID + " ipix out of range "); } if (x2pix[xmax-1] <= 0) mk_xy2pix(); local_magic1 = (nsidesq - 1) / 3; local_magic2 = 2 * local_magic1; face_num = ipix / nsidesq; ipf = (long) BitManipulation.MODULO(ipix, nsidesq); // Pixel number in face ixiy = pix2xy_nest(nside, ipf); ix = ixiy[0]; iy = ixiy[1]; // ixm = ixiy[0] - 1; ixp = ixiy[0] + 1; iym = ixiy[1] - 1; iyp = ixiy[1] + 1; icase = 0; // inside the face /* exclude corners */ if (ipf == local_magic2 && icase == 0) icase = 5; // West corner if (ipf == (nsidesq - 1) && icase == 0) icase = 6; // North corner if (ipf == 0 && icase == 0) icase = 7; // South corner if (ipf == local_magic1 && icase == 0) icase = 8; // East corner /* detect edges */ if ((ipf & local_magic1) == local_magic1 && icase == 0) icase = 1; // NorthEast if ((ipf & local_magic1) == 0 && icase == 0) icase = 2; // SouthWest if ((ipf & local_magic2) == local_magic2 && icase == 0) icase = 3; // NorthWest if ((ipf & local_magic2) == 0 && icase == 0) icase = 4; // SouthEast /* iside a face */ if (icase == 0) { res.add(0, new Long( xy2pix_nest(nside, ixm, iym, face_num))); res.add(1, new Long( xy2pix_nest(nside, ixm, iy, face_num))); res.add(2, new Long( xy2pix_nest(nside, ixm, iyp, face_num))); res.add(3, new Long( xy2pix_nest(nside, ix, iyp, face_num))); res.add(4, new Long( xy2pix_nest(nside, ixp, iyp, face_num))); res.add(5, new Long( xy2pix_nest(nside, ixp, iy, face_num))); res.add(6, new Long( xy2pix_nest(nside, ixp, iym, face_num))); res.add(7, new Long( xy2pix_nest(nside, ix, iym, face_num))); } /* */ ia = face_num / 4; // in [0,2] ib = (long) BitManipulation.MODULO(face_num, 4); // in [0,3] ibp = (long) BitManipulation.MODULO(ib + 1, 4); ibm = (long) BitManipulation.MODULO(ib + 4 - 1, 4); ib2 = (long) BitManipulation.MODULO(ib + 2, 4); if (ia == 0) { // North pole region switch (icase) { case 1: // north-east edge other_face = 0 + ibp; res.set(0, new Long( xy2pix_nest(nside, ixm, iym, face_num))); res.set(1, new Long( xy2pix_nest(nside, ixm, iy, face_num))); res.set(2, new Long( xy2pix_nest(nside, ixm, iyp, face_num))); res.set(3, new Long( xy2pix_nest(nside, ix, iyp, face_num))); res.set(7, new Long( xy2pix_nest(nside, ix, iym, face_num))); ipo = (long) BitManipulation.MODULO(BitManipulation.swapLSBMSB( ipf), nsidesq); ixoiyo = pix2xy_nest(nside, ipo); ixo = ixoiyo[0]; iyo = ixoiyo[1]; res.set(4, new Long( xy2pix_nest(nside, ixo + 1, iyo, other_face))); res.set(5, new Long( (other_face * nsidesq + ipo))); res.set(6, new Long( xy2pix_nest(nside, ixo - 1, iyo, other_face))); break; case 2: // SouthWest edge other_face = 4 + ib; ipo = (long) BitManipulation.MODULO(BitManipulation.invLSB( ipf), nsidesq); // SW-NE flip ixoiyo = pix2xy_nest(nside, ipo); ixo = ixoiyo[0]; iyo = ixoiyo[1]; res.set(0, new Long( xy2pix_nest(nside, ixo, iyo - 1, other_face))); res.set(1, new Long( (other_face * nsidesq + ipo))); res.set(2, new Long( xy2pix_nest(nside, ixo, iyo + 1, other_face))); res.set(3, new Long( xy2pix_nest(nside, ix, iyp, face_num))); res.set(4, new Long( xy2pix_nest(nside, ixp, iyp, face_num))); res.set(5, new Long( xy2pix_nest(nside, ixp, iy, face_num))); res.set(6, new Long( xy2pix_nest(nside, ixp, iym, face_num))); res.set(7, new Long( xy2pix_nest(nside, ix, iym, face_num))); break; case 3: // NorthWest edge other_face = 0 + ibm; ipo = (long) BitManipulation.MODULO(BitManipulation.swapLSBMSB( ipf), nsidesq); // E-W flip ixoiyo = pix2xy_nest(nside, ipo); ixo = ixoiyo[0]; iyo = ixoiyo[1]; res.set(0, new Long( xy2pix_nest(nside, ixm, iym, face_num))); res.set(1, new Long( xy2pix_nest(nside, ixm, iy, face_num))); res.set(2, new Long( xy2pix_nest(nside, ixo, iyo - 1, other_face))); res.set(3, new Long( (other_face * nsidesq + ipo))); res.set(4, new Long( xy2pix_nest(nside, ixo, iyo + 1, other_face))); res.set(5, new Long( xy2pix_nest(nside, ixp, iy, face_num))); res.set(6, new Long( xy2pix_nest(nside, ixp, iym, face_num))); res.set(7, new Long( xy2pix_nest(nside, ix, iym, face_num))); break; case 4: // SouthEast edge other_face = 4 + ibp; ipo = (long) BitManipulation.MODULO(BitManipulation.invMSB( ipf), nsidesq); // SE-NW flip ixoiyo = pix2xy_nest(nside, ipo); ixo = ixoiyo[0]; iyo = ixoiyo[1]; res.set(0, new Long( xy2pix_nest(nside, ixo - 1, iyo, other_face))); res.set(1, new Long( xy2pix_nest(nside, ixm, iy, face_num))); res.set(2, new Long( xy2pix_nest(nside, ixm, iyp, face_num))); res.set(3, new Long( xy2pix_nest(nside, ix, iyp, face_num))); res.set(4, new Long( xy2pix_nest(nside, ixp, iyp, face_num))); res.set(5, new Long( xy2pix_nest(nside, ixp, iy, face_num))); res.set(6, new Long( xy2pix_nest(nside, ixo + 1, iyo, other_face))); res.set(7, new Long( (other_face * nsidesq + ipo))); break; case 5: // West corner other_face = 4 + ib; arb_const = other_face * nsidesq + nsidesq - 1; res.set(0, new Long( (arb_const - 2))); res.set(1, new Long( arb_const)); other_face = 0 + ibm; arb_const = other_face * nsidesq + local_magic1; res.set(2, new Long( arb_const)); res.set(3, new Long( (arb_const + 2))); res.set(4, new Long( (ipix + 1))); res.set(5, new Long( (ipix - 1))); res.set(6, new Long( (ipix - 2))); res.remove(7); break; case 6: // North corner other_face = 0 + ibm; res.set(0, new Long( (ipix - 3))); res.set(1, new Long( (ipix - 1))); arb_const = other_face * nsidesq + nsidesq - 1; res.set(2, new Long( (arb_const - 2))); res.set(3, new Long( arb_const)); other_face = 0 + ib2; res.set(4, new Long( (other_face * nsidesq + nsidesq - 1))); other_face = 0 + ibp; arb_const = other_face * nsidesq + nsidesq - 1; res.set(5, new Long( arb_const)); res.set(6, new Long( (arb_const - 1))); res.set(7, new Long( (ipix - 2))); break; case 7: // South corner other_face = 8 + ib; res.set(0, new Long( (other_face * nsidesq + nsidesq - 1))); other_face = 4 + ib; arb_const = other_face * nsidesq + local_magic1; res.set(1, new Long( arb_const)); res.set(2, new Long( (arb_const + 2))); res.set(3, new Long( (ipix + 2))); res.set(4, new Long( (ipix + 3))); res.set(5, new Long( (ipix + 1))); other_face = 4 + ibp; arb_const = other_face * nsidesq + local_magic2; res.set(6, new Long( (arb_const + 1))); res.set(7, new Long( arb_const)); break; case 8: // East corner other_face = 0 + ibp; res.set(1, new Long( (ipix - 1))); res.set(2, new Long( (ipix + 1))); res.set(3, new Long( (ipix + 2))); arb_const = other_face * nsidesq + local_magic2; res.set(4, new Long( (arb_const + 1))); res.set(5, new Long(( arb_const))); other_face = 4 + ibp; arb_const = other_face * nsidesq + nsidesq - 1; res.set(0, new Long( (arb_const - 1))); res.set(6, new Long( arb_const)); res.remove(7); break; } } else if (ia == 1) { // Equatorial region switch (icase) { case 1: // north-east edge other_face = 0 + ibp; res.set(0, new Long( xy2pix_nest(nside, ixm, iym, face_num))); res.set(1, new Long( xy2pix_nest(nside, ixm, iy, face_num))); res.set(2, new Long( xy2pix_nest(nside, ixm, iyp, face_num))); res.set(3, new Long( xy2pix_nest(nside, ix, iyp, face_num))); res.set(7, new Long( xy2pix_nest(nside, ix, iym, face_num))); ipo = (long) BitManipulation.MODULO(BitManipulation.invLSB( ipf), nsidesq); // NE-SW flip ixoiyo = pix2xy_nest(nside, ipo); ixo = ixoiyo[0]; iyo = ixoiyo[1]; res.set(4, new Long( xy2pix_nest(nside, ixo, iyo + 1, other_face))); res.set(5, new Long( (other_face * nsidesq + ipo))); res.set(6, new Long( xy2pix_nest(nside, ixo, iyo - 1, other_face))); break; case 2: // SouthWest edge other_face = 8 + ibm; ipo = (long) BitManipulation.MODULO(BitManipulation.invLSB( ipf), nsidesq); // SW-NE flip ixoiyo = pix2xy_nest(nside, ipo); ixo = ixoiyo[0]; iyo = ixoiyo[1]; res.set(0, new Long( xy2pix_nest(nside, ixo, iyo - 1, other_face))); res.set(1, new Long((other_face * nsidesq + ipo))); res.set(2, new Long( xy2pix_nest(nside, ixo, iyo + 1, other_face))); res.set(3, new Long( xy2pix_nest(nside, ix, iyp, face_num))); res.set(4, new Long( xy2pix_nest(nside, ixp, iyp, face_num))); res.set(5, new Long( xy2pix_nest(nside, ixp, iy, face_num))); res.set(6, new Long( xy2pix_nest(nside, ixp, iym, face_num))); res.set(7, new Long( xy2pix_nest(nside, ix, iym, face_num))); break; case 3: // NortWest edge other_face = 0 + ibm; ipo = (long) BitManipulation.MODULO(BitManipulation.invMSB( ipf), nsidesq); // NW-SE flip ixoiyo = pix2xy_nest(nside, ipo); ixo = ixoiyo[0]; iyo = ixoiyo[1]; res.set(2, new Long( xy2pix_nest(nside, ixo - 1, iyo, other_face))); res.set(3, new Long( (other_face * nsidesq + ipo))); res.set(4, new Long( xy2pix_nest(nside, ixo + 1, iyo, other_face))); res.set(0, new Long( xy2pix_nest(nside, ixm, iym, face_num))); res.set(1, new Long( xy2pix_nest(nside, ixm, iy, face_num))); res.set(5, new Long( xy2pix_nest(nside, ixp, iy, face_num))); res.set(6, new Long( xy2pix_nest(nside, ixp, iym, face_num))); res.set(7, new Long(xy2pix_nest(nside, ix, iym, face_num))); break; case 4: // SouthEast edge other_face = 8 + ib; ipo = (long) BitManipulation.MODULO(BitManipulation.invMSB( ipf), nsidesq); // SE-NW flip ixoiyo = pix2xy_nest(nside, ipo); ixo = ixoiyo[0]; iyo = ixoiyo[1]; res.set(0, new Long( xy2pix_nest(nside, ixo - 1, iyo, other_face))); res.set(1, new Long( xy2pix_nest(nside, ixm, iy, face_num))); res.set(2, new Long( xy2pix_nest(nside, ixm, iyp, face_num))); res.set(3, new Long( xy2pix_nest(nside, ix, iyp, face_num))); res.set(4, new Long( xy2pix_nest(nside, ixp, iyp, face_num))); res.set(5, new Long( xy2pix_nest(nside, ixp, iy, face_num))); res.set(6, new Long( xy2pix_nest(nside, ixo + 1, iyo, other_face))); res.set(7, new Long( (other_face * nsidesq + ipo))); break; case 5: // West corner other_face = 8 + ibm; arb_const = other_face * nsidesq + nsidesq - 1; res.set(0, new Long( (arb_const - 2))); res.set(1, new Long( arb_const)); other_face = 4 + ibm; res.set(2, new Long( (other_face * nsidesq + local_magic1))); other_face = 0 + ibm; arb_const = other_face * nsidesq; res.set(3, new Long( arb_const)); res.set(4, new Long( (arb_const + 1))); res.set(5, new Long( (ipix + 1))); res.set(6, new Long( (ipix - 1))); res.set(7, new Long( (ipix - 2))); break; case 6: // North corner other_face = 0 + ibm; res.set(0, new Long( (ipix - 3))); res.set(1, new Long( (ipix - 1))); arb_const = other_face * nsidesq + local_magic1; res.set(2, new Long( (arb_const - 1))); res.set(3, new Long( arb_const)); other_face = 0 + ib; arb_const = other_face * nsidesq + local_magic2; res.set(4, new Long( arb_const)); res.set(5, new Long( (arb_const - 2))); res.set(6, new Long( (ipix - 2))); res.remove(7); break; case 7: // South corner other_face = 8 + ibm; arb_const = other_face * nsidesq + local_magic1; res.set(0, new Long( arb_const)); res.set(1, new Long( (arb_const + 2))); res.set(2, new Long( (ipix + 2))); res.set(3, new Long( (ipix + 3))); res.set(4, new Long( (ipix + 1))); other_face = 8 + ib; arb_const = other_face * nsidesq + local_magic2; res.set(5, new Long( (arb_const + 1))); res.set(6, new Long( arb_const)); res.remove(7); break; case 8: // East corner other_face = 8 + ib; arb_const = other_face * nsidesq + nsidesq - 1; res.set(0, new Long( (arb_const - 1))); res.set(1, new Long( (ipix - 1))); res.set(2, new Long( (ipix + 1))); res.set(3, new Long( (ipix + 2))); res.set(7, new Long( arb_const)); other_face = 0 + ib; arb_const = other_face * nsidesq; res.set(4, new Long( (arb_const + 2))); res.set(5, new Long( arb_const)); other_face = 4 + ibp; res.set(6, new Long( (other_face * nsidesq + local_magic2))); break; } } else { // South pole region switch (icase) { case 1: // North-East edge other_face = 4 + ibp; res.set(0, new Long( xy2pix_nest(nside, ixm, iym, face_num))); res.set(1, new Long( xy2pix_nest(nside, ixm, iy, face_num))); res.set(2, new Long( xy2pix_nest(nside, ixm, iyp, face_num))); res.set(3, new Long( xy2pix_nest(nside, ix, iyp, face_num))); res.set(7, new Long( xy2pix_nest(nside, ix, iym, face_num))); ipo = (long) BitManipulation.MODULO(BitManipulation.invLSB( ipf), nsidesq); // NE-SW flip ixoiyo = pix2xy_nest(nside, ipo); ixo = ixoiyo[0]; iyo = ixoiyo[1]; res.set(4, new Long( xy2pix_nest(nside, ixo, iyo + 1, other_face))); res.set(5, new Long( (other_face * nsidesq + ipo))); res.set(6, new Long( xy2pix_nest(nside, ixo, iyo - 1, other_face))); break; case 2: // SouthWest edge other_face = 8 + ibm; ipo = (long) BitManipulation.MODULO(BitManipulation.swapLSBMSB( ipf), nsidesq); // W-E flip ixoiyo = pix2xy_nest(nside, ipo); ixo = ixoiyo[0]; iyo = ixoiyo[1]; res.set(0, new Long( xy2pix_nest(nside, ixo - 1, iyo, other_face))); res.set(1, new Long( (other_face * nsidesq + ipo))); res.set(2, new Long( xy2pix_nest(nside, ixo + 1, iyo, other_face))); res.set(3, new Long( xy2pix_nest(nside, ix, iyp, face_num))); res.set(4, new Long( xy2pix_nest(nside, ixp, iyp, face_num))); res.set(5, new Long( xy2pix_nest(nside, ixp, iy, face_num))); res.set(6, new Long(xy2pix_nest(nside, ixp, iym, face_num))); res.set(7, new Long( xy2pix_nest(nside, ix, iym, face_num))); break; case 3: // NorthWest edge other_face = 4 + ib; ipo = (long) BitManipulation.MODULO(BitManipulation.invMSB( ipf), nsidesq); ixoiyo = pix2xy_nest(nside, ipo); ixo = ixoiyo[0]; iyo = ixoiyo[1]; res.set(0, new Long( xy2pix_nest(nside, ixm, iym, face_num))); res.set(1, new Long( xy2pix_nest(nside, ixm, iy, face_num))); res.set(2, new Long( xy2pix_nest(nside, ixo - 1, iyo, other_face))); res.set(3, new Long( (other_face * nsidesq + ipo))); res.set(4, new Long( xy2pix_nest(nside, ixo + 1, iyo, other_face))); res.set(5, new Long( xy2pix_nest(nside, ixp, iy, face_num))); res.set(6, new Long( xy2pix_nest(nside, ixp, iym, face_num))); res.set(7, new Long( xy2pix_nest(nside, ix, iym, face_num))); break; case 4: // SouthEast edge other_face = 8 + ibp; ipo = (long) BitManipulation.MODULO(BitManipulation.swapLSBMSB( ipf), nsidesq); // SE-NW // flip ixoiyo = pix2xy_nest(nside, ipo); ixo = ixoiyo[0]; iyo = ixoiyo[1]; res.set(0, new Long( xy2pix_nest(nside, ixo, iyo - 1, other_face))); res.set(1, new Long( xy2pix_nest(nside, ixm, iy, face_num))); res.set(2, new Long( xy2pix_nest(nside, ixm, iyp, face_num))); res.set(3, new Long( xy2pix_nest(nside, ix, iyp, face_num))); res.set(4, new Long( xy2pix_nest(nside, ixp, iyp, face_num))); res.set(5, new Long( xy2pix_nest(nside, ixp, iy, face_num))); res.set(6, new Long( xy2pix_nest(nside, ixo, iyo + 1, other_face))); res.set(7, new Long( (other_face * nsidesq + ipo))); break; case 5: // West corner other_face = 8 + ibm; arb_const = other_face * nsidesq + local_magic1; res.set(0, new Long( (arb_const - 2))); res.set(1, new Long( arb_const)); other_face = 4 + ib; res.set(2, new Long( (other_face * nsidesq))); res.set(3, new Long( (other_face * nsidesq + 1))); res.set(4, new Long( (ipix + 1))); res.set(5, new Long( (ipix - 1))); res.set(6, new Long( (ipix - 2))); res.remove(7); break; case 6: // North corner other_face = 4 + ib; res.set(0, new Long( (ipix - 3))); res.set(1, new Long((ipix - 1))); arb_const = other_face * nsidesq + local_magic1; res.set(2, new Long( (arb_const - 1))); res.set(3, new Long( arb_const)); other_face = 0 + ib; res.set(4, new Long( (other_face * nsidesq))); other_face = 4 + ibp; arb_const = other_face * nsidesq + local_magic2; res.set(5, new Long( arb_const)); res.set(6, new Long( (arb_const - 2))); res.set(7, new Long( (ipix - 2))); break; case 7: // South corner other_face = 8 + ib2; res.set(0, new Long( (other_face * nsidesq))); other_face = 8 + ibm; arb_const = other_face * nsidesq; res.set(1, new Long( arb_const)); res.set(2, new Long( (arb_const + 1))); res.set(3, new Long( (ipix + 2))); res.set(4, new Long( (ipix + 3))); res.set(5, new Long( (ipix + 1))); other_face = 8 + ibp; arb_const = other_face * nsidesq; res.set(6, new Long( (arb_const + 2))); res.set(7, new Long( arb_const)); break; case 8: // East corner other_face = 8 + ibp; res.set(1, new Long( (ipix - 1))); res.set(2, new Long( (ipix + 1))); res.set(3, new Long( (ipix + 2))); arb_const = other_face * nsidesq + local_magic2; res.set(6, new Long( arb_const)); res.set(0, new Long( (arb_const - 2))); other_face = 4 + ibp; arb_const = other_face * nsidesq; res.set(4, new Long( (arb_const + 2))); res.set(5, new Long( arb_const)); res.remove(7); break; } } return res; } /** * 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 * * @param nside * long the map resolution * @param iz * long ring number * @param phi0 * double * @param dphi * double * @param nest * boolean format flag * @return ArrayList of pixels * @throws IllegalArgumentException * * Modified by N. Kuropatkin 07/09/2008 Corrected several bugs and make test of all cases. * */ public ArrayList InRing(long nside, long iz, double phi0, double dphi, boolean nest) { boolean take_all = false; boolean to_top = false; boolean do_ring = true; boolean conservative = false; // String SID = "InRing:"; double epsilon = Double.MIN_VALUE; // the constant to eliminate // java calculation jitter if (nest) do_ring = false; double shift = 0.; long ir = 0; long kshift, nr, ipix1, ipix2, nir1, nir2, ncap, npix; long ip_low = 0, ip_hi = 0, in, inext, nir; ArrayList res = new ArrayList(); npix = 12 * nside * nside; // total number of pixels ncap = 2 * nside * (nside - 1); // number of pixels in the north polar // cap double phi_low = BitManipulation.MODULO(phi0 - dphi, TWOPI) - epsilon; // phi min, // excluding // 2pi period double phi_hi = BitManipulation.MODULO(phi0 + dphi, TWOPI) + epsilon; // if (Math.abs(dphi - PI) < epsilon) take_all = true; /* identifies ring number */ if ((iz >= nside) && (iz <= 3 * nside)) { // equatorial region ir = iz - nside + 1; // in [1, 2*nside + 1] ipix1 = ncap + 4 * nside * (ir - 1); // lowest pixel number in the // ring ipix2 = ipix1 + 4 * nside - 1; // highest pixel number in the ring kshift = (long) BitManipulation.MODULO(ir, 2.); nr = nside * 4; } else { if (iz < nside) { // north pole ir = iz; ipix1 = 2 * ir * (ir - 1); // lowest pixel number ipix2 = ipix1 + 4 * ir - 1; // highest pixel number } else { // south pole ir = 4 * nside - iz; ipix1 = npix - 2 * ir * (ir + 1); // lowest pixel number ipix2 = ipix1 + 4 * ir - 1; // highest pixel number } nr = ir * 4; kshift = 1; } // Construct the pixel list if (take_all) { nir = ipix2 - ipix1 + 1; if (do_ring) { long ind = 0; for (long i = ipix1; i <= ipix2; i++) { res.add((int) ind, new Long(i)); ind++; } } else { // in = ring2nest(nside, ipix1); // res.add(0, new Long( in)); int ind = 0; for (int i = 0; i < nir; i++) { // inext = next_in_line_nest(nside, in); // in = inext; in = ring2nest(nside, ipix1 + i); res.add( i, new Long(in)); } } return res; } shift = kshift / 2.0; // conservative : include every intersected pixel, even if the // pixel center is out of the [phi_low, phi_hi] region if (conservative) { ip_low = (long) Math.round((nr * phi_low) / TWOPI - shift); ip_hi = (long) Math.round((nr * phi_hi) / TWOPI - shift); ip_low = (long) BitManipulation.MODULO(ip_low, nr); // in [0, nr - 1] ip_hi = (long) BitManipulation.MODULO(ip_hi, nr); // in [0, nr - 1] // System.out.println("ip_low="+ip_low+" ip_hi="+ip_hi); } else { // strict: includes only pixels whose center is in // [phi_low,phi_hi] ip_low = (long) Math.ceil((nr * phi_low) / TWOPI - shift); ip_hi = (long) Math.floor((nr * phi_hi) / TWOPI - shift); if (ip_low == ip_hi + 1) ip_low = ip_hi; if ((ip_low - ip_hi == 1) && (dphi * nr < PI)) { // the interval is too small ( and away from pixel center) // so no pixels is included in the list System.out .println("the interval is too small and avay from center"); return res; // return empty list } ip_low = Math.min(ip_low, nr - 1); ip_hi = Math.max(ip_hi, 0); } // if (ip_low > ip_hi) to_top = true; if (to_top) { ip_low += ipix1; ip_hi += ipix1; nir1 = ipix2 - ip_low + 1; nir2 = ip_hi + 1; nir = nir1 + nir2; if (do_ring) { int ind = 0; for (long i = ip_low; i <= ipix2; i++) { res.add(ind, new Long(i)); ind++; } // ind = nir1; for (long i = ipix1; i <= ip_hi; i++) { res.add(ind, new Long(i)); ind++; } } else { int ind = 0; for (long i = ip_low; i <= ipix2; i++) { in = ring2nest(nside, i); res.add(ind, new Long(in)); ind++; } for (long i = ipix1; i <= ip_hi; i++) { in = ring2nest(nside, i); res.add(ind, new Long(in)); ind++; } } } else { nir = ip_hi - ip_low + 1; // System.out.println("nir="+nir+" ip_low="+ip_low+" ip_hi="+ip_hi+" ipix1="+ // ipix1+" ipix2="+ipix2); // // Special case when ip_low < 0 // if (ip_low < 0 ){ ip_low = Math.abs(ip_low) ; nir1 = ip_low; nir2 = ip_hi + 1; nir = nir1 + nir2; if (do_ring) { int ind = 0; for (long i = 0; i < ip_low; i++) { res.add(ind, new Long(ipix2 - i)); ind++; } for (long i = 0; i <= ip_hi; i++) { res.add(ind, new Long(ipix1 + i)); ind++; } } else { int ind = 0; for (int i = 0; i < ip_low; i++) { in = ring2nest(nside, ipix2 - i); res.add(ind, new Long(in)); ind++; } for (long i = 0; i <= ip_hi; i++) { in = ring2nest(nside, ipix1 + i); res.add(ind, new Long(in)); ind++; } } // System.out.println("nir="+nir+" ip_low="+ip_low+" ip_hi="+ip_hi+" ipix1="+ // ipix1+" ipix2="+ipix2); // for (int i=0; i< res.size(); i++) { // System.out.print(" "+ res.get(i)); // } // System.out.println(); return res; } ip_low += ipix1; ip_hi += ipix1; if (do_ring) { int ind = 0; for (long i = ip_low; i <= ip_hi; i++) { res.add(ind, new Long(i)); ind++; } } else { // in = ring2nest(nside, ip_low); // res.add(0, new Long(in)); int ind = 0; for (long i = ip_low; i <= ip_hi; i++) { // inext = next_in_line_nest(nside, in); // in = inext; in = ring2nest(nside, i); res.add(ind, new Long(in)); ind++; } } } return res; } /** * calculates the pixel that lies on the East side (and the same * latitude) as the given NESTED pixel number - ipix * * @param nside * long resolution * @param ipix * long pixel number * @return long next pixel in line * @throws IllegalArgumentException */ public long next_in_line_nest(long nside, long ipix) { long npix, ipf, ipo, ix, ixp, iy, iym, ixo, iyo, face_num, other_face; long ia, ib, ibp, nsidesq; long ibm, ib2; int icase; long local_magic1, local_magic2; long[] ixiy = new long[2]; long inext = 0; // next in line pixel in Nest scheme String SID = "next_in_line:"; if ((nside < 1) || (nside > ns_max)) { throw new IllegalArgumentException(SID + " nside should be power of 2 >0 and < "+ns_max); } nsidesq = nside * nside; npix = 12 * nsidesq; // total number of pixels if ((ipix < 0) || (ipix > npix - 1)) { throw new IllegalArgumentException(SID + " ipix out of range defined by nside"); } // initiates array for (x,y) -> pixel number -> (x,y) mapping if (x2pix[xmax-1] <= 0) mk_xy2pix(); local_magic1 = (nsidesq - 1) / 3; local_magic2 = 2 * local_magic1; face_num = ipix / nsidesq; ipf = (long) BitManipulation.MODULO(ipix, nsidesq); // Pixel number in face ixiy = pix2xy_nest(nside, ipf); ix = ixiy[0]; iy = ixiy[1]; ixp = ix + 1; iym = iy - 1; boolean sel = false; icase = -1; // iside the nest flag // Exclude corners if (ipf == local_magic2) { // west coirner inext = ipix - 1; return inext; } if ((ipf == nsidesq - 1) && !sel) { // North corner icase = 6; sel = true; } if ((ipf == 0) && !sel) { // Siuth corner icase = 7; sel = true; } if ((ipf == local_magic1) && !sel) { // East corner icase = 8; sel = true; } // Detect edges if (((ipf & local_magic1) == local_magic1) && !sel) { // North-East icase = 1; sel = true; } if (((ipf & local_magic2) == 0) && !sel) { // South-East icase = 4; sel = true; } if (!sel) { // iside a face inext = xy2pix_nest(nside, ixp, iym, face_num); return inext; } // ia = face_num / 4; // in [0,2] ib = (long) BitManipulation.MODULO(face_num, 4); // in [0,3] ibp = (long) BitManipulation.MODULO(ib + 1, 4); ibm = (long) BitManipulation.MODULO(ib + 4 - 1, 4); ib2 = (long) BitManipulation.MODULO(ib + 2, 4); if (ia == 0) { // North pole region switch (icase) { case 1: other_face = 0 + ibp; ipo = (long) BitManipulation.MODULO(BitManipulation.swapLSBMSB( ipf), nsidesq); inext = other_face * nsidesq + ipo; break; case 4: other_face = 4 + ibp; ipo = (long) BitManipulation.MODULO(BitManipulation.invMSB( ipf), nsidesq); // SE-NW flip ixiy = pix2xy_nest(nside, ipo); ixo = ixiy[0]; iyo = ixiy[1]; inext = xy2pix_nest(nside, ixo + 1, iyo, other_face); break; case 6: // North corner other_face = 0 + ibp; inext = other_face * nsidesq + nsidesq - 1; break; case 7: other_face = 4 + ibp; inext = other_face * nsidesq + local_magic2 + 1; break; case 8: other_face = 0 + ibp; inext = other_face * nsidesq + local_magic2; break; } } else if (ia == 1) { // Equatorial region switch (icase) { case 1: // NorthEast edge other_face = 0 + ib; // System.out.println("ipf="+ipf+" nsidesq="+nsidesq+" invLSB="+BitManipulation.invLSB(ipf)); ipo = (long) BitManipulation.MODULO((double)BitManipulation.invLSB( ipf), (double)nsidesq); // NE-SW flip // System.out.println(" ipo="+ipo); ixiy = pix2xy_nest(nside, ipo); ixo = ixiy[0]; iyo = ixiy[1]; inext = xy2pix_nest(nside, ixo, iyo - 1, other_face); break; case 4: // SouthEast edge other_face = 8 + ib; ipo = (long) BitManipulation.MODULO(BitManipulation.invMSB( ipf), nsidesq); ixiy = pix2xy_nest(nside, ipo); inext = xy2pix_nest(nside, ixiy[0] + 1, ixiy[1], other_face); break; case 6: // Northy corner other_face = 0 + ib; inext = other_face * nsidesq + local_magic2 - 2; break; case 7: // South corner other_face = 8 + ib; inext = other_face * nsidesq + local_magic2 + 1; break; case 8: // East corner other_face = 4 + ibp; inext = other_face * nsidesq + local_magic2; break; } } else { // South pole region switch (icase) { case 1: // NorthEast edge other_face = 4 + ibp; ipo = (long) BitManipulation.MODULO(BitManipulation.invLSB( ipf), nsidesq); // NE-SW flip ixiy = pix2xy_nest(nside, ipo); inext = xy2pix_nest(nside, ixiy[0], ixiy[1] - 1, other_face); break; case 4: // SouthEast edge other_face = 8 + ibp; ipo = (long) BitManipulation.MODULO(BitManipulation.swapLSBMSB( ipf), nsidesq); // E-W flip inext = other_face * nsidesq + ipo; // (8) break; case 6: // North corner other_face = 4 + ibp; inext = other_face * nsidesq + local_magic2 - 2; break; case 7: // South corner other_face = 8 + ibp; inext = other_face * nsidesq; break; case 8: // East corner other_face = 8 + ibp; inext = other_face * nsidesq + local_magic2; break; } } return inext; } /** * 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. * * The computation is made to the highest resolution available (nside=ns_max) * and then degraded to that requared (by Integer division) this doesn't * cost much, and it makes sure that the treatment of round-off will be * consistent for every resolution * * @param nside * long the map resolution * @param vector * Vewctor3d the input vector * @return pixel long * @throws IllegalArgumentException */ public long vect2pix_nest(long nside, Vector3d vector) { long pix = 0; double z, za, tt, tp, tmp, dnorm, phi; long jp, jm, ifp, ifm, face_num, ix, iy, ix_low, ix_hi; long iy_low, iy_hi, ipf, ntt; String SID = " vect2pix_nest:"; /* */ if (nside < 1 || nside > ns_max) { throw new IllegalArgumentException(SID + " nside should be power of 2 >0 and < ns_max"); } if (x2pix[xmax-1] <= 0) mk_xy2pix(); dnorm = vector.length(); z = vector.z / dnorm; phi = 0.; // phi in [-pi,pi] if (vector.x != 0. || vector.y != 0.) phi = Math.atan2(vector.y, vector.x); za = Math.abs(z); if (phi < 0.) phi += TWOPI; // phi in [0,2pi] tt = 2. * phi / PI; // in [0,4] if (za <= twothird) { // Equatorial region /* * the index of edge lines increases when the longitude = phi goes * up */ jp = (long) (ns_max * (0.5 + tt - z * 0.75)); // ascending edge line // index jm = (long) (ns_max * (0.5 + tt + z * 0.75)); // descending edge line // index /* find the face */ ifp = jp / ns_max; // in [0,4] ifm = jm / ns_max; if (ifp == ifm) { // faces 4 to 7 face_num = (long) BitManipulation.MODULO(ifp, 4) + 4; } else if (ifp < ifm) { // (half-) faces 0 to 3 face_num = (long) BitManipulation.MODULO(ifp, 4); } else { // (half-) faces 8 to 11 face_num = (long) BitManipulation.MODULO(ifm, 4) + 8; } ix = (long) BitManipulation.MODULO(jm, ns_max); iy = ns_max - (long) BitManipulation.MODULO(jp, ns_max) - 1; } else { // polar region, za > 2/3 ntt = (long) tt; if (ntt >= 4) ntt = 3; tp = tt - ntt; tmp = Math.sqrt(3.0 * (1.0 - za)); // in [0,1] /* * the index of edge lines increases when distance from the closest * pole goes up */ jp = (long) (ns_max * tp * tmp); // line going toward the pole has // phi increases jm = (long) (ns_max * (1.0 - tp) * tmp); // that one goes away of the // closest pole jp = Math.min(ns_max - 1, jp); // for points too close to the // boundary jm = Math.min(ns_max - 1, jm); /* finds the face and pixel's (x,y) */ if (z >= 0) { face_num = ntt; // in [0,3] ix = ns_max - jm - 1; iy = ns_max - jp - 1; } else { face_num = ntt + 8; // in [8,11] ix = jp; iy = jm; } } ix_low = (long) BitManipulation.MODULO(ix, xmax); ix_hi = ix / xmax; iy_low = (long) BitManipulation.MODULO(iy, xmax); iy_hi = iy / xmax; ipf = (x2pix[(int) (ix_hi + 1)] + y2pix[(int) (iy_hi + 1)]) * (xmax * xmax) + (x2pix[(int) (ix_low + 1)] + y2pix[(int) (iy_low + 1)]); ipf = ipf / ((ns_max / nside) * (ns_max / nside)); // in [0, nside**2 // -1] pix = ipf + face_num * nside * nside; // in [0, 12*nside**2 -1] return pix; } /** * gives the pixel number ipix (NESTED) corresponding to ix, iy and face_num * * @param nside * the map resolution parameter * @param ix * Integer x coordinate * @param iy * Integer y coordinate * @param face_num * long face number * @return long pixel number ipix * @throws IllegalArgumentException */ private long xy2pix_nest(long nside, long ix, long iy, long face_num){ long res = 0; long ix_low, ix_hi, iy_low, iy_hi, ipf; String SID = "xy2pix_nest:"; // if ((nside < 1) || (nside > ns_max)) { throw new IllegalArgumentException(SID + " nside should be power of 2 >0 and < "+ns_max); } // if ((ix < 0) || (ix > nside - 1)) { // throw new IllegalArgumentException(SID + " ix out of range [0, nside-1]"); // } // if ((iy < 0) || (iy > nside - 1)) { // throw new IllegalArgumentException(SID + " iy out of range [0, nside-1]"); // } if (x2pix[xmax-1] <= 0) mk_xy2pix(); ix_low = (long) BitManipulation.MODULO(ix, xmax); ix_hi = ix / xmax; iy_low = (long) BitManipulation.MODULO(iy, xmax); iy_hi = iy / xmax; ipf = (x2pix[(int) (ix_hi + 1)] + y2pix[(int) (iy_hi + 1)]) * xmax * xmax + (x2pix[(int) (ix_low + 1)] + y2pix[(int) (iy_low + 1)]); res = ipf + face_num * nside * nside; // in [0, 12*nside^2 - 1] return res; } /** * gives the x,y coordinates in a face from pixel number within the face * (NESTED) schema. * * @param nside * long resolution parameter * @param ipf * long pixel number * @return ixiy long[] contains x and y coordinates * @throws IllegalArgumentException */ private long[] pix2xy_nest(long nside, long ipf) { long[] ixiy = { 0, 0 }; long ip_low, ip_trunc, ip_med, ip_hi; String SID = "pix2xy_nest:"; // System.out.println(" ipf="+ipf+" nside="+nside); if ((nside < 1) || (nside > ns_max)) { throw new IllegalArgumentException(SID + " nside should be power of 2 >0 and < "+ns_max); } if ((ipf < 0) || (ipf > nside * nside - 1)) { throw new IllegalArgumentException(SID + " ipix out of range defined by nside"); } if (pix2x[pixmax] <= 0) mk_pix2xy(); ip_low = (long) BitManipulation.MODULO(ipf, pixmax); // contents of last 15 bits ip_trunc = ipf / pixmax; // truncation of the last 15 bits ip_med = (long) BitManipulation.MODULO(ip_trunc, pixmax); // next 15 bits ip_hi = ip_trunc / pixmax; // select high 15 bits long ix = pixmax * pix2x[(int) ip_hi] + xmid * pix2x[(int) ip_med] + pix2x[(int) ip_low]; long iy = pixmax * pix2y[(int) ip_hi] + xmid * pix2y[(int) ip_med] + pix2y[(int) ip_low]; ixiy[0] = ix; ixiy[1] = iy; return ixiy; } /** * creates an array of pixel numbers pix2x from x and y coordinates in the * face. Suppose NESTED scheme of pixel ordering Bits corresponding to x and * y are interleaved in the pixel number in even and odd bits. */ private void mk_pix2xy() { long kpix, jpix, ix, iy, ip, id; boolean flag = true; for (kpix = 0; kpix <= pixmax; kpix++) { // loop on pixel numbers jpix = kpix; ix = 0; iy = 0; ip = 1; // bit position in x and y while (jpix != 0) { // go through all the bits id = (long) BitManipulation.MODULO(jpix, 2); // bit value (in kpix), goes in x jpix /= 2; ix += id * ip; id = (long) BitManipulation.MODULO(jpix, 2); // bit value, goes in iy jpix /= 2; iy += id * ip; ip *= 2; // next bit (in x and y ) } pix2x[(int) kpix] = ix; // in [0,pixmax] pix2y[(int) kpix] = iy; // in [0,pixmax] } } /** * converts pixel number from ring numbering schema to the nested one * * @param nside * long resolution * @param ipring long pixel number in ring schema * @return long pixel number in nest schema * @throws IllegalArgumentException */ public long ring2nest(long nside, long ipring) { long ipnest = 0; double fihip; double hip; long npix, nl2, nl4, ncap, ip, iphi, ipt, ipring1, kshift, face_num; long nr, irn, ire, irm, irs, irt, ifm, ifp, ix, iy, ix_low, ix_hi, iy_low; long iy_hi, ipf; long[] jrll = { 0, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4 }; // in units of // nside long[] jpll = { 0, 1, 3, 5, 7, 0, 2, 4, 6, 1, 3, 5, 7 }; // in units of // nside/2 String SID = "ring2nest:"; // face_num = 0; if ((nside < 1) || (nside > ns_max)) { throw new IllegalArgumentException(SID + " nside should be power of 2 >0 and < "+ns_max); } npix = 12 * nside * nside; // total number of points if ((ipring < 0) || (ipring > npix - 1)) { throw new IllegalArgumentException(SID + " ipring out of range [0,npix-1]"); } if (x2pix[xmax-1] <= 0) mk_xy2pix(); nl2 = 2 * nside; nl4 = 4 * nside; ncap = nl2 * (nside - 1); // points in each polar cap, =0 for nside = 1 ipring1 = ipring + 1; // finds the ring number, the position of the ring and the face number if (ipring1 <= ncap) { // north polar cap hip = ipring1 / 2.0; fihip = Math.floor(hip); irn = (long)Math.floor( Math.sqrt(hip - Math.sqrt(fihip))) + 1; // counted from // north pole iphi = ipring1 - 2 * irn * (irn - 1); kshift = 0; nr = irn; // 1/4 of the number of points on the current ring face_num = (iphi - 1) / irn; // in [0,3 ] } else if (ipring1 <= nl2 * (5 * nside + 1)) { // equatorial region ip = ipring1 - ncap - 1; irn = (long)Math.floor(ip / nl4) + nside; // counted from north pole iphi = (long) BitManipulation.MODULO(ip, nl4) + 1; kshift = (long) BitManipulation.MODULO(irn + nside, 2); // 1 if odd 0 // otherwise nr = nside; ire = irn - nside + 1; // in [1, 2*nside+1] irm = nl2 + 2 - ire; ifm = (iphi - ire / 2 + nside - 1) / nside; // face boundary ifp = (iphi - irm / 2 + nside - 1) / nside; if (ifp == ifm) { face_num = (long) BitManipulation.MODULO(ifp, 4.) + 4; } else if (ifp + 1 == ifm) { // (half-) faces 0 to 3 face_num = ifp; } else if (ifp - 1 == ifm) { // (half-) faces 8 to 11 face_num = ifp + 7; } } else { // south polar cap ip = npix - ipring1 + 1; hip = ip / 2.0; fihip = Math.floor(hip); irs = (long)Math.floor( Math.sqrt(hip - Math.sqrt(fihip))) + 1; iphi = 4 * irs + 1 - (ip - 2 * irs * (irs - 1)); kshift = 0; nr = irs; irn = nl4 - irs; face_num = (iphi - 1) / irs + 8; // in [8,11] } // finds the (x,y) on the face // irt = irn - jrll[(int) (face_num + 1)] * nside + 1; // in [-nside+1,0] ipt = 2 * iphi - jpll[(int) (face_num + 1)] * nr - kshift - 1; // in [-nside+1, // nside-1] // if (ipt >= nl2){ ipt = ipt - 8*nside; // for the face #4 } ix = (ipt - irt) / 2; iy = -(ipt + irt) / 2; ix_low = (long) BitManipulation.MODULO(ix, xmax); ix_hi = ix / xmax; iy_low = (long) BitManipulation.MODULO(iy, xmax); iy_hi = iy / xmax; // ipf = (x2pix[(int) (ix_hi + 1)] + y2pix[(int) (iy_hi + 1)]) * xmax * xmax + (x2pix[(int) (ix_low + 1)] + y2pix[(int) (iy_low + 1)]); // in [0, nside**2 -1] ipnest = ipf + face_num * nside * nside; // in [0, 12*nside**2 -1] return ipnest; } /** * converts from NESTED to RING pixel numbering * * @param nside * long resolution * @param ipnest * long NEST pixel number * @return ipring long RING pixel number * @throws IllegalArgumentException */ public long nest2ring(long nside, long ipnest) { long res = 0; long npix, npface, face_num, ncap, n_before, ipf, ip_low, ip_trunc; long ip_med, ip_hi, ix, iy, jrt, jr, nr, jpt, jp, kshift, nl4; // long[] ixiy = { 0, 0 }; // coordinates of lowest corner of each face long[] jrll = { 0, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4 }; // in units of // nside long[] jpll = { 0, 1, 3, 5, 7, 0, 2, 4, 6, 1, 3, 5, 7 }; // in units of // nside/2 String SID = "nest2ring:"; // if ((nside < 1) || (nside > ns_max)) { throw new IllegalArgumentException(SID + " nside should be power of 2 >0 and < ns_max"); } npix = 12 * nside * nside; if ((ipnest < 0) || (ipnest > npix - 1)) { throw new IllegalArgumentException(SID + " ipnest out of range [0,npix-1]"); } if (pix2x[pixmax-1] <= 0) mk_pix2xy(); ncap = 2 * nside * (nside - 1); // number of points in the North polar // cap nl4 = 4 * nside; // finds the face and the number in the face npface = nside * nside; face_num = ipnest / npface; // face number in [0,11] if (ipnest >= npface) { ipf = (long) BitManipulation.MODULO(ipnest, npface); // pixel number in the face } else { ipf = ipnest; } // finds the x,y on the face // from the pixel number ip_low = (long) BitManipulation.MODULO(ipf, pixmax); // last 15 bits if (ip_low < 0) ip_low = -ip_low; ip_trunc = ipf / pixmax; // truncate last 15 bits ip_med = (long) BitManipulation.MODULO(ip_trunc, pixmax); // next 15 bits if (ip_med < 0) ip_med = -ip_med; ip_hi = ip_trunc / pixmax; // high 15 bits ix = pixmax * pix2x[(int) ip_hi] + xmid * pix2x[(int) ip_med] + pix2x[(int) ip_low]; iy = pixmax * pix2y[(int) ip_hi] + xmid * pix2y[(int) ip_med] + pix2y[(int) ip_low]; // transform this in (horizontal, vertical) coordinates jrt = ix + iy; // vertical in [0,2*(nside -1)] jpt = ix - iy; // horizontal in [-nside+1, nside - 1] // calculate the z coordinate on the sphere jr = jrll[(int) (face_num + 1)] * nside - jrt - 1; // ring number in [1,4*nside // -1] nr = nside; // equatorial region (the most frequent) n_before = ncap + nl4 * (jr - nside); kshift = (long) BitManipulation.MODULO(jr - nside, 2); if (jr < nside) { // north pole region nr = jr; n_before = 2 * nr * (nr - 1); kshift = 0; } else if (jr > 3 * nside) { // south pole region nr = nl4 - jr; n_before = npix - 2 * (nr + 1) * nr; kshift = 0; } // computes the phi coordinate on the sphere in [0,2pi] jp = (jpll[(int) (face_num + 1)] * nr + jpt + 1 + kshift) / 2; // 'phi' number // in ring // [1,4*nr] if (jp > nl4) jp -= nl4; if (jp < 1) jp += nl4; res = n_before + jp - 1; // in [0, npix-1] return res; } /** * fills arrays x2pix and y2pix giving the number of the pixel laying in * (x,y). x and y are in [1,512] the pixel number is in [0, 512**2 -1] * * if i-1 = sum_p=0 b_p*2^p then ix = sum+p=0 b_p*4^p iy = 2*ix ix + iy in * [0,512**2 -1] * */ private static void mk_xy2pix() { long k, ip, id; for (int i = 1; i <= xmax; i++) { long j = i - 1; k = 0; ip = 1; while (j != 0) { id = (long) BitManipulation.MODULO(j, 2); j /= 2; k += ip * id; ip *= 4; } x2pix[i] = k; y2pix[i] = 2 * k; } } /** * returns the ring number in {1, 4*nside - 1} calculated from z coordinate * * @param nside * long resolution * @param z * double z coordinate * @return long ring number */ public long RingNum(long nside, double z) { long iring = 0; /* equatorial region */ iring = (long) Math.round(nside * (2.0 - 1.5 * z)); /* north cap */ if (z > twothird) { iring = (long) Math.round(nside * Math.sqrt(3.0 * (1.0 - z))); if (iring == 0) iring = 1; } /* south cap */ if (z < -twothird) { iring = (long) Math.round(nside * Math.sqrt(3.0 * (1.0 + z))); if (iring == 0) iring = 1; iring = 4 * nside - iring; } return iring; } /** * 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) * * @param theta double * @param phi double * @return Vector3d * @throws IllegalArgumentException */ public Vector3d Ang2Vec(double theta, double phi) { double PI = Math.PI; String SID = "Ang2Vec:"; Vector3d v; if ((theta < 0.0) || (theta > PI)) { throw new IllegalArgumentException(SID + " theta out of range [0.,PI]"); } double stheta = Math.sin(theta); double x = stheta * Math.cos(phi); double y = stheta * Math.sin(phi); double z = Math.cos(theta); v = new Vector3d(x, y, z); return 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 * * @param v * Vector3d * @return double[] out_tup out_tup[0] = theta out_tup[1] = phi */ public double[] Vect2Ang(Vector3d v) { double[] out_tup = new double[2]; double norm = v.length(); double z = v.z / norm; double theta = Math.acos(z); double phi = 0.; if ((v.x != 0.) || (v.y != 0)) { phi = Math.atan2(v.y, v.x); // phi in [-pi,pi] } if (phi < 0) phi += 2.0 * Math.PI; // phi in [0, 2pi] // phi += Math.PI; out_tup[0] = theta; out_tup[1] = phi; return out_tup; } /** * returns nside such that npix = 12*nside^2, nside should be * power of 2 and smaller than ns_max if not return -1 * * @param npix * long the number of pixels in the map * @return long nside the map resolution parameter */ public long Npix2Nside(long npix) { long nside = 0; long npixmax = 12 *(long) ns_max *(long) ns_max; String SID = "Npix2Nside:"; nside = (long) Math.rint(Math.sqrt(npix / 12)); if (npix < 12) { throw new IllegalArgumentException(SID + " npix is too small should be > 12"); } if (npix > npixmax) { throw new IllegalArgumentException(SID + " npix is too large > 12 * ns_max^2"); } double fnpix = 12.0 * nside * nside; if (Math.abs(fnpix - npix) > 1.0e-2) { throw new IllegalArgumentException(SID + " npix is not 12*nside*nside"); } double flog = Math.log((double) nside) / Math.log(2.0); double ilog = Math.rint(flog); if (Math.abs(flog - ilog) > 1.0e-6) { throw new IllegalArgumentException(SID + " nside is not power of 2"); } return nside; } /** * calculates npix such that npix = 12*nside^2 ,nside should be * a power of 2, and smaller than ns_max otherwise return -1 * * @param nside * long the map resolution * @return npix long the number of pixels in the map */ public long Nside2Npix(long nside) { long[] nsidelist = { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304}; long res = 0; String SID = "Nside2Npix:"; if (Arrays.binarySearch(nsidelist, nside) < 0) { throw new IllegalArgumentException(SID + " nside should be >0, power of 2, <"+ns_max); } res = 12 * nside * nside; return res; } /** * 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.) * * @param v1 Vector3d * @param v2 Vector3d * @param v3 Vector3d vertices of the triangle * @return double the triangle surface * @throws Exception * */ public double SurfaceTriangle(Vector3d v1, Vector3d v2, Vector3d v3) throws Exception { double res = 0.; double side1 = AngDist(v2, v3) / 4.0; double side2 = AngDist(v3, v1) / 4.0; double side3 = AngDist(v1, v2) / 4.0; double x0 = Math.tan(side1 + side2 + side3); double x1 = Math.tan(side2 + side3 - side1); double x2 = Math.tan(side1 + side3 - side2); double x3 = Math.tan(side1 + side2 - side3); res = 4.0 * Math.atan(Math.sqrt(x0 * x1 * x2 * x3)); return res; } /** * calculates angular distance (in radians) between 2 Vectors * v1 and v2 In general dist = acos(v1.v2) except if the vectors are almost * aligned * * @param v1 Vector3d * @param v2 Vector3d * @return double dist in radians * @throws Exception */ public double AngDist(Vector3d v1, Vector3d v2) throws Exception { double dist = 0.; double aligned = 0.999; /* Normalize both vectors */ Vector3d r1 = new Vector3d(v1.x,v1.y,v1.z); Vector3d r2 = new Vector3d(v2.x,v2.y,v2.z); r1.normalize(); r2.normalize(); double sprod = r1.dot(r2); /* This takes care about the bug in vecmath method from java3d project */ if (sprod > aligned) { // almost aligned r1.sub(r2); double diff = r1.length(); dist = 2.0 * Math.asin(diff / 2.0); } else if (sprod < -aligned) { r1.add(r2); double diff = r1.length(); dist = Math.PI - 2.0 * Math.asin(diff / 2.0); } else { dist = r1.angle(r2); } return dist; } /** * calculates a vector production of two vectors. * * @param v1 * Vectror containing 3 elements of Number type * @param v2 * Vector containing 3 elements of Number type * @return Vector of 3 Objects of Double type * @throws Exception */ public Vector VectProd(Vector v1, Vector v2) throws Exception { Vector res = new Vector(); // double[] v1_element = new double[3]; double[] v2_element = new double[3]; for (int i = 0; i < 3; i++) { if (v1.get(i).getClass().isInstance(Number.class)) { v1_element[i] = ((Number) v1.get(i)).doubleValue(); } else { throw new Exception(); } if (v2.get(i).getClass().isInstance(Number.class)) { v2_element[i] = ((Number) v2.get(i)).doubleValue(); } else { throw new Exception(); } } Double value = new Double(v1_element[1] * v2_element[2] - v1_element[2] * v2_element[1]); res.add( value); value = new Double(v1_element[1] * v2_element[2] - v1_element[2] * v2_element[1]); res.add( value); value = new Double(v1_element[1] * v2_element[2] - v1_element[2] * v2_element[1]); res.add( value); return res; } /** * calculates a dot product (inner product) of two 3D vectors * the result is double * * @param v1 * 3d Vector of Number Objects (Double, long .. ) * @param v2 * 3d Vector * @return double * @throws Exception */ public double dotProduct(Vector3d v1, Vector3d v2) throws Exception { double prod = v1.x * v2.x + v1.y * v2.y + v1.z * v2.z; return prod; } /** * calculate cross product of two vectors * * @param v1 * Vector3d * @param v2 * Vector3d * @return Vector3d result of the product */ public Vector3d crossProduct(Vector3d v1, Vector3d v2) { Vector3d res = new Vector3d(0., 0., 0.); double x = v1.y * v2.z - v1.z * v2.y; double y = v1.z * v2.x - v1.x * v2.z; double z = v1.x * v2.y - v1.y * v2.x; res.x = x; res.y = y; res.z = z; return res; } /** * calculates angular resolution of the pixel map * in arc seconds. * @param nside * @return double resolution in arcsec */ public double PixRes(long nside) { double res = 0.; double degrad = Math.toDegrees(1.0); double skyArea = 4.*PI*degrad*degrad; // 4PI steredian in deg^2 double arcSecArea = skyArea*3600.*3600.; // 4PI steredian in (arcSec^2) long npixels = 12*nside*nside; res = arcSecArea/npixels; // area per pixel res = Math.sqrt(res); // angular size of the pixel arcsec return res; } /** * calculate requared nside given pixel size in arcsec * @param pixsize in arcsec * @return long nside parameter */ public long GetNSide(double pixsize) { long[] nsidelist = { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576 }; long res = 0; double pixelArea = pixsize*pixsize; double degrad = Math.toDegrees(1.); double skyArea = 4.*PI*degrad*degrad*3600.*3600.; long npixels = (long) (skyArea/pixelArea); long nsidesq = npixels/12; long nside_req = (long) Math.sqrt(nsidesq); long mindiff = ns_max; int indmin = 0; for (int i=0; i res) && (nside_req < ns_max)) res = nsidelist[indmin+1]; if (nside_req > ns_max ) { System.out.println("nside cannot be bigger than "+ns_max); return ns_max; } } return res; } /** * returns polar coordinates in radians given ra, dec in degrees * @param radec double array containing ra,dec in degrees * @return res double array containing theta and phi in radians * res[0] = theta res[1] = phi */ public double[] RaDecToPolar(double[] radec) { double[] res = {0.0,0.0}; double ra = radec[0]; double dec = radec[1]; double theta = PI/2. - Math.toRadians(dec); double phi = Math.toRadians(ra); res[0] = theta; res[1] = phi; return res; } /** * returns ra, dec in degrees given polar coordinates in radians * @param polar double array polar[0] = phi in radians * polar[1] = theta in radians * @return double array radec radec[0] = ra in degrees * radec[1] = dec in degrees */ public double[] PolarToRaDec(double[] polar) { double[] radec = {0.0,0.0}; double phi = polar[1]; double theta = polar[0]; double dec = Math.toDegrees(PI/2. - theta); double ra = Math.toDegrees(phi); radec[0] = ra; radec[1] = dec; return radec; } /** * returns polar coordinates of a point on unit sphere given Cartesian coordinates * @param x - Cartesian coordinate x of a point on unit sphere * @param y - y coordinate * @param z - z coordinate * @return double [] theta,phi */ public double[] xyzToPolar(double x, double y, double z) { double[] res; Vector3d vv = new Vector3d(x,y,z); res = Vect2Ang(vv); return res; } /** * Returns singleton instance. */ public static PixTools getInstance() { return pixTools; } } eag-HEALPix-master/gov/fnal/eag/healpix/Region.java000066400000000000000000000106311315400615200222600ustar00rootroot00000000000000package gov.fnal.eag.healpix; import java.util.ArrayList; import javax.vecmath.Vector3d; /** * @author kuropat * The class represents square region on a sphere defined by raMin, raMax * decMin,decMax in degrees. The dec varies from Pi/2 to -Pi/2. * The ra varies from 0. inclusive to 2Pi exclusive. Negative value of ra * will be corrected by adding 2Pi * */ public class Region { private static final double TWOPI = 2.0*Math.PI; private double raMin; private double raMax; private double decMin; private double decMax; private double tetMin; private double tetMax; private double phiMin; private double phiMax; private static final double epsilon = 1.0e-10; // private boolean normalized = false; private ArrayList vertices; private double PI = Math.PI; private BitManipulation bm; /** * default constructor * @param xMin ra min in degrees * @param xMax ra max in degrees * @param yMin dec min in degrees * @param yMax dec max in degrees */ public Region(double xMin, double xMax, double yMin, double yMax) { super(); bm = new BitManipulation(); this.raMin = xMin; this.raMax = xMax; this.phiMin = Math.toRadians(raMin); this.phiMax = Math.toRadians(raMax); if (phiMin < 0.) phiMin += TWOPI; if (phiMax < 0. ) phiMax += TWOPI; if (this.phiMax < this.phiMin) this.phiMax += TWOPI; this.phiMin = bm.MODULO(this.phiMin, TWOPI) - epsilon; // phi min, excluding 2pi period this.phiMax = bm.MODULO(this.phiMax, TWOPI) + epsilon; this.raMin = Math.toDegrees(this.phiMin); this.raMax = Math.toDegrees(this.phiMax); this.decMin = yMin; this.decMax = yMax; this.tetMax = PI/2. - Math.toRadians(decMin); this.tetMin = PI/2. - Math.toRadians(decMax); // create list of vertex vectors vertices = new ArrayList(); PixTools pt = new PixTools(); Vector3d vv = pt.Ang2Vec(tetMin,phiMin); vertices.add(vv); vv = pt.Ang2Vec(tetMin,phiMax); vertices.add(vv); vv = pt.Ang2Vec(tetMax,phiMin); vertices.add(vv); vv = pt.Ang2Vec(tetMax,phiMax); vertices.add(vv); } /** * return true if the point ra,dec is inside region * @param ra in degrees * @param dec in degrees * @return boolean true if inside the region */ public boolean inReg(double ra, double dec) { boolean res = false; double racomp = ra; double phiComp = Math.toRadians(ra); if (phiComp < 0.) phiComp += TWOPI; phiComp = bm.MODULO(phiComp, TWOPI) - epsilon; racomp = Math.toDegrees(phiComp); if ((phiComp >= phiMin - epsilon) && (phiComp <= phiMax + epsilon) && (dec>= decMin - epsilon) && (dec <= decMax + epsilon)) res = true; return res; } /** * return true if point phi, theta is inside region * @param phi in radians * @param theta in radians * @return boolean true if in region */ public boolean inRegPol(double phi, double theta) { boolean res = false; double phicomp = phi; if (phicomp < 0.) phicomp += TWOPI; phicomp = bm.MODULO(this.phiMin, TWOPI) - epsilon; if ((phicomp >= phiMin - epsilon) && (phicomp <= phiMax + epsilon) && (theta>= tetMin - epsilon) && (theta <= tetMax + epsilon)) res = true; return res; } /** * @return ArrayList of 3d vectors of vertices of the region */ public ArrayList getVertices() { return vertices; } /** * divides region on HealPix pixels of given size including * pixels that only partly inside the region * @param precision - angular size of the division element in arcsec * @return ArrayList of pixel numbers in ring schema for specifyed resolution * @throws Exception */ public ArrayList pixelize(double precision) throws Exception { ArrayList res = new ArrayList(); PixTools pt = new PixTools(); long nside = pt.GetNSide(precision); long rnmin = pt.RingNum(nside,Math.cos(tetMin)); long rnmax = pt.RingNum(nside,Math.cos(tetMax)); for (long ir = rnmin; ir < rnmax; ir++) { ArrayList strip = new ArrayList(); double phi = (phiMin + phiMax)/2.; double dphi = (phiMax - phiMin)/2.; strip = pt.InRing(nside, ir, phi, dphi, false); res.addAll(strip); } return res; } /** * provides polar coordinates of the region vertices * @return array of corner coordinates in form of polar thete,phi angles. */ public double[][] getPolReg() { double[][] res = new double[4][2]; res[0][1] = phiMin; res[0][0] = tetMin; res[1][1] = phiMax; res[1][0] = tetMin; res[2][1] = phiMin; res[2][0] = tetMax; res[3][1] = phiMax; res[3][0] = tetMax; return res; } } eag-HEALPix-master/gov/fnal/eag/healpix/test/000077500000000000000000000000001315400615200211505ustar00rootroot00000000000000eag-HEALPix-master/gov/fnal/eag/healpix/test/.gitignore000066400000000000000000000004121315400615200231350ustar00rootroot00000000000000/BitManipulationTest.class /DiscTest.class /PixToolTest1$RaDePoint.class /PixToolTest1.class /PixToolsSingletonTest.class /PixToolsStaticTest.class /PixToolsTest.class /QueryDiscTest.class /RegionTest.class /RingTest.class /ThreadTest$Worker.class /ThreadTest.class eag-HEALPix-master/gov/fnal/eag/healpix/test/BitManipulationTest.java000066400000000000000000000034041315400615200257530ustar00rootroot00000000000000/* * Created on Mar 15, 2005 * */ package gov.fnal.eag.healpix.test; import gov.fnal.eag.healpix.BitManipulation; import junit.framework.TestCase; /** * @author N Kuropatkin * */ public class BitManipulationTest extends TestCase { /** * tests bit manipulation methods */ public void testBitManipulation() { // long mag1 = 178956970; // long a = 3; long b = BitManipulation.swapLSBMSB(a); assertEquals("swapLSBMSB=" + b, 1, a/b, 1e-10); a = 8; b = BitManipulation.swapLSBMSB(a); assertEquals("swapLSBMSB=" + b, 2, a/b, 1e-10); a = 3; b = BitManipulation.invswapLSBMSB(a); assertEquals("invswapLSBMSB=" + b, -4, b, 1e-10); a = 8; b = BitManipulation.invswapLSBMSB(a); assertEquals("invswapLSBMSB=" + b, -5, b, 1e-10); a = 3; b = BitManipulation.invMSB(a); assertEquals("invMSB=" + b, mag1-1, b, 1e-10); a = 8; b = BitManipulation.invMSB(a); assertEquals("invMSB=" + b, mag1-8, b, 1e-10); } /** * test Modulo */ public void testMODULO() { // double a = 5.; double b = 3.; double mod = BitManipulation.MODULO(a,b); System.out.println("a="+a+" b="+b+" mod="+mod); a = -5.0; b = 3.0; mod = BitManipulation.MODULO(a,b); System.out.println("a="+a+" b="+b+" mod="+mod); a = 5.0; b = -3.0; mod = BitManipulation.MODULO(a,b); System.out.println("a="+a+" b="+b+" mod="+mod); a = -5.0; b = -3.0; mod = BitManipulation.MODULO(a,b); System.out.println("a="+a+" b="+b+" mod="+mod); a = 8.0; b = 5.0; mod = BitManipulation.MODULO(a,b); System.out.println("a="+a+" b="+b+" mod="+mod); a = -8.0; b = 5.0; mod = BitManipulation.MODULO(a,b); System.out.println("a="+a+" b="+b+" mod="+mod); a = 1.0; b = 4.0; mod = BitManipulation.MODULO(a,b); System.out.println("a="+a+" b="+b+" mod="+mod); } } eag-HEALPix-master/gov/fnal/eag/healpix/test/DiscTest.java000066400000000000000000000124641315400615200235440ustar00rootroot00000000000000package gov.fnal.eag.healpix.test; import java.util.Collection; import java.util.Iterator; import java.util.Random; import java.util.Set; import java.util.TreeSet; import javax.vecmath.Vector3d; import gov.fnal.eag.healpix.PixTools; public class DiscTest { private int nCheck; private int nFail; public void checkOverlap( int order, double raDeg1, double decDeg1, double raDeg2, double decDeg2 ) throws Exception { double ra1 = Math.toRadians( raDeg1 ); double dec1 = Math.toRadians( decDeg1 ); double ra2 = Math.toRadians( raDeg2 ); double dec2 = Math.toRadians( decDeg2 ); double[] radec1 = {raDeg1,decDeg1}; double[] polar1 = new double[2]; double[] radec2 = {raDeg2,decDeg2}; double[] polar2 = new double[2]; // System.out.println("ra1="+ra1+" dec1="+dec1+" ra2="+ra2+" dec2="+dec2); PixTools pixTools = PixTools.getInstance(); polar1 = pixTools.RaDecToPolar(radec1); polar2 = pixTools.RaDecToPolar(radec2); // System.out.println("thet1="+polar1[0]+" phi1="+polar1[1]+" thet2="+polar2[0]+" phi2="+polar2[1]); Vector3d v1 = pixTools.Ang2Vec(polar1[0], polar1[1]); Vector3d v2 = pixTools.Ang2Vec(polar2[0], polar2[1]); // Distance between the two points. double separation = haversineSeparationFormula( ra1, dec1, ra2, dec2 ); double separation2 = pixTools.AngDist(v1, v2); // System.out.println("separation1="+separation+" separation2="+separation2); // Pick disc radius to be slightly larger than half the distance. // The discs must therefore overlap, which means that the // returned pixel lists must have at least one pixel in common. double radius = separation * 0.5001; double radius2 = separation2 * 0.5001; // System.out.println("radius="+radius+" radius2="+radius2); Collection disc1 = queryDisc( order, ra1, dec1, radius ); Collection disc2 = queryDisc( order, ra2, dec2, radius ); nCheck++; if ( intersection( disc1, disc2 ).isEmpty() ) { System.out.println( "** ERROR: no overlap detected **: " + "(" + raDeg1 + "," + decDeg1 + ") - " + "(" + raDeg2 + "," + decDeg2 + ")" + ", order=" + order + ", radius=" + radius ); nFail++; } } public Collection queryDisc( int order, double ra, double dec, double radius ) { PixTools pixTools = PixTools.getInstance(); long nside = orderToNside( order ); double theta = Math.PI / 2 - dec; double phi = ra; Vector3d vec = pixTools.Ang2Vec( theta, phi ); return pixTools.query_disc( nside, vec, radius, 1, 1 ); } public String report() { return "Checks: " + nCheck + "; " + "Failures: " + nFail; } static long orderToNside( int order ) { return 1L << order; } static Collection intersection( Collection c1, Collection c2 ) { // System.out.println("n pixels 1="+c1.size()+" 2="+c2.size()); Set s = new TreeSet( c1 ); s.retainAll( c2 ); return s; } /** * Haversine formula for spherical trigonometry. * This does not have the numerical instabilities of the cosine formula * at small angles. *

* This implementation derives from Bob Chamberlain's contribution * to the comp.infosystems.gis FAQ; he cites * R.W.Sinnott, "Virtues of the Haversine", Sky and Telescope vol.68, * no.2, 1984, p159. * * @param ra1 right ascension of point 1 in radians * @param dec1 declination of point 1 in radians * @param ra2 right ascension of point 2 in radians * @param dec2 declination of point 2 in radians * @return angular separation of point 1 and point 2 in radians * @see */ static double haversineSeparationFormula( double ra1, double dec1, double ra2, double dec2 ) { double sd2 = Math.sin( 0.5 * ( dec2 - dec1 ) ); double sr2 = Math.sin( 0.5 * ( ra2 - ra1 ) ); double a = sd2 * sd2 + sr2 * sr2 * Math.cos( dec1 ) * Math.cos( dec2 ); if ( Double.isNaN( a ) ) { return Double.NaN; } return a < 1.0 ? 2.0 * Math.asin( Math.sqrt( a ) ) : Math.PI; } public static void main( String[] args ) throws Exception { DiscTest test = new DiscTest(); Random rnd = new Random( 2301L ); double scale = 0.1; // degree for ( int i = 0; i < 1000000; i++ ) { double ra1 = rnd.nextDouble() * 360; double dec1 = rnd.nextDouble() * 180 - 90; double ra2 = Math.min( ra1 + rnd.nextDouble() * scale, 360 ); double dec2 = Math.max( Math.min( dec1 + rnd.nextDouble() * scale, 90 ), -90 ); for ( int order = 5; order < 12; order++ ) { test.checkOverlap( order, ra1, dec1, ra2, dec2 ); } } test.checkOverlap( 8, 0., -89.983888, 180., -89.983888 ); System.out.println( test.report() ); } } eag-HEALPix-master/gov/fnal/eag/healpix/test/PixToolTest1.java000066400000000000000000000116371315400615200243420ustar00rootroot00000000000000package gov.fnal.eag.healpix.test; import javax.vecmath.Vector3d; import gov.fnal.eag.healpix.PixTools; import junit.framework.TestCase; public class PixToolTest1 extends TestCase { static PixTools tools = new PixTools(); long NSIDE1 = 64; long NSIDE2 = 512; public void testCircle1(){ Vector3d vect = tools.Ang2Vec(0.5178634297507729, 0.06421357206295804); System.out.println("vx="+vect.x+" vy="+vect.y+" vz="+vect.z); tools.query_disc(NSIDE1, tools.Ang2Vec(0.5178634297507729, 0.06421357206295804), 5.817764173314432E-4, 1, 1); } public void testCircle2(){ tools.query_disc(NSIDE1, tools.Ang2Vec(0.3127581538205727, 0.1050979097909252), 0.01454441043328608, 1, 1); } public void testCircle3(){ Vector3d vect = tools.Ang2Vec(0.011620983936195673, 0.44456444930382233); System.out.println("vx="+vect.x+" vy="+vect.y+" vz="+vect.z); tools.query_disc(NSIDE1, vect, 5.526875964648709E-4, 1, 1); } public void testCircle4(){ tools.query_disc(NSIDE1, tools.Ang2Vec(0.3127581538205727, 0.1050979097909252), 0.01454441043328608, 1, 1); } /*** with NSIDE 512 **/ public void testCircle5(){ tools.query_disc(NSIDE2, tools.Ang2Vec(1.0486568403767373, 0.036411931519731704), 6.399540590645875E-4, 1, 1); } /*** with NSIDE 512 **/ public void testVertexes(){ double ra = 30.0; double dec=30.0; double rad2deg = 180.0/Math.PI; double[] radec = new double[2]; radec[0] = ra; radec[1] = dec; double[] thetphi = new double[2]; thetphi = tools.RaDecToPolar(radec); double theta = thetphi[0]; double phi = thetphi[1]; long ipix = tools.ang2pix_nest(NSIDE2, theta, phi); double[][] vertexes = tools.pix2vertex_nest(NSIDE2, ipix); long ipixR = tools.ang2pix_ring(NSIDE2, theta, phi); double[][] vertexesr = tools.pix2vertex_ring(NSIDE2, ipixR); for (int i=0; i< 4; i++) { Vector3d vect = new Vector3d(vertexes[0][i],vertexes[1][i],vertexes[2][i]); double[] angs =tools.Vect2Ang(vect); Vector3d vectR = new Vector3d(vertexesr[0][i],vertexesr[1][i],vertexesr[2][i]); double[] angsR =tools.Vect2Ang(vectR); assertEquals("theta="+angs[0],angs[0],angsR[0], 1e-10); assertEquals("phi="+angs[1],angs[1],angsR[1], 1e-10); } } /*** with high res.**/ public void testVertexesHR(){ long nside = 1 << 20 ; double ra = 30.0; double dec=30.0; double[] radec = new double[2]; radec[0] = ra; radec[1] = dec; double[] thetphi = new double[2]; thetphi = tools.RaDecToPolar(radec); double theta = thetphi[0]; double phi = thetphi[1]; long ipix = tools.ang2pix_nest(nside, theta, phi); double[][] vertexes = tools.pix2vertex_nest(nside, ipix); long ipixR = tools.ang2pix_ring(nside, theta, phi); double[][] vertexesr = tools.pix2vertex_ring(nside, ipixR); for (int i=0; i< 4; i++) { Vector3d vect = new Vector3d(vertexes[0][i],vertexes[1][i],vertexes[2][i]); double[] angs =tools.Vect2Ang(vect); Vector3d vectR = new Vector3d(vertexesr[0][i],vertexesr[1][i],vertexesr[2][i]); double[] angsR =tools.Vect2Ang(vectR); assertEquals("theta="+angs[0],angs[0],angsR[0], 1e-10); assertEquals("phi="+angs[1],angs[1],angsR[1], 1e-10); } } public void testInverse(){ for(double ra = 0.0 ; ra < 360.0; ra+=10) { for(double de = -85 ; de <= 85; de+=10) { long area =getHealId(ra,de,NSIDE2); RaDePoint p = getRaDe(area,NSIDE2); //compare with tolerance assertTrue(ra+"!="+p.ra,Math.abs(ra- p.ra)<1); assertTrue(de+"!="+p.de,Math.abs(de- p.de)<1); } } } /** * get position ID for ra,de * @param ra right ascencion in degrees * @param de declination in degrees * @param nsides - non default number of nsides */ public long getHealId(double ra, double de, long nsides) { double[] radec = new double[2]; radec[0] = ra; radec[1] = de; double[] polar = tools.RaDecToPolar(radec); long ip = tools.ang2pix_ring(nsides, polar[0], polar[1]); return ip; } /** inverse method, convert area ID to RaDePoint */ public static RaDePoint getRaDe(long area,long nsides) { double [] polar = tools.pix2ang_ring(nsides , area); double[]radec = tools.PolarToRaDec(polar); return new RaDePoint(radec[0],radec[1]); } /** * Simple point on sky. Used as return value of functions *

* @See CoeliObject for data definition */ static public class RaDePoint { /** coordinates in degrees*/ public double ra,de; public RaDePoint() {} public RaDePoint(double ra, double de){ this.ra = ra; this.de = de; } } } eag-HEALPix-master/gov/fnal/eag/healpix/test/PixToolsSingletonTest.java000066400000000000000000001444331315400615200263300ustar00rootroot00000000000000package gov.fnal.eag.healpix.test; import java.io.File; import java.io.FileNotFoundException; import java.io.OutputStream; import java.io.PrintStream; import java.util.ArrayList; import gov.fnal.eag.healpix.BitManipulation; import gov.fnal.eag.healpix.PixTools; import javax.vecmath.Vector3d; import junit.framework.TestCase; public class PixToolsSingletonTest extends TestCase { /** * test MODULO function */ public void testMODULO() { // double A = 8.; double B = 5.; double res = BitManipulation.MODULO(A, B); assertEquals("modulo = " + res, 3., res, 1e-10); A = -8.; B = 5.; res = BitManipulation.MODULO(A, B); assertEquals("modulo = " + res, 2., res, 1e-10); A = 8.; B = -5.; res = BitManipulation.MODULO(A, B); assertEquals("modulo = " + res, -2., res, 1e-10); A = -8.; B = -5.; res = BitManipulation.MODULO(A, B); assertEquals("modulo = " + res, -3., res, 1e-10); System.out.println(" test MODULO is done"); } /** * tests angular distance calculation * @throws Exception */ public void testAngDist() throws Exception { Vector3d v1 = new Vector3d(1.5, 1.6, 2.0); Vector3d v2 = new Vector3d(1.2, 1.0, 1.5); double res1 = PixTools.getInstance().AngDist(v1, v2); double res2 = v1.angle(v2); System.out.println("res1 = " + res1 + " res2=" + res2); assertEquals("angular Distance=" + res2, 1.0, res1 / res2, 1e-10); Vector3d v3 = new Vector3d(1.5, 1.6, 0.); Vector3d v4 = new Vector3d(1.5, 1.601, 0.); double res3 = PixTools.getInstance().AngDist(v3, v4); double res4 = v3.angle(v4); // System.out.println("res3 = " + res3 + " res4=" + res4); assertEquals("angular Distance=" + res4, 1., res3/res4, 1e-3); Vector3d v5 = new Vector3d(1.5, 1.6, 0.); Vector3d v6 = new Vector3d(-1.5, -1.75, 0.); double res5 = PixTools.getInstance().AngDist(v5, v6); double res6 = v5.angle(v6); System.out.println("res5 = " + res5 + " res6=" + res6); assertEquals("angular Distance=" + res6, 1.0, res5 / res6, 1e-10); System.out.println(" test of AngDist is done"); } /** * @throws Exception */ public void testSurfaceTriangle() throws Exception { Vector3d v1 = new Vector3d(1.0, 0.0, 0.0); Vector3d v2 = new Vector3d(0.0, 1.0, 0.0); Vector3d v3 = new Vector3d(0.0, 0.0, 1.0); double res = PixTools.getInstance().SurfaceTriangle(v1, v2, v3); System.out.println("Triangle surface is=" + res / Math.PI + " steredians"); assertEquals("Triangle surface=" + res, 0.5, res / Math.PI, 1e-10); System.out.println(" test of SurfaceTriangle is done"); } /** * tests calculation of npixels from nside */ public void testNside2Npix() { int nside = 1; int npix = 0; npix = (int) PixTools.getInstance().Nside2Npix(nside); assertEquals("Npix=" + npix, 12, npix, 1e-10); nside = 2; npix = (int) PixTools.getInstance().Nside2Npix(nside); assertEquals("Npix=" + npix, 48, npix, 1e-10); } /** * tests calculation of nsides from npixels */ public void testNpix2Nside() { int npix = 12; int nside = 0; nside = (int) PixTools.getInstance().Npix2Nside(npix); double pixSize1 = PixTools.getInstance().PixRes(65536); long nside1 = PixTools.getInstance().GetNSide(pixSize1); assertEquals("Nside=" + nside1, 65536, nside1, 1e-10); assertEquals("Nside=" + nside, 1, nside, 1e-10); } /** * test of directional angles calculation */ public void testVec2Ang() { double PI = Math.PI; Vector3d v = new Vector3d(0.0, 1.0, 0.0); double[] ang_tup = { 0., 0. }; ang_tup = PixTools.getInstance().Vect2Ang(v); System.out.println(" Theta=" + ang_tup[0] / PI + " Phi=" + ang_tup[1] / PI); assertEquals("Theta=" + ang_tup[0], 0.5, ang_tup[0] / PI, 1e-10); assertEquals("Phi=" + ang_tup[1], 0.5, ang_tup[1] / PI, 1e-10); v = new Vector3d(1.0, 0.0, 0.0); ang_tup = PixTools.getInstance().Vect2Ang(v); assertEquals("phi=" + ang_tup[1], 0., ang_tup[1] / PI, 1e-10); System.out.println(" test Vect2Ang is done"); } /** * tests calculation of pixel from polar angles * in ring schema of pixalization * @throws Exception */ public void testAng2Pix() throws Exception { System.out.println(" Test ang2pix_ring ___________________"); double PI = Math.PI; long pix = -1; double theta = PI / 2. - 0.2; double phi = PI / 2. ; long nside = 4; try { pix = PixTools.getInstance().ang2pix_ring(nside,theta, phi); } catch (Exception e) { e.printStackTrace(); } Vector3d v = PixTools.getInstance().Ang2Vec(theta,phi); long pix1 = PixTools.getInstance().vect2pix_ring(nside,v); assertEquals("pix=" + pix, pix1, pix, 1e-10); assertEquals("pix=" + pix, 76, pix, 1e-10); long pix2 = PixTools.getInstance().ang2pix_nest(nside,theta,phi); long pix3 = PixTools.getInstance().vect2pix_nest(nside,v); assertEquals("pix2=" + pix2, pix3, pix2, 1e-10); assertEquals("pix2=" + pix2, 92, pix2, 1e-10); double[] radec = PixTools.getInstance().pix2ang_ring(nside,76); assertEquals("theta=" + theta, theta, radec[0], 4e-2); assertEquals("phi=" + phi, radec[1], phi, 1e-2); double[] radec1 = PixTools.getInstance().pix2ang_nest(nside,92); System.out.println("theta="+radec1[0]+" phi="+radec1[1]); assertEquals("theta=" + theta, theta, radec1[0], 4e-2); assertEquals("phi=" + phi, radec1[1], phi, 1e-2); System.out.println(" test Ang2Pix is done"); } /** * tests calculation of unit vector from polar angles * @throws Exception */ public void testAng2Vect() throws Exception { System.out.println(" Start test Ang2Vect----------------"); double PI = Math.PI; double theta = PI / 2.; double phi = PI / 2; Vector3d v = PixTools.getInstance().Ang2Vec(theta, phi); System.out.println("Vector x=" + v.x + " y=" + v.y + " z=" + v.z); assertEquals("x=" + v.x, 0., v.x, 1e-10); assertEquals("y=" + v.y, 1., v.y, 1e-10); assertEquals("z=" + v.z, 0., v.z, 1e-10); System.out.println(" test Ang2Vect is done"); } /** * tests calculation of ring number from z coordinate * @throws Exception */ public void testRingNum() throws Exception { double z = 0.25; int nside = 1; System.out.println("Start test RingNum !!!!!!!!!!!!!!!!!!!!"); int nring = (int) PixTools.getInstance().RingNum(nside, z); System.out.println("z=" + z + " ring number =" + nring); assertEquals("z=" + z, 2, nring, 1e-10); z = -0.25; nring = (int) PixTools.getInstance().RingNum(nside, z); assertEquals("z=" + z, 2, nring, 1e-10); z = 0.8; nring = (int) PixTools.getInstance().RingNum(nside, z); assertEquals("z=" + z, 1, nring, 1e-10); z = -0.8; nring = (int) PixTools.getInstance().RingNum(nside, z); assertEquals("z=" + z, 3, nring, 1e-10); System.out.println(" test RingNum is done"); nside = 4; int pix = 3; Vector3d v = PixTools.getInstance().pix2vect_ring(nside, pix); z = v.z; nring = (int) PixTools.getInstance().RingNum(nside, z); assertEquals("z=" + z, 1, nring, 1e-10); pix = 11; v = PixTools.getInstance().pix2vect_ring(nside, pix); z = v.z; nring = (int) PixTools.getInstance().RingNum(nside, z); assertEquals("z=" + z, 2, nring, 1e-10); pix = 23; v = PixTools.getInstance().pix2vect_ring(nside, pix); z = v.z; nring = (int) PixTools.getInstance().RingNum(nside, z); assertEquals("z=" + z, 3, nring, 1e-10); pix = 39; v = PixTools.getInstance().pix2vect_ring(nside, pix); z = v.z; nring = (int) PixTools.getInstance().RingNum(nside, z); assertEquals("z=" + z, 4, nring, 1e-10); pix = 55; v = PixTools.getInstance().pix2vect_ring(nside, pix); z = v.z; nring = (int) PixTools.getInstance().RingNum(nside, z); assertEquals("z=" + z, 5, nring, 1e-10); pix = 71; v = PixTools.getInstance().pix2vect_ring(nside, pix); z = v.z; nring = (int) PixTools.getInstance().RingNum(nside, z); assertEquals("z=" + z, 6, nring, 1e-10); pix = 87; v = PixTools.getInstance().pix2vect_ring(nside, pix); z = v.z; nring = (int) PixTools.getInstance().RingNum(nside, z); assertEquals("z=" + z, 7, nring, 1e-10); pix = 103; v = PixTools.getInstance().pix2vect_ring(nside, pix); z = v.z; nring = (int) PixTools.getInstance().RingNum(nside, z); assertEquals("z=" + z, 8, nring, 1e-10); pix = 119; v = PixTools.getInstance().pix2vect_ring(nside, pix); z = v.z; nring = (int) PixTools.getInstance().RingNum(nside, z); assertEquals("z=" + z, 9, nring, 1e-10); pix = 135; v = PixTools.getInstance().pix2vect_ring(nside, pix); z = v.z; nring = (int) PixTools.getInstance().RingNum(nside, z); assertEquals("z=" + z, 10, nring, 1e-10); pix = 151; v = PixTools.getInstance().pix2vect_ring(nside, pix); z = v.z; nring = (int) PixTools.getInstance().RingNum(nside, z); assertEquals("z=" + z, 11, nring, 1e-10); pix = 167; v = PixTools.getInstance().pix2vect_ring(nside, pix); z = v.z; nring = (int) PixTools.getInstance().RingNum(nside, z); assertEquals("z=" + z, 12, nring, 1e-10); pix = 169; v = PixTools.getInstance().pix2vect_ring(nside, pix); z = v.z; nring = (int) PixTools.getInstance().RingNum(nside, z); assertEquals("z=" + z, 13, nring, 1e-10); pix = 180; v = PixTools.getInstance().pix2vect_ring(nside, pix); z = v.z; nring = (int) PixTools.getInstance().RingNum(nside, z); assertEquals("z=" + z, 14, nring, 1e-10); System.out.println("End test RingNum"); } /** * tests conversion from nest schema pixel to ring schema pixel * @throws Exception */ public void testNest2Ring() throws Exception { int ipnest = 3; int nside = 2; int ipring = (int) PixTools.getInstance().nest2ring(nside, ipnest); assertEquals("ipring=" + ipring, 0, ipring, 1e-10); ipnest = 0; nside = 2; ipring = (int) PixTools.getInstance().nest2ring(nside, ipnest); assertEquals("ipring=" + ipring, 13, ipring, 1e-10); ipnest = 18; nside = 2; ipring = (int) PixTools.getInstance().nest2ring(nside, ipnest); assertEquals("ipring=" + ipring, 27, ipring, 1e-10); ipnest = 23; nside = 2; ipring = (int) PixTools.getInstance().nest2ring(nside, ipnest); assertEquals("ipring=" + ipring, 14, ipring, 1e-10); ipnest = 5; nside = 4; ipring = (int) PixTools.getInstance().nest2ring(nside, ipnest); assertEquals("ipring = " + ipring, 27, ipring, 1e-10); System.out.println(" test Nest2Ring is done"); } /** * tests conversion from ring schema pixel to nest schema pixel * @throws Exception */ public void testRing2Nest() throws Exception { System.out.println(" start test Ring2Nest !!!!!!!!!!!!!!!!!!!!!!"); int ipring = 0; int nside = 2; int ipnest = (int) PixTools.getInstance().ring2nest(nside, ipring); assertEquals("ipnest=" + ipnest, 3, ipnest, 1e-10); ipring = 13; nside = 2; ipnest = (int) PixTools.getInstance().ring2nest(nside, ipring); assertEquals("ipnest=" + ipnest, 0, ipnest, 1e-10); ipring = 27; nside = 2; ipnest = (int) PixTools.getInstance().ring2nest(nside, ipring); assertEquals("ipnest=" + ipnest, 18, ipnest, 1e-10); ipring = 14; nside = 2; ipnest = (int) PixTools.getInstance().ring2nest(nside, ipring); assertEquals("ipnest=" + ipnest, 23, ipnest, 1e-10); ipring = 27; nside = 4; ipnest = (int) PixTools.getInstance().ring2nest(nside, ipring); assertEquals("ipnest = " + ipnest, 5, ipnest, 1e-10); ipring = 83; nside = 4; ipnest = (int) PixTools.getInstance().ring2nest(nside, ipring); assertEquals("ipnest = " + ipnest, 123, ipnest, 1e-10); System.out.println(" test Ring2Nest is done"); } /** * tests Next_In_Line method for the nest schema * @throws Exception */ public void testNext_In_Line_Nest() throws Exception { int ipix = 0; int nside = 2; int ipnext = (int) PixTools.getInstance().next_in_line_nest(nside, ipix); assertEquals("ipnext=" + ipnext, 23, ipnext, 1e-10); ipix = 1; nside = 2; ipnext = (int) PixTools.getInstance().next_in_line_nest(nside, ipix); assertEquals("ipnext=" + ipnext, 6, ipnext, 1e-10); ipix = 4; nside = 2; ipnext = (int) PixTools.getInstance().next_in_line_nest(nside, ipix); assertEquals("ipnext=" + ipnext, 27, ipnext, 1e-10); ipix = 27; nside = 2; ipnext = (int) PixTools.getInstance().next_in_line_nest(nside, ipix); assertEquals("ipnext=" + ipnext, 8, ipnext, 1e-10); ipix = 12; nside = 2; ipnext = (int) PixTools.getInstance().next_in_line_nest(nside, ipix); assertEquals("ipnext=" + ipnext, 19, ipnext, 1e-10); ipix = 118; nside = 4; ipnext = (int) PixTools.getInstance().next_in_line_nest(nside, ipix); assertEquals("ipnext = " + ipnext, 117, ipnext, 1e-10); System.out.println(" test next_in_line_nest is done"); } /** * tests InRing method * @throws Exception */ public void testInRing() throws Exception { System.out.println(" Start test InRing !!!!!!!!!!!!!!!!!!!!!!!!!"); int[] nestComp = { 19, 0, 23, 4, 27, 8, 31, 12 }; long[] ringHi = {17, 18, 19, 12, 13 }; long[] nestHi = { 8, 31, 12, 19, 0 }; long[] ringLow = {19, 12, 13, 14, 15 }; long[] nestLow = { 12, 19, 0, 23, 4 }; double PI = Math.PI; int nside = 2; boolean nest = false; int iz = 3; double phi = PI; double dphi = PI; ArrayList ring = PixTools.getInstance().InRing(nside, iz, phi, dphi, nest); for (int i = 0; i < ring.size(); i++) { assertEquals("ipnext = " + ((Long) ring.get(i)).longValue(), i + 12, ((Long) ring.get(i)).longValue(), 1e-10); } Vector3d v = new Vector3d(1., 0., 0.); double[] ang_tup = { 0., 0. }; ang_tup = PixTools.getInstance().Vect2Ang(v); phi = ang_tup[1]/PI; ring = PixTools.getInstance().InRing(nside, iz, phi, dphi, nest); for (int i = 0; i < ring.size(); i++) { assertEquals("ipnext = " + ((Long) ring.get(i)).longValue(), i + 12, ((Long) ring.get(i)).longValue(), 1e-10); } Vector3d v1 = new Vector3d(-1., 0., 0.); ang_tup = PixTools.getInstance().Vect2Ang(v1); phi = ang_tup[1]/PI; ring = PixTools.getInstance().InRing(nside, iz, phi, dphi, nest); for (int i = 0; i < ring.size(); i++) { assertEquals("ipnext = " + ((Long) ring.get(i)).longValue(), i + 12, ((Long) ring.get(i)).longValue(), 1e-10); } phi = 1.75*PI; dphi = 0.5*PI; ring = PixTools.getInstance().InRing(nside, iz, phi, dphi, nest); for (int i = 0; i < ring.size(); i++) { assertEquals("ipnext = " + ((Long) ring.get(i)).longValue(), ringHi[i], ((Long) ring.get(i)).longValue(), 1e-10); } phi = 1.75*PI; dphi = 0.5*PI; nest = true; ring = PixTools.getInstance().InRing(nside, iz, phi, dphi, nest); for (int i = 0; i < ring.size(); i++) { assertEquals("ipnext = " + ((Long) ring.get(i)).longValue(), nestHi[i], ((Long) ring.get(i)).longValue(), 1e-10); } phi = 0.25*PI; dphi = 0.5*PI; nest = false; ring = PixTools.getInstance().InRing(nside, iz, phi, dphi, nest); for (int i = 0; i < ring.size(); i++) { assertEquals("ipnext = " + ((Long) ring.get(i)).longValue(), ringLow[i], ((Long) ring.get(i)).longValue(), 1e-10); } phi = 0.25*PI; dphi = 0.5*PI; nest = true; ring = PixTools.getInstance().InRing(nside, iz, phi, dphi, nest); for (int i = 0; i < ring.size(); i++) { assertEquals("ipnext = " + ((Long) ring.get(i)).longValue(), nestLow[i], ((Long) ring.get(i)).longValue(), 1e-10); } nest = true; dphi = PI; ring = PixTools.getInstance().InRing(nside, iz, phi, dphi, nest); for (int i = 0; i < ring.size(); i++) { assertEquals("ipnext = " + ((Long) ring.get(i)).longValue(), nestComp[i], ((Long) ring.get(i)).longValue(), 1e-10); } nest = false; nside = 4; phi = 2.1598449493429825; iz = 8; dphi = 0.5890486225480867; // System.out.println(" iz="+iz+" phi="+phi+" dphi="+dphi); ring = PixTools.getInstance().InRing(nside, iz, phi, dphi, nest); // for (int i = 0; i */ static double haversineSeparationFormula( double ra1, double dec1, double ra2, double dec2 ) { double sd2 = Math.sin( 0.5 * ( dec2 - dec1 ) ); double sr2 = Math.sin( 0.5 * ( ra2 - ra1 ) ); double a = sd2 * sd2 + sr2 * sr2 * Math.cos( dec1 ) * Math.cos( dec2 ); if ( Double.isNaN( a ) ) { return Double.NaN; } return a < 1.0 ? 2.0 * Math.asin( Math.sqrt( a ) ) : Math.PI; } /** * * @param order * @param raDeg1 in degrees * @param decDeg1 * @param raDeg2 * @param decDeg2 * @throws Exception */ public void checkRing( int order, double raDeg1, double decDeg1, double raDeg2, double decDeg2 ) throws Exception { double ra1 = raDeg1; double dec1 = decDeg1 ; double ra2 = raDeg2; double dec2 = decDeg2; double[] radec1 = {raDeg1,decDeg1}; double[] polar1 = new double[2]; double[] radec2 = {raDeg2,decDeg2}; double[] polar2 = new double[2]; long nside = orderToNside(order); // double pixSize = Math.PI / (2.0 * nside); // in radians long npix = 12*nside*nside; double pixSize = Math.sqrt(4.0*Math.PI/npix); System.out.println("pixSize="+pixSize+" nside="+nside); //System.out.println("ra1="+ra1+" dec1="+dec1+" ra2="+ra2+" dec2="+dec2); PixTools pixTools = PixTools.getInstance(); polar1 = pixTools.RaDecToPolar(radec1); polar2 = pixTools.RaDecToPolar(radec2); //System.out.println("thet1="+polar1[0]+" phi1="+polar1[1]+" thet2="+polar2[0]+" phi2="+polar2[1]); Vector3d v1 = pixTools.Ang2Vec(polar1[0], polar1[1]); // center of 1 Vector3d v2 = pixTools.Ang2Vec(polar2[0], polar2[1]); // center of 2 // Distance between the two points. double separation = haversineSeparationFormula( ra1, dec1, ra2, dec2 ); double separation2 = pixTools.AngDist(v1, v2); System.out.println("separation1="+separation+" separation2="+separation2); // Pick disc radius to be slightly larger than half the distance. // The discs must therefore overlap, which means that the // returned pixel lists must have at least one pixel in common. double radius = separation * 0.5001; double radius2 = separation2 * 0.5001; radius = 20.0*pixSize; System.out.println("radius="+radius+" radius2="+radius2); Collection disc1 = queryRing( order, ra1, dec1, radius ); // Collection disc2 = queryRing( order, ra2, dec2, radius ); Vector3d vP = new Vector3d(0.,0.,0.); long cp = pixTools.vect2pix_ring(nside, v1); v1 = pixTools.pix2vect_ring(nside, cp); polar1 = pixTools.Vect2Ang(v1); radec1 = pixTools.PolarToRaDec(polar1); disc1 = queryRing( order, radec1[0], radec1[1], radius ); Iterator it = disc1.iterator(); long pix = 0; System.out.println("number of pixels in ring "+disc1.size()); while (it.hasNext()) { pix = ((Long)it.next()).longValue(); // polar1 = pixTools.pix2ang_ring(nside, pix); // vP = pixTools.Ang2Vec(polar1[0], polar1[1]); vP=pixTools.pix2vect_ring(nside, pix); separation = pixTools.AngDist(v1, vP); System.out.println("separation="+separation); } } public static void main( String[] args ) throws Exception { RingTest test = new RingTest(); Random rnd = new Random( 2301L ); double scale = 0.1; // degree // for ( int i = 0; i < 1; i++ ) { // double ra1 = rnd.nextDouble() * 360; // double dec1 = rnd.nextDouble() * 180 - 90; // double ra2 = Math.min( ra1 + rnd.nextDouble() * scale, 360 ); // double dec2 = Math.max( Math.min( dec1 + rnd.nextDouble() * scale, // 90 ), -90 ); // for ( int order = 5; order < 12; order++ ) { // test.checkRing( order, ra1, dec1, ra2, dec2 ); // } // } // test.checkRing( 8, 0., -89.983888, 180., -89.983888 ); test.checkRing( 10, 10.0, 0.0, 180., 0.1 ); System.out.println( test.report() ); } } eag-HEALPix-master/gov/fnal/eag/healpix/test/ThreadTest.java000066400000000000000000000053431315400615200240670ustar00rootroot00000000000000package gov.fnal.eag.healpix.test; import gov.fnal.eag.healpix.PixTools; import java.util.List; import java.util.Random; import javax.vecmath.Vector3d; /** * The thread proof test by Mark Teylor * @author Mark Taylor * */ public class ThreadTest { private static PixTools pixTools = new PixTools(); public void testPixtools() throws InterruptedException { workPixtools( false ); workPixtools( true ); } private void workPixtools( boolean useThreads ) throws InterruptedException { int nw = 40; Worker[] workers = new Worker[ nw ]; Random rnd = new Random( 23001L ); int nside = 6 + rnd.nextInt( 3 ); Vector3d vector = new Vector3d( rnd.nextDouble(), rnd.nextDouble(), rnd.nextDouble() ); double radius = 0.1 * rnd.nextDouble(); int nest = 1; int inclusive = 1; for ( int iw = 0; iw < nw; iw++ ) { workers[ iw ] = new Worker( nside, vector, radius, nest, inclusive ); } if ( useThreads ) { for ( int iw = 0; iw < nw; iw++ ) { workers[ iw ].start(); } for ( int iw = 0; iw < nw; iw++ ) { workers[ iw ].join(); } } else { for ( int iw = 0; iw < nw; iw++ ) { workers[ iw ].run(); } } List result0 = workers[ 0 ].result_; for ( int iw = 1; iw < nw; iw++ ) { assertEquals( "Fail at " + iw + " for useThreads=" + useThreads, result0, workers[ iw ].result_ ); } } private static void assertEquals( String msg, List l1, List l2 ) { if ( ! l1.equals( l2 ) ) { throw new AssertionError( msg + "(" + l1 + " != " + l2 + ")" ); } } private static class Worker extends Thread { private final long nside_; private final Vector3d vector_; private final double radius_; private final int nest_; private final int inclusive_; private List result_; Worker( long nside, Vector3d vector, double radius, int nest, int inclusive ) { nside_ = nside; vector_ = vector; radius_ = radius; nest_ = nest; inclusive_ = inclusive; } public void run() { result_ = pixTools.query_disc( nside_, vector_, radius_, nest_, inclusive_ ); } } public static void main( String[] args ) throws InterruptedException { new ThreadTest().testPixtools(); System.out.println(" if no interrupts the test is complete successfully"); } }