Exemple #1
0
config.read("telescope_server.ini")
server_name = config.get("server", "name")  #e.g. 10.0.0.1
server_port = config.getint("server", "port")  #e.g. 4030
#server_name = socket.gethostbyname(socket.gethostname())
#if server_name.startswith("127.0."): #e.g. 127.0.0.1
#    #This works on Linux but not on Mac OS X or Windows:
#    server_name = commands.getoutput("/sbin/ifconfig").split("\n")[1].split()[1][5:]
##server_name = "10.0.0.1" #Override for wifi access
#server_port = 4030 #Default port used by SkySafari

#If default to low precision, SkySafari turns it on anyway:
high_precision = True

#Default to Greenwich, GMT - Latitude 51deg 28' 38'' N, Longitude zero
local_site = obstools.Site(
    coords.AngularCoordinate(config.get("site", "latitude")),
    coords.AngularCoordinate(config.get("site", "longitude")),
    tz=0)
#Rather than messing with the system clock, will store any difference
#between the local computer's date/time and any date/time set by the
#client (which should match any location set by the client).
local_time_offset = 0

#This will probably best be inferred by calibration...
#For Greenwich, magnetic north is estimated to be 2 deg 40 min west
#of grid north at Greenwich in July 2013.
#http://www.geomag.bgs.ac.uk/data_service/models_compass/gma_calc.html
#local_site_magnetic_offset = -2.67 * pi / 180.0

#These will come from sensor information... storing them in radians
local_alt = 85 * pi / 180.0
local_az = 30 * pi / 180.0
Exemple #2
0
defaultObservationCmd = "~/PSR_8bit_Scripts/Observe_DE601_C34.py"
defaultOutputPath = os.getcwd() + "/schedule.txt"
defaultAllowIdle = False
defaultIdlePenalty = 2
defaultInitialRetries = 20
defaultTimePenalty = 1
defaultDropPenalty = 500
defaultLocation = 'DE609'
defaultLogPath = os.getcwd()
defaultObserverSetupTime = 2
defaultInputPath = None

