TCDSolar / stixpy

STIX data analysis in python
https://stixpy.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
17 stars 20 forks source link

concatenate ScienceData errors when trying to concatenating two CompressedPixelData objects #59

Open hayesla opened 1 year ago

hayesla commented 1 year ago

I have two CompressedPixelData objects read in from two different files (two subsequent data files), and I want to concatenate them together to be one but you get this error:

>>> stix_data1 = ScienceData.from_fits(stix_files[0])
>>> stix_data2 = ScienceData.from_fits(stix_files[1])

>>> stix_data_concat = stix_data1.concatenate([stix_data2])
---------------------------------------------------------------------------
TableMergeError                           Traceback (most recent call last)
Cell In[47], line 1
----> 1 stix_data1.concatenate([stix_data2])

File ~/dev_things/stixpy/stixpy/science.py:629, in ScienceData.concatenate(self, others)
    626     except KeyError:
    627         pass
--> 629     control = vstack([control, other.control])
    630     data = vstack([data, other.data])
    632 return type(self)(header=self.header, control=control, data=data,
    633                   energies=self.energies)

File ~/opt/miniconda3/envs/stix_dev/lib/python3.10/site-packages/astropy/table/operations.py:651, in vstack(tables, join_type, metadata_conflicts)
    648     return tables[0]  # no point in stacking a single table
    649 col_name_map = OrderedDict()
--> 651 out = _vstack(tables, join_type, col_name_map, metadata_conflicts)
    653 # Merge table metadata
    654 _merge_table_meta(out, tables, metadata_conflicts=metadata_conflicts)

File ~/opt/miniconda3/envs/stix_dev/lib/python3.10/site-packages/astropy/table/operations.py:1398, in _vstack(arrays, join_type, col_name_map, metadata_conflicts)
   1395     raise NotImplementedError('vstack unavailable for mixin column type(s): {}'
   1396                               .format(col_cls.__name__))
   1397 try:
-> 1398     col = col_cls.info.new_like(cols, n_rows, metadata_conflicts, out_name)
   1399 except metadata.MergeConflictError as err:
   1400     # Beautify the error message when we are trying to merge columns with incompatible
   1401     # types by including the name of the columns that originated the error.
   1402     raise TableMergeError("The '{}' columns have incompatible types: {}"
   1403                           .format(out_name, err._incompat_types)) from err

File ~/opt/miniconda3/envs/stix_dev/lib/python3.10/site-packages/astropy/table/column.py:453, in ColumnInfo.new_like(self, cols, length, metadata_conflicts, name)
    428 def new_like(self, cols, length, metadata_conflicts='warn', name=None):
    429     """
    430     Return a new Column instance which is consistent with the
    431     input ``cols`` and has ``length`` rows.
   (...)
    451 
    452     """
--> 453     attrs = self.merge_cols_attributes(cols, metadata_conflicts, name,
    454                                        ('meta', 'unit', 'format', 'description'))
    456     return self._parent_cls(length=length, **attrs)

File ~/opt/miniconda3/envs/stix_dev/lib/python3.10/site-packages/astropy/utils/data_info.py:726, in BaseColumnInfo.merge_cols_attributes(cols, metadata_conflicts, name, attrs)
    724 uniq_shapes = set(col.shape[1:] for col in cols)
    725 if len(uniq_shapes) != 1:
--> 726     raise TableMergeError('columns have different shapes')
    727 out['shape'] = uniq_shapes.pop()
    729 # "Merged" output name is the supplied name

TableMergeError: columns have different shapes
samaloney commented 5 months ago

Bit late but do you know the request IDs?