def evaluate(self): self.max_alt = 0 self.max_sun_alt = -2**30 self.min_range = 2**30 self.eclipsed = 0 self.measure_points = 0 for date, obj in tracker.sat_stepper(self.observer, self.obj, self.start, self.end, 10.0 / 86400): sun.compute(self.observer) self.measure_points += 1 if obj.eclipsed: self.eclipsed += 1 if obj.alt > self.max_alt: self.max_alt = obj.alt if sun.alt > self.max_sun_alt: self.max_sun_alt = sun.alt if obj.range < self.min_range: self.min_range = obj.range self.shadow_ratio = self.eclipsed * 100 / self.measure_points total = criteria.Score() total.add(Pass.shadow_crit, self.shadow_ratio) total.add(Pass.max_alt_crit, rad2deg(self.max_alt)) total.add(Pass.max_sun_alt_crit, rad2deg(self.max_sun_alt)) self.score = total.score()
def risings(observer, obj, start_date = ephem.now(), end_date = None): alt_func = calc_alt_func(obj, observer) stepper = tracker.sat_stepper(observer, obj, start_date, end_date) # keep going until the sat has set (we ignore risings which already happened before the func got initialized) for date, obj in stepper: if obj.alt < 0: break print date, "wait for the sat to set", obj.alt prev = None risen = False rise_date = set_date = None # step through the different steps and always look at two consecutive ones for date, obj in stepper: if prev != None: if risen: if obj.alt < 0: set_date = ephem.date(ephem.newton(alt_func, prev, date)) risen = False #print date, "set at ", set_date if set_date - rise_date > 60.0 / 86400: yield rise_date, set_date else: # ignore pass else: pass #print date, "still above horizon", obj.alt else: if obj.alt >= 0: rise_date = ephem.date(ephem.newton(alt_func, prev, date)) risen = True #print date, "rise at", rise_date else: pass #print date, "still below", obj.alt prev = date
import time, ephem, utils, tracker from utils import rad2deg from mpl_toolkits.basemap import Basemap import matplotlib.pyplot as plt import numpy as np from data import reto, iss lats = [] longs = [] start = ephem.now() for date, o in tracker.sat_stepper(reto, iss, start, start+ 1. / 24): lats.append(rad2deg(o.sublat)) longs.append(rad2deg(o.sublong)) # set up orthographic map projection with # perspective of satellite looking down at 50N, 100W. # use low resolution coastlines. # don't plot features that are smaller than 1000 square km. map = Basemap(projection='robin',lat_0=50,lon_0=-100, resolution='l',area_thresh=1000.) # draw coastlines, country boundaries, fill continents. map.drawcoastlines() map.drawcountries() map.fillcontinents(color='coral')