Giter Club home page Giter Club logo

cds-healpix-java's People

Contributors

fxpineau avatar mbtaylor avatar mreineck avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cds-healpix-java's Issues

ConeComputer ArrayIndexOutOfBoundsException

If I run this:

        Healpix.getNested( 6 )
               .newConeComputer( 0.9886484667476922 )
               .overlappingCells( 4.646003386280478, -0.41602905223485265 );

I get

java.lang.ArrayIndexOutOfBoundsException: 1020
        at cds.healpix.NestedSmallCellApproxedMethod.buildMocRecursively(NestedSmallCellApproxedMethod.java:230)

Is my cone too big?

Troubles generating the API documentation

This is probably a newbie mistake, since I haven't worked with Java for a long time...

When running ant make.doc, I'm getting the following errors (and no HTML documentation):

martin@debian:~/codes/cds-healpix-java$ ant make.doc
Buildfile: /home/martin/codes/cds-healpix-java/build.xml

clean.doc:
     [echo] Clean dir: "/home/martin/codes/cds-healpix-java/target/docs/apidocs"...

doc:
     [echo] Create JavaDoc from "/home/martin/codes/cds-healpix-java/src/main/java" to "/home/martin/codes/cds-healpix-java/target/docs/apidocs"...
  [javadoc] Generating Javadoc
  [javadoc] Javadoc execution
  [javadoc] Loading source files for package cds.healpix...
  [javadoc] Loading source files for package cds.healpix.common...
  [javadoc] Loading source files for package cds.healpix.common.math...
  [javadoc] Loading source files for package cds.healpix.common.sphgeom...
  [javadoc] Loading source files for package cds.healpix.fillingcurve...
  [javadoc] /home/martin/codes/cds-healpix-java/src/main/java/cds/healpix/NeighbourList.java:1: error: unmappable character (0xC3) for encoding US-ASCII
  [javadoc] // Copyright 2017-2018 - Universit?? de Strasbourg/CNRS
  [javadoc]                                   ^
  [javadoc] /home/martin/codes/cds-healpix-java/src/main/java/cds/healpix/NeighbourList.java:1: error: unmappable character (0xA9) for encoding US-ASCII
  [javadoc] // Copyright 2017-2018 - Universit?? de Strasbourg/CNRS

... and so on.

Apparently my setup is not sufficiently francophone ;)
Any tips how to fix this?

Tag a version?

Hi,

cds-healpix-java is a new dependency of the upcoming Aladin version, and I would like to package it for Debian as a separate package. Maintenance for me would be easier when you could provide (tag) versions that are supposed to use.

Could I ask you to tag a version of the package?

Best regards

Ole

Numerical error in HealpixNestedPolygonComputer.overlappingCells

Hi @fxpineau. I see a problem if I run the following code against cds-healpix-java v0.30.2:

import cds.healpix.Healpix;
import cds.healpix.HealpixNestedPolygonComputer;

public class Overlap {
    public static void main(String[] args) {
        int order = 12;
        HealpixNestedPolygonComputer pc = Healpix.getNested( 12 ).newPolygonComputer();
        double[][] verts1 = new double[][] {
            { -1.5702949547333407, -0.7295093151415473 },
            { -1.5702171673769950, -0.7295093016804524 },
            { -1.5701393800214274, -0.7295092852142693 },
            { -1.5700615926667945, -0.7295092657429985 },
        };
        double[][] verts2 = new double[][] {
            { -1.5706045044233712, -0.7295105218483977 },
            { -1.5705168372776197, -0.7295105199399403 },
            { -1.5704291701320918, -0.7295105142145686 },
            { -1.5703415029870114, -0.7295105046722821 },
        };
        pc.overlappingCells( verts1 );  // OK
        pc.overlappingCells( verts2 );  // trouble
    }
}

The calculation with the second set of vertices gives me an AssertionError at cds.healpix.NewtonMethod.arcSpecialPointInEqr(NewtonMethod.java:234), or a NullPointerException later on if assertions are turned off. This is probably some kind of edge case since this code has been in topcat for several years and I haven't noticed it before now.

PolygonComputer.overlappingCells can assert false

It is (rarely) possible to provoke an AssertionError (if assertions are enabled) while evaluating cells in a polygon:

        double[][] vertices = { 
            {4.695790732486566, 0.8889150097255261},
            {4.4682913488764395, 0.24417985540748033},
            {4.2460276551603116, -0.1307183283958091},
            {3.915276622719796, -0.42958085596528983},
            {3.159957098738856, -0.5694515052059677},
            {3.4232653287700523, -0.8411539982726408},
            {3.5624631270616547, -1.0765021986213243},
            {3.5643253154494583, -1.3247502355595913},
            {7.889934078990009, -1.4138979988201017},
            {5.093052102418385, -1.0463233540993349},
            {5.212197941830804, -0.6180885659230597},
            {5.375096075892637, -0.2088528564758103},
            {5.776366851387001, 0.33400642074068165},
            {5.4196187097295985, 0.35367158642311125},
            {5.171289457253199, 0.45115053076437905},
            {4.947552986866946, 0.6074987013677716},
            {4.695790732486566, 0.8889150097255261},
         };
         Healpix.getNested( 6 ).newPolygonComputer().overlappingCells( vertices );

