AstroToolkit 1.1.5__tar.gz → 1.1.7__tar.gz

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.
Files changed (51) hide show
  1. {AstroToolkit-1.1.5/src/AstroToolkit.egg-info → AstroToolkit-1.1.7}/PKG-INFO +99 -5
  2. {AstroToolkit-1.1.5 → AstroToolkit-1.1.7}/README.md +98 -4
  3. {AstroToolkit-1.1.5 → AstroToolkit-1.1.7}/pyproject.toml +1 -1
  4. {AstroToolkit-1.1.5 → AstroToolkit-1.1.7}/src/AstroToolkit/Figures/HRD.py +17 -1
  5. {AstroToolkit-1.1.5 → AstroToolkit-1.1.7}/src/AstroToolkit/Figures/SD.py +4 -6
  6. {AstroToolkit-1.1.5 → AstroToolkit-1.1.7}/src/AstroToolkit/Figures/SED.py +39 -10
  7. {AstroToolkit-1.1.5 → AstroToolkit-1.1.7}/src/AstroToolkit/Miscellaneous/ProperMotionCorrection.py +12 -1
  8. {AstroToolkit-1.1.5 → AstroToolkit-1.1.7}/src/AstroToolkit/Miscellaneous/ReadFits.py +10 -1
  9. {AstroToolkit-1.1.5 → AstroToolkit-1.1.7}/src/AstroToolkit/Overlays/Overlay_GALEX.py +12 -0
  10. {AstroToolkit-1.1.5 → AstroToolkit-1.1.7}/src/AstroToolkit/Overlays/Overlay_Gaia.py +9 -7
  11. {AstroToolkit-1.1.5 → AstroToolkit-1.1.7}/src/AstroToolkit/Overlays/Overlay_ROSAT.py +4 -0
  12. {AstroToolkit-1.1.5 → AstroToolkit-1.1.7}/src/AstroToolkit/Overlays/Overlay_Selection.py +4 -1
  13. {AstroToolkit-1.1.5 → AstroToolkit-1.1.7}/src/AstroToolkit/Overlays/Overlay_ZTF.py +12 -4
  14. {AstroToolkit-1.1.5 → AstroToolkit-1.1.7}/src/AstroToolkit/Surveys/DSS.py +22 -5
  15. {AstroToolkit-1.1.5 → AstroToolkit-1.1.7}/src/AstroToolkit/Surveys/GALEX.py +7 -1
  16. {AstroToolkit-1.1.5 → AstroToolkit-1.1.7}/src/AstroToolkit/Surveys/Gaia.py +4 -6
  17. {AstroToolkit-1.1.5 → AstroToolkit-1.1.7}/src/AstroToolkit/Surveys/PanSTARRS.py +12 -3
  18. {AstroToolkit-1.1.5 → AstroToolkit-1.1.7}/src/AstroToolkit/Surveys/ROSAT.py +9 -1
  19. {AstroToolkit-1.1.5 → AstroToolkit-1.1.7}/src/AstroToolkit/Surveys/SDSS.py +19 -2
  20. {AstroToolkit-1.1.5 → AstroToolkit-1.1.7}/src/AstroToolkit/Surveys/SkyMapper.py +30 -5
  21. {AstroToolkit-1.1.5 → AstroToolkit-1.1.7}/src/AstroToolkit/Surveys/TWOMASS.py +8 -1
  22. {AstroToolkit-1.1.5 → AstroToolkit-1.1.7}/src/AstroToolkit/Surveys/WISE.py +8 -1
  23. {AstroToolkit-1.1.5 → AstroToolkit-1.1.7}/src/AstroToolkit/Surveys/ZTF.py +19 -9
  24. {AstroToolkit-1.1.5 → AstroToolkit-1.1.7}/src/AstroToolkit/Tools.py +345 -91
  25. {AstroToolkit-1.1.5 → AstroToolkit-1.1.7/src/AstroToolkit.egg-info}/PKG-INFO +99 -5
  26. {AstroToolkit-1.1.5 → AstroToolkit-1.1.7}/LICENSE +0 -0
  27. {AstroToolkit-1.1.5 → AstroToolkit-1.1.7}/MANIFEST.in +0 -0
  28. {AstroToolkit-1.1.5 → AstroToolkit-1.1.7}/setup.cfg +0 -0
  29. {AstroToolkit-1.1.5 → AstroToolkit-1.1.7}/src/AstroToolkit/Examples/datapage_creation.py +0 -0
  30. {AstroToolkit-1.1.5 → AstroToolkit-1.1.7}/src/AstroToolkit/Figures/__init__.py +0 -0
  31. {AstroToolkit-1.1.5 → AstroToolkit-1.1.7}/src/AstroToolkit/Figures/backdrop_hrd_allmags.fits +0 -0
  32. {AstroToolkit-1.1.5 → AstroToolkit-1.1.7}/src/AstroToolkit/Miscellaneous/TestFile.py +0 -0
  33. {AstroToolkit-1.1.5 → AstroToolkit-1.1.7}/src/AstroToolkit/Miscellaneous/__init__.py +0 -0
  34. {AstroToolkit-1.1.5 → AstroToolkit-1.1.7}/src/AstroToolkit/Overlays/__init__.py +0 -0
  35. {AstroToolkit-1.1.5 → AstroToolkit-1.1.7}/src/AstroToolkit/Surveys/__init__.py +0 -0
  36. {AstroToolkit-1.1.5 → AstroToolkit-1.1.7}/src/AstroToolkit/Timeseries/README - Windows.txt +0 -0
  37. {AstroToolkit-1.1.5 → AstroToolkit-1.1.7}/src/AstroToolkit/Timeseries/README.txt +0 -0
  38. {AstroToolkit-1.1.5 → AstroToolkit-1.1.7}/src/AstroToolkit/Timeseries/__init__.py +0 -0
  39. {AstroToolkit-1.1.5 → AstroToolkit-1.1.7}/src/AstroToolkit/Timeseries/aov.f90 +0 -0
  40. {AstroToolkit-1.1.5 → AstroToolkit-1.1.7}/src/AstroToolkit/Timeseries/aovconst.f90 +0 -0
  41. {AstroToolkit-1.1.5 → AstroToolkit-1.1.7}/src/AstroToolkit/Timeseries/aovsub.f90 +0 -0
  42. {AstroToolkit-1.1.5 → AstroToolkit-1.1.7}/src/AstroToolkit/Timeseries/build.sh +0 -0
  43. {AstroToolkit-1.1.5 → AstroToolkit-1.1.7}/src/AstroToolkit/Timeseries/buildwin.bat +0 -0
  44. {AstroToolkit-1.1.5 → AstroToolkit-1.1.7}/src/AstroToolkit/Timeseries/pyaov.pdf +0 -0
  45. {AstroToolkit-1.1.5 → AstroToolkit-1.1.7}/src/AstroToolkit/Timeseries/pyaov.py +0 -0
  46. {AstroToolkit-1.1.5 → AstroToolkit-1.1.7}/src/AstroToolkit/Timeseries/ztfanalysis.py +0 -0
  47. {AstroToolkit-1.1.5 → AstroToolkit-1.1.7}/src/AstroToolkit/__init__.py +0 -0
  48. {AstroToolkit-1.1.5 → AstroToolkit-1.1.7}/src/AstroToolkit.egg-info/SOURCES.txt +0 -0
  49. {AstroToolkit-1.1.5 → AstroToolkit-1.1.7}/src/AstroToolkit.egg-info/dependency_links.txt +0 -0
  50. {AstroToolkit-1.1.5 → AstroToolkit-1.1.7}/src/AstroToolkit.egg-info/requires.txt +0 -0
  51. {AstroToolkit-1.1.5 → AstroToolkit-1.1.7}/src/AstroToolkit.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: AstroToolkit