# Config:
maxObsDays = 4  # in case no limit is specified
sites = dict(DE609=obstools.Site(lat=coords.AngularCoordinate('53d42m0s'),
                                 long=coords.AngularCoordinate('9d58m50s'),
                                 name="DE609"),
             DE601=obstools.Site(lat=coords.AngularCoordinate('50d31m0s'),
                                 long=coords.AngularCoordinate('6d53m0s'),
                                 name="DE601"),
             DE602=obstools.Site(lat=coords.AngularCoordinate('48d30m4s'),
                                 long=coords.AngularCoordinate('11d17m13s'),
                                 name="DE602"),
             DE603=obstools.Site(lat=coords.AngularCoordinate('50d59m0s'),
                                 long=coords.AngularCoordinate('11d43m0s'),
                                 name="DE603"),
             DE605=obstools.Site(lat=coords.AngularCoordinate('50d55m0s'),
                                 long=coords.AngularCoordinate('6d21m0s'),
                                 name="DE605"),
             SE607=obstools.Site(lat=coords.AngularCoordinate('57d23m54s'),
                                 long=coords.AngularCoordinate('11d55m50s'),
Exemple #3
0
def observability(apg, par, times, lengths, loud=True, south=False):
    obs_start = time()
    if south:
        obs_site = obs.Site(-29.0182, -70.6915)
    else:
        obs_site = obs.Site(32.789278, -105.820278)
    obsarr = np.zeros([len(apg), len(times)])
    beglst = [obs_site.localSiderialTime(x) for x in times]
    endlst = [
        obs_site.localSiderialTime(times[x] + lengths[x] / 24)
        for x in range(len(times))
    ]

    # Determine moon coordinates
    mpos = []
    for t in range(len(times)):
        mooncoords = moonpos(times[t])
        mpos.append(coo.ICRSCoordinates(mooncoords[0], mooncoords[1]))

    if loud:
        df = open('apogeeobs.txt', 'w')
    # Loop over all plates
    for p in range(len(apg)):
        # Initalize obsarr row
        if apg[p].priority <= 0:
            continue
        for t in range(len(times)):
            obsarr[p, t] = apg[p].priority

        if apg[p].manual_priority == 10:
            extra_time = 0.25  # add 15 minute buffer
        else:
            extra_time = 0
        # Compute observing constants
        platecoo = coo.ICRSCoordinates(apg[p].ra, apg[p].dec)
        platelst = float(apg[p].ra + apg[p].ha) / 15
        minlst = float(apg[p].ra + apg[p].minha) / 15 - extra_time
        maxlst = float(apg[p].ra + apg[p].maxha) / 15 + extra_time

        for t in range(len(times)):
            # Adjust LSTs for 24 hour wrapping
            usedminlst, usedmaxlst = minlst, maxlst
            if minlst < 0 and beglst[t] > 12 and endlst[t] > 12:
                usedminlst += 24
                usedmaxlst += 24
            if maxlst > 24 and beglst[t] < 12 and endlst[t] < 12:
                usedminlst -= 24
                usedmaxlst -= 24
            if beglst[t] > endlst[t]:
                if minlst < 12:
                    usedminlst += 24
                if maxlst > 12:
                    usedmaxlst -= 24

            # Adjust LSTs for Gaussian with 24 hour wrapping
            if beglst[t] > endlst[t]:
                lstsum = beglst[t] + endlst[t] - 24
                if platelst > 12:
                    usedplatelst = platelst - 24
                else:
                    usedplatelst = platelst
            else:
                lstsum = beglst[t] + endlst[t]
                if beglst[t] > 18 and platelst < 4:
                    usedplatelst = platelst + 24
                elif beglst[t] < 4 and platelst > 18:
                    usedplatelst = platelst - 24
                else:
                    usedplatelst = platelst

            # Gaussian prioritization on time from transit
            obsarr[p, t] += 50.0 * float(
                np.exp(-(usedplatelst - lstsum / 2 + lengths[t] / 2)**2 / 2))

            # Moon avoidance
            moondist = mpos[t] - platecoo
            if moondist.d < par['moon_threshold']:
                obsarr[p, t] = -3
                continue

            # Determine whether HAs of block are within observational range
            if beglst[t] < usedminlst or endlst[t] > usedmaxlst:
                obsarr[p, t] = -1
                continue

            # Compute horiztonal coordinates
            horz = obs_site.apparentCoordinates(
                platecoo,
                datetime=[
                    times[t] + lengths[t] / 2 / 24 * x for x in range(3)
                ])
            secz = [
                1 / np.cos((90.0 - horz[x].alt.d) * np.pi / 180)
                for x in range(len(horz))
            ]
            # Check whether any of the points contain a bad airmass value
            if south:
                badsecz = [x for x in secz if x > par['maxz']]
            # Check again to ignore zenith avoidance for priority 10 plates in the north
            elif apg[p].manual_priority == 10:
                badsecz = [x for x in secz if x > par['maxz']]
            else:
                badsecz = [x for x in secz if x < 1.003 or x > par['maxz']]
            if len(badsecz) > 0:
                obsarr[p, t] = -2

            # Lower the priority of long exposure plates in the last slot
            if t == len(times) - 1:
                if apg[p].exp_time == 1000.0:
                    obsarr[p, t] = obsarr[p, t] / 3.0

            # Lower priorities for all plates that aren't vplan == 1 for short slots. The priority order should be:
            # vpan == 1, vplan > 3, vplan == 3, cadence == kep_koi or substellar, long exposure
            if lengths[t] < 1.0:
                if apg[p].exp_time == 1000.0:
                    obsarr[p, t] = obsarr[p, t] / 3.0
                elif apg[p].cadence == 'kep_koi' or apg[
                        p].cadence == 'substellar':
                    obsarr[p, t] = obsarr[p, t] / 2.5
                elif apg[p].vplan == 3:
                    obsarr[p, t] = obsarr[p, t] / 2.0
                elif apg[p].vplan > 3:
                    obsarr[p, t] = obsarr[p, t] / 1.5

        if loud:
            print(apg[p].plateid,
                  minlst,
                  maxlst,
                  obs_site.localTime(minlst, utc=True),
                  obs_site.localTime(maxlst, utc=True),
                  obsarr[p, :],
                  file=df)

    obs_end = time()
    if loud:
        print("[PY] Determined APOGEE-II observability (%.3f sec)" %
              (obs_end - obs_start))

    if loud:
        df.close()

    return obsarr
Exemple #4
0
def observability(ebo, par, times, loud=True):
    obs_start = time()
    apo = obs.Site(32.789278, -105.820278)
    obsarr = np.zeros([len(ebo), len(times)])
    beglst = [apo.localSiderialTime(x) for x in times]
    endlst = [apo.localSiderialTime(times[x] + par['exposure']/60/24) for x in range(len(times))]
    
    # Determine moon coordinates
    mpos = []
    for t in range(len(times)):
        mooncoords = moonpos(times[t])
        mpos.append(coo.ICRSCoordinates(mooncoords[0], mooncoords[1]))
    
    # Loop over all plates
    for p in range(len(ebo)):
        # Initalize obsarr row
        for t in range(len(times)): obsarr[p,t] = ebo[p].manual_priority * 100
        
        # Compute observing constants
        platecoo = coo.ICRSCoordinates(ebo[p].ra, ebo[p].dec)
        platelst = float(ebo[p].ra + ebo[p].ha) / 15
        try: 
            minlst = float(ebo[p].ra + ebo[p].minha) / 15
        except:
            print("Plate Missing minha info: {}".format(ebo[p].plateid))
            continue

        maxlst = float(ebo[p].ra + ebo[p].maxha) / 15
        
        for t in range(len(times)): 
            # Adjust LSTs for 24 hour wrapping
            usedminlst, usedmaxlst = minlst, maxlst
            if minlst < 0 and beglst[t] > 12 and endlst[t] > 12:
                usedminlst += 24
                usedmaxlst += 24
            if maxlst > 24 and beglst[t] < 12 and endlst[t] < 12:
                usedminlst -= 24
                usedmaxlst -= 24
            if beglst[t] > endlst[t]:
                if minlst < 12: usedminlst += 24
                if maxlst > 12: usedmaxlst -= 24
                
            # Adjust LSTs for Gaussian with 24 hour wrapping
            if beglst[t] > endlst[t]:
                lstsum = beglst[t]+endlst[t]-24
                if platelst > 12: usedplatelst = platelst - 24
                else: usedplatelst = platelst
            else:
                lstsum = beglst[t]+endlst[t]
                if beglst[t] > 18 and platelst < 4: usedplatelst = platelst + 24
                elif beglst[t] < 4 and platelst > 18: usedplatelst = platelst - 24
                else: usedplatelst = platelst
        
            # Gaussian prioritization on time from transit
            obsarr[p,t] += 50.0 * float(np.exp( -(usedplatelst - lstsum/2 + par['exposure']/60/2)**2 / 2))
        
            # Moon avoidance
            moondist = mpos[t] - platecoo
            if moondist.d < par['moon_threshold']:
                obsarr[p,t] = -3
                continue
            
            # Determine whether HAs of block are within observational range
            if beglst[t] < usedminlst or endlst[t] > usedmaxlst: 
                obsarr[p,t] = -1
                continue
        
            # Compute horiztonal coordinates
            horz = apo.apparentCoordinates(platecoo, datetime=times[t] + par['exposure'] / 60 / 2 / 24)
            secz = 1/np.cos((90.0 - horz[0].alt.d) * np.pi / 180)
            # Check whether any of the points contain a bad airmass value
            if secz < 1.003 or secz > par['maxz']: obsarr[p,t] = -2
    obs_end = time()
    if loud: print("[PY] Determined eBOSS observability (%.3f sec)" % (obs_end - obs_start))
    return obsarr
Exemple #5
0
from __future__ import print_function, division
import astropysics.obstools as obs
import numpy as np
import sys
import matplotlib.pyplot as plt
import json

weather = 0.50
south_frac = 0.75
apg_frac = 1
man_frac = 12.6
ebo_frac = 5.3

apo = obs.Site(32.789278, -105.820278)
schedule = np.loadtxt(sys.argv[1])
apg_lst, man_lst, ebo_lst = np.zeros(24), np.zeros(24), np.zeros(24)
apg_met, man_met, ebo_met = [], [], []

for d in range(schedule.shape[0]):
	# APOGEE-II LST Calculations
	apg_start, apg_end = schedule[d,4], schedule[d,5]
	if apg_start > 1:
		apg_length = int((apg_end - apg_start) * 24 * 60 / 87 + 0.4)
		midpts = apg_start + np.arange(apg_length)*(87/60/24) + 0.5/24
		apg_nightlst = [apo.localSiderialTime(x) for x in midpts]
		for l in apg_nightlst: apg_lst[int(l)] += 87/60
		if len(apg_met) == 0: apg_met.append([int(schedule[d,0]-2400000), len(apg_nightlst)])
		else: apg_met.append([int(schedule[d,0]-2400000), len(apg_nightlst) + apg_met[-1][1]])
	else:
		if len(apg_met) == 0: apg_met.append([int(schedule[d,0]-2400000), 0])
		else: apg_met.append([int(schedule[d,0]-2400000), apg_met[-1][1]])