fails the assert statement at cds.healpix.NewtonMethod.arcSpecialPointInPc(NewtonMethod.java:394).
I haven't noticed problems with the call apart from that.

newConeComputerApprox failure

@fxpineau, I'm getting an ArrayIndexOutOfBoundsException for this code:

import cds.healpix.Healpix;
import cds.healpix.HealpixNestedFixedRadiusConeComputer;

public class T1 {
    public static void main(String[] args) {
        int depth = 14;
        double radius = 0.001;
        double alpha = 0.002;
        double delta = -1.3;
        HealpixNestedFixedRadiusConeComputer coner =
            Healpix.getNested(depth).newConeComputerApprox(radius);
        coner.overlappingCells(alpha, delta);      // ArrayOutOfBoundsException here
    }
}

It does not seem too dependent on the numerical values. Can you take a look?

[0.25.1] HasckerDelightTestPerf test error

When I run the test suite (ant make.test), I get the following error:

Testsuite: cds.healpix.common.math.HasckerDelightTestPerf
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.018 sec

Testcase: initializationError(cds.healpix.common.math.HasckerDelightTestPerf):	Caused an ERROR
Method testPerf should have no parameters
java.lang.Exception: Method testPerf should have no parameters
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)


Test cds.healpix.common.math.HasckerDelightTestPerf FAILED

However, the test still suceeds (exit value of ant is zero). Java version is openjdk-11.

Tag 0.28 version?

Hi,

as I am currently upgrading starjava (STIL, STILTS, TOPCAT) in Debian, I found that it contains now a specific test for a bug in cds-healpix-java. This bug was actually fixed in 8d607b7, and the fixed library is included as a jar in Starjava with version number 0.28.
To keep the version numbers consistent: would it be possible to tag the current master as v0.28 or v0.28.1? I then could update its Debian package as a dependency of Starjava-tables. This is not absolutely required for me, but it would help to keep the versions in sync.

Thanks,

Olebole (Debian maintainer of both cds-healpix-java and starjava-table)

HealpixNestedFast.hash and negative longitudes

Hi @fxpineau . The behaviour of the HashComputer.hash() method for HealpixNested and HealpixNestedFast seems to differ when lonRad<0, though the documentation says

lonRad ... must support reasonably large positive and negative values

Here is a test:

import cds.healpix.Healpix;
public class MbtTest {
    public static void checkHash( int depth, double lon, double lat ) {
        long h0 = Healpix.getNested( depth ).hash( lon, lat );
        long h1 = Healpix.getNestedFast( depth ).hash( lon, lat );
        System.out.println( "(" + lon + "," + lat + "):\t-> " 
                          + h0 + "\t" + h1 + "\t"
                          + ( h0 == h1 ? "" : "!!!" ) );
    }
    public static void main( String[] args ) {
        int depth = 3; 
        for ( int ilon = 1; ilon >= -1; ilon-- ) {
            for ( int ilat = 1; ilat >= -1; ilat-- ) {
                checkHash( depth, 0.5 * ilon, 0.5 * ilat );
            }
        }
    }
}

which gives me

(0.5,0.5):      -> 33   33
(0.5,0.0):      -> 278  278
(0.5,-0.5):     -> 557  557
(0.0,0.5):      -> 316  316
(0.0,0.0):      -> 304  304
(0.0,-0.5):     -> 259  259
(-0.5,0.5):     -> 210  33      !!!
(-0.5,0.0):     -> 297  278     !!!
(-0.5,-0.5):    -> 734  557     !!!

AssertionError in vertex calculation

The following program throws an AssertionError (if run with -enableassertions) in the vertex invocation:

import cds.healpix.CompassPoint;
import cds.healpix.Healpix;
import cds.healpix.VerticesAndPathComputer;

public class Vert {
    public static void main( String[] args ) {
        int order = 4;
        int hash = 87;
        CompassPoint.Cardinal cardinal = CompassPoint.Cardinal.N;
        VerticesAndPathComputer vc = Healpix.getNestedFast(order);
        double[] lonlat = vc.vertex(hash, cardinal);
        System.out.println(lonlat[0] + ", " + lonlat[1]);
    }
}

Tests for UltraCompactMOC fail with OpenJDK 11.0.3

