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,148 @@
|
|
|
1
|
+
import pandas as pd
|
|
2
|
+
import math
|
|
3
|
+
from astropy.time import Time
|
|
4
|
+
|
|
5
|
+
from ..Surveys.Gaia import GaiaQueryCoords
|
|
6
|
+
from ..Surveys.GALEX import GALEXQueryCoords
|
|
7
|
+
from ..Miscellaneous.ProperMotionCorrection import PMCorrection
|
|
8
|
+
|
|
9
|
+
#Creates Galex overlay
|
|
10
|
+
def getGalexOverlayNUV(plot,ra,dec,sizeAS,mjd,border,pmra,pmdec):
|
|
11
|
+
#checks if GALEX search was successful
|
|
12
|
+
gaiaTime=[2016,0]
|
|
13
|
+
imageTime=Time(mjd,format='mjd').to_datetime()
|
|
14
|
+
imageTime=[imageTime.year,imageTime.month]
|
|
15
|
+
galexTime=[2007,0]
|
|
16
|
+
|
|
17
|
+
if pmra!=None and pmdec!=None:
|
|
18
|
+
sizeAS=PMCorrection(gaiaTime,imageTime,ra,dec,pmra,pmdec,radius=sizeAS)[2]
|
|
19
|
+
|
|
20
|
+
nearby=GALEXQueryCoords(ra,dec,sizeAS)
|
|
21
|
+
|
|
22
|
+
detections_made=False
|
|
23
|
+
if isinstance(nearby,pd.DataFrame):
|
|
24
|
+
nearby_gaia=GaiaQueryCoords(ra,dec,sizeAS)
|
|
25
|
+
|
|
26
|
+
#Plotting of Galex detections + brightness/radius scaling
|
|
27
|
+
nearbyRA=nearby.loc[:,'RAJ2000'].tolist()
|
|
28
|
+
nearbyDEC=nearby.loc[:,'DEJ2000'].tolist()
|
|
29
|
+
nearbyMagUV=nearby.loc[:,'NUVmag'].tolist()
|
|
30
|
+
|
|
31
|
+
#checks if any NUV magnitudes exist
|
|
32
|
+
magCheck=False
|
|
33
|
+
for i in range(0,len(nearbyMagUV)):
|
|
34
|
+
if not math.isnan(nearbyMagUV[i]):
|
|
35
|
+
magCheck=True
|
|
36
|
+
|
|
37
|
+
if magCheck==False:
|
|
38
|
+
return plot, detections_made
|
|
39
|
+
|
|
40
|
+
#fetches gaia data
|
|
41
|
+
if isinstance(nearby_gaia,pd.DataFrame):
|
|
42
|
+
nearbyRA_gaia=nearby_gaia.loc[:,'ra'].tolist()
|
|
43
|
+
nearbyDEC_gaia=nearby_gaia.loc[:,'dec'].tolist()
|
|
44
|
+
nearbyPMRA=nearby_gaia.loc[:,'pmra'].tolist()
|
|
45
|
+
nearbyPMDEC=nearby_gaia.loc[:,'pmdec'].tolist()
|
|
46
|
+
|
|
47
|
+
#transforms gaia detections back to GALEX time
|
|
48
|
+
for i in range(0,len(nearbyRA_gaia)):
|
|
49
|
+
if not math.isnan(nearbyPMRA[i]) and not math.isnan(nearbyPMDEC[i]):
|
|
50
|
+
RA_corrected,DEC_corrected=PMCorrection(gaiaTime,galexTime,nearbyRA_gaia[i],nearbyDEC_gaia[i],nearbyPMRA[i],nearbyPMDEC[i])
|
|
51
|
+
nearbyRA_gaia[i]=RA_corrected
|
|
52
|
+
nearbyDEC_gaia[i]=DEC_corrected
|
|
53
|
+
|
|
54
|
+
#checks if there are any GALEX objects within a radius, if there are, applies gaia pm corrections to matching GALEX detection
|
|
55
|
+
correctedIndices=[]
|
|
56
|
+
for i in range(0,len(nearbyRA)):
|
|
57
|
+
for j in range(0,len(nearbyRA_gaia)):
|
|
58
|
+
delta=math.sqrt((nearbyRA[i]-nearbyRA_gaia[j])**2+(nearbyDEC[i]-nearbyDEC_gaia[j])**2)*3600
|
|
59
|
+
if delta<5:
|
|
60
|
+
if not math.isnan(nearbyPMRA[j]) and not math.isnan(nearbyPMDEC[j]):
|
|
61
|
+
RA_corrected,DEC_corrected=PMCorrection(galexTime,imageTime,nearbyRA[i],nearbyDEC[i],nearbyPMRA[j],nearbyPMDEC[j])
|
|
62
|
+
nearbyRA[i]=RA_corrected
|
|
63
|
+
nearbyDEC[i]=DEC_corrected
|
|
64
|
+
correctedIndices.append(i)
|
|
65
|
+
|
|
66
|
+
#draw detections
|
|
67
|
+
for i in range(0,len(nearby)):
|
|
68
|
+
radiusMultiplier=(nearbyMagUV[i]/20.7)
|
|
69
|
+
radius=(border/50+(border/75)**radiusMultiplier)*0.75
|
|
70
|
+
|
|
71
|
+
if i in correctedIndices and not math.isnan(nearbyMagUV[i]):
|
|
72
|
+
plot.circle(x=nearbyRA[i],y=nearbyDEC[i],radius=radius,line_color='blue',fill_color=None,legend_label='GALEX NUV detections (corrected)')
|
|
73
|
+
detections_made=True
|
|
74
|
+
elif i not in correctedIndices and not math.isnan(nearbyMagUV[i]):
|
|
75
|
+
plot.circle(x=nearbyRA[i],y=nearbyDEC[i],radius=radius,line_color='purple',fill_color=None,line_dash='dotted',legend_label='GALEX NUV detections (uncorrected)')
|
|
76
|
+
detections_made=True
|
|
77
|
+
|
|
78
|
+
return plot, detections_made
|
|
79
|
+
|
|
80
|
+
#Creates Galex overlay
|
|
81
|
+
def getGalexOverlayFUV(plot,ra,dec,sizeAS,mjd,border,pmra,pmdec):
|
|
82
|
+
gaiaTime=[2016,0]
|
|
83
|
+
imageTime=Time(mjd,format='mjd').to_datetime()
|
|
84
|
+
imageTime=[imageTime.year,imageTime.month]
|
|
85
|
+
galexTime=[2007,0]
|
|
86
|
+
|
|
87
|
+
if pmra!=None and pmdec!=None:
|
|
88
|
+
sizeAS=PMCorrection(gaiaTime,imageTime,ra,dec,pmra,pmdec,radius=sizeAS)[2]
|
|
89
|
+
|
|
90
|
+
nearby=GALEXQueryCoords(ra,dec,sizeAS)
|
|
91
|
+
|
|
92
|
+
detections_made=False
|
|
93
|
+
if isinstance(nearby,pd.DataFrame):
|
|
94
|
+
nearby_gaia=GaiaQueryCoords(ra,dec,sizeAS)
|
|
95
|
+
|
|
96
|
+
#Plotting of Galex detections + brightness/radius scaling
|
|
97
|
+
nearbyRA=nearby.loc[:,'RAJ2000'].tolist()
|
|
98
|
+
nearbyDEC=nearby.loc[:,'DEJ2000'].tolist()
|
|
99
|
+
nearbyMagUV=nearby.loc[:,'FUVmag'].tolist()
|
|
100
|
+
|
|
101
|
+
#checks if any FUV magnitudes exist
|
|
102
|
+
magCheck=False
|
|
103
|
+
for i in range(0,len(nearbyMagUV)):
|
|
104
|
+
if not math.isnan(nearbyMagUV[i]):
|
|
105
|
+
magCheck=True
|
|
106
|
+
|
|
107
|
+
if magCheck==False:
|
|
108
|
+
return plot, detections_made
|
|
109
|
+
|
|
110
|
+
#fetches gaia data
|
|
111
|
+
if isinstance(nearby_gaia,pd.DataFrame):
|
|
112
|
+
nearbyRA_gaia=nearby_gaia.loc[:,'ra'].tolist()
|
|
113
|
+
nearbyDEC_gaia=nearby_gaia.loc[:,'dec'].tolist()
|
|
114
|
+
nearbyPMRA=nearby_gaia.loc[:,'pmra'].tolist()
|
|
115
|
+
nearbyPMDEC=nearby_gaia.loc[:,'pmdec'].tolist()
|
|
116
|
+
|
|
117
|
+
#transforms gaia detections back to GALEX time
|
|
118
|
+
for i in range(0,len(nearbyRA_gaia)):
|
|
119
|
+
if not math.isnan(nearbyPMRA[i]) and not math.isnan(nearbyPMDEC[i]):
|
|
120
|
+
RA_corrected,DEC_corrected=PMCorrection(gaiaTime,galexTime,nearbyRA_gaia[i],nearbyDEC_gaia[i],nearbyPMRA[i],nearbyPMDEC[i])
|
|
121
|
+
nearbyRA_gaia[i]=RA_corrected
|
|
122
|
+
nearbyDEC_gaia[i]=DEC_corrected
|
|
123
|
+
|
|
124
|
+
#checks if there are any GALEX objects within a radius, if there are, applies gaia pm corrections to matching GALEX detection
|
|
125
|
+
correctedIndices=[]
|
|
126
|
+
for i in range(0,len(nearbyRA)):
|
|
127
|
+
for j in range(0,len(nearbyRA_gaia)):
|
|
128
|
+
delta=math.sqrt((nearbyRA[i]-nearbyRA_gaia[j])**2+(nearbyDEC[i]-nearbyDEC_gaia[j])**2)*3600
|
|
129
|
+
if delta<5:
|
|
130
|
+
if not math.isnan(nearbyPMRA[j]) and not math.isnan(nearbyPMDEC[j]):
|
|
131
|
+
RA_corrected,DEC_corrected=PMCorrection(galexTime,imageTime,nearbyRA[i],nearbyDEC[i],nearbyPMRA[j],nearbyPMDEC[j])
|
|
132
|
+
nearbyRA[i]=RA_corrected
|
|
133
|
+
nearbyDEC[i]=DEC_corrected
|
|
134
|
+
correctedIndices.append(i)
|
|
135
|
+
|
|
136
|
+
#draw detections
|
|
137
|
+
for i in range(0,len(nearby)):
|
|
138
|
+
radiusMultiplier=(nearbyMagUV[i]/20.7)
|
|
139
|
+
radius=(border/50+(border/75)**radiusMultiplier/2)*0.75
|
|
140
|
+
|
|
141
|
+
if i in correctedIndices and not math.isnan(nearbyMagUV[i]):
|
|
142
|
+
plot.circle(x=nearbyRA[i],y=nearbyDEC[i],radius=radius,line_color='blue',fill_color=None,legend_label='GALEX FUV detections (corrected)')
|
|
143
|
+
detections_made=True
|
|
144
|
+
elif i not in correctedIndices and not math.isnan(nearbyMagUV[i]):
|
|
145
|
+
plot.circle(x=nearbyRA[i],y=nearbyDEC[i],radius=radius,line_color='purple',fill_color=None,line_dash='dotted',legend_label='GALEX FUV detections (uncorrected)')
|
|
146
|
+
detections_made=True
|
|
147
|
+
|
|
148
|
+
return plot, detections_made
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import pandas as pd
|
|
2
|
+
import math
|
|
3
|
+
from astropy.time import Time
|
|
4
|
+
|
|
5
|
+
from ..Surveys.Gaia import GaiaQueryCoords
|
|
6
|
+
from ..Miscellaneous.ProperMotionCorrection import PMCorrection
|
|
7
|
+
|
|
8
|
+
#Creates Gaia overlay
|
|
9
|
+
def getGaiaOverlay(plot,ra,dec,sizeAS,mjd,border,pmra=None,pmdec=None):
|
|
10
|
+
gaiaTime=[2016,0]
|
|
11
|
+
imageTime=Time(mjd,format='mjd').to_datetime()
|
|
12
|
+
imageTime=[imageTime.year,imageTime.month]
|
|
13
|
+
|
|
14
|
+
if pmra==None and pmdec==None:
|
|
15
|
+
pass
|
|
16
|
+
else:
|
|
17
|
+
sizeAS=PMCorrection(gaiaTime,imageTime,ra,dec,pmra,pmdec,radius=sizeAS)[2]
|
|
18
|
+
|
|
19
|
+
detections_made=False
|
|
20
|
+
nearby=GaiaQueryCoords(ra,dec,sizeAS,'dr3')
|
|
21
|
+
#Check if any data was returned by Gaia search
|
|
22
|
+
if isinstance(nearby,pd.DataFrame):
|
|
23
|
+
dataAvailability=True
|
|
24
|
+
nearbyRA=nearby.loc[:,'ra'].tolist()
|
|
25
|
+
nearbyDEC=nearby.loc[:,'dec'].tolist()
|
|
26
|
+
nearbyMagG=nearby.loc[:,'phot_g_mean_mag'].tolist()
|
|
27
|
+
nearbyPMRA=nearby.loc[:,'pmra'].tolist()
|
|
28
|
+
nearbyPMDEC=nearby.loc[:,'pmdec'].tolist()
|
|
29
|
+
|
|
30
|
+
#Check if any g magnitudes exist
|
|
31
|
+
magCheck=False
|
|
32
|
+
for i in range(0,len(nearbyMagG)):
|
|
33
|
+
if not math.isnan(nearbyMagG[i]):
|
|
34
|
+
magCheck=True
|
|
35
|
+
|
|
36
|
+
if magCheck==False:
|
|
37
|
+
return plot, detections_made
|
|
38
|
+
|
|
39
|
+
#correct detection coordinates and list those that were corrected
|
|
40
|
+
correctedIndices=[]
|
|
41
|
+
for i in range(0,len(nearbyRA)):
|
|
42
|
+
if not math.isnan(nearbyPMRA[i]) and not math.isnan(nearbyPMDEC[i]):
|
|
43
|
+
RA_corrected,DEC_corrected=PMCorrection(gaiaTime,imageTime,nearbyRA[i],nearbyDEC[i],nearbyPMRA[i],nearbyPMDEC[i])
|
|
44
|
+
nearbyRA[i]=RA_corrected
|
|
45
|
+
nearbyDEC[i]=DEC_corrected
|
|
46
|
+
correctedIndices.append(i)
|
|
47
|
+
|
|
48
|
+
#draw detections
|
|
49
|
+
for i in range(0,len(nearby)):
|
|
50
|
+
radiusMultiplier=(nearbyMagG[i]/20.7)
|
|
51
|
+
radius=(border/50+(border/75)**radiusMultiplier)*0.75
|
|
52
|
+
|
|
53
|
+
if i in correctedIndices and not math.isnan(nearbyMagG[i]):
|
|
54
|
+
plot.circle(x=nearbyRA[i],y=nearbyDEC[i],radius=radius,line_color='red',fill_color=None,legend_label='Gaia g detections (corrected)')
|
|
55
|
+
detections_made=True
|
|
56
|
+
elif i not in correctedIndices and not math.isnan(nearbyMagG[i]):
|
|
57
|
+
plot.circle(x=nearbyRA[i],y=nearbyDEC[i],radius=radius,line_color='red',fill_color=None,line_dash='dotted',legend_label='Gaia g detections (uncorrected)')
|
|
58
|
+
detections_made=True
|
|
59
|
+
else:
|
|
60
|
+
print('[PanSTARRS: getGaiaOverlay] Note: no Gaia detections found. This will limit accuracy of other detection overlays.')
|
|
61
|
+
return plot, detections_made
|
|
62
|
+
|
|
63
|
+
return plot, detections_made
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import pandas as pd
|
|
2
|
+
|
|
3
|
+
from ..Surveys.ROSAT import ROSATQueryCoords
|
|
4
|
+
|
|
5
|
+
#Creates ROSAT overlay
|
|
6
|
+
def getROSATOverlay(plot,ra,dec,sizeAS):
|
|
7
|
+
nearby=ROSATQueryCoords(ra,dec,sizeAS)
|
|
8
|
+
#checks if ROSAT query was successful
|
|
9
|
+
|
|
10
|
+
detections_made=False
|
|
11
|
+
if isinstance(nearby,pd.DataFrame):
|
|
12
|
+
nearbyRA=nearby.loc[:,'RAJ2000'].tolist()
|
|
13
|
+
nearbyDEC=nearby.loc[:,'DEJ2000'].tolist()
|
|
14
|
+
|
|
15
|
+
#draws detections
|
|
16
|
+
for i in range(0,len(nearby)):
|
|
17
|
+
plot.cross(x=nearbyRA[i],y=nearbyDEC[i],color='orange',size=10,legend_label='ROSAT detections (uncorrected)')
|
|
18
|
+
detections_made=True
|
|
19
|
+
|
|
20
|
+
return plot, detections_made
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
from .Overlay_Gaia import getGaiaOverlay
|
|
2
|
+
from .Overlay_GALEX import getGalexOverlayFUV
|
|
3
|
+
from .Overlay_GALEX import getGalexOverlayNUV
|
|
4
|
+
from .Overlay_ROSAT import getROSATOverlay
|
|
5
|
+
from .Overlay_ZTF import getZTFOverlay
|
|
6
|
+
|
|
7
|
+
def overlaySelection(plot,ra,dec,overlay,mjd,sizeAS,border,pmra=None,pmdec=None):
|
|
8
|
+
plot.cross(x=ra,y=dec,color='lime',size=10)
|
|
9
|
+
|
|
10
|
+
overlay=['gaia']+overlay
|
|
11
|
+
|
|
12
|
+
for i in range(0,len(overlay)):
|
|
13
|
+
overlay[i]=overlay[i].lower()
|
|
14
|
+
for i in range(0,len(overlay)):
|
|
15
|
+
if overlay[i] not in ['gaia','galex_nuv','rosat','ztf','galex_fuv']:
|
|
16
|
+
raise Exception('invalid overlay')
|
|
17
|
+
|
|
18
|
+
adaptive_correction=True
|
|
19
|
+
if pmra==None and pmdec==None:
|
|
20
|
+
adapative_correction=False
|
|
21
|
+
|
|
22
|
+
if 'gaia' in overlay:
|
|
23
|
+
if adaptive_correction==True:
|
|
24
|
+
plot,detections_made=getGaiaOverlay(plot=plot,ra=ra,dec=dec,sizeAS=sizeAS,mjd=mjd,border=border,pmra=pmra,pmdec=pmdec)
|
|
25
|
+
else:
|
|
26
|
+
plot,detections_made=getGaiaOverlay(plot=plot,ra=ra,dec=dec,sizeAS=sizeAS,mjd=mjd,border=border)
|
|
27
|
+
if 'galex_fuv' in overlay:
|
|
28
|
+
if adaptive_correction==True:
|
|
29
|
+
plot,detections_made=getGalexOverlayFUV(plot=plot,ra=ra,dec=dec,sizeAS=sizeAS,mjd=mjd,border=border,pmra=pmra,pmdec=pmdec)
|
|
30
|
+
else:
|
|
31
|
+
plot,detections_made=getGalexOverlayFUV(plot=plot,ra=ra,dec=dec,sizeAS=sizeAS,mjd=mjd,border=border)
|
|
32
|
+
if 'galex_nuv' in overlay:
|
|
33
|
+
if adaptive_correction==True:
|
|
34
|
+
plot,detections_made=getGalexOverlayNUV(plot=plot,ra=ra,dec=dec,sizeAS=sizeAS,mjd=mjd,border=border,pmra=pmra,pmdec=pmdec)
|
|
35
|
+
else:
|
|
36
|
+
plot,detections_made=getGalexOverlayNUV(plot=plot,ra=ra,dec=dec,sizeAS=sizeAS,mjd=mjd,border=border)
|
|
37
|
+
if 'rosat' in overlay:
|
|
38
|
+
plot,detections_made=getROSATOverlay(plot,ra,dec,sizeAS)
|
|
39
|
+
if 'ztf' in overlay:
|
|
40
|
+
plot,detections_made=getZTFOverlay(plot,ra,dec,sizeAS)
|
|
41
|
+
|
|
42
|
+
return plot, detections_made
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
from ..Surveys.ZTF import getData
|
|
2
|
+
import pandas as pd
|
|
3
|
+
|
|
4
|
+
#Creates ZTF overlay
|
|
5
|
+
def getZTFOverlay(plot,ra,dec,sizeAS):
|
|
6
|
+
detections_made=False
|
|
7
|
+
data=getData(ra,dec,sizeAS/2,'gri')
|
|
8
|
+
#Checks if data was returned and if so, splits into bands
|
|
9
|
+
if data!=None:
|
|
10
|
+
gData,rData,iData=data[0],data[1],data[2]
|
|
11
|
+
else:
|
|
12
|
+
return plot, detections_made
|
|
13
|
+
|
|
14
|
+
#checks which bands have data
|
|
15
|
+
do_g,do_r,do_i=False,False,False
|
|
16
|
+
if isinstance(gData,pd.DataFrame):
|
|
17
|
+
do_g=True
|
|
18
|
+
elif isinstance(rData,pd.DataFrame):
|
|
19
|
+
do_r=True
|
|
20
|
+
elif isinstance(iData,pd.DataFrame):
|
|
21
|
+
do_i=True
|
|
22
|
+
|
|
23
|
+
#draws detections
|
|
24
|
+
if do_g==True:
|
|
25
|
+
nearbyRA=gData.loc[:,'ra'].tolist()
|
|
26
|
+
nearbyDEC=gData.loc[:,'dec'].tolist()
|
|
27
|
+
|
|
28
|
+
for i in range(0,len(gData)):
|
|
29
|
+
plot.cross(x=nearbyRA[i],y=nearbyDEC[i],color='aqua',legend_label='ZTF detections (g) (uncorrected)')
|
|
30
|
+
detections_made=True
|
|
31
|
+
elif do_r==True:
|
|
32
|
+
nearbyRA=rData.loc[:,'ra'].tolist()
|
|
33
|
+
nearbyDEC=rData.loc[:,'dec'].tolist()
|
|
34
|
+
|
|
35
|
+
for i in range(0,len(gData)):
|
|
36
|
+
plot.cross(x=nearbyRA[i],y=nearbyDEC[i],color='aqua',legend_label='ZTF detections (r) (uncorrected)')
|
|
37
|
+
detections_made=True
|
|
38
|
+
elif do_i==True:
|
|
39
|
+
nearbyRA=iData.loc[:,'ra'].tolist()
|
|
40
|
+
nearbyDEC=iData.loc[:,'dec'].tolist()
|
|
41
|
+
|
|
42
|
+
for i in range(0,len(gData)):
|
|
43
|
+
plot.cross(x=nearbyRA[i],y=nearbyDEC[i],color='aqua',legend_label='ZTF detections (i) (uncorrected)')
|
|
44
|
+
detections_made=True
|
|
45
|
+
|
|
46
|
+
return plot, detections_made
|
|
File without changes
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
from astropy.io import fits
|
|
2
|
+
from astropy.visualization import PercentileInterval, AsinhStretch
|
|
3
|
+
from io import BytesIO
|
|
4
|
+
import requests
|
|
5
|
+
import numpy as np
|
|
6
|
+
from astropy.wcs import WCS
|
|
7
|
+
import warnings
|
|
8
|
+
from astropy.utils.exceptions import AstropyWarning
|
|
9
|
+
from astropy.time import Time
|
|
10
|
+
import astropy
|
|
11
|
+
from bokeh.plotting import figure
|
|
12
|
+
from bokeh.models import Range1d
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
#Ignore warning about deprecated header
|
|
16
|
+
warnings.simplefilter('ignore',category=AstropyWarning)
|
|
17
|
+
|
|
18
|
+
# DSS Query
|
|
19
|
+
def get_image(ra,dec,size=30):
|
|
20
|
+
service='http://archive.stsci.edu/cgi-bin/dss_search'
|
|
21
|
+
url=f'{service}?ra={ra}&d={dec}&v=3&e=J2000&f=fits&h={size}&w={size}'
|
|
22
|
+
|
|
23
|
+
try:
|
|
24
|
+
r=requests.get(url,timeout=15)
|
|
25
|
+
if r.status_code!=200:
|
|
26
|
+
print('[DSS: get_image_data] Error: experiencing issues with DSS.')
|
|
27
|
+
return None, None
|
|
28
|
+
except:
|
|
29
|
+
print('[DSS: get_image_data] Error: experiencing issues with DSS.')
|
|
30
|
+
return None, None
|
|
31
|
+
|
|
32
|
+
try:
|
|
33
|
+
fh=fits.open(BytesIO(r.content))
|
|
34
|
+
fitsImage=fh[0].data
|
|
35
|
+
image_header=fh[0].header
|
|
36
|
+
fitsImage[np.isnan(fitsImage)]=0.0
|
|
37
|
+
transform=AsinhStretch()+PercentileInterval(95)
|
|
38
|
+
image=transform(fitsImage)
|
|
39
|
+
|
|
40
|
+
if not isinstance(image,np.ndarray):
|
|
41
|
+
return None, None
|
|
42
|
+
|
|
43
|
+
return image,image_header
|
|
44
|
+
except:
|
|
45
|
+
print('[DSS: get_image_data] Error: no DSS images found using given fields')
|
|
46
|
+
return None, None
|
|
47
|
+
|
|
48
|
+
# Filters inputs and performs any necessary arithmetic
|
|
49
|
+
def input_management(ra,dec,size=30):
|
|
50
|
+
if not isinstance(ra,float):
|
|
51
|
+
try:
|
|
52
|
+
ra=float(ra)
|
|
53
|
+
except:
|
|
54
|
+
raise Exception('object RA must be a float or an integer')
|
|
55
|
+
if not isinstance(dec,float):
|
|
56
|
+
try:
|
|
57
|
+
dec=float(dec)
|
|
58
|
+
except:
|
|
59
|
+
raise Exception('object DEC must be a float or an integer')
|
|
60
|
+
|
|
61
|
+
if not isinstance(size,int):
|
|
62
|
+
try:
|
|
63
|
+
size=int(size)
|
|
64
|
+
except:
|
|
65
|
+
raise Exception('size must take an integer value')
|
|
66
|
+
|
|
67
|
+
sizeAS=size
|
|
68
|
+
size=size/60
|
|
69
|
+
|
|
70
|
+
if size>60:
|
|
71
|
+
raise Exception('maximum size allowed by DSS is 60 arcminutes.')
|
|
72
|
+
|
|
73
|
+
return ra, dec, size, sizeAS
|
|
74
|
+
|
|
75
|
+
# Returns only the wcs projection for a retrieved image
|
|
76
|
+
def get_info(ra,dec,size=30):
|
|
77
|
+
ra,dec,size,sizeAS=input_management(ra=ra,dec=dec,size=size)
|
|
78
|
+
|
|
79
|
+
image_data=get_image(ra=ra,dec=dec,size=size)[1]
|
|
80
|
+
|
|
81
|
+
if not isinstance(image_data,astropy.io.fits.header.Header):
|
|
82
|
+
return None, None
|
|
83
|
+
|
|
84
|
+
wcs=WCS(image_data)
|
|
85
|
+
|
|
86
|
+
time=image_data['DATE-OBS']
|
|
87
|
+
mins=int(time[14:16])
|
|
88
|
+
hours=int(time[11:13])
|
|
89
|
+
if mins>=60:
|
|
90
|
+
mins=mins-60
|
|
91
|
+
hours+=1
|
|
92
|
+
|
|
93
|
+
mins=str(mins).zfill(2)
|
|
94
|
+
hours=str(hours).zfill(2)
|
|
95
|
+
|
|
96
|
+
time=time[0:10]+'T'+str(hours)+':'+str(mins)+':'+time[17:20]
|
|
97
|
+
|
|
98
|
+
imageTime=Time(time,format='fits')
|
|
99
|
+
|
|
100
|
+
mjd=imageTime.mjd
|
|
101
|
+
|
|
102
|
+
return wcs, mjd
|
|
103
|
+
|
|
104
|
+
# Sets up axis and casts image onto them
|
|
105
|
+
def get_plot(ra,dec,size=30):
|
|
106
|
+
ra,dec,size,sizeAS=input_management(ra=ra,dec=dec,size=size)
|
|
107
|
+
|
|
108
|
+
# Create axes and plot image
|
|
109
|
+
plot=figure(width=400,height=400,title=f'DSS Image ({sizeAS}")')
|
|
110
|
+
# Fixes scaling issue
|
|
111
|
+
plot.min_border=75
|
|
112
|
+
|
|
113
|
+
plot.xgrid.grid_line_color=None
|
|
114
|
+
plot.ygrid.grid_line_color=None
|
|
115
|
+
|
|
116
|
+
image,image_data=get_image(ra=ra,dec=dec,size=size)
|
|
117
|
+
|
|
118
|
+
if not isinstance(image,np.ndarray) or not isinstance(image_data,astropy.io.fits.header.Header):
|
|
119
|
+
return None
|
|
120
|
+
|
|
121
|
+
# Get x and y limit (in pixels) from image header
|
|
122
|
+
xlim=image_data['NAXIS1']
|
|
123
|
+
ylim=image_data['NAXIS2']
|
|
124
|
+
|
|
125
|
+
# DSS images have one less pixel in one axis sometimes, so set both axes limits to that of the smaller one
|
|
126
|
+
lower_limit=min([xlim,ylim])
|
|
127
|
+
if lower_limit==xlim:
|
|
128
|
+
ylim=xlim
|
|
129
|
+
elif lower_limit==ylim:
|
|
130
|
+
xlim=ylim
|
|
131
|
+
|
|
132
|
+
# Get points on axes in world coordinates (deg)
|
|
133
|
+
points=[]
|
|
134
|
+
wcs=WCS(image_data)
|
|
135
|
+
|
|
136
|
+
# Get array of pixels in x and y
|
|
137
|
+
x_points=np.arange(start=0,stop=xlim+1,step=1)
|
|
138
|
+
y_points=np.arange(start=0,stop=ylim+1,step=1)
|
|
139
|
+
|
|
140
|
+
# Apply transformation to coordinates
|
|
141
|
+
coords=wcs.all_pix2world(x_points,y_points,1)
|
|
142
|
+
x_points,y_points=coords[0],coords[1]
|
|
143
|
+
|
|
144
|
+
# Get image size in degrees
|
|
145
|
+
x_range=max(x_points)-min(x_points)
|
|
146
|
+
y_range=max(y_points)-min(y_points)
|
|
147
|
+
|
|
148
|
+
plot.x_range=Range1d(max(x_points),min(x_points))
|
|
149
|
+
plot.y_range=Range1d(min(y_points),max(y_points))
|
|
150
|
+
|
|
151
|
+
plot.image(image=[image],x=x_points[0],y=y_points[0],dw=x_range,dh=y_range,palette='Greys256',level="image",origin='bottom_right',anchor='bottom_right')
|
|
152
|
+
|
|
153
|
+
return plot
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import pandas as pd
|
|
2
|
+
import astropy.coordinates as coord
|
|
3
|
+
from astroquery.vizier import Vizier
|
|
4
|
+
import astropy.units as u
|
|
5
|
+
|
|
6
|
+
catalogue_name='II/335/galex_ais'
|
|
7
|
+
|
|
8
|
+
Vizier.ROW_LIMIT = -1
|
|
9
|
+
|
|
10
|
+
def GALEXQueryCoords(ra,dec,radius=3):
|
|
11
|
+
data=[]
|
|
12
|
+
|
|
13
|
+
if not isinstance(radius,int) and not isinstance(radius,float):
|
|
14
|
+
raise Exception('search radius must be a float or an integer')
|
|
15
|
+
|
|
16
|
+
if not isinstance(ra,float):
|
|
17
|
+
try:
|
|
18
|
+
ra=float(ra)
|
|
19
|
+
except:
|
|
20
|
+
raise Exception('object RA must be a float or an integer')
|
|
21
|
+
if not isinstance(dec,float):
|
|
22
|
+
try:
|
|
23
|
+
dec=float(dec)
|
|
24
|
+
except:
|
|
25
|
+
raise Exception('object DEC must be a float or an integer')
|
|
26
|
+
|
|
27
|
+
v=Vizier(columns=['**'])
|
|
28
|
+
|
|
29
|
+
#Sends Vizier query, can return multiple objects in given search radius
|
|
30
|
+
data.append(v.query_region(coord.SkyCoord(ra=ra,dec=dec,unit=(u.deg,u.deg),frame='icrs'),width=radius*u.arcsec,catalog=catalogue_name))
|
|
31
|
+
if len(data[0])==0:
|
|
32
|
+
print('[GALEX: GALEXQueryCoords] Error: no GALEX data found at given coordinates')
|
|
33
|
+
return None
|
|
34
|
+
data=data[0][0].to_pandas()
|
|
35
|
+
data=data.reset_index(drop=True)
|
|
36
|
+
return data
|
|
37
|
+
|
|
38
|
+
def GALEXGetPhotometryCoords(ra,dec,radius=3):
|
|
39
|
+
GALEXdata=GALEXQueryCoords(ra,dec,radius=radius)
|
|
40
|
+
if not isinstance(GALEXdata,pd.DataFrame) or GALEXdata.empty:
|
|
41
|
+
return None
|
|
42
|
+
|
|
43
|
+
photometry=GALEXdata[['RAJ2000','DEJ2000','objid','NUVmag','e_NUVmag','FUVmag','e_FUVmag']].copy()
|
|
44
|
+
|
|
45
|
+
return photometry
|