-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAutomator.py
executable file
·85 lines (82 loc) · 3.38 KB
/
Automator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
from unwise import unwise as uw
from astropy.table import Table
import numpy as np
import os
from toolie import MFTOOLIE as mft
import pandas as pd
class auto:
def run(self,plates,file):
dist = []
dist = np.array(dist)
lum = []
lum = np.array(lum)
sfr = []
sfr = np.array(sfr)
imfl = []
imfl = np.array(imfl)
scales = [1.5, 2, 2.5, 3] # Radius, 1.5,2,2.5,3
s1 = []
s1 = np.array(s1)
b = []
b = np.array(b)
pl = []
pl = np.array(pl)
print('Starting For loop for an array of '+str(len(plates))+' elements')
for i in range(len(plates)):
gal = mft(plates[i],locality='local') #Make sure to change locality to local when run in Utah
d = gal.findDist()
dist = np.append(dist, np.full(8, d))
pl = np.append(pl, np.full(8, plates[i]))
l = gal.findLum()
lum = np.append(lum, np.full(8, l))
strf = gal.findSFR()
sfr = np.append(sfr, np.full(8, strf))
axy = uw(plates[i], 3)
imfl = np.append(imfl, axy.getApFlux(scales))
b = np.append(b, [axy.band, axy.band, axy.band, axy.band])
s1 = np.append(s1, scales)
axy = uw(plates[i], 4)
imfl = np.append(imfl, axy.getApFlux(scales))
b = np.append(b, [axy.band, axy.band, axy.band, axy.band])
s1 = np.append(s1, scales)
data = pd.DataFrame(
{'Plate-IFU': pl, 'Distance': dist, 'Luminosity': lum, 'SFR': sfr, 'WISE Band': b, 'Scale of radius': s1,
'Flux': imfl},columns=['Plate-IFU','Distance','Luminosity','SFR','WISE Band','Scale of radius','Flux'])
data.to_csv(file,index=False)
print('Data table saved as = '+file)
def __init__(self,temp):
if temp=='0':
f = Table.read(os.getenv('MANGA_SPECTRO_REDUX')+'/MPL-9/drpall-v2_7_1.fits',format='fits')
r = f[f['mngtarg1'] > 0]
# ra=np.random.randint(0,len(r))
k = 0
a = []
while k < 5:
a.append(r[np.random.randint(0, len(r))]['plateifu'])
k = k + 1
a = np.array(a)
b = a.astype(str)
self.run(b,'/uufs/chpc.utah.edu/common/home/u6030555/data_folder/csv_data/test1.csv')
print('DONE!')
else:
umm=input('****WARNING: You are about to run the automator for the WHOLE drpall file****\n'
'Do you want to continue (y/[n])?')
if umm=='y':
f = Table.read(os.getenv('MANGA_SPECTRO_REDUX')+'/MPL-9/drpall-v2_7_1.fits',format='fits')
r = f[f['mngtarg1'] > 0]
k = 0
a = []
for i in range(len(r)):
a.append(r[i]['plateifu'])
a = np.array(a)
b = a.astype(str)
self.run(b,'/uufs/chpc.utah.edu/common/home/u6030555/data_folder/csv_data/full_MPL9.csv')
if umm=='n' or '':
print('Exiting Program')
return
if __name__=='__main__':
inp=input('\nType 0 for Demo, "exit" to exit, and anything else for the full thing -> ')
if inp =='exit':
print('Exiting Program')
else:
auto(inp)