AstroToolkit 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- AstroToolkit/Figures/HRD.py +82 -0
- AstroToolkit/Figures/SED.py +364 -0
- AstroToolkit/Figures/__init__.py +0 -0
- AstroToolkit/Miscellaneous/ProperMotionCorrection.py +50 -0
- AstroToolkit/Miscellaneous/ReadFits.py +35 -0
- AstroToolkit/Miscellaneous/TestFile.py +138 -0
- AstroToolkit/Miscellaneous/__init__.py +0 -0
- AstroToolkit/Overlays/Overlay_GALEX.py +148 -0
- AstroToolkit/Overlays/Overlay_Gaia.py +63 -0
- AstroToolkit/Overlays/Overlay_ROSAT.py +20 -0
- AstroToolkit/Overlays/Overlay_Selection.py +42 -0
- AstroToolkit/Overlays/Overlay_ZTF.py +46 -0
- AstroToolkit/Overlays/__init__.py +0 -0
- AstroToolkit/Surveys/DSS.py +153 -0
- AstroToolkit/Surveys/GALEX.py +45 -0
- AstroToolkit/Surveys/Gaia.py +168 -0
- AstroToolkit/Surveys/PanSTARRS.py +221 -0
- AstroToolkit/Surveys/ROSAT.py +51 -0
- AstroToolkit/Surveys/SDSS.py +78 -0
- AstroToolkit/Surveys/SkyMapper.py +215 -0
- AstroToolkit/Surveys/TWOMASS.py +45 -0
- AstroToolkit/Surveys/WISE.py +45 -0
- AstroToolkit/Surveys/ZTF.py +206 -0
- AstroToolkit/Surveys/__init__.py +0 -0
- AstroToolkit/Timeseries/__init__.py +0 -0
- AstroToolkit/Timeseries/pyaov.py +781 -0
- AstroToolkit/Timeseries/ztfanalysis.py +847 -0
- AstroToolkit/Tools.py +1222 -0
- AstroToolkit/__init__.py +0 -0
- AstroToolkit-1.0.0.dist-info/LICENSE +0 -0
- AstroToolkit-1.0.0.dist-info/METADATA +934 -0
- AstroToolkit-1.0.0.dist-info/RECORD +34 -0
- AstroToolkit-1.0.0.dist-info/WHEEL +5 -0
- AstroToolkit-1.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
from astropy.table import Table
|
|
2
|
+
import matplotlib.pyplot as plt
|
|
3
|
+
import numpy as np
|
|
4
|
+
from scipy import stats
|
|
5
|
+
import math
|
|
6
|
+
import cmasher as cmr
|
|
7
|
+
from bokeh.plotting import figure,show
|
|
8
|
+
import os
|
|
9
|
+
from importlib_resources import files
|
|
10
|
+
|
|
11
|
+
from ..Surveys.Gaia import GaiaQueryDesignation
|
|
12
|
+
|
|
13
|
+
fits_file = files('WDPlanetsToolkit.Figures').joinpath('backdrop_hrd_allmags.fits')
|
|
14
|
+
|
|
15
|
+
def get_plot(source=None,sources=None):
|
|
16
|
+
background=Table.read(fits_file).to_pandas()
|
|
17
|
+
background_100pc=background.loc[background['type']==b'100pc']
|
|
18
|
+
background_wd=background.loc[background['type']==b'WD']
|
|
19
|
+
background_cv=background.loc[background['type']==b'CV']
|
|
20
|
+
background_wd_dm=background.loc[background['type']==b'WD+dM']
|
|
21
|
+
background_sd=background.loc[background['type']==b'SD']
|
|
22
|
+
|
|
23
|
+
background_split=[background_100pc,background_wd,background_wd_dm,background_cv,background_sd]
|
|
24
|
+
|
|
25
|
+
x_arr=[]
|
|
26
|
+
y_arr=[]
|
|
27
|
+
colour_arr=[]
|
|
28
|
+
|
|
29
|
+
for sample in background_split:
|
|
30
|
+
x=sample['phot_bp_mean_mag'].values-sample['phot_rp_mean_mag'].values
|
|
31
|
+
y=sample['phot_g_mean_mag'].values+5*np.log10(sample['parallax'].values/1000)+5
|
|
32
|
+
|
|
33
|
+
x_arr.append(x)
|
|
34
|
+
y_arr.append(y)
|
|
35
|
+
|
|
36
|
+
colour_maps=['Greens','Purples','Reds','Blues','YlOrBr']
|
|
37
|
+
|
|
38
|
+
for i in range(0,len(colour_maps)):
|
|
39
|
+
colour_maps[i]=cmr.get_sub_cmap(colour_maps[i],0.4,1.0)
|
|
40
|
+
|
|
41
|
+
for i in range(0,len(x_arr)):
|
|
42
|
+
values=np.vstack([x_arr[i],y_arr[i]])
|
|
43
|
+
kernel=stats.gaussian_kde(values)
|
|
44
|
+
weights=kernel(values)
|
|
45
|
+
weights=weights/weights.max()
|
|
46
|
+
|
|
47
|
+
colour=["#%02x%02x%02x" % (int(r), int(g), int(b)) for r, g, b, _ in 255*colour_maps[i](weights)]
|
|
48
|
+
colour_arr.append(colour)
|
|
49
|
+
|
|
50
|
+
plot=figure(width=400,height=400,title='Gaia HRD',x_axis_label=r'\[\text{bp-rp}\]',y_axis_label=r'\[\text{abs g}\]')
|
|
51
|
+
plot.y_range.flipped = True
|
|
52
|
+
|
|
53
|
+
labels=['100pc','WDs','CVs','WD+dM','SDs']
|
|
54
|
+
for i in range(0,len(x_arr)):
|
|
55
|
+
plot.scatter(x_arr[i],y_arr[i],size=3,color=colour_arr[i],legend_label=labels[i])
|
|
56
|
+
|
|
57
|
+
if source!=None:
|
|
58
|
+
data=GaiaQueryDesignation(Designation=source)
|
|
59
|
+
gmag,bpmag,rpmag,parallax=data['phot_g_mean_mag'].values,data['phot_bp_mean_mag'].values,data['phot_rp_mean_mag'].values,data['parallax'].values
|
|
60
|
+
x=bpmag-rpmag
|
|
61
|
+
y=gmag+5*np.log10(parallax/1000)+5
|
|
62
|
+
|
|
63
|
+
if not math.isnan(gmag) and not math.isnan(bpmag) and not math.isnan(rpmag) and not math.isnan(parallax):
|
|
64
|
+
plot.scatter(x=x,y=y,marker='square_dot',line_color='black',fill_color=None,size=20,line_width=2,legend_label='Source')
|
|
65
|
+
else:
|
|
66
|
+
return None
|
|
67
|
+
|
|
68
|
+
elif sources!=None:
|
|
69
|
+
for i in range(0,len(sources)):
|
|
70
|
+
data=GaiaQueryDesignation(Designation=sources[i])
|
|
71
|
+
gmag,bpmag,rpmag,parallax=data['phot_g_mean_mag'].values,data['phot_bp_mean_mag'].values,data['phot_rp_mean_mag'].values,data['parallax'].values
|
|
72
|
+
x=bpmag-rpmag
|
|
73
|
+
y=gmag+5*np.log10(parallax/1000)+5
|
|
74
|
+
|
|
75
|
+
if not math.isnan(gmag) and not math.isnan(bpmag) and not math.isnan(rpmag) and not math.isnan(parallax):
|
|
76
|
+
plot.scatter(x=x,y=y,marker='square_dot',line_color='black',fill_color=None,size=20,line_width=2,legend_label='Source')
|
|
77
|
+
else:
|
|
78
|
+
pass
|
|
79
|
+
|
|
80
|
+
plot.legend.click_policy="hide"
|
|
81
|
+
|
|
82
|
+
return plot
|
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
import astropy.units as u
|
|
2
|
+
import math
|
|
3
|
+
import pandas as pd
|
|
4
|
+
import matplotlib
|
|
5
|
+
import numpy as np
|
|
6
|
+
from bokeh.plotting import figure,show
|
|
7
|
+
from bokeh.models import Whisker, ColumnDataSource
|
|
8
|
+
|
|
9
|
+
from ..Surveys.Gaia import GaiaQueryDesignation
|
|
10
|
+
from ..Miscellaneous.ProperMotionCorrection import PMCorrection as CorrectPM
|
|
11
|
+
from ..Surveys.SDSS import get_photometry as get_phot_sdss
|
|
12
|
+
from ..Surveys.WISE import get_photometry as get_phot_wise
|
|
13
|
+
from ..Surveys.TWOMASS import get_photometry as get_phot_twomass
|
|
14
|
+
from ..Surveys.Gaia import GaiaGetPhotometryCoords
|
|
15
|
+
from ..Surveys.GALEX import GALEXGetPhotometryCoords
|
|
16
|
+
from ..Surveys.PanSTARRS import PanSTARRSGetPhotometryCoords
|
|
17
|
+
from ..Surveys.SkyMapper import SkyMapperGetPhotometryCoords
|
|
18
|
+
|
|
19
|
+
def zeropoint(mag,zp,wl):
|
|
20
|
+
flux=zp*10**(-0.4*mag)
|
|
21
|
+
c=2.988*10**18
|
|
22
|
+
fnl=1*10**(-23)
|
|
23
|
+
flux=flux/((fnl*c)/wl**2)*1000
|
|
24
|
+
return flux
|
|
25
|
+
|
|
26
|
+
def get_plot(source=None,pos=None,radius=3):
|
|
27
|
+
if source!=None and pos!=None:
|
|
28
|
+
raise Exception('simulatenous source and pos input detected')
|
|
29
|
+
|
|
30
|
+
if source!=None:
|
|
31
|
+
gaia_data=GaiaQueryDesignation(Designation=source)
|
|
32
|
+
ra,dec,pmra,pmdec=gaia_data['ra'].values[0],gaia_data['dec'].values[0],gaia_data['pmra'].values[0],gaia_data['pmdec'].values[0]
|
|
33
|
+
|
|
34
|
+
pos_corrected=CorrectPM([2016,0],[2012,0],ra,dec,pmra,pmdec)
|
|
35
|
+
ra_panstarrs,dec_panstarrs=pos_corrected[0],pos_corrected[1]
|
|
36
|
+
|
|
37
|
+
pos_corrected=CorrectPM([2016,0],[2016,0],ra,dec,pmra,pmdec)
|
|
38
|
+
ra_skymapper,dec_skymapper=pos_corrected[0],pos_corrected[1]
|
|
39
|
+
|
|
40
|
+
ra_gaia,dec_gaia=ra,dec
|
|
41
|
+
|
|
42
|
+
pos_corrected=CorrectPM([2016,0],[2007,0],ra,dec,pmra,pmdec)
|
|
43
|
+
ra_galex,dec_galex=pos_corrected[0],pos_corrected[1]
|
|
44
|
+
|
|
45
|
+
pos_corrected=CorrectPM([2016,0],[1991,0],ra,dec,pmra,pmdec)
|
|
46
|
+
ra_rosat,dec_rosat=pos_corrected[0],pos_corrected[1]
|
|
47
|
+
|
|
48
|
+
pos_corrected=CorrectPM([2016,0],[2017,0],ra,dec,pmra,pmdec)
|
|
49
|
+
ra_sdss,dec_sdss=pos_corrected[0],pos_corrected[1]
|
|
50
|
+
|
|
51
|
+
pos_corrected=CorrectPM([2016,0],[2010,5],ra,dec,pmra,pmdec)
|
|
52
|
+
ra_wise,dec_wise=pos_corrected[0],pos_corrected[1]
|
|
53
|
+
|
|
54
|
+
pos_corrected=CorrectPM([2016,0],[1999,0],ra,dec,pmra,pmdec)
|
|
55
|
+
ra_twomass,dec_twomass=pos_corrected[0],pos_corrected[1]
|
|
56
|
+
|
|
57
|
+
elif pos!=None:
|
|
58
|
+
ra_panstarrs,dec_panstarrs=pos[0],pos[1]
|
|
59
|
+
ra_skymapper,dec_skymapper=pos[0],pos[1]
|
|
60
|
+
ra_gaia,dec_gaia=pos[0],pos[1]
|
|
61
|
+
ra_galex,dec_galex=pos[0],pos[1]
|
|
62
|
+
ra_rosat,dec_rosat=pos[0],pos[1]
|
|
63
|
+
ra_sdss,dec_sdss=pos[0],pos[1]
|
|
64
|
+
ra_wise,dec_wise=pos[0],pos[1]
|
|
65
|
+
ra_twomass,dec_twomass=pos[0],pos[1]
|
|
66
|
+
|
|
67
|
+
else:
|
|
68
|
+
raise Exception('either source or pos input required')
|
|
69
|
+
return None
|
|
70
|
+
|
|
71
|
+
filter_arr=[]
|
|
72
|
+
|
|
73
|
+
error_arr=[]
|
|
74
|
+
wavelength_arr=[]
|
|
75
|
+
flux_arr=[]
|
|
76
|
+
mag_arr=[]
|
|
77
|
+
|
|
78
|
+
wavelengths=[]
|
|
79
|
+
flux=[]
|
|
80
|
+
errors=[]
|
|
81
|
+
mags=[]
|
|
82
|
+
photometry=GaiaGetPhotometryCoords(ra_gaia,dec_gaia,radius=radius)
|
|
83
|
+
if isinstance(photometry,pd.DataFrame):
|
|
84
|
+
filter_list=['phot_g_mean_mag','phot_rp_mean_mag','phot_bp_mean_mag']
|
|
85
|
+
error_list=['phot_g_mean_mag_error','phot_rp_mean_mag_error','phot_bp_mean_mag_error']
|
|
86
|
+
zero_points=[2.5e-9,1.24e-9,4.11e-9]
|
|
87
|
+
|
|
88
|
+
#g,rp,bp
|
|
89
|
+
filter_ref=[5850.88,7690.74,5041.61]
|
|
90
|
+
|
|
91
|
+
for filter, error, zp in zip(filter_list,error_list,zero_points):
|
|
92
|
+
try:
|
|
93
|
+
mag=photometry._get_value(0,filter)
|
|
94
|
+
mags.append(mag)
|
|
95
|
+
|
|
96
|
+
errors.append((photometry._get_value(0,error)*u.ABmag))
|
|
97
|
+
wavelength=(filter_ref[filter_list.index(filter)])
|
|
98
|
+
wavelengths.append(wavelength)
|
|
99
|
+
|
|
100
|
+
fl=zeropoint(mag=mag,zp=zp,wl=wavelength)
|
|
101
|
+
flux.append(fl)
|
|
102
|
+
|
|
103
|
+
filter_arr.append(filter)
|
|
104
|
+
except:
|
|
105
|
+
pass
|
|
106
|
+
wavelength_arr.append(wavelengths)
|
|
107
|
+
flux_arr.append(flux)
|
|
108
|
+
error_arr.append(errors)
|
|
109
|
+
mag_arr.append(mags)
|
|
110
|
+
|
|
111
|
+
wavelengths=[]
|
|
112
|
+
flux=[]
|
|
113
|
+
errors=[]
|
|
114
|
+
mags=[]
|
|
115
|
+
photometry=GALEXGetPhotometryCoords(ra_galex,dec_galex,radius=radius)
|
|
116
|
+
if isinstance(photometry,pd.DataFrame):
|
|
117
|
+
filter_list=['NUVmag','FUVmag']
|
|
118
|
+
error_list=['e_NUVmag','e_FUVmag']
|
|
119
|
+
|
|
120
|
+
#nuv,fuv
|
|
121
|
+
filter_ref=[2303.37,1548.85]
|
|
122
|
+
|
|
123
|
+
for filter,error in zip(filter_list,error_list):
|
|
124
|
+
try:
|
|
125
|
+
mag=photometry._get_value(0,filter)
|
|
126
|
+
mags.append(mag)
|
|
127
|
+
|
|
128
|
+
errors.append((photometry._get_value(0,error)*u.ABmag))
|
|
129
|
+
wavelength=(filter_ref[filter_list.index(filter)])
|
|
130
|
+
wavelengths.append(wavelength)
|
|
131
|
+
|
|
132
|
+
zp=10**((5*np.log10(filter_ref[filter_list.index(filter)])+2.406)/-2.5)
|
|
133
|
+
fl=zeropoint(mag=mag,zp=zp,wl=wavelength)
|
|
134
|
+
flux.append(fl)
|
|
135
|
+
|
|
136
|
+
filter_arr.append(filter)
|
|
137
|
+
except:
|
|
138
|
+
pass
|
|
139
|
+
wavelength_arr.append(wavelengths)
|
|
140
|
+
flux_arr.append(flux)
|
|
141
|
+
error_arr.append(errors)
|
|
142
|
+
mag_arr.append(mags)
|
|
143
|
+
|
|
144
|
+
wavelengths=[]
|
|
145
|
+
flux=[]
|
|
146
|
+
errors=[]
|
|
147
|
+
mags=[]
|
|
148
|
+
photometry=PanSTARRSGetPhotometryCoords(ra_panstarrs,dec_panstarrs,radius=radius)
|
|
149
|
+
if isinstance(photometry,pd.DataFrame):
|
|
150
|
+
filter_list=['gMeanPSFMag','rMeanPSFMag','iMeanPSFMag','zMeanPSFMag','yMeanPSFMag']
|
|
151
|
+
error_list=['gMeanPSFMagErr','rMeanPSFMagErr','iMeanPSFMagErr','zMeanPSFMagErr','yMeanPSFMagErr']
|
|
152
|
+
|
|
153
|
+
#g,r,i,z,y
|
|
154
|
+
filter_ref=[4810.16,6155.47,7503.03,8668.36,9613.60]
|
|
155
|
+
|
|
156
|
+
for filter,error in zip(filter_list,error_list):
|
|
157
|
+
try:
|
|
158
|
+
mag=photometry._get_value(0,filter)
|
|
159
|
+
mags.append(mag)
|
|
160
|
+
|
|
161
|
+
errors.append((photometry._get_value(0,error)*u.ABmag))
|
|
162
|
+
wavelength=(filter_ref[filter_list.index(filter)])
|
|
163
|
+
wavelengths.append(wavelength)
|
|
164
|
+
|
|
165
|
+
zp=10**((5*np.log10(filter_ref[filter_list.index(filter)])+2.406)/-2.5)
|
|
166
|
+
fl=zeropoint(mag=mag,zp=zp,wl=wavelength)
|
|
167
|
+
flux.append(fl)
|
|
168
|
+
|
|
169
|
+
filter_arr.append(filter)
|
|
170
|
+
except:
|
|
171
|
+
pass
|
|
172
|
+
wavelength_arr.append(wavelengths)
|
|
173
|
+
flux_arr.append(flux)
|
|
174
|
+
error_arr.append(errors)
|
|
175
|
+
mag_arr.append(mags)
|
|
176
|
+
|
|
177
|
+
wavelengths=[]
|
|
178
|
+
flux=[]
|
|
179
|
+
errors=[]
|
|
180
|
+
mags=[]
|
|
181
|
+
photometry=SkyMapperGetPhotometryCoords(ra_skymapper,dec_skymapper,radius=radius)
|
|
182
|
+
if isinstance(photometry,pd.DataFrame):
|
|
183
|
+
filter_list=['g_psf','r_psf','i_psf','z_psf','u_psf','v_psf']
|
|
184
|
+
error_list=['e_g_psf','e_r_psf','e_i_psf','e_z_psf','e_u_psf','e_v_psf']
|
|
185
|
+
|
|
186
|
+
#g,r,i,z,u,v
|
|
187
|
+
filter_ref=[5016.05,6076.85,6076.85,9120.25,3500.22,3878.68]
|
|
188
|
+
|
|
189
|
+
for filter,error in zip(filter_list,error_list):
|
|
190
|
+
try:
|
|
191
|
+
mag=photometry._get_value(0,filter)
|
|
192
|
+
mags.append(mag)
|
|
193
|
+
|
|
194
|
+
errors.append((photometry._get_value(0,error)*u.ABmag))
|
|
195
|
+
wavelength=(filter_ref[filter_list.index(filter)])
|
|
196
|
+
wavelengths.append(wavelength)
|
|
197
|
+
|
|
198
|
+
zp=10**((5*np.log10(filter_ref[filter_list.index(filter)])+2.406)/-2.5)
|
|
199
|
+
fl=zeropoint(mag=mag,zp=zp,wl=wavelength)
|
|
200
|
+
flux.append(fl)
|
|
201
|
+
|
|
202
|
+
filter_arr.append(filter)
|
|
203
|
+
except:
|
|
204
|
+
pass
|
|
205
|
+
wavelength_arr.append(wavelengths)
|
|
206
|
+
flux_arr.append(flux)
|
|
207
|
+
error_arr.append(errors)
|
|
208
|
+
mag_arr.append(mags)
|
|
209
|
+
|
|
210
|
+
wavelengths=[]
|
|
211
|
+
flux=[]
|
|
212
|
+
errors=[]
|
|
213
|
+
mags=[]
|
|
214
|
+
photometry=get_phot_sdss(ra_sdss,dec_sdss,radius=radius)
|
|
215
|
+
if isinstance(photometry,pd.DataFrame):
|
|
216
|
+
filter_list=['uPmag','gPmag','rPmag','iPmag','zPmag']
|
|
217
|
+
error_list=['e_uPmag','e_gPmag','e_rPmag','e_iPmag','e_zPmag']
|
|
218
|
+
|
|
219
|
+
#u,g,r,i,z
|
|
220
|
+
filter_ref=[3608.04,4671.78,6141.12,7457.89,8922.78]
|
|
221
|
+
|
|
222
|
+
for filter,error in zip(filter_list,error_list):
|
|
223
|
+
try:
|
|
224
|
+
mag=photometry._get_value(0,filter)
|
|
225
|
+
mags.append(mag)
|
|
226
|
+
|
|
227
|
+
errors.append((photometry._get_value(0,error)*u.ABmag))
|
|
228
|
+
wavelength=(filter_ref[filter_list.index(filter)])
|
|
229
|
+
wavelengths.append(wavelength)
|
|
230
|
+
|
|
231
|
+
zp=10**((5*np.log10(filter_ref[filter_list.index(filter)])+2.406)/-2.5)
|
|
232
|
+
fl=zeropoint(mag=mag,zp=zp,wl=wavelength)
|
|
233
|
+
flux.append(fl)
|
|
234
|
+
|
|
235
|
+
filter_arr.append(filter)
|
|
236
|
+
except:
|
|
237
|
+
pass
|
|
238
|
+
wavelength_arr.append(wavelengths)
|
|
239
|
+
flux_arr.append(flux)
|
|
240
|
+
error_arr.append(errors)
|
|
241
|
+
mag_arr.append(mags)
|
|
242
|
+
|
|
243
|
+
wavelengths=[]
|
|
244
|
+
flux=[]
|
|
245
|
+
errors=[]
|
|
246
|
+
mags=[]
|
|
247
|
+
photometry=get_phot_wise(ra_wise,dec_wise,radius=radius)
|
|
248
|
+
if isinstance(photometry,pd.DataFrame):
|
|
249
|
+
filter_list=['W1mag','W2mag','W3mag','W4mag']
|
|
250
|
+
error_list=['e_W1mag','e_W2mag','e_W3mag','e_W4mag']
|
|
251
|
+
|
|
252
|
+
#w1,w2,w3,w4
|
|
253
|
+
filter_ref=[33526.00,46028.00,115608.00,220883.00]
|
|
254
|
+
|
|
255
|
+
for filter,error in zip(filter_list,error_list):
|
|
256
|
+
try:
|
|
257
|
+
mag=photometry._get_value(0,filter)
|
|
258
|
+
mags.append(mag)
|
|
259
|
+
|
|
260
|
+
errors.append((photometry._get_value(0,error)*u.ABmag))
|
|
261
|
+
wavelength=(filter_ref[filter_list.index(filter)])
|
|
262
|
+
wavelengths.append(wavelength)
|
|
263
|
+
|
|
264
|
+
zp=10**((5*np.log10(filter_ref[filter_list.index(filter)])+2.406)/-2.5)
|
|
265
|
+
fl=zeropoint(mag=mag,zp=zp,wl=wavelength)
|
|
266
|
+
flux.append(fl)
|
|
267
|
+
|
|
268
|
+
filter_arr.append(filter)
|
|
269
|
+
except:
|
|
270
|
+
pass
|
|
271
|
+
wavelength_arr.append(wavelengths)
|
|
272
|
+
flux_arr.append(flux)
|
|
273
|
+
error_arr.append(errors)
|
|
274
|
+
mag_arr.append(mags)
|
|
275
|
+
|
|
276
|
+
wavelengths=[]
|
|
277
|
+
flux=[]
|
|
278
|
+
errors=[]
|
|
279
|
+
mags=[]
|
|
280
|
+
photometry=get_phot_twomass(ra_twomass,dec_twomass,radius=radius)
|
|
281
|
+
if isinstance(photometry,pd.DataFrame):
|
|
282
|
+
filter_list=['Jmag','Hmag','Kmag']
|
|
283
|
+
error_list=['e_Jmag','e_Hmag','e_Kmag']
|
|
284
|
+
|
|
285
|
+
#j,h,k
|
|
286
|
+
filter_ref=[12350.00,16620.00,21590.00]
|
|
287
|
+
|
|
288
|
+
for filter,error in zip(filter_list,error_list):
|
|
289
|
+
try:
|
|
290
|
+
mag=photometry._get_value(0,filter)
|
|
291
|
+
mags.append(mag)
|
|
292
|
+
|
|
293
|
+
errors.append((photometry._get_value(0,error)*u.ABmag))
|
|
294
|
+
wavelength=(filter_ref[filter_list.index(filter)])
|
|
295
|
+
wavelengths.append(wavelength)
|
|
296
|
+
|
|
297
|
+
zp=10**((5*np.log10(filter_ref[filter_list.index(filter)])+2.406)/-2.5)
|
|
298
|
+
fl=zeropoint(mag=mag,zp=zp,wl=wavelength)
|
|
299
|
+
flux.append(fl)
|
|
300
|
+
|
|
301
|
+
filter_arr.append(filter)
|
|
302
|
+
except:
|
|
303
|
+
pass
|
|
304
|
+
wavelength_arr.append(wavelengths)
|
|
305
|
+
flux_arr.append(flux)
|
|
306
|
+
error_arr.append(errors)
|
|
307
|
+
mag_arr.append(mags)
|
|
308
|
+
|
|
309
|
+
for i in range(0,len(flux_arr)):
|
|
310
|
+
for j in range(0,len(flux_arr[i])):
|
|
311
|
+
try:
|
|
312
|
+
flux_arr[i][j]=flux_arr[i][j].value
|
|
313
|
+
except:
|
|
314
|
+
pass
|
|
315
|
+
for i in range(0,len(error_arr)):
|
|
316
|
+
for j in range(0,len(error_arr[i])):
|
|
317
|
+
error_arr[i][j]=error_arr[i][j].value
|
|
318
|
+
|
|
319
|
+
rel_error_arr=[]
|
|
320
|
+
for i in range(0,len(mag_arr)):
|
|
321
|
+
flux_arr[i]=np.asarray(flux_arr[i])
|
|
322
|
+
error_arr[i]=np.asarray(error_arr[i])
|
|
323
|
+
mag_arr[i]=np.asarray(mag_arr[i])
|
|
324
|
+
|
|
325
|
+
rel_error_arr.append(flux_arr[i]*error_arr[i]/mag_arr[i])
|
|
326
|
+
|
|
327
|
+
if len(flux)==0 and len(wavelengths)==0:
|
|
328
|
+
return None
|
|
329
|
+
|
|
330
|
+
#Order on plot: GALEX, SDSS, SkyMapper, PanSTARRS, Gaia, 2MASS, WISE
|
|
331
|
+
#Order in script: Gaia, GALEX, PanSTARRS, SkyMapper, SDSS, WISE, 2MASS
|
|
332
|
+
colour_arr=['springgreen','royalblue','gold','aquamarine','deepskyblue','orangered','orange']
|
|
333
|
+
|
|
334
|
+
plot=figure(width=400,height=400,title='SED',x_axis_label=r'\[\lambda_{\text{eff}}\text{ }[\text{AA}]\]',y_axis_label=r'\[\text{flux [mJy]}\]',x_axis_type='log',y_axis_type="log")
|
|
335
|
+
|
|
336
|
+
# Bokeh only understands np nan values
|
|
337
|
+
for i in range(0,len(wavelength_arr)):
|
|
338
|
+
wavelength_arr[i]=[np.nan if math.isnan(x) else x for x in wavelength_arr[i]]
|
|
339
|
+
flux_arr[i]=[np.nan if math.isnan(x) else x for x in flux_arr[i]]
|
|
340
|
+
rel_error_arr[i]=[np.nan if math.isnan(x) else x for x in rel_error_arr[i]]
|
|
341
|
+
|
|
342
|
+
sources=[]
|
|
343
|
+
for i in range(0,len(wavelength_arr)):
|
|
344
|
+
upper=[x+e for x,e in zip(flux_arr[i],rel_error_arr[i])]
|
|
345
|
+
lower=[x-e for x,e in zip(flux_arr[i],rel_error_arr[i])]
|
|
346
|
+
|
|
347
|
+
source=ColumnDataSource(data=dict(wavelength=wavelength_arr[i],flux=flux_arr[i],upper=upper,lower=lower))
|
|
348
|
+
sources.append(source)
|
|
349
|
+
|
|
350
|
+
surveys=['Gaia','GALEX','PanSTARRS','SkyMapper','SDSS','WISE','2MASS']
|
|
351
|
+
|
|
352
|
+
for i in range(0,len(wavelength_arr)):
|
|
353
|
+
if len(flux_arr[i])>0:
|
|
354
|
+
plot.circle(x='wavelength',y='flux',source=sources[i],color=colour_arr[i],legend_label=f'{surveys[i]}')
|
|
355
|
+
errors=Whisker(source=sources[i],base='wavelength',upper='upper',lower='lower',line_width=0.5,line_color=colour_arr[i])
|
|
356
|
+
errors.upper_head.line_width,errors.lower_head.line_width=0.5,0.5
|
|
357
|
+
errors.upper_head.size,errors.lower_head.size=3,3
|
|
358
|
+
errors.upper_head.line_color,errors.lower_head.line_color=colour_arr[i],colour_arr[i]
|
|
359
|
+
|
|
360
|
+
return plot
|
|
361
|
+
|
|
362
|
+
if __name__=='__main__':
|
|
363
|
+
img=get_plot(source=6050296829033196032)
|
|
364
|
+
show(img)
|
|
File without changes
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import math
|
|
2
|
+
|
|
3
|
+
def PMCorrection(input,target,inputObjRA,inputObjDEC,pmRA,pmDEC,radius=None):
|
|
4
|
+
#Filter inputs
|
|
5
|
+
if not isinstance(input[0],int):
|
|
6
|
+
raise Exception('input year must be an integer')
|
|
7
|
+
if not isinstance(input[1],int):
|
|
8
|
+
raise Exception('input month must be an integer')
|
|
9
|
+
if not isinstance(target[0],int):
|
|
10
|
+
raise Exception('target year must be an integer')
|
|
11
|
+
if not isinstance(target[1],int):
|
|
12
|
+
raise Exception('target month must be an integer')
|
|
13
|
+
|
|
14
|
+
if not isinstance(inputObjRA,float):
|
|
15
|
+
try:
|
|
16
|
+
inputObjRA=float(inputObjRA)
|
|
17
|
+
except:
|
|
18
|
+
raise Exception('object RA must be a float or an integer')
|
|
19
|
+
if not isinstance(inputObjDEC,float):
|
|
20
|
+
try:
|
|
21
|
+
inputObjDEC=float(inputObjDEC)
|
|
22
|
+
except:
|
|
23
|
+
raise Exception('object DEC must be a float or an integer')
|
|
24
|
+
if not isinstance(pmRA,float):
|
|
25
|
+
try:
|
|
26
|
+
pmRA=float(pmRA)
|
|
27
|
+
except:
|
|
28
|
+
raise Exception('object PM_RA must be a float or an integer')
|
|
29
|
+
if not isinstance(pmDEC,float):
|
|
30
|
+
try:
|
|
31
|
+
pmDEC=float(pmDEC)
|
|
32
|
+
except:
|
|
33
|
+
raise Exception('object PM_DEC must be a float or an integer')
|
|
34
|
+
|
|
35
|
+
inputYear,inputMonth=input[0],input[1]
|
|
36
|
+
targetYear,targetMonth=target[0],target[1]
|
|
37
|
+
|
|
38
|
+
yearDelta=targetYear-inputYear
|
|
39
|
+
monthDelta=targetMonth-inputMonth
|
|
40
|
+
|
|
41
|
+
inputObjRA+=(yearDelta*pmRA/3600000+monthDelta*pmRA/43200000)*1/math.cos(inputObjDEC/360*2*math.pi)
|
|
42
|
+
inputObjDEC+=yearDelta*pmDEC/3600000+monthDelta*pmDEC/43200000
|
|
43
|
+
|
|
44
|
+
timeDelta=abs(yearDelta+monthDelta/12)
|
|
45
|
+
|
|
46
|
+
if radius!=None:
|
|
47
|
+
radius=radius+math.sqrt((pmRA/1000)**2+(pmDEC/1000)**2)*timeDelta
|
|
48
|
+
return inputObjRA,inputObjDEC,radius
|
|
49
|
+
else:
|
|
50
|
+
return inputObjRA,inputObjDEC
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
from astropy.table import Table
|
|
2
|
+
|
|
3
|
+
def get_source_list(file_name):
|
|
4
|
+
if not file_name.endswith('.fits'):
|
|
5
|
+
file_name+='.fits'
|
|
6
|
+
|
|
7
|
+
try:
|
|
8
|
+
data=Table.read(file_name).to_pandas()
|
|
9
|
+
except:
|
|
10
|
+
raise Exception(f'File: {file_name} not found, or invalid format.')
|
|
11
|
+
|
|
12
|
+
try:
|
|
13
|
+
sources=data.loc[:,'source_id'].tolist()
|
|
14
|
+
except:
|
|
15
|
+
raise Exception('No source_id column found.')
|
|
16
|
+
|
|
17
|
+
return sources
|
|
18
|
+
|
|
19
|
+
def get_pos_list(file_name):
|
|
20
|
+
if not file_name.endswith('.fits'):
|
|
21
|
+
file_name+='.fits'
|
|
22
|
+
|
|
23
|
+
try:
|
|
24
|
+
data=Table.read(file_name).to_pandas()
|
|
25
|
+
except:
|
|
26
|
+
raise Exception(f'File: {file_name} not found, or invalid format.')
|
|
27
|
+
|
|
28
|
+
try:
|
|
29
|
+
ra=data.loc[:,'ra'].tolist()
|
|
30
|
+
dec=data.loc[:,'dec'].tolist()
|
|
31
|
+
except:
|
|
32
|
+
raise Exception('ra/dec columns not found.')
|
|
33
|
+
|
|
34
|
+
pos_list=[list(x) for x in zip(ra,dec)]
|
|
35
|
+
return pos_list
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
from WDPlanetsToolkit.Tools import *
|
|
2
|
+
|
|
3
|
+
import time
|
|
4
|
+
from bokeh.plotting import show
|
|
5
|
+
|
|
6
|
+
start_time=time.time()
|
|
7
|
+
|
|
8
|
+
figs=[]
|
|
9
|
+
|
|
10
|
+
'''
|
|
11
|
+
AR Sco (6050296829033196032,245.4470133276900,-22.8862182469700) is used for all imaging functions as it returns images in all surveys, HU Leo (587316166180416640,141.1853304445800,08.0308343220600)
|
|
12
|
+
is used for everything else.
|
|
13
|
+
'''
|
|
14
|
+
|
|
15
|
+
print('testing imaging functions (source):\n')
|
|
16
|
+
fig1=getpanstarrsimage(source=6050296829033196032)
|
|
17
|
+
fig2=getskymapperimage(source=6050296829033196032)
|
|
18
|
+
fig3=getdssimage(source=6050296829033196032)
|
|
19
|
+
print('success \n\n\n')
|
|
20
|
+
|
|
21
|
+
figs.append(fig1)
|
|
22
|
+
figs.append(fig2)
|
|
23
|
+
figs.append(fig3)
|
|
24
|
+
|
|
25
|
+
print('testing imaging functions (pos):\n')
|
|
26
|
+
fig4=getpanstarrsimage(pos=[245.4470133276900,-22.8862182469700])
|
|
27
|
+
fig5=getskymapperimage(pos=[245.4470133276900,-22.8862182469700])
|
|
28
|
+
fig6=getdssimage(pos=[245.4470133276900,-22.8862182469700])
|
|
29
|
+
print('success \n\n\n')
|
|
30
|
+
|
|
31
|
+
figs.append(fig4)
|
|
32
|
+
figs.append(fig5)
|
|
33
|
+
figs.append(fig6)
|
|
34
|
+
|
|
35
|
+
print('panstarrsquery (source):\n',panstarrsquery(source=587316166180416640),'\n\n\n')
|
|
36
|
+
print('skymapperquery (source):\n',skymapperquery(source=587316166180416640),'\n\n\n')
|
|
37
|
+
print('gaiaquery: (source):\n',gaiaquery(source=587316166180416640),'\n\n\n')
|
|
38
|
+
print('galexquery (source):\n',galexquery(source=587316166180416640),'\n\n\n')
|
|
39
|
+
print('rosatquery (source):\n',rosatquery(source=587316166180416640),'\n\n\n')
|
|
40
|
+
print('ztfquery (source):\n',ztfquery(source=587316166180416640),'\n\n\n')
|
|
41
|
+
print('sdssquery (source):\n',sdssquery(source=587316166180416640),'\n\n\n')
|
|
42
|
+
print('wisequery (source):\n',wisequery(source=587316166180416640),'\n\n\n')
|
|
43
|
+
print('twomassquery (source):\n',twomassquery(source=587316166180416640),'\n\n\n')
|
|
44
|
+
|
|
45
|
+
print('panstarrsquery (pos):\n',panstarrsquery(pos=[141.1853304445800,08.0308343220600]),'\n\n\n')
|
|
46
|
+
print('skymapperquery (pos):\n',skymapperquery(pos=[141.1853304445800,08.0308343220600]),'\n\n\n')
|
|
47
|
+
print('gaiaquery (pos):\n',gaiaquery(pos=[141.1853304445800,08.0308343220600]),'\n\n\n')
|
|
48
|
+
print('galexquery (pos):\n',galexquery(pos=[141.1853304445800,08.0308343220600]),'\n\n\n')
|
|
49
|
+
print('rosatquery (pos):\n',rosatquery(pos=[141.1853304445800,08.0308343220600]),'\n\n\n')
|
|
50
|
+
print('ztfquery (pos):\n',ztfquery(pos=[141.1853304445800,08.0308343220600]),'\n\n\n')
|
|
51
|
+
print('sdssquery (pos):\n',sdssquery(pos=[141.1853304445800,08.0308343220600]),'\n\n\n')
|
|
52
|
+
print('wisequery (pos):\n',wisequery(pos=[141.1853304445800,08.0308343220600]),'\n\n\n')
|
|
53
|
+
print('twomassquery (pos):\n',twomassquery(pos=[141.1853304445800,08.0308343220600]),'\n\n\n')
|
|
54
|
+
|
|
55
|
+
print('getpanstarrsphot (source):\n',getpanstarrsphot(source=587316166180416640),'\n\n\n')
|
|
56
|
+
print('getskymapperphot (source):\n',getskymapperphot(source=587316166180416640),'\n\n\n')
|
|
57
|
+
print('getgaiaphot (source):\n',getgaiaphot(source=587316166180416640),'\n\n\n')
|
|
58
|
+
print('getgalexphot (source):\n',getgalexphot(source=587316166180416640),'\n\n\n')
|
|
59
|
+
print('getsdssphot (source):\n',getsdssphot(source=587316166180416640),'\n\n\n')
|
|
60
|
+
print('getwisephot (source):\n',getwisephot(source=587316166180416640),'\n\n\n')
|
|
61
|
+
print('gettwomassphot (source):\n',gettwomassphot(source=587316166180416640),'\n\n\n')
|
|
62
|
+
|
|
63
|
+
print('getpanstarrsphot (pos):\n',getpanstarrsphot(pos=[141.1853304445800,08.0308343220600]),'\n\n\n')
|
|
64
|
+
print('getskymapperphot (pos):\n',getskymapperphot(pos=[141.1853304445800,08.0308343220600]),'\n\n\n')
|
|
65
|
+
print('getgaiaphot (pos):\n',getgaiaphot(pos=[141.1853304445800,08.0308343220600]),'\n\n\n')
|
|
66
|
+
print('getgalexphot (pos):\n',getgalexphot(pos=[141.1853304445800,08.0308343220600]),'\n\n\n')
|
|
67
|
+
print('getsdssphot (pos):\n',getsdssphot(pos=[141.1853304445800,08.0308343220600]),'\n\n\n')
|
|
68
|
+
print('getwisephot (pos):\n',getwisephot(pos=[141.1853304445800,08.0308343220600]),'\n\n\n')
|
|
69
|
+
print('gettwomassphot (pos):\n',gettwomassphot(pos=[141.1853304445800,08.0308343220600]),'\n\n\n')
|
|
70
|
+
|
|
71
|
+
print('getbulkphot (source):\n',getbulkphot(source=587316166180416640),'\n\n\n')
|
|
72
|
+
|
|
73
|
+
print('getbulkphot (pos):\n',getbulkphot(pos=[141.1853304445800,08.0308343220600]),'\n\n\n')
|
|
74
|
+
|
|
75
|
+
print('testing ztf lightcurve functions (source):\n')
|
|
76
|
+
fig7=getztflc(source=587316166180416640)
|
|
77
|
+
print('success \n\n\n')
|
|
78
|
+
|
|
79
|
+
figs.append(fig7)
|
|
80
|
+
|
|
81
|
+
print('testing lightcurve functions (pos):\n')
|
|
82
|
+
fig8=getztflc(pos=[141.1853304445800,08.0308343220600])
|
|
83
|
+
print('success \n\n\n')
|
|
84
|
+
|
|
85
|
+
figs.append(fig8)
|
|
86
|
+
|
|
87
|
+
print('testing SED functions (source):\n')
|
|
88
|
+
fig9=getsed(source=587316166180416640)
|
|
89
|
+
print('success \n\n\n')
|
|
90
|
+
|
|
91
|
+
figs.append(fig9)
|
|
92
|
+
|
|
93
|
+
print('testing SED functions (pos):\n')
|
|
94
|
+
fig10=getsed(pos=[141.1853304445800,08.0308343220600])
|
|
95
|
+
print('success \n\n\n')
|
|
96
|
+
|
|
97
|
+
figs.append(fig10)
|
|
98
|
+
|
|
99
|
+
print('getgaiacoords (source):\n',getgaiacoords(source=587316166180416640),'\n\n\n')
|
|
100
|
+
print('getgaiasource (pos):\n',getgaiasource(pos=[141.1853304445800,08.0308343220600]),'\n\n\n')
|
|
101
|
+
|
|
102
|
+
print('testing spectrum functions (source):\n')
|
|
103
|
+
fig11=getsdssspectrum(source=587316166180416640)
|
|
104
|
+
print('success \n\n\n')
|
|
105
|
+
|
|
106
|
+
figs.append(fig11)
|
|
107
|
+
|
|
108
|
+
print('testing spectrum functions (pos):\n')
|
|
109
|
+
fig12=getsdssspectrum(pos=[141.1853304445800,08.0308343220600])
|
|
110
|
+
print('success \n\n\n')
|
|
111
|
+
|
|
112
|
+
figs.append(fig12)
|
|
113
|
+
|
|
114
|
+
print('testing HR diagram function (source):\n')
|
|
115
|
+
fig13=gethrd(source=587316166180416640)
|
|
116
|
+
print('success \n\n\n')
|
|
117
|
+
|
|
118
|
+
figs.append(fig13)
|
|
119
|
+
|
|
120
|
+
print('testing datapage function (source):\n')
|
|
121
|
+
fig14=getdatapage(source=587316166180416640)
|
|
122
|
+
print('success \n\n\n')
|
|
123
|
+
|
|
124
|
+
figs.append(fig14)
|
|
125
|
+
|
|
126
|
+
print('testing datapage function (pos):\n')
|
|
127
|
+
fig15=getdatapage(pos=[141.1853304445800,08.0308343220600])
|
|
128
|
+
print('success \n\n\n')
|
|
129
|
+
|
|
130
|
+
figs.append(fig15)
|
|
131
|
+
|
|
132
|
+
delta_time=round((time.time()-start_time),2)
|
|
133
|
+
|
|
134
|
+
newline='\n'
|
|
135
|
+
print(f'{newline}all tests passed in: {delta_time}s')
|
|
136
|
+
|
|
137
|
+
for figure in figs:
|
|
138
|
+
show(figure)
|
|
File without changes
|