3
- Version: 1.1.5
3
+ Version: 1.1.7
4
4
  Summary: A package for the gathering and plotting of astronomical data.
5
5
  Author-email: Ethan Moorfield <ethan.moorfield@hotmail.co.uk>
6
6
  Project-URL: Homepage, https://github.com/WD-planets/AstroToolkit
@@ -988,12 +988,12 @@ returns: list of 'pos' objects, i.e. a list of lists with each 'pos' = [ra,dec].
988
988
 
989
989
  ### 6. getsd
990
990
 
991
+ Gets a spatial distribution plot of all objects in a .fits file.
992
+
991
993
  ```
992
994
  getsd(file_name)
993
995
  ```
994
996
 
995
- Gets a spatial distribution plot of all objects in a .fits file.
996
-
997
997
  where:
998
998
  ```
999
999
  file_name = string
@@ -1004,18 +1004,112 @@ returns: bokeh plot or None (if no data retrieved).
1004
1004
 
1005
1005
  ### 7. convertsource
1006
1006
 
1007
+ Converts a gaia source_id to a JHHMMSS.SS+DDMMSS.SS identifier (as seen in the save_data file naming convention).
1008
+
1007
1009
  ```
1008
1010
  convertsource(source)
1009
1011
  ```
1010
1012
 
1011
- Converts a gaia source_id to a JHHMMSS.SS+DDMMSS.SS identifier (as seen in the save_data file naming convention).
1012
-
1013
1013
  where:
1014
1014
  ```
1015
1015
  source = integer/string
1016
1016
  = Gaia source_id (e.g. 6050296829033196032).
