Skip to content

cube.get_tpf(): IndexError when frame_range is specified and calculate_poscorr=False #12

Description

@orionlee

An IndexError is raised from cube.get_tpf() when frame_range is specified and calculate_poscorr=False

Workaround: setcalculate_poscorr=True


Example:

%%time

from astropy.coordinates.sky_coordinate import SkyCoord
import astropy.units as u
import numpy as np

from tesscube import TESSCube

# TIC 400621146, sector 45
ra, dec = 95.954934, 31.679387
sector, camera, ccd = 45, 1, 2

coord = SkyCoord(ra * u.deg, dec *u.deg, frame="icrs")
cube = TESSCube(sector=sector, camera=camera, ccd=ccd)

# get only 1 good quality frame
frame_day3 = np.where((cube.time > cube.time[0] + 3) & (cube.quality == 0))[0][0]
hdul = cube.get_tpf(coord, shape=(11, 11), frame_range=(frame_day3, frame_day3 + 1), calculate_poscorr=False)
hdul

The error and the stack trace.

C:\dev\tesscube\src\tesscube\query.py:52: RuntimeWarning: overflow encountered in scalar multiply
  pixel_offset = (column - 1) * self.nframes * self.nsets + (
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
File <timed exec>:18

File C:\dev\tesscube\src\tesscube\cube.py:296, in TESSCube.get_tpf(self, target, shape, frame_range, frame_bin, calculate_poscorr)
    288 else:
    289     k = np.ones(len(self), bool)
    291 time, timecorr, cadenceno, quality, pos_corr1, pos_corr2 = (
    292     self.time[k],
    293     self.timecorr[k],
    294     self.cadence_number[k],
    295     self.quality[k],
--> 296     pos_corr1[k],
    297     pos_corr2[k],
    298 )
    300 if frame_bin > 1:
    301     idxs = np.hstack(
    302         [
    303             r[: frame_bin * np.floor(len(r) / frame_bin).astype(int)]
   (...)
    307         ]
    308     )

IndexError: boolean index did not match indexed array along dimension 0; dimension is 1 but corresponding boolean dimension is 3450

Version: 1.0.2dev0
Platform: Windows 11

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions