Created
March 15, 2013 18:55
-
-
Save ferayebend/5172164 to your computer and use it in GitHub Desktop.
mine ESO instrument simulator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Name V RA DEC Paper | |
WD0030+44 16.59 00 33 02.78 +44 44 13.2 Zhao et al.(2012) | |
WD0315-011 10.03 03 18 25.0 -00 55 12 Catalan et al. (2008) | |
WD0413-077 9.50 04 15 21.786 -07 39 29.22 40 EriB Catalan et al. (2008) Zhao et al.(2012) | |
WD0615-591 14.09 06 16 14.26 -59 12 27.5 Zhao et al.(2012) | |
WD0642-285 15.2 06 44 28.727 -28 32 37.99 Zhao et al.(2012) | |
WD0845-188 15.68 08 47 29.44 -18 59 49.8 Zhao et al.(2012) | |
WD1354+340 16.20 13 57 06 +33 48.8 Catalan et al. (2008) | |
WD1544-374 12.80 15 47 30.11 -37 55 08.3 Zhao et al.(2012) | |
WD1544-377 12.80 15 47 30.11 -37 55 08.3 same as -374 Catalan et al. (2008) | |
WD1620-39 11.029 16 23 33.83733 -39 13 46.15 Zhao et al.(2012) | |
WD1620-391 11.03 16 23 33.84 -39 13 46.15 Catalan et al. (2008) | |
WD1659-531 13.47 17 02 56.334 -53 14 36.63 Catalan et al. (2008) | |
WD1706+33 15.92 17 08 52.06 +33 12 58.5 Zhao et al.(2012) | |
WD2253-08/1 16.5 22 55 49.42 -07 50 02.4 Catalan et al. (2008) Zhao et al.(2012) | |
#WD2350-083 23 53 28 -08 01.4 Zhao et al.(2012) | |
WD0437+138 14.92 04 28 17 +15 45 40 Claver et al. (2001) Teff=15335 | |
WD0438+108 13.83 04 28 17 +15 45 40 Claver et al. (2001) Teff=27390 | |
WD0431+125 14.18 04 28 17 +15 45 40 Claver et al. (2001) Teff=21340 | |
WD0425+168 14.02 04 28 17 +15 45 40 Claver et al. (2001) Teff=24420 | |
WD0421+125 14.29 04 28 17 +15 45 40 Claver et al. (2001) Teff=19570 | |
WD0406+169 15.35 04 28 17 +15 45 40 Claver et al. (2001) Teff=15180 | |
WD0352+098 14.47 04 28 17 +15 45 40 Claver et al. (2001) Teff=14770 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import mechanize | |
from math import sqrt | |
def loadData(inputFile,delimiter): | |
data = [] | |
for line in inputFile: | |
if line.startswith("#"): | |
continue | |
data.append([str(v) for v in line.strip().split(delimiter)]) | |
return data | |
def transpose(data): | |
return [[data[j][i] for j in range(len(data))] for i in range(len(data[0]))] | |
def transposef(data): | |
return [[float(data[j][i]) for j in range(len(data))] for i in range(len(data[0]))] | |
def fillRepetitions(array): | |
newlist= [] | |
for i in range(len(array)): | |
if array[i].replace(' ',''): | |
newlist.append(float(array[i].replace('?','10000'))) | |
else: #if float(newlist[i])==True: | |
newlist.append(float(newlist[i-1])) | |
#else: | |
# print "smt strange" | |
return newlist | |
def extractExposure(result): | |
for line in result.strip().split('\n'): | |
if "Exposure" in line: | |
exposure = line.split()[-2][:-4] # normally line is smt like ['Exposure', 'Time', '(1', 'exposure)', ':', '<b>', '100.000</b>', 'seconds'] | |
return exposure | |
def extractS2N(result): | |
for line in result.strip().split('\n'): | |
if "Signal to Noise (*)" in line: | |
signal = float(line.split()[-1][:-4]) # normally line is smt like ['Signal', 'to', 'Noise', '(*)', 'at', 'central', 'wavelength', ':', '<b>', '203.674</b>'] | |
return signal | |
def initializeForm(br): | |
br.select_form(nr=0) | |
''' fixed button selections | |
SRC.MAG.BAND=[U, B, *V, R, I] | |
SKY.MOON.DAYS=[0, *3, 7, 10, 14] | |
USR.OUT.MODE = [USR.OUT.MODE.SNR, *USR.OUT.MODE.EXPOSURE.TIME] | |
INS.POLARIMETRY.MODE = [*none, linear] | |
INS.SLIT.MODE.PRESET=[SLIT1, *SLIT2, SLIT3, SLIT4, SLIT5, SLIT6, SLITA, SLIT7, SLIT8] #correspond to [0.28,0.40,0.51,0.70,1.0,1.31,1.60,2.0,2.50] arcseconds | |
INS.GRISM.FROM.LIST=[GRISM9, GRISMTEN, GRISM6, GRISM7, GRISM8, GRISM_300I_OG590, *GRISM1, 600RI+19, 600Z+23, GRISMB, GRIS_1200B+97, GRISMF, GRISMC, (=======================================================), (NOTE! The following grisms are only available in Visitor Mode !), (=======================================================), GRISM2A, GRIS_1200g+96, GRISM3, GRISM4, GRISMA] | |
INS.RESOLUTION=[*SR, HR] | |
''' | |
''' select ''' | |
br.form["INS.POLARIMETRY.MODE"] = ["linear"] | |
#br.form["USR.OUT.MODE"] = ["USR.OUT.MODE.SNR"] | |
br.form["USR.OUT.MODE"] = ["USR.OUT.MODE.EXPOSURE.TIME"] | |
br.form["INS.SLIT.MODE.PRESET"] = ["SLIT5"] | |
br.form["INS.GRISM.FROM.LIST"] = ["GRISM1"] | |
br.form["SKY.MOON.DAYS"] = ["7"] | |
br.form["INS.RESOLUTION"] = ["HR"] | |
''' value select''' | |
S2N = "425" #corresponds to 3sigma signal for V/I according to 3*100*sqrt(2) | |
exposure = "1664" | |
magnitude = "15.8" | |
airmass = "1.60" | |
seeing = "0.80" | |
Teff = "10000" | |
br.form["SRC.BB.TEMP"] = Teff | |
br.form["INS.S2N.VALUE"]=S2N | |
br.form["USR.OUT.MODE.EXPOSURE.TIME"]=exposure | |
br.form["SRC.MAG"]=magnitude | |
br.form["SKY.AIRMASS"]=airmass | |
br.form["SKY.SEEING"]=seeing | |
#print br.form | |
def checkObs(): | |
br = mechanize.Browser() | |
br.open("http://www.eso.org/observing/etc/bin/gen/form?INS.NAME=FORS+INS.MODE=spectro") | |
table = 'bagnulotable.dat' | |
data = transpose(loadData(open(table),'&')) | |
names = data[0] | |
magnitudes = fillRepetitions(data[2]) | |
Teff = fillRepetitions(data[4]) | |
ts = data[7] | |
B_sigmas = data[10] | |
obs_sigmas = [] | |
r = open('ESOFORMresults.dat','w') | |
r.write('#magnitude(V) T_eff(K) exposure(s) sigma (B/sigma) sigma (P_v/sigma)\n') | |
for i in range(len(ts)): | |
initializeForm(br) | |
br.form["SRC.BB.TEMP"] = str(Teff[i]) | |
br.form["USR.OUT.MODE.EXPOSURE.TIME"]=str(ts[i]) | |
br.form["SRC.MAG"]=str(magnitudes[i]) | |
response = br.submit() | |
result = response.read() | |
s2n = extractS2N(result) | |
print s2n, 'sigma', s2n/sqrt(2)/100 | |
obs_sigmas.append(s2n/sqrt(2)/100.0) | |
ln = '%8.1f \t %8.0f \t %s \t %s \t %10.4f \n'%(magnitudes[i],Teff[i],ts[i],B_sigmas[i],obs_sigmas[i]) | |
r.write(ln) | |
br.back() | |
r.close() | |
if __name__ == '__main__': | |
br = mechanize.Browser() | |
br.open("http://www.eso.org/observing/etc/bin/gen/form?INS.NAME=FORS+INS.MODE=spectro") | |
silvia = 'list_objects_short.txt' | |
data = transpose(loadData(open(silvia),'\t')) | |
magnitudes = data[1] | |
obs_exposures = [] | |
r = open('Exposures.dat','w') | |
r.write('#Name V exposure(s) RA DEC Paper\n') | |
for i in range(len(magnitudes)): | |
initializeForm(br) | |
br.form["USR.OUT.MODE"] = ["USR.OUT.MODE.SNR"] | |
br.form["SRC.MAG"]=str(magnitudes[i]) | |
response = br.submit() | |
result = response.read() | |
obs_exposure = extractExposure(result) | |
print magnitudes[i],obs_exposure | |
obs_exposures.append(obs_exposure) | |
ln = '%s \t %s \t %s \t %s \t %s \t %s \n'%(data[0][i], magnitudes[i],obs_exposures[i],data[2][i],data[3][i],data[4][i],) | |
r.write(ln) | |
br.back() | |
r.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment