Astropy.coord

1 minute read

Published:

Import packages


import numpy as np
import pandas as pd
import os
from astropy.table import Table
from scipy.stats import spearmanr#
from scipy.stats.stats import pearsonr

from astropy.table import Table
from astropy.cosmology import FlatLambdaCDM,Planck13,Planck15,z_at_value
from astropy import units as u
from astropy import constants 

from astropy.coordinates import SkyCoord
from astropy.cosmology import LambdaCDM

cosmo = LambdaCDM(H0=70, Om0=0.27, Ode0=0.73)
from astropy.time import Time
from astropy.time import TimeYearDayTime


from datetime import datetime
import time
from time import strftime,strptime
import calendar
from dateutil.parser import parse

#from adjustText import adjust_text
import matplotlib as mpl
import matplotlib.pyplot as plt
from pylab import cm
from collections import OrderedDict
#from adjustText import adjust_text

%matplotlib inline
%config InlineBackend.figure_format='svg'
# Edit the font, font size, and axes width
mpl.rcParams['font.family'] = 'Times New Roman' #'Avenir'
plt.rcParams['font.size'] = 18
plt.rcParams['axes.linewidth'] = 1.5

coord




coord = SkyCoord('%dh%dm%.2fs'%(RAh,RAm,RAs), '%s%dd%dm%.2fs'%(DE_sig,DE_d,DE_m,DE_s), frame='icrs') 

c = SkyCoord(10.625, 41.2, frame='icrs', unit='deg')
c = SkyCoord('00h42m30s', '+41d12m00s', frame='icrs')
c = SkyCoord('00h42.5m', '+41d12m')
c = SkyCoord('00 42 30 +41 12 00', unit=(u.hourangle, u.deg))
c = SkyCoord('00:42.5 +41:12', unit=(u.hourangle, u.deg))







SDSS


from astroquery.sdss import SDSS


plate_=datafile.loc[index,'Plate']
mjd_ = datafile.loc[index,'MJD']
fiber_=datafile.loc[index,'Fiber']
filename = f"spec-{str(plate_).zfill(4)}-{str(mjd_).zfill(5)}-{str(fiber_).zfill(4)}.fits"




fnames = list([f"sdss_{b}0" for b in "ugriz"])    
bands = "ugriz"
mcol = [f"cModelMag_{b}" for b in bands]
ecol = [f"cModelMagErr_{b}" for b in bands]
cat = SDSS.query_crossid(SkyCoord(ra=ra, dec=dec, unit="deg"),
                     data_release=16,timeout=180,
                     photoobj_fields=mcol + ecol + ["specObjID"])
                     
#filters = load_filters([f"sdss_{b}0" for b in bands])
mags= np.array([cat[0][f"cModelMag_{b}"] for b in bands])
maggies = np.squeeze(10**(-mags/2.5))    #in unit of maggies
magerr = np.array([cat[0][f"cModelMagErr_{b}"] for b in bands])
mag_g =cat[0][f"cModelMag_g"]
mag_r =cat[0][f"cModelMag_r"]
magerr = np.hypot(magerr, 0.05)
 

Other

time.sleep(5+np.random.randint(5,10))
 

欢迎关注微信公众号:曜灵集