Skip to content

Instantly share code, notes, and snippets.

@j-faria j-faria/etc.py
Last active Dec 6, 2018

Embed
What would you like to do?
Query the ESPRESSO ETC
import re
import requests
from itertools import product
import numpy as np
url = 'https://www.eso.org/observing/etc/bin/simu/espresso'
form_data = {
'almanac_time_option': 'almanac_time_option_ut_time',
'COORD.DEC': '00:00:00',
'COORD.RA': '04:00:00',
'INS.DET.EXP.TIME.VAL': '30.000',
'INS.ESPRESSO.MODE': 'single_HR_1x1_fast',
'INS.FEED.UT.COUNT': '1',
'INS.GEN.TABLE.RES.SWITCH.VAL': 'yes',
'INS.GEN.TABLE.SF.SWITCH.VAL': 'yes',
'INS.MODE': 'spectro',
'INS.NAME': 'ESPRESSO',
'POSTFILE.FLAG': '0',
'RESULT.RV.PRECISION.FLAG': '1',
'SKY.AIRMASS': '1.5',
'SKY.MOON.FLI': '0.5',
'SKY.SEEING.ZENITH.V': '1.00',
'SKYMODEL.ECL.LAT': '90',
'SKYMODEL.ECL.LON': '135',
'SKYMODEL.INCL.AIRGLOW': 'Y',
'SKYMODEL.INCL.MOLEC.EMIS.LOWER.ATM': 'Y',
'SKYMODEL.INCL.MOLEC.EMIS.UPPER.ATM': 'Y',
'SKYMODEL.INCL.MOON': 'Y',
'SKYMODEL.INCL.STARLIGHT': 'Y',
'SKYMODEL.INCL.THERMAL': 'N',
'SKYMODEL.INCL.ZODIACAL': 'Y',
'SKYMODEL.MOON.ALT': '45',
'SKYMODEL.MOON.EARTH.DIST': '1',
'SKYMODEL.MOON.SUN.SEP': '90.000',
'SKYMODEL.MOON.TARGET.SEP': '45',
'SKYMODEL.MSOLFLUX': '130.00',
'SKYMODEL.PWV.MODE': 'pwv',
'SKYMODEL.SEASON': '0',
'SKYMODEL.TARGET.ALT': '90.000',
'SKYMODEL.THERMAL.E1': '0.20',
'SKYMODEL.THERMAL.E2': '0.10',
'SKYMODEL.THERMAL.E3': '0.01',
'SKYMODEL.THERMAL.T1': '+285.0',
'SKYMODEL.THERMAL.T2': '+288.0',
'SKYMODEL.THERMAL.T3': '++33.0',
'SKYMODEL.TIME': '0',
'SRC.TARGET.GEOM': 'seeing_ltd',
'SRC.TARGET.MAG': '7.00',
'SRC.TARGET.MAG.BAND': 'V',
'SRC.TARGET.MAG.SYSTEM': 'Vega',
'SRC.TARGET.REDSHIFT': '0.00',
'SRC.TARGET.SPEC.TYPE': 'Kurucz_G2V',
'SRC.TARGET.TYPE': 'template_spectrum',
'step_size': '1',
'toggleTables': 'on',
'USR.SEEING.OR.IQ': 'seeing_given',
'USR.SESSION.ID': 'non-init',
'ut_time': '07/12/2018+03:04:08',
}
def query(exptime=30, Vmag=7, airmass=1.5):
fill = form_data
fill['INS.DET.EXP.TIME.VAL'] = str(exptime)
fill['SRC.TARGET.MAG'] = str(Vmag)
fill['SKY.AIRMASS'] = str(airmass)
r = requests.post(url, data=fill)
return r
def RVprecision(**kwargs):
r = query(**kwargs)
a = re.compile(r"[-+]?\d*\.\d+ m/s")
precision = re.findall(a, r.text)[0]
return precision
grid = product(
np.linspace(1, 1.5, 10), # airmass grid
np.linspace(5, 11, 10), # Vmag grid
)
for airmass, Vmag in grid:
print(f'airmass: {airmass:>6.3f} Vmag: {Vmag:>6.3f}', end=' - ')
precision = RVprecision(exptime=900, Vmag=Vmag, airmass=airmass)
print(f'{precision:10s}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.