1017
1017
  ```
1018
1018
 
1019
+ ### 8. readlocal
1020
+
1021
+ Reads a local csv-esque file (ie. columns separated by a separator, rows separated by a newline) into a 2D list containing the column data. A complete file name is not needed, the search will pick up any file whos name contains the input Gaia source_id or position in the format: ra_dec (i.e. the same format used throughout the toolkit for saving data).
1022
+
1023
+ ```
1024
+ readlocal(source=None,pos=None,extension='csv',headers=True,separator=',',getfilename=False):
1025
+ ```
1026
+
1027
+ where:
1028
+
1029
+ ```
1030
+ source = integer/string
1031
+ = Gaia source_id (e.g. 6050296829033196032).
1032
+ ```
1033
+ ```
1034
+ pos = 1D tuple of two integers
1035
+ = [ra,dec], object coordinates in degrees.
1036
+ ```
1037
+ ```
1038
+ extension = string
1039
+ = file extension (without the '.')
1040
+ ```
1041
+ ```
1042
+ headers = boolean
1043
+ = tells the tool whether to ignore the first row of data (if being used as column headers)
1044
+ ```
1045
+ ```
1046
+ separator = str
1047
+ = tells the tool what separator to expect between columns
1048
+ ```
1049
+ ```
1050
+ getfilename = boolean
1051
+ = tells the tool whether to also return the name of the file it found
1052
+ ```
1053
+
1054
+ ### 9. plotdata
1055
+
1056
+ A significantly simplified plotting function for making quick Bokeh plots.
1057
+
1058
+ ***Note:*** This function is only intended to make the quick creation of basic Bokeh plots easier. For fully customizable Bokeh plots, refer to the Bokeh documentation.
1059
+
1060
+ ```
1061
+ plotdata(x,y,x_err=None,y_err=None,title=None,xlabel=None,ylabel=None,xtype='linear',ytype='linear',marker='circle',colour='black',legend='Data Points')
1062
+ ```
1063
+
1064
+ where:
1065
+
1066
+ ```
1067
+ x = tuple
1068
+ = coordinates of data points on x-axis
1069
+ ```
1070
+ ```
1071
+ y = tuple
1072
+ = coordinates of data points on y axis
1073
+ ```
1074
+ ```
1075
+ x_err = tuple
1076
+ = x errors on data points (in same order as x)
1077
+ ```
1078
+ ```
1079
+ y_err = tuple
1080
+ = y errors on data points (in same order as x)
1081
+ ```
1082
+ ```
1083
+ title = string
1084
+ = plot title
1085
+ ```
1086
+ ```
1087
+ xlabel = string
1088
+ = x-axis label
1089
+ ```
1090
+ ```
1091
+ ylabel = string
1092
+ = y-axis label
1093
+ ```
1094
+ ```
1095
+ xtype = string, 'linear' or 'log'
1096
+ = x-axis type
1097
+ ```
1098
+ ```
1099
+ ytype = string, 'linear' or 'log'
1100
+ = y-axis type
1101
+ ```
1102
+ ```
1103
+ marker = string, 'circle' or 'line'
1104
+ = type of plot (circle = scatter, line = line)
1105
+ ```
1106
+ ```
1107
+ colour = colour of markers/lines/error bars
1108
+ ```
1109
+ ```
1110
+ legend = name to give the data points in the legend
1111
+ ```
1112
+
1019
1113
  ## Datapage functions
1020
1114
 
1021
1115
  These functions are used to create custom datapages from any plots/data supported by AstroToolkit.
@@ -960,12 +960,12 @@ returns: list of 'pos' objects, i.e. a list of lists with each 'pos' = [ra,dec].
960
960
 
961
961
  ### 6. getsd
962
962
 
963
+ Gets a spatial distribution plot of all objects in a .fits file.
964
+
963
965
  ```
964
966
  getsd(file_name)
965
967
  ```
966
968
 
967
- Gets a spatial distribution plot of all objects in a .fits file.
968
-
969
969
  where:
970
970
  ```
971
971
  file_name = string
@@ -976,18 +976,112 @@ returns: bokeh plot or None (if no data retrieved).
976
976
 
977
977
  ### 7. convertsource
978
978
 
979
+ Converts a gaia source_id to a JHHMMSS.SS+DDMMSS.SS identifier (as seen in the save_data file naming convention).
980
+
979
981
  ```
980
982
  convertsource(source)
981
983
  ```
982
984
 
983
- Converts a gaia source_id to a JHHMMSS.SS+DDMMSS.SS identifier (as seen in the save_data file naming convention).
984
-
985
985
  where:
986
986
  ```
987
987
  source = integer/string
988
988
  = Gaia source_id (e.g. 6050296829033196032).
989
989
  ```
990
990
 
