Ejemplo n.º 1
0
def get_panstarrs_catalog_old(imgwcs, radius=0.2, verbose=False):
    import astropy.units as u
    from astropy.coordinates import SkyCoord
    from astroquery.mast import Catalogs

    ra0, dec0 = imgwcs.wcs.crval
    coords = SkyCoord(ra0, dec0, unit=u.deg, frame='icrs')

    if verbose:
        print('Querying Pan-STARRS {:.3f} deg around RA, Dec={:.5f}, {:.5f} '.
              format(radius, ra0, dec0))

    cat = Catalogs.query_criteria(coordinates=coords,
                                  radius=radius,
                                  catalog='PANSTARRS',
                                  data_release='dr2',
                                  table='mean',
                                  columns=[
                                      'objID', 'raMean', 'decMean',
                                      'gMeanPSFMag', 'rMeanPSFMag',
                                      'iMeanPSFMag', 'zMeanPSFMag'
                                  ],
                                  gMeanPSFMag=[('lte', 18), ('gte', 8)],
                                  rMeanPSFMag=[('lte', 18), ('gte', 8)],
                                  iMeanPSFMag=[('lte', 18), ('gte', 8)],
                                  zMeanPSFMag=[('lte', 18), ('gte', 8)])
    #sort_by=[("asc", "rMeanPSFMag")]

    # http://legacysurvey.org/dr8/description/#photometry
    gi = cat['gMeanPSFMag'] - cat['iMeanPSFMag']
    keep = np.where((gi > 0.4) * (gi < 2.7))[0]
    cat = cat[keep]

    return cat
Ejemplo n.º 2
0
def tic_to_name(tic, ra=None, dec=None):
    """
    Function to determine the common name of a TIC ID or given RA/Dec position, 
    if it has one. Queries the MAST and Simbad to gather this information.

    !!Keysort so planet doesn't come first?!!

    Parameters
    ----------
    tic : int
       The TIC ID of the object for which the common name is desired.
    ra : float
       The RA in decimal degrees. Optional with Dec to circumvent querying MAST.
    dec : float
       The Dec in decimal degrees. Optional with TA to circumvent querying MAST.

    Returns
    -------
    name : str
       The common name of the input TIC ID.
    """
    if not isinstance(tic, int):
        raise ValueError('TIC must be an integer')

    if not ra and not dec:
        cat = Catalogs.query_criteria(catalog="TIC", ID=int(tic))
        ra = cat[0]['ra']
        dec = cat[0]['dec']
    
    results = Simbad.query_region(coord.SkyCoord(ra, dec, unit=(u.deg, u.deg)),
                                  radius='0d0m5s')

    name = str(results[0]['MAIN_ID'].decode('utf-8'))
    
    return str(name)
Ejemplo n.º 3
0
def getting_star_mass_radius(tic_id):
    target_info = Catalogs.query_criteria(catalog='TIC', ID=tic_id).to_pandas()
    star_radius = target_info['rad']
    star_mass = target_info['mass']
    print(f'Star mass: {star_mass}')
    print(f'Star radius: {star_radius}')
    return star_mass, star_radius
Ejemplo n.º 4
0
def load_catalog(filename=False,
                 header=False,
                 wcs=False,
                 ra_key=False,
                 dec_key=False):
    '''
    From Anna Marini: get positions from catalog.
    '''

    if filename and not header:
        header = get_fits_header(filename)
    if header and not wcs:
        wcs = WCS(header)
        if ra_key and dec_key:
            ra = header[ra_key]
            dec = header[dec_key]

    ra = wcs.wcs.crval[0]
    dec = wcs.wcs.crval[1]

    # Diagonal
    diag_bound = wcs.pixel_to_world_values([[0, 0], wcs.pixel_shape])
    radius = np.mean(diag_bound[1] - diag_bound[0]) / 2

    catalog = Catalogs.query_region(
        f'{ra} {dec}',
        # frame='icrs',
        # unit="deg",
        radius=radius,
        catalog='Gaia',
        version=2)

    return catalog
Ejemplo n.º 5
0
Archivo: toco.py Proyecto: tessgi/toco
def get_tic_name(name):
    with warnings.catch_warnings():
        warnings.simplefilter('ignore')
        customSimbad = Simbad()
        customSimbad.add_votable_fields(
            'ra(2;A;ICRS;J2000;2000)', 'dec(2;D;ICRS;J2000;2000)')
        customSimbad.remove_votable_fields('coordinates')
        result_table = customSimbad.query_object(name)
    if result_table is None:
        logger.error("Target name failed to resolve, please check")
        sys.exit(1)

    with warnings.catch_warnings():
        warnings.simplefilter('ignore')
        ra_sex = result_table['RA_2_A_ICRS_J2000_2000'][0]
        dec_sex = result_table['DEC_2_D_ICRS_J2000_2000'][0]
        catalogData = Catalogs.query_region(SkyCoord
                                            (ra_sex, dec_sex, unit=(u.hour, u.deg)),
                                            catalog='Tic', radius=0.006)

    try:
        return catalogData['ID'][0]
    except IndexError:
        logger.error("No TIC target at those coordiantes")
        sys.exit(1)
Ejemplo n.º 6
0
def get_catalog_data(tic_id):
    catalogTIC = Catalogs.query_criteria(
        ID=tic_id,
        catalog='Tic',
        provenance_name='TASOC',
    )
    return catalogTIC['Tmag'], catalogTIC['Teff'], catalogTIC['logg'],
Ejemplo n.º 7
0
def tic_list_by_magnitudes(path, lowermag, uppermag, n, filelabel):
    """ Creates a fits file of the first n TICs that fall between the given
    magnitude ranges. 
    parameters: 
        * path to where you want things saved
        * lower magnitude limit
        * upper magnitude limit
        * n - number of TICs you want
        * file label (what to call the fits file)
    modified [lcg 07082020]
    """
    catalog_data = Catalogs.query_criteria(catalog="Tic", Tmag=[uppermag, lowermag], objType="STAR")

    T_mags = np.asarray(catalog_data["Tmag"], dtype= float)
    TICIDS = np.asarray(catalog_data["ID"], dtype = int)
    
    tmag_index = np.argsort(T_mags)
    
    sorted_tmags = T_mags[tmag_index]
    sorted_ticids = TICIDS[tmag_index]
    
    hdr = fits.Header() # >> make the header
    hdu = fits.PrimaryHDU(sorted_ticids[0:n], header=hdr)
    hdu.writeto(path + filelabel + ".fits")
    fits.append(path + filelabel + ".fits",sorted_tmags[0:n])
    
    return sorted_ticids, sorted_tmags
Ejemplo n.º 8
0
def get_TIC_data(ra, dec):
    radii = np.linspace(start=0.0001, stop=0.001, num=19)
    #for i,row in self.df.iterrows():
    tic_found = False
    for rad in radii:
        if tic_found == False:
            # query_string = str(ra) + " " + str(dec) # make sure to have a space between the strings!#SkyCoord(ra = row['ra'], dec = row['dec'], frame = 'icrs') str(row['ra']) + " " + str(row['dec']) # make sure to have a space between the strings!
            sc = SkyCoord(ra=ra * u.deg, dec=dec * u.deg)
            obs_table = Catalogs.query_region(coordinates=sc,
                                              radius=rad * u.deg,
                                              catalog="TIC")
            obs_df = obs_table.to_pandas()
            if len(obs_table['ID']) == 1:
                tic = obs_table['ID'][0]
                tic_found = True
                continue
            if len(obs_df[obs_df['GAIA'].to_numpy(dtype='str') != '']) == 1:
                temp_obs_df = obs_df[obs_df['GAIA'].to_numpy(
                    dtype='str') != '']
                tic = temp_obs_df['ID'].iloc[0]
                tic_found = True
                continue
            # if len(np.unique(obs_df[obs_df['HIP'].to_numpy(dtype = 'str') != '']['HIP'])) == 1:
            #     tic = obs_table['ID'][0]
            #     tic_found = True
            #     continue
    if tic_found == False:
        tic = np.nan
        print("Didn't find TIC for this object.")
    else:
        print("Found TIC Data for TIC " + str(tic) + "!")
        #self.tic = tic
    return (obs_df, tic)
