def multi_sectors(sectors, tic=None, gaia=None, coords=None, name=None, tc=False, local=False, post_dir=None, pm_dir=None, metadata_path=None, tesscut_size=31): """Obtain a list of Source objects for a single target, for each of multiple sectors for which the target was observed. Parameters ---------- sectors : list or str The list of sectors for which data should be returned, or `'all'` to return all sectors for which there are data. tic : int, optional The TIC ID of the source. gaia : int, optional The Gaia DR2 source_id. coords : tuple, optional The (RA, Dec) coords of the object in degrees. tc : bool, optional If True, use a TessCut cutout to produce postcards rather than downloading the eleanor postcard data products. tesscut_size : int, array-like, astropy.units.Quantity The size of the cutout array, when tc is True. Details can be seen in astroquery.mast.TesscutClass.download_cutouts """ objs = [] if sectors == 'all': if coords is None: if tic is not None: coords, _, _, _ = coords_from_tic(tic) elif gaia is not None: coords = coords_from_gaia(gaia) elif name is not None: coords = coords_from_name(name) if coords is not None: if type(coords) is SkyCoord: coords = (coords.ra.degree, coords.dec.degree) result = tess_stars2px(8675309, coords[0], coords[1]) sector = result[3][result[3] < maxsector + 0.5] sectors = sector.tolist() if len(sectors) == 0 or sectors[0] < 0: raise SearchError("Your target is not observed by TESS, or maybe you need to run eleanor.Update()") else: print('Found star in Sector(s) ' +" ".join(str(x) for x in sectors)) if (type(sectors) == list) or (type(sectors) == np.ndarray): for s in sectors: star = Source(tic=tic, gaia=gaia, coords=coords, sector=int(s), tc=tc, local=local, post_dir=post_dir, pm_dir=pm_dir, metadata_path=metadata_path, tesscut_size=tesscut_size) if star.sector is not None: objs.append(star) if len(objs) < len(sectors): warnings.warn('Only {} targets found instead of desired {}. Your ' 'target may not have been observed yet in these sectors.' ''.format(len(objs), len(sectors))) return objs
def multi_sectors(sectors, tic=None, gaia=None, coords=None, tc=False): """Obtain a list of Source objects for a single target, for each of multiple sectors for which the target was observed. Parameters ---------- sectors : list or str The list of sectors for which data should be returned, or `'all'` to return all sectors for which there are data. tic : int, optional The TIC ID of the source. gaia : int, optional The Gaia DR2 source_id. coords : tuple, optional The (RA, Dec) coords of the object in degrees. tc : bool, optional If True, use a TessCut cutout to produce postcards rather than downloading the eleanor postcard data products. """ objs = [] if sectors == 'all': if coords is None: if tic is not None: coords, _, _, _ = coords_from_tic(tic) elif gaia is not None: coords = coords_from_gaia(gaia) if coords is not None: if type(coords) is SkyCoord: coords = (coords.ra.degree, coords.dec.degree) result = tess_stars2px(8675309, coords[0], coords[1]) sector = result[3][result[3] < 16.5] sectors = sector.tolist() if sectors[0] < 0: raise SearchError("Your target is not observed by TESS.") else: print('Found star in Sector(s) ' + " ".join(str(x) for x in sectors)) if (type(sectors) == list) or (type(sectors) == np.ndarray): for s in sectors: star = Source(tic=tic, gaia=gaia, coords=coords, sector=int(s), tc=tc) if star.sector is not None: objs.append(star) if len(objs) < len(sectors): warnings.warn( 'Only {} targets found instead of desired {}. Your ' 'target may not have been observed yet in these sectors.' ''.format(len(objs), len(sectors))) return objs
def locate_on_tess(self): """Finds the TESS sector, camera, chip, and position on chip for the source. Attributes ---------- sector : int camera : int chip : int position_on_chip : np.array """ sector = None if self.usr_sec is None: self.usr_sec = 'recent' result = tess_stars2px(self.tic, self.coords[0], self.coords[1]) cameras = result[4][result[3] <= maxsector] chips = result[5][result[3] <= maxsector] cols = result[6][result[3] <= maxsector] rows = result[7][result[3] <= maxsector] sectors = result[3][result[3] <= maxsector] # tess_stars2px returns array [-1] when star not observed yet if len(sectors) < 1 or sectors[0] == np.array([-1]): raise SearchError("Tess has not (yet) observed your target.") else: # Handles cases where users can pass in their sector if type(self.usr_sec) == int: arg = np.argwhere(sectors == self.usr_sec)[0] if len(arg) > 0: self.sector = sectors[arg][0] camera = cameras[arg][0] chip = chips[arg][0] position_on_chip = np.array([cols[arg][0], rows[arg][0]]) # Handles cases where the user does not pass in a sector elif self.usr_sec.lower() == 'recent': self.sector = sectors[-1] camera = cameras[-1] chip = chips[-1] position_on_chip = np.array([cols[-1], rows[-1]]) if self.sector is None or type(self.sector) == np.ndarray: raise SearchError("TESS has not (yet) observed your target.") else: self.camera = camera self.chip = chip self.position_on_chip = position_on_chip
def multi_sectors(sectors, tic=None, gaia=None, coords=None, tc=False): """Obtain a list of Source objects for a single target, for each of multiple sectors for which the target was observed. Parameters ---------- tic : int, optional The TIC ID of the source. gaia : int, optional The Gaia DR2 source_id. coords : tuple, optional The (RA, Dec) coords of the object in degrees. sectors : list or str The list of sectors for which data should be returned, or `all` to return all sectors for which there are data. """ objs = [] if sectors == 'all': if coords is None: if tic is not None: coords, _, _ = coords_from_tic(tic) elif gaia is not None: coords = coords_from_gaia(gaia) if coords is not None: if type(coords) is SkyCoord: coords = (coords.ra.degree, coords.dec.degree) result = tess_stars2px(8675309, coords[0], coords[1]) sector = result[3][result[3] < 11.5] sectors = sector.tolist() print('Found star in Sector(s) ' +" ".join(str(x) for x in sectors)) if type(sectors) == list: for s in sectors: star = Source(tic=tic, gaia=gaia, coords=coords, sector=int(s), tc=tc) if star.sector is not None: objs.append(star) if len(objs) < len(sectors): warnings.warn('Only {} targets found instead of desired {}. Your ' 'target may not have been observed yet in these sectors.' ''.format(len(objs), len(sectors))) return objs else: raise TypeError("Sectors needs to be either 'all' or a type(list) to work.")