Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
orionlee opened this issue Oct 7, 2024 · 0 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@orionlee
Copy link

orionlee commented Oct 7, 2024

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

@christinahedges christinahedges self-assigned this Jan 7, 2025
@christinahedges christinahedges added the bug Something isn't working label Jan 7, 2025
@christinahedges christinahedges added this to the v1.1.0 milestone Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants