diff --git a/src/main/java/fr/jmmc/oitools/meta/CustomUnits.java b/src/main/java/fr/jmmc/oitools/meta/CustomUnits.java index e6bc03e..6bc9b01 100644 --- a/src/main/java/fr/jmmc/oitools/meta/CustomUnits.java +++ b/src/main/java/fr/jmmc/oitools/meta/CustomUnits.java @@ -47,6 +47,14 @@ public CustomUnits(final boolean required) { super("UNIT_CUSTOM", ""); this.required = required; } + + /** + * Define the value of unit + * @param unit other CustomUnits instance + */ + public void set(final CustomUnits unit) { + set(unit.getStandardRepresentation()); + } /** * Define the value of unit diff --git a/src/main/java/fr/jmmc/oitools/model/OITable.java b/src/main/java/fr/jmmc/oitools/model/OITable.java index ef0375f..51b2595 100644 --- a/src/main/java/fr/jmmc/oitools/model/OITable.java +++ b/src/main/java/fr/jmmc/oitools/model/OITable.java @@ -21,13 +21,10 @@ import fr.jmmc.oitools.OIFitsConstants; import fr.jmmc.oitools.fits.FitsConstants; -import fr.jmmc.oitools.fits.FitsHeaderCard; import fr.jmmc.oitools.fits.FitsTable; -import fr.jmmc.oitools.fits.FitsUtils; import fr.jmmc.oitools.meta.ColumnMeta; import fr.jmmc.oitools.meta.KeywordMeta; import fr.jmmc.oitools.meta.Types; -import fr.nom.tam.fits.HeaderCard; import java.util.logging.Level; /** @@ -130,8 +127,9 @@ protected final void copyTable(final OITable src) throws IllegalArgumentExceptio } } - // Copy header cards: - if (src.hasHeaderCards()) { + // Copy header cards ? + // disabled for now (how to ensure consistency if the table is modified ?) + if (false && src.hasHeaderCards()) { // Copy references to Fits header cards: getHeaderCards().addAll(src.getHeaderCards()); } @@ -145,9 +143,17 @@ protected final void copyTable(final OITable src) throws IllegalArgumentExceptio columnName = column.getName(); columnValue = src.getColumnValue(columnName); - if (columnValue == null) { + if (columnValue == null && !column.isOptional()) { columnValue = createColumnArray(column, getNbRows()); } + + // Copy custom units: + if (column.isCustomUnits()) { + final ColumnMeta srcColumn = src.getColumnDesc(columnName); + if (srcColumn != null && srcColumn.isCustomUnits()) { + column.getCustomUnits().set(srcColumn.getCustomUnits()); + } + } if (logger.isLoggable(Level.FINE)) { logger.log(Level.FINE, "COLUMN {0} = ''{1}''", new Object[]{columnName, columnValue});