Ejemplo n.º 9
0
def download_tic_coord(tic):
    '''
    Use the MAST archive to download a SkyCoord for one
    star from the TESS Input Catalog.

    '''


    # import Catalogs only when we need it
    # (otherwise, we'll need the internet to ever run tfs)
    from astroquery.mast import Catalogs

    # download that TIC from the archive
    t = Catalogs.query_criteria(catalog="Tic", ID=tic)[0]

    # the 'ra' and 'dec' columns were propagated to J2000 (https://outerspace.stsci.edu/display/TESS/TIC+v8+and+CTL+v8.xx+Data+Release+Notes)
    obstime='J2000.0'

    # define a sky coord, with proper motions and a time
    s = coord.SkyCoord(  ra=t['ra']*u.deg,
                         dec=t['dec']*u.deg,
                         pm_ra_cosdec=t['pmRA']*u.mas/u.year,
                         pm_dec=t['pmDEC']*u.mas/u.year,
                         obstime='J2000.0')

    return s
Ejemplo n.º 10
0
    def __init__(self, ID: int, sectors: np.ndarray, search_radius: int = 10):
        """
        Queries TIC for sources near the target and obtains a cutout
        of the pixels enclosing the target.
        Args:
            ID (int): TIC ID of the target.
            sectors (numpy array): Sectors in which the target
                                   has been observed.
            search_radius (int): Number of pixels from the target
                                 star to search.
        """
        self.ID = ID
        self.sectors = sectors
        self.search_radius = search_radius
        self.N_pix = 2 * search_radius + 2
        # query TIC for nearby stars
        pixel_size = 20.25 * u.arcsec
        df = Catalogs.query_object("TIC" + str(ID),
                                   radius=search_radius * pixel_size,
                                   catalog="TIC")
        new_df = df["ID", "Tmag", "ra", "dec", "mass", "rad", "Teff", "plx"]
        stars = new_df.to_pandas()
        self.stars = stars

        TESS_images = []
        col0s, row0s = [], []
        pix_coords = []
        # for each sector, get FFI cutout and transform RA/Dec into
        # TESS pixel coordinates
        for j, sector in enumerate(sectors):
            Tmag = stars["Tmag"].values
            ra = stars["ra"].values
            dec = stars["dec"].values
            cutout_coord = SkyCoord(ra[0], dec[0], unit="deg")
            cutout_hdu = Tesscut.get_cutouts(cutout_coord,
                                             size=self.N_pix,
                                             sector=sector)[0]
            cutout_table = cutout_hdu[1].data
            hdu = cutout_hdu[2].header
            wcs = WCS(hdu)
            TESS_images.append(np.mean(cutout_table["FLUX"], axis=0))
            col0 = cutout_hdu[1].header["1CRV4P"]
            row0 = cutout_hdu[1].header["2CRV4P"]
            col0s.append(col0)
            row0s.append(row0)

            pix_coord = np.zeros([len(ra), 2])
            for i in range(len(ra)):
                RApix = np.asscalar(wcs.all_world2pix(ra[i], dec[i], 0)[0])
                Decpix = np.asscalar(wcs.all_world2pix(ra[i], dec[i], 0)[1])
                pix_coord[i, 0] = col0 + RApix
                pix_coord[i, 1] = row0 + Decpix
            pix_coords.append(pix_coord)

        self.TESS_images = TESS_images
        self.col0s = col0s
        self.row0s = row0s
        self.pix_coords = pix_coords
        return
Ejemplo n.º 11
0
def get_IDS(number):

    catalogTIC = Catalogs.query_criteria(catalog="Tic",
                                         Tmag=[12.0, 12.5],
                                         Teff=[3500.0, 3550.0],
                                         logg=[4.2, 5.0])
    catalogTIC = catalogTIC[catalogTIC['dec'] < 0]
    return catalogTIC['ID'][:number]
Ejemplo n.º 12
0
def get_coord_from_ticid(ticid):
    df = Catalogs.query_criteria(catalog="Tic", ID=ticid).to_pandas()
    coord = SkyCoord(
        ra=df.iloc[0]["ra"],
        dec=df.iloc[0]["dec"],
        distance=Distance(parallax=df.iloc[0]["plx"] * u.mas).pc,
        unit=(u.degree, u.degree, u.pc),
    )
    return coord
Ejemplo n.º 13
0
    def get_TIC(ra, dec, radius):
        """Retrieve TIC from MAST."""
        cat = Catalogs.query_region(
            SkyCoord(
                ra=ra, dec=dec, unit=(u.deg, u.deg), frame='icrs'
            ), radius=radius, catalog='TIC'
        )

        return cat
Ejemplo n.º 14
0
def get_star_info(IDnumber):
    tic = Catalogs.query_object("TIC {0}".format(IDnumber),
                                radius=0.0001,
                                catalog="TIC")
    star = tic[np.argmin(tic["dstArcSec"])]
    tic_ID = int(star["ID"])
    tic_ra = float(star["ra"])
    tic_dec = float(star["dec"])
    return tic_ID, tic_ra, tic_dec
Ejemplo n.º 15
0
def check_tess(df):
    """
    Verify TESS objects with MAST archive
    Args:
        df (pd.Dataframe): Dataframe with objects not found yet
    Returns:
        df with match info updated
    """

    df = df.copy()

    # Load TOI/TIC list
    data = requests.get(TOI_URL)
    tbl = Table.read(data.text, format='ascii')
    df_toi = tbl.to_pandas()[['TIC ID', 'TOI']].astype(str)

    # Replace TOI names with TIC
    # Keep order consistent with dataframe
    toi_inds = df.index[df['OBJECT'].str.startswith('TOI')]
    tois = df['OBJECT'].loc[toi_inds]
    # tois = tois.str.split('-').map(lambda x: x[1]) + '.01'
    tois = tois.str[3:].str.strip('-') + '.01'
    tois = tois.tolist()
    toi_to_tic = df_toi.loc[df_toi['TOI'].isin(tois)]
    toi_to_tic = toi_to_tic.set_index('TOI', drop=False)
    toi_to_tic = toi_to_tic.reindex(tois).set_index(np.arange(len(tois)))
    tics = toi_to_tic['TIC ID']

    gaiaids = df['GAIADR2ID'].loc[toi_inds]

    # Check where TIC ID matches same as local Gaia ID
    if tics.size == 0:
        return df
    tic_gaia = Catalogs.query_criteria(catalog='TIC',
                                       objType='STAR',
                                       ID=tics.tolist()).to_pandas()[[
                                           'ID', 'GAIA'
                                       ]]
    tic_gaia = tic_gaia.set_index('ID', drop=False)
    tic_gaia = tic_gaia.reindex(tics).set_index(np.arange(len(tics)))
    mask = tic_gaia['GAIA'].values == gaiaids.values

    # Record if match or not
    df['FOUND'].loc[toi_inds] = mask
    df['CHECKED'].loc[toi_inds] = mask

    # Where no match, replace by new ID
    df['GAIADR2ID'].loc[toi_inds] = df['GAIADR2ID'].loc[toi_inds].where(
        mask, other=tic_gaia['GAIA'])
    msg = 'Updated Gaia ID from TIC'
    df['COMMENTS'].loc[toi_inds] = df['COMMENTS'].loc[toi_inds].where(
        mask, other=msg)
    df['FOUND'].loc[toi_inds] = True
    df['CHECKED'].loc[toi_inds] = True

    return df
Ejemplo n.º 16
0
def get_ID_from_ID(id_type, ID, new_id_type):
    if id_type == 'TIC':
        query_string = 'tic ' + str(ID)
        obs_table = Catalogs.query_object(query_string,
                                          radius=0.002 * u.deg,
                                          catalog='TIC')
        obs_table = obs_table[obs_table['ID'] == str(ID)]
        ra = obs_table['ra'][0]
        dec = obs_table['dec'][0]
    return (ra, dec)
Ejemplo n.º 17
0
    def get_tess_input_catalog_row(tic_id: int) -> pd.Series:
        """
        Get the TIC row for a TIC ID.

        :param tic_id: The target's TIC ID.
        :return: The row of a the TIC corresponding to the TIC ID.
        """
        target_observations = Catalogs.query_criteria(catalog='TIC',
                                                      ID=tic_id).to_pandas()
        return target_observations.iloc[0]
Ejemplo n.º 18
0
def fetch_local_bright_TICs(ra_dec_string, targetname):
    """Produces a CSV of all <Tmag 10 targets w/in 2 degrees of the target for reference """
    catalog_data1 = Catalogs.query_criteria(coordinates=ra_dec_string, radius=2,
                                        catalog="TIC", Tmag = [-40, 10])

    correctcols = catalog_data1['ID', 'ra', 'dec', 'Tmag']
    
    print(correctcols)
    
    correctcols.write("/users/conta/urop/Local_TIC_to_" + targetname +".csv")
Ejemplo n.º 19
0
def find_tic(target_ID, from_file = True):
    if from_file == True:
        try:
            table_data = Table.read("Original_BANYAN_XI-III_xmatch_TIC.csv" , format='ascii.csv')
            #table_data = Table.read("Original VCA Members.csv" , format='ascii.csv') 
            #table_data = Table.read("Original Argus members info.csv" , format='ascii.csv')
            
            # Obtains ra and dec for object from target_ID
            i = list(table_data['main_id']).index(target_ID)
            ra = table_data['ra'][i]
            dec = table_data['dec'][i]
            tic = table_data['MatchID'][i]
        except:
            try:
                TIC_table = Catalogs.query_object(target_ID, catalog = "TIC")
                ra = TIC_table['ra'][0]
                dec = TIC_table['dec'][0]
                tic = TIC_table['ID'][0] 
            except:
                table_data = Table.read('BANYAN_XI-III_combined_members.csv')
                i = list(table_data['main_id']).index(target_ID)
                ra = table_data['ra'][i]
                dec = table_data['dec'][i]
                object_coord = SkyCoord(ra, dec, unit="deg")
                TIC_table = Catalogs.query_region(object_coord, radius = '1 deg', catalog = 'TIC')
                tic = TIC_table['ID'][0]
    else:
        # Find ra, dec and tic # via the TIC (typically based on Gaia DR2)
        try:
            TIC_table = Catalogs.query_object(target_ID, catalog = "TIC")
            ra = TIC_table['ra'][0]
            dec = TIC_table['dec'][0]
            tic = TIC_table['ID'][0] 
        except:
            table_data = Table.read('BANYAN_XI-III_combined_members.csv')
            i = list(table_data['main_id']).index(target_ID)
            ra = table_data['ra'][i]
            dec = table_data['dec'][i]
            object_coord = SkyCoord(ra, dec, unit="deg")
            TIC_table = Catalogs.query_region(object_coord, radius = '1 deg', catalog = 'TIC')
            tic = TIC_table['ID'][0]
    
    return ra, dec, tic
Ejemplo n.º 20
0
 def get_catalog(self, image):
     max_fov = image.fov.max() * np.sqrt(2) / 2
     table = Catalogs.query_region(image.skycoord,
                                   max_fov,
                                   "TIC",
                                   verbose=False)
     table["ra"].unit = "deg"
     table["dec"].unit = "deg"
     table.rename_column('ID', 'id')
     return table
Ejemplo n.º 21
0
def get_panstarrs_catalog(imgwcs,
                          imgfile,
                          radius=0.2,
                          rfaint=17,
                          region=False):
    from astroquery.mast import Catalogs
    ra0, dec0 = imgwcs.wcs.crval
    print(
        'Querying Pan-STARRS catalog with radius={:.3f} deg and central coordinates RA,Dec={:.5f},{:.5f}'
        .format(radius, ra0, dec0))
    if region:
        allcat = Catalogs.query_region('{} {}'.format(ra0, dec0),
                                       radius=radius,
                                       catalog='PANSTARRS',
                                       data_release='dr2',
                                       table='mean')  #, rMeanPSFMag=[12, 22])
    else:
        allcat = Catalogs.query_criteria(coordinates='{} {}'.format(ra0, dec0),
                                         radius=radius,
                                         catalog='PANSTARRS',
                                         data_release='dr2',
                                         table='mean',
                                         columns=[
                                             'objID', 'raMean', 'decMean',
                                             'gMeanPSFMag', 'rMeanPSFMag',
                                             'iMeanPSFMag', 'zMeanPSFMag'
                                         ],
                                         gMeanPSFMag=[('lte', 18),
                                                      ('gte', 12)],
                                         rMeanPSFMag=[('lte', 18),
                                                      ('gte', 12)],
                                         iMeanPSFMag=[('lte', 18),
                                                      ('gte', 12)],
                                         zMeanPSFMag=[('lte', 18),
                                                      ('gte', 12)],
                                         sort_by=[("asc", "rMeanPSFMag")])

    #rmag = allcat['rMeanPSFMag']
    #good = np.isfinite(rmag) * rmag < rfaint
    #cat = allcat[good]
    #print('Keeping {}/{} Pan-STARRS sources.'.format(len(cat), len(allcat)))
    return allcat
Ejemplo n.º 22
0
def app_catalogs():
    global blc
    global trc
    global im
    if blc is None or trc is None or im is None: load_image()

    searchString = '{} {}'.format(np.mean([blc[0], trc[0]]),
                                  np.mean([blc[1], trc[1]]))
    catalogData = Catalogs.query_object(searchString,
                                        radius=0.2,
                                        catalog="GAIAdr2")

    # get plot
    p = make_base_bokeh()

    source = ColumnDataSource(catalogData.to_pandas())
    p.scatter('ra',
              'dec',
              source=source,
              legend="GAIA DR2",
              alpha=0.7,
              size=10)

    # Add hover tooltip for GAIA data
    tooltip = [("RA", "@ra"), ("Dec", "@dec"), ("Desig.", "@designation"),
               ("parallax", "@parallax"),
               ("phot_g_mean_mag", "@phot_g_mean_mag")]
    p.add_tools(HoverTool(tooltips=tooltip))

    p.legend.click_policy = "hide"

    # Table data
    columns = []
    for col in catalogData.to_pandas().columns:
        if col not in ('ra', 'dec', 'designation', 'parallax'):
            continue
        columns.append(TableColumn(field=col, title=col))
    data_table = DataTable(source=source,
                           columns=columns,
                           width=1200,
                           height=280)

    # Fails to load anything
    # script, div_dict = components({'plot': p, 'table': widgetbox(data_table)})
    # return render_template('catalogs.html', script=script, div=div_dict)

    # Fails to load table
    # script1, div1 = components(p)
    # script2, div2 = components(widgetbox(data_table))
    # return render_template('catalogs.html', script1=script1, div1=div1, script2=script2, div2=div2)

    # No table
    script, div = components(p)
    return render_template('base.html', script=script, plot=div)
Ejemplo n.º 23
0
    def get_target_coordinates(tic_id: int) -> SkyCoord:
        """
        Get the sky coordinates of the target by a TIC ID.

        :param tic_id: The target's TIC ID.
        :return: The coordinates of the target.
        """
        target_observations = Catalogs.query_criteria(catalog='TIC', ID=tic_id).to_pandas()
        ra = target_observations['ra'].iloc[0]
        dec = target_observations['dec'].iloc[0]
        return SkyCoord(ra, dec, unit='deg')
Ejemplo n.º 24
0
Archivo: toco.py Proyecto: tessgi/toco
def get_tic_radec(ra, dec):
    with warnings.catch_warnings():
        warnings.simplefilter('ignore')
        catalogData = Catalogs.query_region('{} {}'.format(
            ra, dec),
            catalog='Tic', radius=1 * u.arcsec)

    try:
        return catalogData['ID'][0]
    except IndexError:
        logger.error("No TIC target at those coordiantes")
        sys.exit(1)
