sncosmo.select_data

sncosmo.select_data(data, index)[source]

Convenience function for indexing photometric data with covariance.

This is like data[index] on an astropy Table, but handles covariance columns correctly.

Parameters:
dataTable

Table of photometric data.

indexslice or array or int

Row selection to apply to table.

Returns:
Table

Examples

We have a small table of photometry with a covariance column and we want to select some rows based on a mask:

>>> data = Table([[1., 2., 3.],
...               ['a', 'b', 'c'],
...               [[1.1, 1.2, 1.3],
...                [2.1, 2.2, 2.3],
...                [3.1, 3.2, 3.3]]],
...               names=['time', 'x', 'cov'])
>>> mask = np.array([True, True, False])

Selecting directly on the table, the covariance column is not sliced in each row: it has shape (2, 3) when it should be (2, 2):

>>> data[mask]
<Table length=2>
  time   x    cov [3]
float64 str1  float64
------- ---- ----------
    1.0    a 1.1 .. 1.3
    2.0    b 2.1 .. 2.3

Using select_data solves this:

>>> sncosmo.select_data(data, mask)
<Table length=2>
  time   x    cov [2]
float64 str1  float64
------- ---- ----------
    1.0    a 1.1 .. 1.2
    2.0    b 2.1 .. 2.2