991
+ ### 8. readlocal
992
+
993
+ Reads a local csv-esque file (ie. columns separated by a separator, rows separated by a newline) into a 2D list containing the column data. A complete file name is not needed, the search will pick up any file whos name contains the input Gaia source_id or position in the format: ra_dec (i.e. the same format used throughout the toolkit for saving data).
994
+
995
+ ```
996
+ readlocal(source=None,pos=None,extension='csv',headers=True,separator=',',getfilename=False):
997
+ ```
998
+
999
+ where:
1000
+
1001
+ ```
1002
+ source = integer/string
1003
+ = Gaia source_id (e.g. 6050296829033196032).
1004
+ ```
1005
+ ```
1006
+ pos = 1D tuple of two integers
1007
+ = [ra,dec], object coordinates in degrees.
1008
+ ```
1009
+ ```
1010
+ extension = string
1011
+ = file extension (without the '.')
1012
+ ```
1013
+ ```
1014
+ headers = boolean
1015
+ = tells the tool whether to ignore the first row of data (if being used as column headers)
1016
+ ```
1017
+ ```
1018
+ separator = str
1019
+ = tells the tool what separator to expect between columns
1020
+ ```
1021
+ ```
1022
+ getfilename = boolean
1023
+ = tells the tool whether to also return the name of the file it found
1024
+ ```
1025
+
1026
+ ### 9. plotdata
1027
+
1028
+ A significantly simplified plotting function for making quick Bokeh plots.
1029
+
1030
+ ***Note:*** This function is only intended to make the quick creation of basic Bokeh plots easier. For fully customizable Bokeh plots, refer to the Bokeh documentation.
1031
+
1032
+ ```
1033
+ plotdata(x,y,x_err=None,y_err=None,title=None,xlabel=None,ylabel=None,xtype='linear',ytype='linear',marker='circle',colour='black',legend='Data Points')
1034
+ ```
1035
+
1036
+ where:
1037
+
1038
+ ```
1039
+ x = tuple
1040
+ = coordinates of data points on x-axis
1041
+ ```
1042
+ ```
1043
+ y = tuple
1044
+ = coordinates of data points on y axis
1045
+ ```
1046
+ ```
1047
+ x_err = tuple
1048
+ = x errors on data points (in same order as x)
1049
+ ```
1050
+ ```
1051
+ y_err = tuple
1052
+ = y errors on data points (in same order as x)
1053
+ ```
1054
+ ```
1055
+ title = string
1056
+ = plot title
1057
+ ```
1058
+ ```
1059
+ xlabel = string
1060
+ = x-axis label
1061
+ ```
1062
+ ```
1063
+ ylabel = string
1064
+ = y-axis label
1065
+ ```
1066
+ ```
1067
+ xtype = string, 'linear' or 'log'
1068
+ = x-axis type
1069
+ ```
1070
+ ```
1071
+ ytype = string, 'linear' or 'log'
1072
+ = y-axis type
1073
+ ```
1074
+ ```
1075
+ marker = string, 'circle' or 'line'
1076
+ = type of plot (circle = scatter, line = line)
1077
+ ```
1078
+ ```
1079
+ colour = colour of markers/lines/error bars
1080
+ ```
1081
+ ```
1082
+ legend = name to give the data points in the legend
1083
+ ```
1084
+
991
1085
  ## Datapage functions
992
1086
 
993
1087
  These functions are used to create custom datapages from any plots/data supported by AstroToolkit.
@@ -7,7 +7,7 @@ include-package-data = true
7
7
 
8
8
  [project]
9
9
  name = "AstroToolkit"
10
- version = "1.1.5"
10
+ version = "1.1.7"
11
11
  authors = [
12
12
  { name="Ethan Moorfield", email="ethan.moorfield@hotmail.co.uk"},
13
13
  ]
@@ -12,7 +12,11 @@ from ..Surveys.Gaia import GaiaQuerySource
12
12
 
13
13
  fits_file = files('AstroToolkit.Figures').joinpath('backdrop_hrd_allmags.fits')
14
14
 
15
+ '''
16
+ Creates the HRD plot with a source/sources as an overlay
17
+ '''
15
18
  def get_plot(source=None,sources=None):
19
+ # reads the background file ('backdrop_hrd_allmags.fits') into separate datasets based on their object classifications.
16
20
  background=Table.read(fits_file).to_pandas()
17
21
  background_100pc=background.loc[background['type']==b'100pc']
18
22
  background_wd=background.loc[background['type']==b'WD']
@@ -20,12 +24,14 @@ def get_plot(source=None,sources=None):
20
24
  background_wd_dm=background.loc[background['type']==b'WD+dM']
21
25
  background_sd=background.loc[background['type']==b'SD']
22
26
 
27
+ # combines these into a split dataset
23
28
  background_split=[background_100pc,background_wd,background_wd_dm,background_cv,background_sd]
24
29
 
25
30
  x_arr=[]
26
31
  y_arr=[]
27
32
  colour_arr=[]
28
33
 
34
+ # calculates x (bp-rp) and y (abs g) positions of all objects in the background sample
29
35
  for sample in background_split:
30
36
  x=sample['phot_bp_mean_mag'].values-sample['phot_rp_mean_mag'].values
31
37
  y=sample['phot_g_mean_mag'].values+5*np.log10(sample['parallax'].values/1000)+5
@@ -33,27 +39,36 @@ def get_plot(source=None,sources=None):
33
39
  x_arr.append(x)
34
40
  y_arr.append(y)
35
41
 
42
+ # Sets the colour maps used by each category of object
36
43
  colour_maps=['Greens','Purples','Reds','Blues','YlOrBr']
37
44
 
45
+ # Removes extreme ends of colour maps for visibility (i.e. strips colours that are too light)
38
46
  for i in range(0,len(colour_maps)):
39
47
  colour_maps[i]=cmr.get_sub_cmap(colour_maps[i],0.4,1.0)
40
48
 
49
+ # Creates the effect of darker colours in higher density regions of each category
41
50
  for i in range(0,len(x_arr)):
51
+ #stacks x and y values to calculate a gaussian density and then uses this to normalise across the colour map based on density of nearby data points
42
52
  values=np.vstack([x_arr[i],y_arr[i]])
43
53
  kernel=stats.gaussian_kde(values)
44
54
  weights=kernel(values)
45
55
  weights=weights/weights.max()
46
56
 
57
+ # uses a hex representation of RGB colour values to create the final colour maps weighted for each object based on nearby point density
47
58
  colour=["#%02x%02x%02x" % (int(r), int(g), int(b)) for r, g, b, _ in 255*colour_maps[i](weights)]
48
59
  colour_arr.append(colour)
49
60
 
61
+ # Create plot
50
62
  plot=figure(width=400,height=400,title='Gaia HRD',x_axis_label=r'\[\text{bp-rp}\]',y_axis_label=r'\[\text{abs g}\]')
51
63
  plot.y_range.flipped = True
52
64
 
65
+ # sets labels for legend
53
66
  labels=['100pc','WDs','CVs','WD+dM','SDs']
67
+ # places background points with their colours set, and addstheir respective category to the legend
54
68
  for i in range(0,len(x_arr)):
55
69
  plot.scatter(x_arr[i],y_arr[i],size=3,color=colour_arr[i],legend_label=labels[i])
56
70
 
71
+ # overlays source on top of background sample as long as all the necessary data is available
57
72
  if source!=None:
58
73
  data=GaiaQuerySource(source=source)
59
74
  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
@@ -64,7 +79,8 @@ def get_plot(source=None,sources=None):
64
79
  plot.scatter(x=x,y=y,marker='square_dot',line_color='black',fill_color=None,size=20,line_width=2,legend_label='Source')
65
80
  else:
66
81
  return None
67
-
82
+
83
+ # same as above but handles multiple sources
68
84
  elif sources!=None:
69
85
  for i in range(0,len(sources)):
70
86
  data=GaiaQuerySource(source=sources[i])
@@ -1,15 +1,13 @@
1
1
  from AstroToolkit.Tools import getpositions
2
- from bokeh.plotting import figure,show
2
+ from bokeh.plotting import figure
3
3
 
4
+ # gets list of positions from .fits file
4
5
  def get_plot(file_name):
5
6
  pos_list=getpositions(file_name)
6
7
 
8
+ # creates spatial distribution plot
7
9
  plot=figure(width=400,height=400,title='Spatial Distribution',x_axis_label='ra [deg]',y_axis_label='dec [deg]')
8
10
  for i in range(0,len(pos_list)):
9
11
  plot.circle(x=pos_list[i][0],y=pos_list[i][1],color='black',legend_label='Sources')
10
12
 
11
- return plot
12
-
13
- if __name__=='__main__':
14
- fig=getSD(file_name='pre-ztf.fits')
15
- show(fig)
13
+ return plot
@@ -1,3 +1,4 @@
1
+ from ssl import cert_time_to_seconds
1
2
  import astropy.units as u
2
3
  import math
3
4
  import pandas as pd
@@ -16,6 +17,7 @@ from ..Surveys.GALEX import GALEXGetPhotometryCoords
16
17
  from ..Surveys.PanSTARRS import PanSTARRSGetPhotometryCoords
17
18
  from ..Surveys.SkyMapper import SkyMapperGetPhotometryCoords
18
19
 
