Skip to content

Commit

Permalink
Completes javadoc
Browse files Browse the repository at this point in the history
Adds unit tests
  • Loading branch information
malapert committed Mar 24, 2016
1 parent a2a987d commit 4719169
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 9 deletions.
3 changes: 3 additions & 0 deletions test/io/github/malapert/jwcs/JWcsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public void testGetSkySystem() {

/**
* Test of pix2wcs method, of class JWcs.
* @throws java.lang.Exception
*/
@Test
public void testPix2wcs_doubleArr() throws Exception {
Expand All @@ -105,6 +106,7 @@ public void testPix2wcs_doubleArr() throws Exception {

/**
* Test of getCenter method, of class JWcs.
* @throws java.lang.Exception
*/
@Test
public void testGetCenter() throws Exception {
Expand All @@ -116,6 +118,7 @@ public void testGetCenter() throws Exception {

/**
* Test of getFov method, of class JWcs.
* @throws java.lang.Exception
*/
@Test
public void testGetFov() throws Exception {
Expand Down
89 changes: 81 additions & 8 deletions test/io/github/malapert/jwcs/coordsystem/SkySystemTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@

package io.github.malapert.jwcs.coordsystem;

import io.github.malapert.jwcs.coordsystem.Galactic;
import io.github.malapert.jwcs.coordsystem.FK5;
import io.github.malapert.jwcs.coordsystem.FK4;
import io.github.malapert.jwcs.coordsystem.SkySystem;
import io.github.malapert.jwcs.coordsystem.ICRS;
import io.github.malapert.jwcs.coordsystem.Equatorial;
import io.github.malapert.jwcs.coordsystem.ReferenceSystemInterface;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
Expand Down Expand Up @@ -55,13 +48,93 @@ public void setUp() {
@After
public void tearDown() {
}

@Test
public void separation() {
System.out.println("separation");
ReferenceSystemInterface icrs = new ICRS();
SkySystem sysEqIcrs = new Equatorial(icrs);
ReferenceSystemInterface fk5 = new FK5();
SkySystem sysEqFK5 = new Equatorial(fk5);
SkyPosition pos1 = new SkyPosition(10, 9, sysEqIcrs);
SkyPosition pos2 = new SkyPosition(11, 10, sysEqFK5);
double separation = SkySystem.separation(pos1, pos2);
double expectedSeparation = 1.4045335865;
assertEquals(expectedSeparation, separation, 0.0000000001);
}

@Test
public void testConvertFK4B1950ToFK5J2000() {
System.out.println("convert FK4 B1950 to FK5 J2000");
ReferenceSystemInterface fk4 = new FK4(1950.0f);
SkySystem sysEqFK4 = new Equatorial(fk4);
ReferenceSystemInterface fk5 = new FK5(2000.0f);
SkySystem sysEqFK5 = new Equatorial(fk5);
SkyPosition pos = sysEqFK4.convertTo(sysEqFK5, 0.0d, 0.0d);
double expectedLongitude = 0.640691;
double expectedLatitude = 0.27840944;
assertEquals(expectedLongitude, pos.getLongitude(), 0.000001);
assertEquals(expectedLatitude, pos.getLatitude(), 0.000001);
}

@Test
/**
* Test based on http://docs.astropy.org/en/stable/coordinates/
*/
public void testConvertIcrsToGal() {
System.out.println("convert ICRS to Gal");
ReferenceSystemInterface icrs = new ICRS();
SkySystem sysEqIcrs = new Equatorial(icrs);
SkySystem galactic = new Galactic();
SkyPosition posInGal = sysEqIcrs.convertTo(galactic, 10.68458d, 41.26917d);
double expectedLongitude = 121.174241811;
double expectedLatitude = -21.5728855724;
assertEquals(expectedLongitude, posInGal.getLongitude(), 0.000000001);
assertEquals(expectedLatitude, posInGal.getLatitude(), 0.000000001);
}

@Test
/**
* Test based on http://docs.astropy.org/en/stable/coordinates/
*/
public void testConvertIcrsToFK5J2000() {
System.out.println("convert ICRS to FK5 J2000");
ReferenceSystemInterface icrs = new ICRS();
SkySystem sysEqIcrs = new Equatorial(icrs);
ReferenceSystemInterface fk5 = new FK5(2000.000f);
SkySystem EqFk5 = new Equatorial(fk5);
SkyPosition posInFk5 = sysEqIcrs.convertTo(EqFk5, 10.68458d, 41.26917d);
double expectedLongitude = 10.6845915393;
double expectedLatitude = 41.2691714591;
assertEquals(expectedLongitude, posInFk5.getLongitude(), 0.000000001);
assertEquals(expectedLatitude, posInFk5.getLatitude(), 0.000000001);
}

@Test
/**
* Test based on http://docs.astropy.org/en/stable/coordinates/
*/
public void testConvertToFK5J1975() {
System.out.println("convert FK5J2000 to FK5 J1975");
ReferenceSystemInterface icrs = new ICRS();
SkySystem sysEqIcrs = new Equatorial(icrs);
ReferenceSystemInterface fk5 = new FK5(2000.000f);
SkySystem EqFk5J2000 = new Equatorial(fk5);
SkyPosition posInFk5J2000 = sysEqIcrs.convertTo(EqFk5J2000, 10.68458, 41.26917);
ReferenceSystemInterface fk5_1975 = new FK5(1975.000f);
SkySystem EqFk5J1975 = new Equatorial(fk5_1975);
SkyPosition posInFk5J1975 = EqFk5J2000.convertTo(EqFk5J1975, posInFk5J2000.getLongitude(), posInFk5J2000.getLatitude());
double expectedLongitude = 10.3420913461;
double expectedLatitude = 41.1323211229;
assertEquals(expectedLongitude, posInFk5J1975.getLongitude(), 0.00002);
assertEquals(expectedLatitude, posInFk5J1975.getLatitude(), 0.00002);
}

/**
* Test of convertTo method, of class SkySystem.
*/
@Test
public void testConvertTo() {
public void testConvertTo() {
System.out.println("convert ICRS To FK5");
ReferenceSystemInterface ref = new ICRS();
SkySystem sys1 = new Equatorial(ref);
Expand Down
1 change: 0 additions & 1 deletion test/io/github/malapert/jwcs/proj/AITTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;

Expand Down

0 comments on commit 4719169

Please sign in to comment.