Skip to content

Commit

Permalink
Update tests for WCS output of CD and PC matrixes
Browse files Browse the repository at this point in the history
  • Loading branch information
at88mph committed Aug 13, 2024
1 parent db6759f commit 5fca804
Showing 1 changed file with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@
import ca.nrc.cadc.util.Log4jInit;
import nom.tam.fits.Header;
import nom.tam.fits.HeaderCard;
import nom.tam.fits.header.Standard;
import nom.tam.fits.header.extra.NOAOExt;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.junit.Assert;
Expand Down Expand Up @@ -131,7 +133,29 @@ public void testMultipleWCS() throws Exception {
}

@Test
public void testLinearResolutionAdjustment() throws Exception {
public void testWCSAdjustment() throws Exception {
final String headerFileName = "test-blast-header-1.txt";
final File testFile = FileUtil.getFileFromResource(headerFileName, CircleCutoutTest.class);
final int[] corners = new int[]{0, 0};
final int[] stridingValues = new int[]{1, 5};

try (final InputStream inputStream = Files.newInputStream(testFile.toPath());
final BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream))) {
final Header testHeader = new Header();
final char[] buff = new char[80];
while (bufferedReader.read(buff) >= 0) {
testHeader.addLine(HeaderCard.create(new String(buff)));
}

final double originalCD11 = testHeader.getDoubleValue(NOAOExt.CD1_1);
final double originalCD21 = testHeader.getDoubleValue(NOAOExt.CD2_1);

WCSCutoutUtil.adjustHeaders(testHeader, testHeader.getIntValue(Standard.NAXIS), corners, stridingValues);

Assert.assertEquals("Should remain unchanged as only applies to second axis.", originalCD11, testHeader.getDoubleValue(NOAOExt.CD1_1),
0.0D);
Assert.assertEquals("Should be adjusted.", originalCD21 * ((double) stridingValues[1]), testHeader.getDoubleValue(NOAOExt.CD2_1),
0.0D);
}
}
}

0 comments on commit 5fca804

Please sign in to comment.