From 06870ca7c80e83a24e39b9f70012ea4b48211416 Mon Sep 17 00:00:00 2001 From: Dustin Jenkins Date: Wed, 12 Jun 2024 06:39:11 -0700 Subject: [PATCH 1/2] Upgrade to latest nom-tam-fits. --- cadc-data-ops-fits/build.gradle | 6 +-- .../main/java/org/opencadc/fits/CADCExt.java | 17 +------ .../fits/slice/FITSHeaderWCSKeywords.java | 40 +++++++++-------- .../fits/slice/TimeHeaderWCSKeywords.java | 45 ++++++++++--------- .../test/java/org/opencadc/fits/FitsTest.java | 8 +--- .../opencadc/fits/slice/TimeCutoutTest.java | 25 ++++++----- .../fits/slice/TimeHeaderWCSKeywordsTest.java | 18 ++++---- 7 files changed, 74 insertions(+), 85 deletions(-) diff --git a/cadc-data-ops-fits/build.gradle b/cadc-data-ops-fits/build.gradle index d467ef85..621685ff 100644 --- a/cadc-data-ops-fits/build.gradle +++ b/cadc-data-ops-fits/build.gradle @@ -10,9 +10,9 @@ repositories { mavenLocal() } -sourceCompatibility = 1.8 +sourceCompatibility = 11 group = 'org.opencadc' -version = '0.3.0' +version = '0.4.0' description = 'OpenCADC FITS cutout library' def git_url = 'https://github.com/opencadc/dal' @@ -23,7 +23,7 @@ dependencies { implementation 'org.opencadc:cadc-soda-server:[1.2.1,2.0)' implementation 'org.opencadc:cadc-wcs:[2.1.4,3.0)' implementation 'org.opencadc:jsky:[1.0.0,2.0.0)' - implementation 'gov.nasa.gsfc.heasarc:nom-tam-fits:1.18.0' + implementation 'gov.nasa.gsfc.heasarc:nom-tam-fits:1.20.0' // Use JUnit test framework testImplementation 'junit:junit:[4.13,5.0)' diff --git a/cadc-data-ops-fits/src/main/java/org/opencadc/fits/CADCExt.java b/cadc-data-ops-fits/src/main/java/org/opencadc/fits/CADCExt.java index 39679da1..49dff126 100644 --- a/cadc-data-ops-fits/src/main/java/org/opencadc/fits/CADCExt.java +++ b/cadc-data-ops-fits/src/main/java/org/opencadc/fits/CADCExt.java @@ -99,33 +99,18 @@ public enum CADCExt implements IFitsHeader { SPECSYS(HDU.IMAGE, VALUE.STRING, ""), // Temporal values. - MJDREF(HDU.IMAGE, VALUE.REAL, "Reference time in MJD"), MJDREFI(HDU.IMAGE, VALUE.REAL, "Integer part of reference time in MJD"), MJDREFF(HDU.IMAGE, VALUE.REAL, "Fractional part of reference time in MJD"), - JDREF(HDU.IMAGE, VALUE.REAL, "Reference time in JD"), JDREFI(HDU.IMAGE, VALUE.REAL, "Integer part of reference time in JD"), JDREFF(HDU.IMAGE, VALUE.REAL, "Fractional part of reference time in JD"), - DATEBEG("DATE-BEG", HDU.PRIMARY_EXTENSION, VALUE.REAL, "Start time of data in iso-8601"), - DATEOBS("DATE-OBS", HDU.PRIMARY_EXTENSION, VALUE.REAL, "Time (or start time) of data in iso-8601"), - DATEEND("DATE-END", HDU.PRIMARY_EXTENSION, VALUE.REAL, "Stop time of data in iso-8601"), - JDBEG("JD-BEG", HDU.PRIMARY_EXTENSION, VALUE.REAL, "Start time of data in JD"), JDOBS("JD-OBS", HDU.PRIMARY_EXTENSION, VALUE.REAL, "Time (or start time) of data in JD"), JDEND("JD-END", HDU.PRIMARY_EXTENSION, VALUE.REAL, "Stop time of data in JD"), - MJDBEG("MJD-BEG", HDU.PRIMARY_EXTENSION, VALUE.REAL, "Start time of data in MJD"), - MJDOBS("MJD-OBS", HDU.PRIMARY_EXTENSION, VALUE.REAL, "Time (or start time) of data in MJD"), - MJDEND("MJD-END", HDU.PRIMARY_EXTENSION, VALUE.REAL, "Stop time of data in MJD"), - TSTART(HDU.PRIMARY_EXTENSION, VALUE.REAL, "Start time of data in units of TIMEUNIT relative to MJDREF, JDREF or DATEREF according to TIMESYS."), TSTOP(HDU.PRIMARY_EXTENSION, VALUE.REAL, - "Stop time of data in units of TIMEUNIT relative to MJDREF, JDREF or DATEREF according to TIMESYS."), - - DATEREF(HDU.IMAGE, VALUE.REAL, "Reference time in ISO-8601"), - - TIMESYS(HDU.PRIMARY_EXTENSION, VALUE.STRING, "Time scale. Defaults to UTC."), - TIMEUNIT(HDU.ANY, VALUE.STRING, "Unit of elapsed time."); + "Stop time of data in units of TIMEUNIT relative to MJDREF, JDREF or DATEREF according to TIMESYS."); private final IFitsHeader key; diff --git a/cadc-data-ops-fits/src/main/java/org/opencadc/fits/slice/FITSHeaderWCSKeywords.java b/cadc-data-ops-fits/src/main/java/org/opencadc/fits/slice/FITSHeaderWCSKeywords.java index c84c9871..40a4a3c7 100644 --- a/cadc-data-ops-fits/src/main/java/org/opencadc/fits/slice/FITSHeaderWCSKeywords.java +++ b/cadc-data-ops-fits/src/main/java/org/opencadc/fits/slice/FITSHeaderWCSKeywords.java @@ -70,18 +70,16 @@ import ca.nrc.cadc.util.StringUtil; import ca.nrc.cadc.wcs.WCSKeywords; - import java.math.BigDecimal; import java.math.BigInteger; import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; import java.util.Map; - -import nom.tam.fits.FitsFactory; import nom.tam.fits.Header; import nom.tam.fits.HeaderCard; import nom.tam.fits.HeaderCardException; +import nom.tam.fits.header.DateTime; import nom.tam.fits.header.Standard; import nom.tam.fits.header.extra.NOAOExt; import nom.tam.util.Cursor; @@ -103,7 +101,8 @@ public class FITSHeaderWCSKeywords implements WCSKeywords { /** * Empty constructor. - * @throws HeaderCardException If cloning the header fails. + * + * @throws HeaderCardException If cloning the header fails. */ public FITSHeaderWCSKeywords() throws HeaderCardException { this(new Header()); @@ -411,11 +410,12 @@ private Header cloneHeader(final Header source) throws HeaderCardException { /** * Copy a header card with some potential modifications. COMMENT and HISTORY cards are truncated to the * maximum length. - * @param destination The Header to write to. - * @param headerCardKey The current key. - * @param valueType The class type of the value. - * @param comment The comment value for COMMENT or HISTORY values. - * @param value The string value. + * + * @param destination The Header to write to. + * @param headerCardKey The current key. + * @param valueType The class type of the value. + * @param comment The comment value for COMMENT or HISTORY values. + * @param value The string value. * @throws HeaderCardException */ private void cloneHeaderCard(final Header destination, final String headerCardKey, final Class valueType, @@ -484,8 +484,8 @@ private void sanitizeHeader(final Header destination) throws HeaderCardException } if (x == temporalAxis && !destination.containsKey(CADCExt.CUNITn.n(x)) - && !destination.containsKey(CADCExt.TIMEUNIT)) { - destination.addValue(CADCExt.TIMEUNIT.key(), "s", CADCExt.TIMEUNIT.comment()); + && !destination.containsKey(DateTime.TIMEUNIT)) { + destination.addValue(DateTime.TIMEUNIT.key(), "s", DateTime.TIMEUNIT.comment()); } } @@ -502,6 +502,7 @@ private void sanitizeHeader(final Header destination) throws HeaderCardException /** * Obtain the spatial longitude axis value. + * * @return int axis, or -1 if no spectral axis present. */ int getSpatialLongitudeAxis() { @@ -510,8 +511,9 @@ int getSpatialLongitudeAxis() { /** * Obtain the two spatial axis value. - * @param h The header to check for the axes. - * @return int of longitude axis numbers, or -1 if none found. + * + * @param h The header to check for the axes. + * @return int of longitude axis numbers, or -1 if none found. */ int getSpatialLongitudeAxis(final Header h) { final int naxis = h.getIntValue(Standard.NAXIS); @@ -529,6 +531,7 @@ int getSpatialLongitudeAxis(final Header h) { /** * Obtain the spatial longitude axis value. + * * @return int axis, or -1 if no spectral axis present. */ int getSpatialLatitudeAxis() { @@ -537,8 +540,9 @@ int getSpatialLatitudeAxis() { /** * Obtain the two spatial axis value. - * @param h The header to check for the axes. - * @return int of longitude axis numbers, or -1 if none found. + * + * @param h The header to check for the axes. + * @return int of longitude axis numbers, or -1 if none found. */ int getSpatialLatitudeAxis(final Header h) { final int naxis = h.getIntValue(Standard.NAXIS); @@ -566,7 +570,7 @@ int getSpectralAxis() { /** * Obtain the energy (1-based) axis from the given header. Return -1 if none found that match the Spectral types. * - * @param h The header to search in + * @param h The header to search in * @return integer axis, or -1 if not found. */ int getSpectralAxis(final Header h) { @@ -594,7 +598,7 @@ public int getTemporalAxis() { /** * Obtain the time (1-based) axis from the given header. Return -1 if none found that match the Temporal types. * - * @param h The header to search in + * @param h The header to search in * @return integer axis, or -1 if not found. */ int getTemporalAxis(final Header h) { @@ -622,7 +626,7 @@ int getPolarizationAxis() { /** * Obtain the time (1-based) axis from the given header. Return -1 if none found that match the Temporal types. * - * @param h The header to search in + * @param h The header to search in * @return integer axis, or -1 if not found. */ int getPolarizationAxis(final Header h) { diff --git a/cadc-data-ops-fits/src/main/java/org/opencadc/fits/slice/TimeHeaderWCSKeywords.java b/cadc-data-ops-fits/src/main/java/org/opencadc/fits/slice/TimeHeaderWCSKeywords.java index f503f328..16d99c79 100644 --- a/cadc-data-ops-fits/src/main/java/org/opencadc/fits/slice/TimeHeaderWCSKeywords.java +++ b/cadc-data-ops-fits/src/main/java/org/opencadc/fits/slice/TimeHeaderWCSKeywords.java @@ -77,6 +77,7 @@ import nom.tam.fits.Header; import nom.tam.fits.HeaderCardException; +import nom.tam.fits.header.DateTime; import org.apache.log4j.Logger; import org.opencadc.fits.CADCExt; @@ -113,21 +114,21 @@ public double getMJDRef() throws ParseException { && this.fitsHeaderWCSKeywords.containsKey(CADCExt.MJDREFF.key())) { mjdRef = this.fitsHeaderWCSKeywords.getIntValue(CADCExt.MJDREFI.key()) + this.fitsHeaderWCSKeywords.getDoubleValue(CADCExt.MJDREFF.key()); - } else if (this.fitsHeaderWCSKeywords.containsKey(CADCExt.MJDREF.key())) { - mjdRef = this.fitsHeaderWCSKeywords.getDoubleValue(CADCExt.MJDREF.key()); + } else if (this.fitsHeaderWCSKeywords.containsKey(DateTime.MJDREF.key())) { + mjdRef = this.fitsHeaderWCSKeywords.getDoubleValue(DateTime.MJDREF.key()); } else if (this.fitsHeaderWCSKeywords.containsKey(CADCExt.JDREFI.key()) && this.fitsHeaderWCSKeywords.containsKey(CADCExt.JDREFF.key())) { final double jdRef = this.fitsHeaderWCSKeywords.getIntValue(CADCExt.JDREFI.key()) + this.fitsHeaderWCSKeywords.getDoubleValue(CADCExt.JDREFF.key()); mjdRef = DateUtil.toModifiedJulianDate(jdRef); - } else if (this.fitsHeaderWCSKeywords.containsKey(CADCExt.JDREF.key())) { - mjdRef = DateUtil.toModifiedJulianDate(this.fitsHeaderWCSKeywords.getDoubleValue(CADCExt.JDREF.key())); - } else if (this.fitsHeaderWCSKeywords.containsKey(CADCExt.DATEREF.key())) { - LOGGER.debug("Using DATEREF: " + this.fitsHeaderWCSKeywords.getStringValue(CADCExt.DATEREF.key())); + } else if (this.fitsHeaderWCSKeywords.containsKey(DateTime.JDREF.key())) { + mjdRef = DateUtil.toModifiedJulianDate(this.fitsHeaderWCSKeywords.getDoubleValue(DateTime.JDREF.key())); + } else if (this.fitsHeaderWCSKeywords.containsKey(DateTime.DATEREF.key())) { + LOGGER.debug("Using DATEREF: " + this.fitsHeaderWCSKeywords.getStringValue(DateTime.DATEREF.key())); final String timeSystem = getSystem(); final TimeZone timeZone = TimeZone.getTimeZone(timeSystem); final Date date = DateUtil.getDateFormat(DateUtil.ISO8601_DATE_FORMAT_LOCAL, timeZone).parse( - this.fitsHeaderWCSKeywords.getStringValue(CADCExt.DATEREF.key())); + this.fitsHeaderWCSKeywords.getStringValue(DateTime.DATEREF.key())); mjdRef = DateUtil.toModifiedJulianDate(date, timeZone); } else { mjdRef = 0.0D; @@ -141,27 +142,27 @@ public double getMJDRef() throws ParseException { public double getMJDStart() throws ParseException { final double startMJD; - if (this.fitsHeaderWCSKeywords.containsKey(CADCExt.MJDBEG.key())) { - startMJD = this.fitsHeaderWCSKeywords.getDoubleValue(CADCExt.MJDBEG.key()); - } else if (this.fitsHeaderWCSKeywords.containsKey(CADCExt.MJDOBS.key())) { - startMJD = this.fitsHeaderWCSKeywords.getDoubleValue(CADCExt.MJDOBS.key()); + if (this.fitsHeaderWCSKeywords.containsKey(DateTime.MJD_BEG.key())) { + startMJD = this.fitsHeaderWCSKeywords.getDoubleValue(DateTime.MJD_BEG.key()); + } else if (this.fitsHeaderWCSKeywords.containsKey(DateTime.MJD_OBS.key())) { + startMJD = this.fitsHeaderWCSKeywords.getDoubleValue(DateTime.MJD_OBS.key()); } else if (this.fitsHeaderWCSKeywords.containsKey(CADCExt.JDBEG.key())) { startMJD = DateUtil.toModifiedJulianDate( this.fitsHeaderWCSKeywords.getDoubleValue(CADCExt.JDBEG.key())); } else if (this.fitsHeaderWCSKeywords.containsKey(CADCExt.JDOBS.key())) { startMJD = DateUtil.toModifiedJulianDate( this.fitsHeaderWCSKeywords.getDoubleValue(CADCExt.JDOBS.key())); - } else if (this.fitsHeaderWCSKeywords.containsKey(CADCExt.DATEOBS.key())) { + } else if (this.fitsHeaderWCSKeywords.containsKey(DateTime.DATE_OBS.key())) { final String timeSystem = getSystem(); final TimeZone timeZone = TimeZone.getTimeZone(timeSystem); final Date date = DateUtil.getDateFormat(DateUtil.ISO8601_DATE_FORMAT_LOCAL, timeZone).parse( - this.fitsHeaderWCSKeywords.getStringValue(CADCExt.DATEOBS.key())); + this.fitsHeaderWCSKeywords.getStringValue(DateTime.DATE_OBS.key())); startMJD = DateUtil.toModifiedJulianDate(date, timeZone); - } else if (this.fitsHeaderWCSKeywords.containsKey(CADCExt.DATEBEG.key())) { + } else if (this.fitsHeaderWCSKeywords.containsKey(DateTime.DATE_BEG.key())) { final String timeSystem = getSystem(); final TimeZone timeZone = TimeZone.getTimeZone(timeSystem); final Date date = DateUtil.getDateFormat(DateUtil.ISO8601_DATE_FORMAT_LOCAL, timeZone).parse( - this.fitsHeaderWCSKeywords.getStringValue(CADCExt.DATEBEG.key())); + this.fitsHeaderWCSKeywords.getStringValue(DateTime.DATE_BEG.key())); startMJD = DateUtil.toModifiedJulianDate(date, timeZone); } else if (this.fitsHeaderWCSKeywords.containsKey(CADCExt.TSTART.key())) { final String unit = getUnit(); @@ -188,17 +189,19 @@ private double addToMJD(final double mjdValue, final double crval, final String } private String getSystem() { - return this.fitsHeaderWCSKeywords.containsKey(CADCExt.TIMESYS.key()) - ? this.fitsHeaderWCSKeywords.getStringValue(CADCExt.TIMESYS.key()) : DEFAULT_TIME_SYSTEM; + return this.fitsHeaderWCSKeywords.containsKey(DateTime.TIMESYS.key()) + ? this.fitsHeaderWCSKeywords.getStringValue(DateTime.TIMESYS.key()) : DEFAULT_TIME_SYSTEM; } public String getUnit() { final String unit; - final String cUnitKey = CADCExt.CUNITn.n(this.fitsHeaderWCSKeywords.getTemporalAxis()).key(); + final int temporalAxis = this.fitsHeaderWCSKeywords.getTemporalAxis(); - if (this.fitsHeaderWCSKeywords.containsKey(CADCExt.TIMEUNIT.key())) { - unit = this.fitsHeaderWCSKeywords.getStringValue(CADCExt.TIMEUNIT.key()); - } else if (this.fitsHeaderWCSKeywords.containsKey(cUnitKey)) { + final String cUnitKey = temporalAxis < 0 ? null : CADCExt.CUNITn.n(temporalAxis).key(); + + if (this.fitsHeaderWCSKeywords.containsKey(DateTime.TIMEUNIT.key())) { + unit = this.fitsHeaderWCSKeywords.getStringValue(DateTime.TIMEUNIT.key()); + } else if (cUnitKey != null && this.fitsHeaderWCSKeywords.containsKey(cUnitKey)) { unit = this.fitsHeaderWCSKeywords.getStringValue(cUnitKey); } else { unit = DEFAULT_TIME_UNIT; diff --git a/cadc-data-ops-fits/src/test/java/org/opencadc/fits/FitsTest.java b/cadc-data-ops-fits/src/test/java/org/opencadc/fits/FitsTest.java index d0728e13..48d53001 100644 --- a/cadc-data-ops-fits/src/test/java/org/opencadc/fits/FitsTest.java +++ b/cadc-data-ops-fits/src/test/java/org/opencadc/fits/FitsTest.java @@ -104,12 +104,8 @@ public static void assertFitsEqual(final Fits expected, final Fits result) throw final BasicHDU nextExpectedHDU = expectedHDUList[expectedIndex]; final BasicHDU nextResultHDU = resultHDUList[expectedIndex]; - try { - FitsTest.assertHDUEqual(nextExpectedHDU, nextResultHDU); - } catch (AssertionError assertionError) { - LOGGER.error("On Extension at index " + expectedIndex); - throw assertionError; - } + LOGGER.debug("On Extension at index " + expectedIndex); + FitsTest.assertHDUEqual(nextExpectedHDU, nextResultHDU); } } diff --git a/cadc-data-ops-fits/src/test/java/org/opencadc/fits/slice/TimeCutoutTest.java b/cadc-data-ops-fits/src/test/java/org/opencadc/fits/slice/TimeCutoutTest.java index 2d5bfffd..453e7b32 100644 --- a/cadc-data-ops-fits/src/test/java/org/opencadc/fits/slice/TimeCutoutTest.java +++ b/cadc-data-ops-fits/src/test/java/org/opencadc/fits/slice/TimeCutoutTest.java @@ -72,6 +72,7 @@ import ca.nrc.cadc.date.DateUtil; import ca.nrc.cadc.util.Log4jInit; import nom.tam.fits.Header; +import nom.tam.fits.header.DateTime; import nom.tam.fits.header.Standard; import nom.tam.fits.header.extra.NOAOExt; import org.apache.log4j.Level; @@ -89,7 +90,7 @@ public class TimeCutoutTest extends BaseCutoutTest { } @Test - public void testSimpleOverlap() throws Exception { + public void testSimpleOverlap() { final Header testHeader = new Header(); final Calendar calendar = Calendar.getInstance(DateUtil.UTC); calendar.set(2007, Calendar.SEPTEMBER, 18, 1, 15, 0); @@ -102,9 +103,9 @@ public void testSimpleOverlap() throws Exception { testHeader.addValue(Standard.CRPIXn.n(1), 10.0); testHeader.addValue(Standard.CDELTn.n(1), 13.3629); testHeader.addValue(Standard.CTYPEn.n(1), "UTC"); - testHeader.addValue(CADCExt.DATEOBS, "2008-10-07T00:39:35.3342"); - testHeader.addValue(CADCExt.MJDOBS, 54746.02749237); - testHeader.addValue(CADCExt.MJDREF, 54746.0); + testHeader.addValue(DateTime.DATE_OBS, "2008-10-07T00:39:35.3342"); + testHeader.addValue(DateTime.MJD_OBS, 54746.02749237); + testHeader.addValue(DateTime.MJDREF, 54746.0); final Interval testInterval = new Interval<>(54746.013D, 54746.058D); final TimeCutout testSubject = new TimeCutout(testHeader); @@ -116,7 +117,7 @@ public void testSimpleOverlap() throws Exception { } @Test - public void testSimpleMJDOverlap() throws Exception { + public void testSimpleMJDOverlap() { final Header testHeader = new Header(); testHeader.setNaxes(3); @@ -128,8 +129,8 @@ public void testSimpleMJDOverlap() throws Exception { testHeader.addValue(Standard.CRPIXn.n(1), 102.0); testHeader.addValue(Standard.CDELTn.n(1), 0.369); testHeader.addValue(Standard.CTYPEn.n(1), "UTC"); - testHeader.addValue(CADCExt.MJDBEG, 54533.0112D); - testHeader.addValue(CADCExt.MJDEND, 54565.0112D); + testHeader.addValue(DateTime.MJD_BEG, 54533.0112D); + testHeader.addValue(DateTime.MJD_END, 54565.0112D); testHeader.addValue(CADCExt.MJDREFI, 54468); testHeader.addValue(CADCExt.MJDREFF, 0.2489D); @@ -155,7 +156,7 @@ public void testSimpleMJDOverlap() throws Exception { } @Test - public void testNoOverlap() throws Exception { + public void testNoOverlap() { final Header testHeader = new Header(); testHeader.setNaxes(1); @@ -165,10 +166,10 @@ public void testNoOverlap() throws Exception { testHeader.addValue(Standard.CRPIXn.n(1), 1.0D); testHeader.addValue(Standard.CDELTn.n(1), 7.0856D); testHeader.addValue(Standard.CTYPEn.n(1), "TIME"); - testHeader.addValue(NOAOExt.TIMESYS, "UTC"); - testHeader.addValue(CADCExt.DATEBEG, "1977-11-25T01:21:13.0"); - testHeader.addValue(CADCExt.DATEEND, "1977-11-25T03:11:00.0"); - testHeader.addValue(CADCExt.MJDREF, 30005.3321D); + testHeader.addValue(DateTime.TIMESYS, "UTC"); + testHeader.addValue(DateTime.DATE_BEG, "1977-11-25T01:21:13.0"); + testHeader.addValue(DateTime.DATE_END, "1977-11-25T03:11:00.0"); + testHeader.addValue(DateTime.MJDREF, 30005.3321D); final Interval testInterval = new Interval<>(52644.1D, 52830.33D); final TimeCutout testSubject = new TimeCutout(testHeader); diff --git a/cadc-data-ops-fits/src/test/java/org/opencadc/fits/slice/TimeHeaderWCSKeywordsTest.java b/cadc-data-ops-fits/src/test/java/org/opencadc/fits/slice/TimeHeaderWCSKeywordsTest.java index 9fa70a79..9f9c9709 100644 --- a/cadc-data-ops-fits/src/test/java/org/opencadc/fits/slice/TimeHeaderWCSKeywordsTest.java +++ b/cadc-data-ops-fits/src/test/java/org/opencadc/fits/slice/TimeHeaderWCSKeywordsTest.java @@ -70,7 +70,10 @@ import ca.nrc.cadc.date.DateUtil; import ca.nrc.cadc.util.Log4jInit; +import java.util.Calendar; +import java.util.Date; import nom.tam.fits.Header; +import nom.tam.fits.header.DateTime; import nom.tam.fits.header.Standard; import nom.tam.fits.header.extra.NOAOExt; import org.apache.log4j.Level; @@ -78,9 +81,6 @@ import org.junit.Test; import org.opencadc.fits.CADCExt; -import java.util.Calendar; -import java.util.Date; - public class TimeHeaderWCSKeywordsTest { @@ -102,8 +102,8 @@ public void testMJDRef() throws Exception { testHeader.addValue(Standard.CRPIXn.n(1), 1.0); testHeader.addValue(Standard.CDELTn.n(1), 0.369); testHeader.addValue(Standard.CTYPEn.n(1), "UTC"); - testHeader.addValue(CADCExt.DATEREF, DateUtil.getDateFormat(DateUtil.ISO8601_DATE_FORMAT_LOCAL, DateUtil.UTC) - .format(calendar.getTime())); + testHeader.addValue(DateTime.DATEREF, DateUtil.getDateFormat(DateUtil.ISO8601_DATE_FORMAT_LOCAL, DateUtil.UTC) + .format(calendar.getTime())); final FITSHeaderWCSKeywords fitsHeaderWCSKeywords = new FITSHeaderWCSKeywords(testHeader); final TimeHeaderWCSKeywords testSubject = new TimeHeaderWCSKeywords(fitsHeaderWCSKeywords); @@ -135,9 +135,9 @@ public void testMJDStart() throws Exception { testHeader.addValue(Standard.CRVALn.n(1), 40.0D); // Forty seconds long exposure testHeader.addValue(Standard.CRPIXn.n(1), 1.0); testHeader.addValue(Standard.CDELTn.n(1), 0.369); - testHeader.addValue(CADCExt.DATEBEG, DateUtil.getDateFormat(DateUtil.ISO8601_DATE_FORMAT_LOCAL, DateUtil.UTC) + testHeader.addValue(DateTime.DATE_BEG, DateUtil.getDateFormat(DateUtil.ISO8601_DATE_FORMAT_LOCAL, DateUtil.UTC) .format(startDate)); - testHeader.addValue(CADCExt.DATEEND, DateUtil.getDateFormat(DateUtil.ISO8601_DATE_FORMAT_LOCAL, DateUtil.UTC) + testHeader.addValue(DateTime.DATE_END, DateUtil.getDateFormat(DateUtil.ISO8601_DATE_FORMAT_LOCAL, DateUtil.UTC) .format(stopDate)); testHeader.addValue(NOAOExt.TIMESYS, "UTC"); testHeader.addValue(CADCExt.MJDREFI, mjdValueI); @@ -150,10 +150,10 @@ public void testMJDStart() throws Exception { } @Test - public void testMJDUnit() throws Exception { + public void testMJDUnit() { final Header testHeader = new Header(); - testHeader.addValue(CADCExt.TIMEUNIT, "m"); + testHeader.addValue(DateTime.TIMEUNIT, "m"); final TimeHeaderWCSKeywords testSubject = new TimeHeaderWCSKeywords(testHeader); Assert.assertEquals("Wrong unit.", "m", testSubject.getUnit()); From cd70ae5c847f315fc385b1255374fadff514bfd7 Mon Sep 17 00:00:00 2001 From: Dustin Jenkins Date: Thu, 13 Jun 2024 12:31:14 -0700 Subject: [PATCH 2/2] Cleanup of keywords. --- .../src/test/java/org/opencadc/fits/slice/EnergyCutoutTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cadc-data-ops-fits/src/test/java/org/opencadc/fits/slice/EnergyCutoutTest.java b/cadc-data-ops-fits/src/test/java/org/opencadc/fits/slice/EnergyCutoutTest.java index cf45da12..0ab12e8b 100644 --- a/cadc-data-ops-fits/src/test/java/org/opencadc/fits/slice/EnergyCutoutTest.java +++ b/cadc-data-ops-fits/src/test/java/org/opencadc/fits/slice/EnergyCutoutTest.java @@ -207,7 +207,7 @@ public void test1DEnergy() throws Exception { testHeader.addValue(Standard.CRPIXn.n(1), 1.000000000000E+00D); testHeader.addValue(CADCExt.CUNITn.n(1), "Hz"); testHeader.addValue(CADCExt.PC1_1, 1.000000000000E+00D); - testHeader.addValue(CADCExt.RESTFRQ, 1.152712000000E+11D); + testHeader.addValue(Standard.RESTFRQ, 1.152712000000E+11D); testHeader.addValue(CADCExt.SPECSYS, "LSRK"); testHeader.addValue(Standard.BSCALE, 1.000000000000E+00D); testHeader.addValue(Standard.BZERO, 0.000000000000E+00D);