Esempio n. 1
0
def splusCuts(table, bands):
    username = str(input("Login: "******"Password: ")
    conn = splusdata.connect(username, password)

    for key, value in table.iterrows():
        hdu = conn.get_cut(value.RA, value.DEC, 128, bands.capitalize())
        #ID = value.ID[0:len(value.ID)-1]  ???
        imagename = './data/splus/%s_%.6f_%.6f.fz' % (value.ID, value.RA,
                                                      value.DEC)
        hdu.writeto(imagename)
        fz2fits(imagename)

    print('\nSPLUS stamps have been downloaded.')
Esempio n. 2
0
def make_stamps_interacting_galaxies():
    names = ["AM1054-325", "AM1025-433", "AM0453-372", "AM0155-691",
             "NGC1209", "NGC3312"]
    ras = [164.2423, 156.963624, 73.72375, 29.210415, 46.5125, 159.26041]
    decs = [-33.16453, -43.903748, -37.321722, -68.995255, -15.61139, -27.5650]
    sizes = [516] * len(names)
    wdir = os.path.join(context.data_dir, "interacting_galaxies")
    outdir = os.path.join(wdir, "cutouts")
    for _dir in [wdir, outdir]:
        if not os.path.exists(_dir):
            os.mkdir(_dir)
    credentials_file = "./credentials.txt"
    if os.path.exists(credentials_file):
        with open(credentials_file) as f:
            fields = f.readlines()
        conn = splusdata.connect(fields[0], fields[1])  ## from splus.cloud
    else:
        print("Access to S-PLUS data requires authentication.")
        user = input("login: "******"Getting cutouts for sample"
    for i in tqdm(range(len(names))):
        gal_dir = os.path.join(outdir, names[i])
        if not os.path.exists(gal_dir):
            os.mkdir(gal_dir)
        for band in context.bands:
            cutout = conn.get_cut(ras[i], decs[i], sizes[i], band)

            header = cutout[1].header
            data = cutout[1].data
            imgname = "{0}_{1}_{2}_{3}x{3}_swp.fits".format(names[i],
                      header["object"].replace("_", "-"), band, sizes[i])
            hdu = fits.ImageHDU(data=data, header=header)
            hdulist = fits.HDUList([fits.PrimaryHDU(), hdu])
            hdulist.writeto(os.path.join(gal_dir, imgname), overwrite=True)
import numpy as np
from astropy.nddata import Cutout2D
from astropy.wcs import WCS
import astropy.io.fits as pf
import getpass
# from tqdm.notebook import tqdm

#remove warnings
import warnings
warnings.filterwarnings("ignore")

name = getpass.getpass(prompt='Username Login at S-PLUS cloud:')
password = getpass.getpass(prompt='Password:'******'s header.
        """
        infile = open(File, 'r')
        firstLine = infile.readline()
        header=firstLine.split(',')
        if HEADER==1:
            print(header)
            return(header)
Esempio n. 4
0
import splusdata
import getpass
import pandas as pd
'''
Code to get the probability of being galaxy (Nakazono et al, 2021)
The table used here (candidates.csv) is from the selecting-gals.py code
'''

# Connecting with SPLUS database
username = str(input("Login: "******"Password: "******"""SELECT upl.ID, upl.RA, upl.DEC, upl.FWHM_R, sgq.PROB_STAR, sgq.PROB_QSO, sgq.PROB_GAL 
                 FROM TAP_UPLOAD.upload AS upl LEFT OUTER JOIN "idr3_vacs"."star_galaxy_quasar" AS sgq 
                 ON upl.id = sgq.id WHERE "CLASS" = 2"""

# Applying query
result = conn.query(Query, df)

#Converting the astropy table into pandas and saving
df_result = result.to_pandas()
df_result.to_csv('./data/selected-gals-vac.csv')