20
+ # used to calculate fluxes using zero point, mag and wavelength of filter
19
21
  def zeropoint(mag,zp,wl):
20
22
  flux=zp*10**(-0.4*mag)
21
23
  c=2.988*10**18
@@ -24,9 +26,7 @@ def zeropoint(mag,zp,wl):
24
26
  return flux
25
27
 
26
28
  def get_plot(source=None,pos=None,radius=3,save_data=False):
27
- if source!=None and pos!=None:
28
- raise Exception('simulatenous source and pos input detected')
29
-
29
+ # proper motion corrects positions for use in each supported survey
30
30
  if source!=None:
31
31
  gaia_data=GaiaQuerySource(source=source)
32
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]
@@ -63,9 +63,6 @@ def get_plot(source=None,pos=None,radius=3,save_data=False):
63
63
  ra_sdss,dec_sdss=pos[0],pos[1]
64
64
  ra_wise,dec_wise=pos[0],pos[1]
65
65
  ra_twomass,dec_twomass=pos[0],pos[1]
66
-
67
- else:
68
- raise Exception('either source or pos input required')
69
66
 
70
67
  filter_arr=[]
71
68
 
@@ -74,39 +71,60 @@ def get_plot(source=None,pos=None,radius=3,save_data=False):
74
71
  flux_arr=[]
75
72
  mag_arr=[]
76
73
 
74
+ '''
75
+ wavelength_arr = list of lists with wavelengths of each filter in a survey, i.e. [[gaia_g,gaia_r,gaia_i],[galex_nuv,galex_fuv] ... etc.]
76
+ flux = same as above but with the corresponding fluxes
77
+ error_arr = same as above but with the corresponding flux errors
78
+ mag_arr = same as above but with the object's magnitudes through these filters, used to calculate the fluxes
79
+
80
+ The functionality is the same for each survey, so I probably need to try and parameterise this at some point
81
+ '''
82
+
77
83
  wavelengths=[]
78
84
  flux=[]
79
85
  errors=[]
80
86
  mags=[]
87
+ # Get survey photometry
81
88
  photometry=GaiaGetPhotometryCoords(ra_gaia,dec_gaia,radius=radius)
82
89
  if isinstance(photometry,pd.DataFrame):
90
+ # names of filters and errors in survey
83
91
  filter_list=['phot_g_mean_mag','phot_rp_mean_mag','phot_bp_mean_mag']
84
92
  error_list=['phot_g_mean_mag_error','phot_rp_mean_mag_error','phot_bp_mean_mag_error']
93
+ # zero points of filters
85
94
  zero_points=[2.5e-9,1.24e-9,4.11e-9]
86
95
 
87
96
  #g,rp,bp
88
97
  filter_ref=[5850.88,7690.74,5041.61]
89
98
 
99
+ # iterates through filter_list,error_list,zero_points simultaneously
90
100
  for filter, error, zp in zip(filter_list,error_list,zero_points):
91
101
  try:
102
+ # gets magnitude value in current filter
92
103
  mag=photometry._get_value(0,filter)
93
104
  mags.append(mag)
94
105
 
106
+ # gets error value for this magnitude
95
107
  errors.append((photometry._get_value(0,error)*u.ABmag))
108
+ # gets the wavelength of the current filter
96
109
  wavelength=(filter_ref[filter_list.index(filter)])
97
110
  wavelengths.append(wavelength)
98
111
 
112
+ # calculates the flux using the current filter's zero point
99
113
  fl=zeropoint(mag=mag,zp=zp,wl=wavelength)
100
114
  flux.append(fl)
101
115
 
116
+ # appends the filter's name to filter_arr if this was all successful
102
117
  filter_arr.append(filter)
103
118
  except:
104
119
  pass
120
+
121
+ # Appends the obtained values to the data arrays (see above)
105
122
  wavelength_arr.append(wavelengths)
106
123
  flux_arr.append(flux)
107
124
  error_arr.append(errors)
108
125
  mag_arr.append(mags)
109
126
 
127
+ # These are only temporary arrays used in each survey, so here they get over-written. The functionality is then the same for all future surveys, except filter zero points are calculated manually.
110
128
  wavelengths=[]
111
129
  flux=[]
112
130
  errors=[]
@@ -127,7 +145,8 @@ def get_plot(source=None,pos=None,radius=3,save_data=False):
127
145
  errors.append((photometry._get_value(0,error)*u.ABmag))
128
146
  wavelength=(filter_ref[filter_list.index(filter)])
129
147
  wavelengths.append(wavelength)
130
-
148
+
149
+ # calculate zero point of current filter manually
131
150
  zp=10**((5*np.log10(filter_ref[filter_list.index(filter)])+2.406)/-2.5)
132
151
  fl=zeropoint(mag=mag,zp=zp,wl=wavelength)
133
152
  flux.append(fl)
@@ -305,6 +324,7 @@ def get_plot(source=None,pos=None,radius=3,save_data=False):
305
324
  error_arr.append(errors)
306
325
  mag_arr.append(mags)
307
326
 
327
+ # strip all data of its units if it has any
308
328
  for i in range(0,len(flux_arr)):
309
329
  for j in range(0,len(flux_arr[i])):
310
330
  try:
@@ -315,6 +335,7 @@ def get_plot(source=None,pos=None,radius=3,save_data=False):
315
335
  for j in range(0,len(error_arr[i])):
316
336
  error_arr[i][j]=error_arr[i][j].value
317
337
 
338
+ # calculate an array of relative errors from error values (cannot directly calculate errors using error propagation due to quirks of magnitude system (i.e. logarithmic and decreasing >> brighter))
318
339
  rel_error_arr=[]
319
340
  for i in range(0,len(mag_arr)):
320
341
  flux_arr[i]=np.asarray(flux_arr[i])
@@ -323,6 +344,7 @@ def get_plot(source=None,pos=None,radius=3,save_data=False):
323
344
 
324
345
  rel_error_arr.append(flux_arr[i]*error_arr[i]/mag_arr[i])
325
346
 
347
+ # if no data, return None
326
348
  if len(wavelength_arr)==0 and len(flux_arr)==0:
327
349
  if save_data==True:
328
350
  return None, None
@@ -333,14 +355,16 @@ def get_plot(source=None,pos=None,radius=3,save_data=False):
333
355
  #Order in script: Gaia, GALEX, PanSTARRS, SkyMapper, SDSS, WISE, 2MASS
334
356
  colour_arr=['springgreen','royalblue','gold','aquamarine','deepskyblue','orangered','orange']
335
357
 
358
+ # Create figure object
336
359
  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")
337
360
 
338
- # Bokeh only understands np nan values
361
+ # Bokeh only understands np nan values, so convert math.nan to np.nan
339
362
  for i in range(0,len(wavelength_arr)):
340
363
  wavelength_arr[i]=[np.nan if math.isnan(x) else x for x in wavelength_arr[i]]
341
364
  flux_arr[i]=[np.nan if math.isnan(x) else x for x in flux_arr[i]]
342
365
  rel_error_arr[i]=[np.nan if math.isnan(x) else x for x in rel_error_arr[i]]
343
-
366
+
367
+ # create data sources used to create plots
344
368
  sources=[]
345
369
  for i in range(0,len(wavelength_arr)):
346
370
  upper=[x+e for x,e in zip(flux_arr[i],rel_error_arr[i])]
@@ -351,14 +375,19 @@ def get_plot(source=None,pos=None,radius=3,save_data=False):
351
375
 
352
376
  surveys=['Gaia','GALEX','PanSTARRS','SkyMapper','SDSS','WISE','2MASS']
353
377
 
378
+ # plot data points
354
379
  for i in range(0,len(wavelength_arr)):
355
380
  if len(flux_arr[i])>0:
356
381
  plot.circle(x='wavelength',y='flux',source=sources[i],color=colour_arr[i],legend_label=f'{surveys[i]}')
382
+ # add errors (has to be handled separately in bokeh :/ )
357
383
  errors=Whisker(source=sources[i],base='wavelength',upper='upper',lower='lower',line_width=0.5,line_color=colour_arr[i])
358
384
  errors.upper_head.line_width,errors.lower_head.line_width=0.5,0.5
359
385
  errors.upper_head.size,errors.lower_head.size=3,3
360
386
  errors.upper_head.line_color,errors.lower_head.line_color=colour_arr[i],colour_arr[i]
361
-
387
+ plot.add_layout(errors)
388
+
389
+ # if saving data, flatten arrays to 1d (i.e. you lose information about which survey each point is obtained from, not ideal but cannot seem to write to .csv with different sized dataframes unless
390
+ # completely separating the data as with getbulkphot() etc, which is then going to annoying to handle. Can improve.
362
391
  if save_data==True:
363
392
  flat_flux=[]
364
393
  flat_wavelength=[]
@@ -1,7 +1,11 @@
1
+ from calendar import c
1
2
  import math
2
3
 
4
+ '''
5
+ Takes an input year in format [year,month] and corrects coordinates of an object (using its pmra and pmdec) to correct for its proper motion to a target year in format [year,month]
6
+ '''
3
7
  def PMCorrection(input,target,inputObjRA,inputObjDEC,pmRA,pmDEC,radius=None):
4
- #Filter inputs
8
+ # Filter inputs
5
9
  if not isinstance(input[0],int):
6
10
  raise Exception('input year must be an integer')
7
11
  if not isinstance(input[1],int):
