Skip to content

Commit 6ad2a3f

Browse files
authored
Add files via upload
1 parent d6d2dc5 commit 6ad2a3f

11 files changed

+4173
-0
lines changed
576 KB
Loading
275 KB
Loading

InitialMassFunction/PolynomialFit.png

118 KB
Loading
Binary file not shown.

InitialMassFunction/automatedplans_analysis/M35-BV.csv

Lines changed: 1988 additions & 0 deletions
Large diffs are not rendered by default.

InitialMassFunction/automatedplans_analysis/M35-offsetfield-BV.csv

Lines changed: 1757 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Cluster Match
2+
3+
(Pre-requisites: Python >=3.7, Astropy, Numpy, Matplotlib)
4+
5+
To install pre-requisities run:
6+
`pip install astropy numpy matplotlib`
7+
8+
For LRC computers you will need to specify `C:\Python39\python` instead of just `python` as the path to run python 3 (by default `python` uses python 2.7).
9+
10+
To install astropy on LRC computers run `C:\Python39\Scripts\pip install astropy`
11+
12+
If using Spyder you can add parameters by clicking Run>Configuration per file, then entering the parameters (not including the script name itself) into the "Command line options" box in the "General Settings" section (be careful NOT to use the "Command line options" box in the "Console" section higher up).
13+
14+
Images will need to be plate-solved for these scripts (and APT) to run successfully.
15+
16+
17+
**Step 1:**
18+
19+
Download the UCAC4 stars covering the area around an input file:
20+
If your files have spaces, don't forget to enclose the entire path in double quotes.
21+
22+
Use:
23+
24+
`download.py <input file>`
25+
26+
e.g.
27+
28+
`>> python download.py "NGC 457_B_15s_B2_T3_72939.fit"`
29+
30+
**Step 2:**
31+
32+
For each filter (V and B), match stars in the image to the UCAC4 stars, and estimate the zero point:
33+
34+
Use:
35+
36+
`match-zp.py <catalog file> <APT source list> <output file name> <filter (V or B)>`
37+
38+
e.g.
39+
40+
` >> python match-zp.py "ngc 457_V_15s_B2_T3_72941-UCAC4.tbl" "NGC457-V-inst-mags.csv" "NGC457-V-cal-mags.csv" V`
41+
42+
`>> python match-zp.py "ngc 457_V_15s_B2_T3_72941-UCAC4.tbl" "NGC457-B-inst-mags.csv" "NGC457-B-cal-mags.csv" B`
43+
44+
**Step 3:**
45+
46+
Match stars from the V and B files, and calculate B-V colour:
47+
48+
Use:
49+
50+
`match-bv.py <B mag file> <V mag file> <output file>`
51+
52+
e.g.
53+
54+
`>> python match-bv.py "NGC457-B-cal-mags.csv" "NGC457-V-cal-mags.csv" "NGC457-BV.csv"`
55+
56+
**Step 4:**
57+
58+
The CSV file can be opened in Excel or other software to plot the results.
59+
60+
You can make a basic plot of B-V colours against apparent V magnitudes to create an HR diagram:
61+
62+
Use:
63+
64+
`plot.py <BV file>`
65+
66+
e.g.
67+
68+
`>> python plot.py "NGC457-BV.csv"`
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
from urllib import request, parse
2+
from astropy.io import fits
3+
import os
4+
import sys
5+
6+
#read the filename from the arguments
7+
filename = sys.argv[1:][0]
8+
9+
#Open the fits file header data unit
10+
hdul = fits.open(filename)
11+
12+
try:
13+
#Extract Right ascension of centre of the image
14+
RA= float(hdul[0].header['CRVAL1'])
15+
print("RA: "+str(RA))
16+
17+
#Extract declination of centre of the image
18+
DEC= float(hdul[0].header['CRVAL2'])
19+
print("DEC: "+str(DEC))
20+
21+
except:
22+
print("Error: Could not find CRVAL1 or CRVAL2 in FITS header. This likely means the image has not been plate-solved.")
23+
print("See https://observatory.herts.ac.uk/wiki/Plate_Solving for help with plate-solving images.")
24+
quit()
25+
26+
27+
postData = { '-source' : 'I/322A/out', '-out.max' : '10000', '-out.form' : '| -Separated-Values', '-oc.form' : 'dec', '-c.eq' : 'J2000', '-c.r' : '++2', '-c.u' : 'arcmin', '-c.geom' : 'r', '-out.src' : 'I/322A/out', '-out.orig' : 'standard', '-out' : 'RAJ2000, DEJ2000, Vmag, Bmag', 'Bmag' : '>0', 'Vmag' : '>0', 'RAJ2000' : str(RA)+'+/-0.5', 'DEJ2000' : str(DEC)+'+/-0.5'}
28+
29+
#URL encode data
30+
31+
data = parse.urlencode(postData).encode()
32+
33+
34+
#Create web request
35+
req = request.Request('http://vizier.u-strasbg.fr/viz-bin/asu-tsv', data=data)
36+
37+
#print("Downloading UCAC4 data")
38+
39+
#Request web query
40+
response = request.urlopen(req)
41+
42+
#Get return data
43+
return_data = response.read()
44+
45+
#print(response)
46+
47+
#print(return_data)
48+
49+
print("Writing to file: "+os.path.splitext(filename)[0]+"-UCAC4.tbl")
50+
51+
#write the return data to file
52+
with open(os.path.splitext(filename)[0]+"-UCAC4.tbl", 'wb') as s:
53+
s.write(return_data)
54+
55+
print("Done")
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
import os
2+
import math
3+
import sys
4+
5+
BMags= sys.argv[1:][0] # "NGC457-B-cal-mags.csv"
6+
7+
VMags= sys.argv[1:][1] #"NGC457-V-cal-mags.csv"
8+
9+
outFile= sys.argv[1:][2] #"NGC457-BV.csv"
10+
11+
print("B magnitudes: "+BMags)
12+
13+
print("V magnitudes: "+VMags)
14+
15+
print("Output file: "+outFile)
16+
17+
if os.path.exists(outFile):
18+
print("Output file already exists")
19+
sys.exit()
20+
21+
#Maximum distance from expected coordinates for a source to be considered (arcseconds)
22+
maxDist = 2
23+
24+
#Open the corresponding source list for reading
25+
VMagsFile = open(VMags, "r")
26+
#skip headers
27+
Vfirst_line = VMagsFile.readline()
28+
VLines = VMagsFile.readlines()
29+
30+
BMagsFile = open(BMags, "r")
31+
Bfirst_line = BMagsFile.readline()
32+
BLines = BMagsFile.readlines()
33+
34+
35+
36+
37+
lineNum=0
38+
39+
outlist = []
40+
41+
x=0
42+
43+
matches = 0
44+
45+
print("---------------------")
46+
print("Matching stars...")
47+
48+
#Loop through all lines in the file
49+
for Vline in VLines:
50+
51+
52+
partsV = Vline.split(",")
53+
54+
#Extract useful values from the source list
55+
raV = float(partsV[0]) #Right ascensions (degrees)
56+
decV = float(partsV[1]) #Declination (degrees)
57+
Vmag = float(partsV[2].strip()) #Source instrument magnitude
58+
59+
firstLine = 0
60+
61+
closest = 360
62+
63+
bestB =0
64+
65+
for Bline in BLines:
66+
67+
68+
partsB = Bline.split(",")
69+
70+
raB = float(partsB[0]) #Right ascensions (degrees)
71+
decB = float(partsB[1]) #Declination (degrees)
72+
Bmag= float(partsB[2].strip()) #Source instrument magnitude
73+
74+
ra1 = math.radians(raB)
75+
ra2 = math.radians(raV)
76+
d1 = math.radians(decB)
77+
d2 = math.radians(decV)
78+
79+
#Calculate the distance from this source to the target
80+
81+
if abs(ra1-ra2)==0 and abs(d1-d2)==0:
82+
angSep = 0
83+
else:
84+
angSep = 3600*math.degrees(math.acos(math.sin(d1)*math.sin(d2)+math.cos(d1)*math.cos(d2)*math.cos(ra1-ra2)))
85+
86+
if angSep < maxDist and angSep<closest:
87+
88+
closest = angSep
89+
90+
bestB = Bmag
91+
92+
Bmag = bestB
93+
94+
if closest<maxDist:
95+
96+
string = str(raV)+","+str(decV)+","+str(round(Vmag,4))+","+str(round(Bmag,4))+","+str(round(Bmag-Vmag,4))
97+
outlist.append(string)
98+
matches = matches + 1
99+
100+
101+
102+
print(str(matches) + " matches found")
103+
104+
print("---------------------")
105+
print("Writing to file: " +outFile)
106+
107+
f= open(outFile,"a")
108+
109+
#write header
110+
f.write("RA,Dec,Vmag,Bmag,B-V\n")
111+
112+
lineNum=0
113+
114+
for line in outlist:
115+
116+
f.write(line+"\n")
117+
118+
f.close()
119+
120+
print("Done")

0 commit comments

Comments
 (0)