Skip to content

Commit

Permalink
🐛 Fixes lightkurve#954
Browse files Browse the repository at this point in the history
  • Loading branch information
barentsen committed Mar 12, 2021
1 parent 08c3b19 commit 2b9007e
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/lightkurve/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from . import MPLSTYLE
from .targetpixelfile import TargetPixelFile
from .utils import LightkurveDeprecationWarning
from .utils import LightkurveWarning, LightkurveDeprecationWarning


log = logging.getLogger(__name__)
Expand Down Expand Up @@ -227,6 +227,25 @@ def stitch(self, corrector_func=lambda x: x.normalize()):
with warnings.catch_warnings(): # ignore "already normalized" message
warnings.filterwarnings("ignore", message=".*already.*")
lcs = [corrector_func(lc) for lc in self]

# Address issue #954: ignore incompatible columns with the same name
columns_to_remove = set()
for col in lcs[0].columns:
for lc in lcs[1:]:
if col in lc.columns:
if not (issubclass(lcs[0][col].__class__, lc[col].__class__) \
or lcs[0][col].__class__.info is lc[col].__class__.info):
columns_to_remove.add(col)
continue

if len(columns_to_remove) > 0:
warnings.warn(
f"The following columns will be ignored from the stitch because the data types are incompatible: {columns_to_remove}",
LightkurveWarning,
)
lcs = [lc.copy() for lc in lcs]
[lc.remove_columns(columns_to_remove.intersection(lc.columns)) for lc in lcs]

# Need `join_type='inner'` until AstroPy supports masked Quantities
return vstack(lcs, join_type="inner", metadata_conflicts="silent")

Expand Down

0 comments on commit 2b9007e

Please sign in to comment.