def __init__(self, num_RA_sources, num_De_sources): ''' constructor ''' AbstractAstronomicalSource.__init__(self) self.LINE_COLOR = 0x14F8EFBC # These are great (semi)circles, so only need 3 points. self.NUM_DEC_VERTICES = 3 # every 10 degrees self.NUM_RA_VERTICES = 36 self.line_sources = [] self.text_sources = [] for r in range(0, num_RA_sources): self.line_sources.append(self.create_ra_line(r, num_RA_sources)) for d in range(0, num_De_sources): self.line_sources.append(self.create_dec_line(d, num_De_sources)) # North & South pole, hour markers every 2hrs. self.text_sources.append(TextSource("NP", self.LINE_COLOR, get_instance(0.0, 90.0))) self.text_sources.append(TextSource("SP", self.LINE_COLOR, get_instance(0.0, -90.0))) for index in range(0, 12): ra = index * 30.0 title = str(index * 2) + "h" self.text_sources.append(TextSource(title, self.LINE_COLOR, get_instance(ra, 0.0)))
def __init__(self, num_RA_sources, num_De_sources): ''' constructor ''' AbstractAstronomicalSource.__init__(self) self.LINE_COLOR = 0x14F8EFBC # These are great (semi)circles, so only need 3 points. self.NUM_DEC_VERTICES = 3 # every 10 degrees self.NUM_RA_VERTICES = 36 self.line_sources = [] self.text_sources = [] for r in range(0, num_RA_sources): self.line_sources.append(self.create_ra_line( r, num_RA_sources)) for d in range(0, num_De_sources): self.line_sources.append( self.create_dec_line(d, num_De_sources)) # North & South pole, hour markers every 2hrs. self.text_sources.append( TextSource("NP", self.LINE_COLOR, get_instance(0.0, 90.0))) self.text_sources.append( TextSource("SP", self.LINE_COLOR, get_instance(0.0, -90.0))) for index in range(0, 12): ra = index * 30.0 title = str(index * 2) + "h" self.text_sources.append( TextSource(title, self.LINE_COLOR, get_instance(ra, 0.0)))
def __init__(self): ''' constructor ''' AbstractAstronomicalSource.__init__(self) self.line_sources = [] self.text_sources = [] title = "Ecliptic" self.text_sources.append( TextSource(title, self.LINE_COLOR, get_instance(90.0, self.EPSILON))) self.text_sources.append( TextSource(title, self.LINE_COLOR, get_instance(270.0, -self.EPSILON))) # Create line source. ra = [0.0, 90.0, 180.0, 270.0, 0.0] dec = [0.0, self.EPSILON, 0.0, -self.EPSILON, 0.0] vertices = [] for i in range(0, len(ra)): vertices.append(get_instance(ra[i], dec[i])) self.line_sources.append(LineSource(vertices, self.LINE_COLOR, 1.5))
def initialize_showers(self): ''' A list of all the meteor showers with > 10 per hour Source: http://www.imo.net/calendar/2011#table5 Note the zero-based month. 10=November Actual start for Quadrantids is December 28 - but we can't cross a year boundary. ''' self.showers.append(self.Shower("Quadrantids", get_instance(230, 49), dt.datetime(self.ANY_OLD_YEAR,1,1,0,0,0).timetuple(), dt.datetime(self.ANY_OLD_YEAR,1,4,0,0,0).timetuple(), dt.datetime(self.ANY_OLD_YEAR,1,12,0,0,0).timetuple(), 120)) self.showers.append(self.Shower("Lyrids", get_instance(271, 34), dt.datetime(self.ANY_OLD_YEAR,4,16,0,0,0).timetuple(), dt.datetime(self.ANY_OLD_YEAR,4,22,0,0,0).timetuple(), dt.datetime(self.ANY_OLD_YEAR,4,25,0,0,0).timetuple(), 18)) self.showers.append(self.Shower("Eta Aquariids", get_instance(338, -1), dt.datetime(self.ANY_OLD_YEAR,4,19,0,0,0).timetuple(), dt.datetime(self.ANY_OLD_YEAR,5,6,0,0,0).timetuple(), dt.datetime(self.ANY_OLD_YEAR,5,28,0,0,0).timetuple(), 70)) self.showers.append(self.Shower("Delta Aquariids", get_instance(340, -16), dt.datetime(self.ANY_OLD_YEAR,7,12,0,0,0).timetuple(), dt.datetime(self.ANY_OLD_YEAR,7,30,0,0,0).timetuple(), dt.datetime(self.ANY_OLD_YEAR,8,23,0,0,0).timetuple(), 16)) self.showers.append(self.Shower("Perseids", get_instance(48, 58), dt.datetime(self.ANY_OLD_YEAR,7,17,0,0,0).timetuple(), dt.datetime(self.ANY_OLD_YEAR,8,13,0,0,0).timetuple(), dt.datetime(self.ANY_OLD_YEAR,8,24,0,0,0).timetuple(), 100)) self.showers.append(self.Shower("Orionids", get_instance(95, 16), dt.datetime(self.ANY_OLD_YEAR,10,2,0,0,0).timetuple(), dt.datetime(self.ANY_OLD_YEAR,10,21,0,0,0).timetuple(), dt.datetime(self.ANY_OLD_YEAR,11,7,0,0,0).timetuple(), 25)) self.showers.append(self.Shower("Leonids", get_instance(152, 22), dt.datetime(self.ANY_OLD_YEAR,11,6,0,0,0).timetuple(), dt.datetime(self.ANY_OLD_YEAR,11,18,0,0,0).timetuple(), dt.datetime(self.ANY_OLD_YEAR,11,30,0,0,0).timetuple(), 20)) self.showers.append(self.Shower("Puppid-Velids", get_instance(123, -45), dt.datetime(self.ANY_OLD_YEAR,12,1,0,0,0).timetuple(), dt.datetime(self.ANY_OLD_YEAR,12,7,0,0,0).timetuple(), dt.datetime(self.ANY_OLD_YEAR,12,15,0,0,0).timetuple(), 10)) self.showers.append(self.Shower("Geminids", get_instance(112, 33), dt.datetime(self.ANY_OLD_YEAR,12,7,0,0,0).timetuple(), dt.datetime(self.ANY_OLD_YEAR,12,14,0,0,0).timetuple(), dt.datetime(self.ANY_OLD_YEAR,12,17,0,0,0).timetuple(), 120)) self.showers.append(self.Shower("Ursids", get_instance(217, 76), dt.datetime(self.ANY_OLD_YEAR,12,17,0,0,0).timetuple(), dt.datetime(self.ANY_OLD_YEAR,12,23,0,0,0).timetuple(), dt.datetime(self.ANY_OLD_YEAR,12,26,0,0,0).timetuple(), 10))
def create_dec_line(self, index, num_dec_sources): ''' Creates a single latitudinal line. ''' line = LineSource([], self.LINE_COLOR) dec = 90.0 - (index + 1.0) * 180.0 / (num_dec_sources + 1.0) for i in range(0, self.NUM_RA_VERTICES): ra = i * 360.0 / self.NUM_RA_VERTICES ra_dec = RaDec(ra, dec) line.ra_decs.append(ra_dec) line.gc_vertices.append(get_instance(ra, dec)) ra_dec = RaDec(0.0, dec) line.ra_decs.append(ra_dec) line.gc_vertices.append(get_instance(0.0, dec)) return line
def calculate_local_north_and_up_in_celestial_coords(self, force_update): current_time = self.get_time_in_millis() diff = math.fabs(current_time - self.celestial_coords_last_updated) if (not force_update) and diff < self.MINIMUM_TIME_BETWEEN_CELESTIAL_COORD_UPDATES_MILLIS: return self.celestial_coords_last_updated = current_time self.update_magnetic_correction() up_ra, up_dec = Geometry.calculate_RADec_of_zenith(self.get_time(), self.location) self.up_celestial = get_instance(up_ra, up_dec) z = self.AXIS_OF_EARTHS_ROTATION z_dotu = Geometry.scalar_product(self.up_celestial, z) self.true_north_celestial = \ Geometry.add_vectors(z, Geometry.scale_vector(self.up_celestial, -z_dotu)) self.true_north_celestial.normalize() self.true_east_celestial = Geometry.vector_product(self.true_north_celestial, \ self.up_celestial) # Apply magnetic correction. Rather than correct the phone's axes for # the magnetic declination, it's more efficient to rotate the # celestial axes by the same amount in the opposite direction. declination = self.magnetic_declination_calc.get_declination() rotation_matrix = Geometry.calculate_rotation_matrix(declination, self.up_celestial) magnetic_north_celestial = Geometry.matrix_vector_multiply(rotation_matrix, \ self.true_north_celestial) magnetic_east_celestial = Geometry.vector_product(magnetic_north_celestial, \ self.up_celestial) self.axes_magnetic_celestial_matrix = get_colmatrix_from_vectors(magnetic_north_celestial, \ self.up_celestial, \ magnetic_east_celestial)
def create_ra_line(self, index, num_ra_sources): ''' Constructs a single longitude line. These lines run from the north pole to the south pole at fixed Right Ascensions. ''' line = LineSource([], self.LINE_COLOR) ra = index * 360.0 / num_ra_sources for i in range(0, self.NUM_DEC_VERTICES - 1): dec = 90.0 - i * 180.0 / (self.NUM_DEC_VERTICES - 1) ra_dec = RaDec(ra, dec) line.ra_decs.append(ra_dec) line.gc_vertices.append(get_instance(ra, dec)) ra_dec = RaDec(0.0, -90.0) line.ra_decs.append(ra_dec) line.gc_vertices.append(get_instance(0.0, -90.0)) return line
def __init__(self, new_color, new_size, geo_coords=get_instance(0.0, 0.0), new_shape=shape_enum.CIRCLE): """ Constructor """ Source.__init__(self, new_color, geo_coords) self.size = new_size self.point_shape = new_shape
def get_points(self): point_list = [] for p in self.astro_source_proto.point: gc_proto = p.location gc = get_instance(gc_proto.right_ascension, gc_proto.declination) point_list.append(PointSource(p.color, p.size, gc, self.shape_map[p.shape])) return point_list
def __init__(self, new_color, geo_coords=get_instance(0.0, 0.0)): ''' Constructor ''' self.color = new_color self.geocentric_coords = geo_coords self.granulatriy = None self.name_list = []
def get_points(self): point_list = [] for p in self.astro_source_proto.point: gc_proto = p.location gc = get_instance(gc_proto.right_ascension, gc_proto.declination) point_list.append( PointSource(p.color, p.size, gc, self.shape_map[p.shape])) return point_list
def __init__(self, new_color, new_size, geo_coords=get_instance(0.0, 0.0), \ new_shape=shape_enum.CIRCLE): ''' Constructor ''' Source.__init__(self, new_color, geo_coords) self.size = new_size self.point_shape = new_shape
def __init__(self, new_label, color, geo_coords=get_instance(0.0, 0.0), \ new_offset=0.02, new_fontsize=15): ''' Constructor ''' Source.__init__(self, color, geo_coords) self.label = new_label self.offset = new_offset self.font_size = new_fontsize
def get_labels(self): ''' Strings are loaded from strings.txt in the assets folder. ''' label_list = [] for l in self.astro_source_proto.label: gc_proto = l.location gc = get_instance(gc_proto.right_ascension, gc_proto.declination) label_list.append(TextSource(self.strings[l.string_index], l.color, gc, l.offset, l.font_size)) return label_list
def get_labels(self): ''' Strings are loaded from strings.txt in the assets folder. ''' label_list = [] for l in self.astro_source_proto.label: gc_proto = l.location gc = get_instance(gc_proto.right_ascension, gc_proto.declination) label_list.append( TextSource(self.strings[l.string_index], l.color, gc, l.offset, l.font_size)) return label_list
def get_lines(self): line_list = [] for l in self.astro_source_proto.line: geocentric_verticies = [] for gc_proto in l.vertex: gc = get_instance(gc_proto.right_ascension, \ gc_proto.declination) geocentric_verticies.append(gc) line_list.append(LineSource(geocentric_verticies, l.color, \ l.line_width)) return line_list
def __init__(self): ''' constructor ''' AbstractAstronomicalSource.__init__(self) self.line_sources = [] self.text_sources = [] title = "Ecliptic" self.text_sources.append(TextSource(title, self.LINE_COLOR, get_instance(90.0, self.EPSILON))) self.text_sources.append(TextSource(title, self.LINE_COLOR, get_instance(270.0, -self.EPSILON))) # Create line source. ra = [0.0, 90.0, 180.0, 270.0, 0.0] dec = [0.0, self.EPSILON, 0.0, -self.EPSILON, 0.0] vertices = [] for i in range(0, len(ra)): vertices.append(get_instance(ra[i], dec[i])) self.line_sources.append(LineSource(vertices, self.LINE_COLOR, 1.5))
def redraw(self): ''' Redraws the sky shading gradient using the model's current time. ''' model_time = self.model.get_time() Ms_since_epoch = calendar.timegm(model_time) * 100 if abs(Ms_since_epoch - self.last_update_time_Ms) > self.UPDATE_FREQUENCY_MS: self.last_update_time_Ms = Ms_since_epoch sun_pos = get_solar_position(model_time) with self.renderer_lock: gc = get_instance(sun_pos.ra, sun_pos.dec) self.controller.queue_enable_sky_gradient(gc)
def get_geo_coords(self): gc = self.astro_source_proto.search_location return get_instance(gc.right_ascension, gc.declination)
def initialize_showers(self): ''' A list of all the meteor showers with > 10 per hour Source: http://www.imo.net/calendar/2011#table5 Note the zero-based month. 10=November Actual start for Quadrantids is December 28 - but we can't cross a year boundary. ''' self.showers.append( self.Shower( "Quadrantids", get_instance(230, 49), dt.datetime(self.ANY_OLD_YEAR, 1, 1, 0, 0, 0).timetuple(), dt.datetime(self.ANY_OLD_YEAR, 1, 4, 0, 0, 0).timetuple(), dt.datetime(self.ANY_OLD_YEAR, 1, 12, 0, 0, 0).timetuple(), 120)) self.showers.append( self.Shower( "Lyrids", get_instance(271, 34), dt.datetime(self.ANY_OLD_YEAR, 4, 16, 0, 0, 0).timetuple(), dt.datetime(self.ANY_OLD_YEAR, 4, 22, 0, 0, 0).timetuple(), dt.datetime(self.ANY_OLD_YEAR, 4, 25, 0, 0, 0).timetuple(), 18)) self.showers.append( self.Shower( "Eta Aquariids", get_instance(338, -1), dt.datetime(self.ANY_OLD_YEAR, 4, 19, 0, 0, 0).timetuple(), dt.datetime(self.ANY_OLD_YEAR, 5, 6, 0, 0, 0).timetuple(), dt.datetime(self.ANY_OLD_YEAR, 5, 28, 0, 0, 0).timetuple(), 70)) self.showers.append( self.Shower( "Delta Aquariids", get_instance(340, -16), dt.datetime(self.ANY_OLD_YEAR, 7, 12, 0, 0, 0).timetuple(), dt.datetime(self.ANY_OLD_YEAR, 7, 30, 0, 0, 0).timetuple(), dt.datetime(self.ANY_OLD_YEAR, 8, 23, 0, 0, 0).timetuple(), 16)) self.showers.append( self.Shower( "Perseids", get_instance(48, 58), dt.datetime(self.ANY_OLD_YEAR, 7, 17, 0, 0, 0).timetuple(), dt.datetime(self.ANY_OLD_YEAR, 8, 13, 0, 0, 0).timetuple(), dt.datetime(self.ANY_OLD_YEAR, 8, 24, 0, 0, 0).timetuple(), 100)) self.showers.append( self.Shower( "Orionids", get_instance(95, 16), dt.datetime(self.ANY_OLD_YEAR, 10, 2, 0, 0, 0).timetuple(), dt.datetime(self.ANY_OLD_YEAR, 10, 21, 0, 0, 0).timetuple(), dt.datetime(self.ANY_OLD_YEAR, 11, 7, 0, 0, 0).timetuple(), 25)) self.showers.append( self.Shower( "Leonids", get_instance(152, 22), dt.datetime(self.ANY_OLD_YEAR, 11, 6, 0, 0, 0).timetuple(), dt.datetime(self.ANY_OLD_YEAR, 11, 18, 0, 0, 0).timetuple(), dt.datetime(self.ANY_OLD_YEAR, 11, 30, 0, 0, 0).timetuple(), 20)) self.showers.append( self.Shower( "Puppid-Velids", get_instance(123, -45), dt.datetime(self.ANY_OLD_YEAR, 12, 1, 0, 0, 0).timetuple(), dt.datetime(self.ANY_OLD_YEAR, 12, 7, 0, 0, 0).timetuple(), dt.datetime(self.ANY_OLD_YEAR, 12, 15, 0, 0, 0).timetuple(), 10)) self.showers.append( self.Shower( "Geminids", get_instance(112, 33), dt.datetime(self.ANY_OLD_YEAR, 12, 7, 0, 0, 0).timetuple(), dt.datetime(self.ANY_OLD_YEAR, 12, 14, 0, 0, 0).timetuple(), dt.datetime(self.ANY_OLD_YEAR, 12, 17, 0, 0, 0).timetuple(), 120)) self.showers.append( self.Shower( "Ursids", get_instance(217, 76), dt.datetime(self.ANY_OLD_YEAR, 12, 17, 0, 0, 0).timetuple(), dt.datetime(self.ANY_OLD_YEAR, 12, 23, 0, 0, 0).timetuple(), dt.datetime(self.ANY_OLD_YEAR, 12, 26, 0, 0, 0).timetuple(), 10))