diff --git a/lsmtool/tableio.py b/lsmtool/tableio.py index 59e6021692c3d3f251d721e0ed8b50c8bb5bcb3a..7eb7b3910b3e54e0b157d947672609a1a6a5a28e 100644 --- a/lsmtool/tableio.py +++ b/lsmtool/tableio.py @@ -29,6 +29,7 @@ import numpy.ma as ma import re import logging import os +from copy import deepcopy # Python 3 compatibility try: @@ -401,7 +402,9 @@ def processFormatString(formatString): colDefaults[i] = defaultVal metaDict[colNames[i]] = defaultVal elif allowedColumnDefaults[colName] is not None: - colDefaults[i] = allowedColumnDefaults[colName] + # Note: we used deepcopy() here to ensure that the original + # is not altered by later changes to colDefaults + colDefaults[i] = deepcopy(allowedColumnDefaults)[colName] # Check for required columns for reqCol in requiredColumnNames: @@ -1124,7 +1127,9 @@ def convertExternalTable(table, columnMapping, fluxUnits='mJy'): table.columns[colName].unit = allowedColumnUnits[colName.lower()] if hasattr(table.columns[colName], 'filled') and allowedColumnDefaults[colName.lower()] is not None: - fillVal = allowedColumnDefaults[colName.lower()] + # Note: we used deepcopy() here to ensure that the original + # is not altered by later changes to fillVal + fillVal = deepcopy(allowedColumnDefaults)[colName.lower()] if colName == 'SpectralIndex': while len(fillVal) < 1: fillVal.append(0.0) @@ -1280,4 +1285,3 @@ registry.register_writer('ds9', Table, ds9RegionWriter) registry.register_writer('kvis', Table, kvisAnnWriter) registry.register_writer('casa', Table, casaRegionWriter) registry.register_writer('factor', Table, factorDirectionsWriter) - diff --git a/tests/single_spectralindx.sky b/tests/single_spectralindx.sky new file mode 100644 index 0000000000000000000000000000000000000000..9a5c6328bad384f8b9afc7c3e8fa697bb4c8b921 --- /dev/null +++ b/tests/single_spectralindx.sky @@ -0,0 +1,9 @@ +FORMAT = Name, Type, Ra, Dec, I, Q, U, V, ReferenceFrequency='60e6', SpectralIndex='[0.0]', MajorAxis, MinorAxis, Orientation + +# the next lines define the sources +1553.9+5220, POINT, 15:53:56.76000000, +52.20.49.41600000, 2.5599, , , , , [-0.2648] +1555.2+5517, POINT, 15:55:12.73920000, +55.17.12.30000000, 0.7088, , , , , [-0.3858] +1556.2+5348, POINT, 15:56:15.38880000, +53.48.11.30400000, 0.7697, , , , , [-0.4379] +1556.4+5539, POINT, 15:56:26.76960000, +55.39.01.80000000, 0.9, , , , , [-0.7] +1556.7+5705, POINT, 15:56:42.78000000, +57.05.39.01200000, 1.1941, , , , , [-0.3247] +1556.7+5558, POINT, 15:56:45.23040000, +55.58.31.11600000, 0.9446, , , , , [-0.0414] diff --git a/tests/test_lsmtool.py b/tests/test_lsmtool.py index 77767190de5a346c8760766fc13147952cd1c9c0..7d7fa1f10c01e66e809fb502ada9c97b82d8c2d3 100644 --- a/tests/test_lsmtool.py +++ b/tests/test_lsmtool.py @@ -38,6 +38,13 @@ def test_concatenate(): assert len(s) == 2165 +def test_concatenate_differing_spectral_index(): + print('Concatenate with single_spectralindx.sky') + s4 = lsmtool.load('tests/no_patches.sky') + s4.concatenate('tests/single_spectralindx.sky', matchBy = 'position', radius = '30 arcsec', keep = 'from2') + assert len(s) == 2165 + + def test_compare(): print('Compare to concat.sky') if os.path.exists('tests/flux_ratio_vs_distance.sky'):