def slew(self, target): """Perform the slewing operation for the observatory to the given target. Parameters ---------- target : SALPY_scheduler.targetC The Scheduler topic instance holding the target information. Returns ------- float The time to slew the telescope from its current position to the target position. """ self.slew_count += 1 self.log.log(LoggingLevel.TRACE.value, "Slew count: {}".format(self.slew_count)) initial_slew_state = copy.deepcopy(self.model.current_state) self.log.log(LoggingLevel.TRACE.value, "Initial slew state: {}".format(initial_slew_state)) self.slew_initial_state = self.get_slew_state(initial_slew_state) sched_target = Target.from_topic(target) self.model.slew(sched_target) final_slew_state = copy.deepcopy(self.model.current_state) self.log.log(LoggingLevel.TRACE.value, "Final slew state: {}".format(final_slew_state)) self.slew_final_state = self.get_slew_state(final_slew_state) slew_time = (final_slew_state.time - initial_slew_state.time, "seconds") slew_distance = palpy.dsep(final_slew_state.ra_rad, final_slew_state.dec_rad, initial_slew_state.ra_rad, initial_slew_state.dec_rad) self.slew_history = SlewHistory(self.slew_count, initial_slew_state.time, final_slew_state.time, slew_time[0], math.degrees(slew_distance), self.observations_made) self.get_slew_activities() self.slew_maxspeeds = SlewMaxSpeeds(self.slew_count, final_slew_state.domalt_peakspeed, final_slew_state.domaz_peakspeed, final_slew_state.telalt_peakspeed, final_slew_state.telaz_peakspeed, final_slew_state.telrot_peakspeed, self.slew_count) return slew_time
def slew(self, target): """Perform the slewing operation for the observatory to the given target. Parameters ---------- target : SALPY_scheduler.targetC The Scheduler topic instance holding the target information. Returns ------- float The time to slew the telescope from its current position to the target position. """ self.slew_count += 1 self.log.log(LoggingLevel.TRACE.value, "Slew count: {}".format(self.slew_count)) initial_slew_state = copy.deepcopy(self.model.currentState) self.log.log(LoggingLevel.TRACE.value, "Initial slew state: {}".format(initial_slew_state)) self.slew_initial_state = self.get_slew_state(initial_slew_state) sched_target = Target.from_topic(target) self.model.slew(sched_target) final_slew_state = copy.deepcopy(self.model.currentState) self.log.log(LoggingLevel.TRACE.value, "Final slew state: {}".format(final_slew_state)) self.slew_final_state = self.get_slew_state(final_slew_state) slew_time = (final_slew_state.time - initial_slew_state.time, "seconds") slew_distance = palpy.dsep(final_slew_state.ra_rad, final_slew_state.dec_rad, initial_slew_state.ra_rad, initial_slew_state.dec_rad) self.slew_history = SlewHistory(self.slew_count, initial_slew_state.time, final_slew_state.time, slew_time[0], math.degrees(slew_distance), self.observations_made) self.get_slew_activities() self.slew_maxspeeds = SlewMaxSpeeds(self.slew_count, final_slew_state.domalt_peakspeed, final_slew_state.domaz_peakspeed, final_slew_state.telalt_peakspeed, final_slew_state.telaz_peakspeed, final_slew_state.telrot_peakspeed, self.slew_count) return slew_time
def distance(field0, fields): """ Compute the distance (on a sphere) between field0 and each one of fields. Input field0: a two dimensional list of floats/doubles (x, y) fields: a list of two dimensional list of floats/doubles ((x, y), ...) Output A list of N+1 distances, where N=len(fields). Each distance is the angular distance between pairs of coordinates. Note 1. x and y are assumed to be in radians. 2. x and y are assumed to be spherical coordinates. 3. This is a fallback solution in case an optimized version of this routine does not exist. """ #return([slalib.sla_dsep(field0[0], field0[1], field[0], field[1]) for field in fields]) return ([pal.dsep(field0[0], field0[1], field[0], field[1]) for field in fields])
def MoonProfile(self): (self.moonRA_RAD, self.moonDec_RAD, self.moonDiam) = pal.rdplan(self.mjd, 3, self.lon_RAD, self.lat_RAD) #print 'hello moon',self.moonRA_RAD, self.moonDec_RAD, self.moonDiam #getting the moon phase v6moon = pal.dmoon(self.mjd) Rmatrix = pal.prenut(2000.0, self.mjd) xyzMoon2000 = pal.dmxv(Rmatrix, v6moon) (moonra, moondec) = pal.dcc2s(xyzMoon2000) moonra = pal.dranrm(2.0 * math.pi + moonra) sun12 = pal.evp(self.mjd, 2000.0) sun3heliocentric = sun12[3] for i in range(3): sun3heliocentric[i] *= -1 (sunra, sundec) = pal.dcc2s(sun3heliocentric) sunra = pal.dranrm(2.0 * math.pi + sunra) moonsunsep = pal.dsep(sunra, sundec, moonra, moondec) self.moonPhase = ((1.0 - math.cos(moonsunsep)) / 2.0) * 100
def distance(field0, fields): """ Compute the distance (on a sphere) between field0 and each one of fields. Input field0: a two dimensional list of floats/doubles (x, y) fields: a list of two dimensional list of floats/doubles ((x, y), ...) Output A list of N+1 distances, where N=len(fields). Each distance is the angular distance between pairs of coordinates. Note 1. x and y are assumed to be in radians. 2. x and y are assumed to be spherical coordinates. 3. This is a fallback solution in case an optimized version of this routine does not exist. """ #return([slalib.sla_dsep(field0[0], field0[1], field[0], field[1]) for field in fields]) return ([ pal.dsep(field0[0], field0[1], field[0], field[1]) for field in fields ])
def __init__(self, ra, dec, mjd, date, filtre, airmass_opsim, extinction=0.172, skyBrightness=21.587): self.ra_RAD = ra self.dec_RAD = dec self.mjd = mjd self.k = extinction self.skyBrightness = skyBrightness self.date = date self.simEpoch = 59580 #self.simEpoch=53371 #if date<0.: ddate = self.date mjd_new = float(ddate) / float(DAY) + float(self.simEpoch) self.date = int((self.mjd - self.simEpoch) * float(DAY)) self.filter = filtre self.airmass_opsim = airmass_opsim self.lon_RAD = -70.7494 * DEG2RAD #obs site long (from sims_operations/conf/system/SiteCP.conf) self.lat_RAD = -30.2444 * DEG2RAD #obs site lat (from sims_operations/conf/system/SiteCP.conf) self.lst_RAD = self.Get_Sidereal_Time_at_Site( ) #local sidereal time at site (radians) # TWILIGHT LIMITS # Altitude of the Sun in degrees that define the twilight. # When the sun is above this limit and below the night limit, a special # twilight factor is included in the sky brightness model self.SunAltitudeTwilightLimit = -18.0 self.SunAltitudeNightLimit = -12.0 self.n1dp92104 = (1. / 0.92104) self.log34p08 = math.log(34.08) self.twilightBrightness = 17.3 self.fluxTwilight = 10.**((-self.twilightBrightness) / 2.5) self.MoonProfile() self.Moon_Distance() alpha = self.Get_alpha() self.distance2moon_RAD = pal.dsep(self.moonRA_RAD, self.moonDec_RAD, self.ra_RAD, self.dec_RAD) self.distance2moon_DEG = self.distance2moon_RAD * RAD2DEG lha_RAD = self.lst_RAD - self.ra_RAD (az_RAD, d1, d2, alt_RAD, d4, d5, pa_RAD, d7, d8) = pal.altaz(lha_RAD, self.dec_RAD, self.lat_RAD) # Altitude -> Zenith distance (degrees) targetZD_DEG = 90. - (alt_RAD * RAD2DEG) # Altitude -> Zenith distance (radian) zd_RAD = 1.5707963 - alt_RAD # Airmass #am = slalib.sla_airmas (zd_RAD) am = pal.airmas(zd_RAD) self.airmass_pal = am # Compute Raileigh scattering rs = (10.**5.36) * (1.06 + (math.cos(self.distance2moon_RAD))**2.) #rs = 2.27E5 * (1.06 + (math.cos(self.distance2moon_RAD)) ** 2.) # Compute Mie scattering #print 'distance',self.distance2moon_DEG if self.distance2moon_DEG > 10.: ms = 10.**(6.15 - (self.distance2moon_DEG / 40.)) else: ms = 6.2E7 / (self.distance2moon_DEG**2.) # Compute illumninace of the Moon i = 10.**(-0.4 * (3.84 + 0.026 * abs(alpha) + 4.E-9 * (alpha)**4.)) # Compute optical pathlength (in units of airmass) as a # function of the Zenith Distance (ZD) x = lambda z: (1. - 0.96 * (math.sin(z * DEG2RAD))**2.)**-0.5 #xa = lambda z: pal.airmas(z* DEG2RAD) #print 'airmass here',x(self.moonZD_DEG),xa(self.moonZD_DEG),x(targetZD_DEG),xa(targetZD_DEG),self.distance2moon_RAD,self.moonRA_RAD, self.moonDec_RAD,lha_RAD,zd_RAD,alt_RAD,self.lst_RAD,targetZD_DEG,self.mjd # Put all together (nanoLamberts)! moonBr = (rs + ms) * i * 10.**(-0.4 * self.k * x(self.moonZD_DEG)) moonBr *= (1. - 10.**(-0.4 * self.k * x(targetZD_DEG))) self.moon_airmass = x(self.moonZD_DEG) self.targetZD_DEG = targetZD_DEG self.target_airmass = x(targetZD_DEG) #print 'airmasses',self.target_airmass,self.airmass_opsim,pal.airmas(zd_RAD) # Taper brightness to 0, at moon altitude = self.sunAltitudeNightLimit if self.moonAlt_DEG < self.SunAltitudeNightLimit: moonBr = 0. elif self.moonAlt_DEG < 0. and self.moonAlt_DEG >= self.SunAltitudeNightLimit: moonBr *= (1 - self.moonAlt_DEG / self.SunAltitudeNightLimit) # Now, compute the dark sky brightness (in nanoLamberts) at # the Zenith from the same value in mag/arcsec^s skyBrightness = 34.08 * math.exp(20.7233 - 0.92104 * skyBrightness) # ... and at our position in the sky (targetZD_DEG) skyBr = skyBrightness * x(targetZD_DEG) * 10.**(-0.4 * self.k * (x(targetZD_DEG) - 1.)) # Add the brightness of the moon to that of the dark sky (nanoLamberts) self.moonBr = moonBr totBr = moonBr + skyBr # Transform it into mag/arcsec^2 #totBr = (1. / 0.92104) * math.log (34.08 * math.exp (20.7233) / totBr) totBr = self.n1dp92104 * (self.log34p08 + 20.7233 - math.log(totBr)) #print 'totbr',totBr #Get the Twilight profile self.TwilightProfile() #if self.date < self.sunSetTwil or self.date > self.sunRiseTwil: self.twilight = 0 (yy, mm, dd, hh, min, sec) = self.mjd2gre(mjd)[:6] if (hh < 20 and self.date > self.sunRiseTwil) or ( hh > 20 and self.date < self.sunSetTwil): totBr = -2.5 * math.log10(10.**( (-totBr) / 2.5) + self.fluxTwilight) self.twilight = 1 #print 'after twilight',totBr,self.date,self.sunSetTwil,self.sunRiseTwil #print 'filterskybrightness',self.FilterSkyBrightness(totBr) self.totBr = totBr self.skybrightness_moon = self.FilterSkyBrightness(totBr)