Class PixSampler


  • public class PixSampler
    extends java.lang.Object
    Interrogates a HEALPix all-sky map to sample pixel data. The map is supplied in the form of a table (one row per pixel, using HEALPix pixel indices), as used for instance by LAMBDA.
    Since:
    5 Dec 2011
    Author:
    Mark Taylor
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static interface  PixSampler.StatMode
      Defines how statistics are to be acquired from a pixel or set of pixels.
    • Constructor Summary

      Constructors 
      Constructor Description
      PixSampler​(uk.ac.starlink.table.StarTable pixTable, long nside, boolean nested)
      Constructor.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static PixSampler createPixSampler​(uk.ac.starlink.table.StarTable pixTable)
      Constructs a PixSampler from a given table.
      uk.ac.starlink.table.ColumnInfo[] getValueInfos​(PixSampler.StatMode statMode)
      Returns the metadata for the columns output by the sampler.
      static java.lang.Boolean inferNested​(uk.ac.starlink.table.StarTable pixTable)
      Tries to work out whether a given table uses the nested or ring HEALPix ordering scheme.
      static int inferNside​(uk.ac.starlink.table.StarTable pixTable)
      Tries to work out the HEALPix nside parameter for a pixel data table.
      java.lang.Object sampleValue​(int icol, double alphaDeg, double deltaDeg, double radiusDeg, PixSampler.StatMode statMode)
      Samples a single value from a given sky position.
      java.lang.Object[] sampleValues​(double alphaDeg, double deltaDeg, double radiusDeg, PixSampler.StatMode statMode)
      Samples values from all columns in given table at a given sky position.
      • Methods inherited from class java.lang.Object

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

      • POINT_MODE

        public static final PixSampler.StatMode POINT_MODE
        StatMode for making point samples.
    • Constructor Detail

      • PixSampler

        public PixSampler​(uk.ac.starlink.table.StarTable pixTable,
                          long nside,
                          boolean nested)
                   throws java.io.IOException
        Constructor.
        Parameters:
        pixTable - random access HEALPix-format table (one row per pixel)
        nside - HEALPix nside value
        nested - true for nested pixel order, false for ring
        Throws:
        java.io.IOException - if the table has the wrong number of rows or is not random access
    • Method Detail

      • sampleValue

        public java.lang.Object sampleValue​(int icol,
                                            double alphaDeg,
                                            double deltaDeg,
                                            double radiusDeg,
                                            PixSampler.StatMode statMode)
                                     throws java.io.IOException
        Samples a single value from a given sky position.
        Parameters:
        icol - column index of value to sample
        alphaDeg - longitude position in degrees
        deltaDeg - latitude position in degrees
        radiusDeg - radius of disc over which statistics will be gathered (ignored for point-like statMode)
        statMode - mode for sampling statistics
        Returns:
        sampled value at given point
        Throws:
        java.io.IOException
      • sampleValues

        public java.lang.Object[] sampleValues​(double alphaDeg,
                                               double deltaDeg,
                                               double radiusDeg,
                                               PixSampler.StatMode statMode)
                                        throws java.io.IOException
        Samples values from all columns in given table at a given sky position.
        Parameters:
        alphaDeg - longitude position in degrees
        deltaDeg - latitude position in degrees
        radiusDeg - radius of disc over which statistics will be gathered (ignored for point-like statMode)
        statMode - mode for sampling statistics
        Returns:
        array of sampled column values at given point
        Throws:
        java.io.IOException
      • getValueInfos

        public uk.ac.starlink.table.ColumnInfo[] getValueInfos​(PixSampler.StatMode statMode)
        Returns the metadata for the columns output by the sampler.
        Parameters:
        statMode - mode for sampling statistics
        Returns:
        array of output metadata objects, one for each output column
      • createPixSampler

        public static PixSampler createPixSampler​(uk.ac.starlink.table.StarTable pixTable)
                                           throws java.io.IOException
        Constructs a PixSampler from a given table. The current implementation works with any table having a row count corresponding to a HEALPix pixel count, the nside is inferred. Parameters are interrogated in accordance with the conventions used by, for instance the FITS files used at NASA's LAMBDA archive, but other HEALPix tables that work in a more or less similar way will probably work.

        I don't know of any proper reference for encoding of HEALPix maps in FITS files, but the documentation for the HPIC package (http://cmb.phys.cwru.edu/hpic/) has a useful list of heuristics (manual section 2.10.1). One of these acknowledges the fact that some HEALPix FITS files have columns which are 1024-element arrays (TFORMn = '1024E'). This routine does not currently support this rather perverse convention. If somebody requests it, maybe I'll consider implementing it.

        Parameters:
        pixTable - random access table containing HEALPix pixels
        Returns:
        PixSampler object taking data from table
        Throws:
        java.io.IOException - if table is not random access or does not appear to contain HEALPix data
      • inferNested

        public static java.lang.Boolean inferNested​(uk.ac.starlink.table.StarTable pixTable)
        Tries to work out whether a given table uses the nested or ring HEALPix ordering scheme. Parameters are interrogated in accordance with the conventions used by, for instance the FITS files used at NASA's LAMBDA archive.
        Parameters:
        pixTable - pixel data table
        Returns:
        TRUE for nested, FALSE for ring, null for don't know
      • inferNside

        public static int inferNside​(uk.ac.starlink.table.StarTable pixTable)
                              throws java.io.IOException
        Tries to work out the HEALPix nside parameter for a pixel data table. Mainly it looks at the row count, but if the table obeys HEALPix header conventions any discrepancies between declared and apparent nside result in an error.
        Parameters:
        pixTable - pixel data table
        Returns:
        HEALPix nside
        Throws:
        java.io.IOException