Ejemplo n.º 25
0
    def getRaDec(self, ticid):
        """
        Use astroquery catalogs to get the RA and Dec
        """

        #@todo check ticid is an integer.

        starName = "TIC %i" % int(ticid)
        cat = Catalogs.query_criteria(ID=starName, catalog="Tic")
        coord = SkyCoord(cat[0]['ra'], cat[0]['dec'], unit="deg")

        return coord
Ejemplo n.º 26
0
def get_IDS(number1, number2):

    catalogTIC = Catalogs.query_criteria(catalog="Tic",
                                         Teff=[3450.0, 3500.0],
                                         logg=[4.2, 5.0],
                                         Tmag=[11.5, 12.0])
    catalogTIC = catalogTIC[catalogTIC['dec'] < 0]
    return catalogTIC['ID'][number1:number2]


# catalogTIC = Catalogs.query_criteria(catalog = "Tic", Teff = [3450.0, 3500.0], logg=[4.2,5.0], Tmag=[11.5,12.0])
# catalogTIC = catalogTIC[catalogTIC['dec'] < 0]
# print(catalogTIC)
def ticid_to_coord(ticid):
    """
    Input:
        ticid: string containing the TIC Identificaiton number.
    Returns:
        coord: astropy SkyCoordinate object of ra and dec
    """
    info = Catalogs.query_criteria(catalog='Tic', ID=ticid)
    ra = info['ra'][0]  # deg
    dec = info['dec'][0]  # deg
    coord = SkyCoord(ra, dec, unit='deg')

    return coord
Ejemplo n.º 28
0
def coords_from_tic(tic):
    """Finds the RA, Dec, and magnitude for a given TIC source_id.

    Returns
    -------
    coords : tuple
        (RA, Dec) position [degrees].
    tmag : float
        TESS apparent magnitude.
    """

    ticData = Catalogs.query_object('tic'+str(tic), radius=.0001, catalog="TIC")
    return [ticData['ra'].data[0], ticData['dec'].data[0]], [ticData['Tmag'].data[0]], int(ticData['version'].data[0]), ticData['contratio'].data[0]
Ejemplo n.º 29
0
def tessobs_info(tic=None, ra=None, dec=None):
    #!!Update to include exp time, pixel location, other observation-specific
    #  quantities!!
    """
    Function to retrieve observation information for objects observed by TESS.

    Parameters
    ----------
    tic : int or None
       TIC ID of target to be queried. Must not be None if ra and dec are None.
    ra : float or None
       RA of target to be queried. Must not be None if tic is None.
    dec : float or None
       Dec of target to be queried. Must not be None if tic is None.

    Returns
    -------
    info : dict
       Dictionary continaing TESS observation info.
    """
    if not tic and not ra and not dec:
        raise ValueError('Please provide either a TIC ID or both RA and Dec')

    if not ra or not dec:
        cat = Catalogs.query_criteria(catalog="TIC", ID=int(tic))
        ra = cat[0]['ra']
        dec = cat[0]['dec']

    coords = coord.SkyCoord(ra, dec, unit='deg')
    sector_table = Tesscut.get_sectors(coordinates=coords)
    
    if len(sector_table) == 0:
        print('Object not observed by TESS')

    sec_name = []
    sec = []
    cam = []
    ccd = []

    for i in range(len(sector_table)):
        sec_name.append(sector_table[i]['sectorName'])
        sec.append(sector_table[i]['sector'])
        cam.append(sector_table[i]['camera'])
        ccd.append(sector_table[i]['ccd'])

    info = {'sectorName' : sec_name, 'sector' : sec, 'camera' : cam,
            'ccd' : ccd}

    return info
Ejemplo n.º 30
0
def loadSingleSector(ticId, sector, size_pixels):
    starname = "TIC %08i" % (ticId)

    catalogData = Catalogs.query_object(starname,
                                        radius=1 / 60.,
                                        catalog="TIC")
    ra = catalogData[0]['ra']
    dec = catalogData[0]['dec']
    coord = SkyCoord(ra, dec, unit='deg')

    data, hdr, wcshdr = getTessCutout(coord, size_pixels, sector)
    time = data['TIME']
    cube = getTargetPixelArrayFromFits(data, hdr)

    return time, cube, hdr, wcshdr