When running the test suite, I get (among others) the following error:

    [junit] Testcase: test1(cds.healpix.HealpixNestedUltraCompactMOCTest):	Caused an ERROR
    [junit] Index 6 out of bounds for length 6
    [junit] java.lang.ArrayIndexOutOfBoundsException: Index 6 out of bounds for length 6
    [junit] 	at cds.healpix.HealpixNestedUltraCompactMOC.bitSetFromBytes(HealpixNestedUltraCompactMOC.java:147)
    [junit] 	at cds.healpix.HealpixNestedUltraCompactMOC.decompress(HealpixNestedUltraCompactMOC.java:153)
    [junit] 	at cds.healpix.HealpixNestedUltraCompactMOCTest.test1(HealpixNestedUltraCompactMOCTest.java:72)
    [junit] 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    [junit] 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    [junit] 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

I'm pretty sure this happens because of the following code in HealpixNestedUltraCompactMOC.java:

    final BitSet bs = new BitSet(8 * compressedMoc.length);
    for (int i = 0; i < bs.size(); i++) {

Here, the implicit assumption seems to be that bs.size() is exactly equal to 8 * compressedMoc.length. But I don't think this is the case; the BitSet implementation may be allowed to round up its size to the nearest convenient value (e.g. the next multiple of 32). In this case the code above will break.

HealpixNestedFast.pathAlongCellEdge bug?

The result of VerticesAndPathComputer.pathAlongCellEdge differs in some cases between HealpixNested and HealpixNestedFast. I think HealpixNestedFast is the one getting it wrong.

Running this:

import cds.healpix.CompassPoint;
import cds.healpix.Healpix;
import cds.healpix.VerticesAndPathComputer;
import java.util.Arrays;

public class MbtTest {
    public static void checkVertices( int depth, long hash ) {
        VerticesAndPathComputer vpc0 = Healpix.getNested( depth );
        VerticesAndPathComputer vpc1 = Healpix.getNestedFast( depth );
        CompassPoint.Cardinal east = CompassPoint.Cardinal.E;
        double[][] vs0 = vpc0.pathAlongCellEdge( hash, east, true, 1 );
        double[][] vs1 = vpc1.pathAlongCellEdge( hash, east, true, 1 );
        System.out.println( depth + "\t" + hash + ": "
                          + (Arrays.deepEquals( vs0, vs1 ) ? "ok" : "NOT OK") );
    }
    public static void main( String[] args ) {
        for ( long h = 42236L; h < 42243L; h++ ) {
            checkVertices( 6, h );
        }
    }
}

gives me

6       42236: ok
6       42237: ok
6       42238: ok
6       42239: NOT OK
6       42240: ok
6       42241: ok
6       42242: ok

May or may not be related to #9.

HealpixNestedFast.pathAlongCellEdge bug

HealpixNestedFast, but not other VerticesAndPathComputers, gets the North vertex wrong for tiles just below the northern cap when executing pathAlongCellEdge, though not when calling vertex directly. Using v0.30_1, this code:

import java.util.Arrays;
import cds.healpix.CompassPoint;
import cds.healpix.Healpix;
import cds.healpix.VerticesAndPathComputer;

public class Vert {
    public static void main( String[] args ) {
        int order = 3;
        int hash = 42;
        VerticesAndPathComputer vc1 = Healpix.getNested(order).newVerticesAndPathComputer();
        VerticesAndPathComputer vc2 = Healpix.getNestedFast(order);
        printVertexNorth(vc1, hash);
        printVertexNorth(vc2, hash);
        System.out.println();
        printVertices(vc1, hash);
        printVertices(vc2, hash);
    }
    static void printVertexNorth(VerticesAndPathComputer vc, int hash) {
        System.out.println(Arrays.toString(vc.vertex(hash, CompassPoint.Cardinal.N)));
    }
    static void printVertices(VerticesAndPathComputer vc, int hash) {
        double[][] lonlats = vc.pathAlongCellEdge(hash, CompassPoint.Cardinal.E, true, 1);
        for (int i = 0; i < 4; i++) {
            System.out.print(Arrays.toString(lonlats[i]));
        }
        System.out.println();
    }
}

gives this result:

[0.0, 0.8402225818983444]
[0.0, 0.8402225818983444]

[0.19634954084936207, 0.7297276562269663][0.09817477042468103, 0.6228265854120029][0.0, 0.7297276562269663][0.0, 0.8402225818983444]
[0.19634954084936207, 0.7297276562269663][0.09817477042468103, 0.6228265854120029][0.0, 0.7297276562269663][0.09817477042468103, 0.848062078981481]

Problem with the CLI

I don't manage to get the CLI to work. Whichever action I specify, I get an "unknown action" error.

I think this can be fixed by replacing all "==" operators between strings in HealpixCLI.java by .equals(). However I'm sure I'm not the first one to notice this ... so am I missing something obvious?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.