@@ -16,16 +20,19 @@ def PMCorrection(input,target,inputObjRA,inputObjDEC,pmRA,pmDEC,radius=None):
16
20
  inputObjRA=float(inputObjRA)
17
21
  except:
18
22
  raise Exception('object RA must be a float or an integer')
23
+
19
24
  if not isinstance(inputObjDEC,float):
20
25
  try:
21
26
  inputObjDEC=float(inputObjDEC)
22
27
  except:
23
28
  raise Exception('object DEC must be a float or an integer')
29
+
24
30
  if not isinstance(pmRA,float):
25
31
  try:
26
32
  pmRA=float(pmRA)
27
33
  except:
28
34
  raise Exception('object PM_RA must be a float or an integer')
35
+
29
36
  if not isinstance(pmDEC,float):
30
37
  try:
31
38
  pmDEC=float(pmDEC)
@@ -35,14 +42,18 @@ def PMCorrection(input,target,inputObjRA,inputObjDEC,pmRA,pmDEC,radius=None):
35
42
  inputYear,inputMonth=input[0],input[1]
36
43
  targetYear,targetMonth=target[0],target[1]
37
44
 
45
+ # get change in years and change in months
38
46
  yearDelta=targetYear-inputYear
39
47
  monthDelta=targetMonth-inputMonth
40
48
 
49
+ # correct for proper motion
41
50
  inputObjRA+=(yearDelta*pmRA/3600000+monthDelta*pmRA/43200000)*1/math.cos(inputObjDEC/360*2*math.pi)
42
51
  inputObjDEC+=yearDelta*pmDEC/3600000+monthDelta*pmDEC/43200000
43
52
 
53
+ # get time delta in years
44
54
  timeDelta=abs(yearDelta+monthDelta/12)
45
55
 
56
+ # if a radius is given, use this time delta to scale the radius (used in adaptive proper motion correction)
46
57
  if radius!=None:
47
58
  radius=radius+math.sqrt((pmRA/1000)**2+(pmDEC/1000)**2)*timeDelta
48
59
  return inputObjRA,inputObjDEC,radius
@@ -1,14 +1,19 @@
1
1
  from astropy.table import Table
2
2
 
3
+ '''
4
+ gets a list of sources from a fits file
5
+ '''
3
6
  def get_source_list(file_name):
4
7
  if not file_name.endswith('.fits'):
5
8
  file_name+='.fits'
6
-
9
+
10
+ # read file into a pandas dataframe
7
11
  try:
8
12
  data=Table.read(file_name).to_pandas()
9
13
  except:
10
14
  raise Exception(f'File: {file_name} not found, or invalid format.')
11
15
 
16
+ # get source_id column
12
17
  try:
13
18
  sources=data.loc[:,'source_id'].tolist()
14
19
  except:
@@ -20,16 +25,20 @@ def get_pos_list(file_name):
20
25
  if not file_name.endswith('.fits'):
21
26
  file_name+='.fits'
22
27
 
28
+ # read file into pandas dataframe
23
29
  try:
24
30
  data=Table.read(file_name).to_pandas()
25
31
  except:
26
32
  raise Exception(f'File: {file_name} not found, or invalid format.')
27
33
 
34
+ # get ra and dec columns
28
35
  try:
29
36
  ra=data.loc[:,'ra'].tolist()
30
37
  dec=data.loc[:,'dec'].tolist()
31
38
  except:
32
39
  raise Exception('ra/dec columns not found.')
33
40
 
41
+ # zips ra and dec values into pos ([ra,dec]) as supported by the rest of the toolkit
34
42
  pos_list=[list(x) for x in zip(ra,dec)]
43
+
35
44
  return pos_list
@@ -6,6 +6,18 @@ from ..Surveys.Gaia import GaiaQueryCoords
6
6
  from ..Surveys.GALEX import GALEXQueryCoords
7
7
  from ..Miscellaneous.ProperMotionCorrection import PMCorrection
8
8
 
9
+ '''
10
+ Functionality is essentially the same in all overlay functions, so refer to Overlay_Gaia for further comments
11
+ '''
12
+
13
+ '''
14
+ Functionality of all overlays other than Gaia follows this process:
15
+ 1. Get Gaia detections for proper motions
16
+ 2. Proper motion correct these Gaia detections back to the time of any other overlay (e.g. GALEX)
17
+ 3. do a radius search around this new corrected gaia location and see if it picks up any detections in the selected overlays
18
+ 4. use proper motions obtained from Gaia to correct these and any picked up detections to the image time
19
+ '''
20
+
9
21
  #Creates Galex overlay
10
22
  def getGalexOverlayNUV(plot,ra,dec,sizeAS,mjd,border,pmra,pmdec):
11
23
  #checks if GALEX search was successful