def _init(self): """ Additional init of our functional block """ self._sun = sun.Sun(latitude=self.dp["latitude"].value, longitude=self.dp["longitude"].value, timeZone=self.dp["time_zone"].value, savingTime=self.dp["saving_time"].value)
def __init__(self, width, height): self.mWidth = width self.mHeight = height self.mWalls = walls.Walls(self.mWidth, self.mHeight) self.mSun = sun.Sun(0.75 * self.mWidth, 0.66 * self.mHeight, (1. / 8.) * self.mHeight) self.mDoor = door.Door(self.mWidth / 6, self.mHeight / 3) return
def get_az_el(self, utc_date, lat, lon, alt): s = sun.Sun() loc = location.Location(lat, lon, alt=alt) ra, decl = s.radec(utc_date) _el, _az = loc.equatorial_to_horizontal(utc_date, ra,decl) el, az = np.round([_el.to_degrees(), _az.to_degrees()], decimals=6) ret = [] ret.append({'name': 'sun', 'r': 1e10, 'el':el, 'az':az, 'jy':10000.0}) return ret
def __init__(self, width, height): self.mWidth = width self.mHeight = height self.mSun = sun.Sun( (247, 238, 101), 175, 125, 50) self.mSky = rect.Rect((101, 233, 247), 0, 0, 900, 450) self.mGrass = rect.Rect((86, 219, 110), 0, 450, 900, 350) self.mTree1 = tree.Tree((143, 102, 26), (71, 153, 17), 650, 325, 75, 125) self.mTree2 = tree.Tree((168, 141, 50), (168, 50, 100), 800, 375, 50, 75) adult = 'adult' child = 'child' self.mParent1 = person.Person(adult, 225, 300 ) self.mParent2 = person.Person(adult, 100, 300) self.mChild1 = person.Person(child, 350, 350) self.mChild2 = person.Person(child, 450, 350) self.mChild3 = person.Person(child, 550, 350) self.mCloud1 = cloud.Cloud(400, 50, 150, 100) self.mCloud2 = cloud.Cloud(650, 70, 200, 100) self.mBlanket = blanket.Blanket((219, 50, 107), 100, 500, 350, 150) return
def __init__(self, width, height): self.mWidth = width self.mHeight = height self.mSky = sky.Sky(self.mWidth, self.mHeight) self.mSun = sun.Sun(0.67 * self.mWidth, 0.47 * self.mHeight, (1. / 8.) * self.mHeight) outline = [(int(0 * self.mWidth), int(1 * self.mHeight)), (int(0 * self.mWidth), int((2 / 3) * self.mHeight)), (int(0.25 * self.mWidth), int((5 / 9) * self.mHeight)), (int(0.5 * self.mWidth), int((2 / 3) * self.mHeight)), (int((5 / 6) * self.mWidth), int((4 / 9) * self.mHeight)), (int(1 * self.mWidth), int((7 / 9) * self.mHeight)), (int(1 * self.mWidth), int(1 * self.mHeight))] self.mMountain = mountain.Mountain(outline) self.mCloud1 = cloud.Cloud(0.1 * self.mWidth, .43 * self.mHeight, 0.31 * self.mWidth, 0.20 * self.mHeight) self.mCloud1.darken() self.mCloud2 = cloud.Cloud(0.70 * self.mWidth, .10 * self.mHeight, 0.16 * self.mWidth, 0.10 * self.mHeight) self.mCloud3 = cloud.Cloud(0.55 * self.mWidth, .40 * self.mHeight, 0.40 * self.mWidth, 0.10 * self.mHeight) self.mCloud3.lighten() self.mSmallBird1 = small_bird.SmallBird(0.25 * self.mWidth, 0.25 * self.mHeight, 0.07 * self.mWidth, 0.04 * self.mHeight) self.mSmallBird2 = small_bird.SmallBird(0.22 * self.mWidth, 0.28 * self.mHeight, 0.07 * self.mWidth, 0.04 * self.mHeight) self.mSmallBird2.thicken() self.mSmallBird3 = small_bird.SmallBird(0.15 * self.mWidth, 0.30 * self.mHeight, 0.07 * self.mWidth, 0.04 * self.mHeight) return
from __future__ import division, print_function import body import sun import solarsystem import turtle import numpy as np # Now just need to fix the scaling/relative sizes! yay # Should scale everything in terms of the Earth's mass, radius, and distance to the sun # Otherwise this won't work solar_system = solarsystem.SolarSystem(5, 5) sun = sun.Sun('sun', 5000, 10, 'yellow') solar_system.addSun(sun) # for the initial velocities, I am saying that the planet starts at a position of x = position from the sun and y=0 earth = body.Body('Earth', 47.5, 5000, 0.3, 0, 1.8, .5, 'green') solar_system.addPlanet(earth) mercury = body.Body('Mercury', 9.09, 276.5, 0.1161, 0, 2.862, 0.2, 'gray') solar_system.addPlanet(mercury) mars = body.Body('Mars', 12.63, 535, 0.456, 0, 1.4544, 0.25, 'red') solar_system.addPlanet(mars) jupiter = body.Body('Jupiter', 266.24, 1589000, 0.8, 0, np.sqrt( (.1 * 10) / 0.8), 0.8, 'orange') solar_system.addPlanet(jupiter) venus = body.Body('Venus', 22.539, 4075, 0.2169, 0, 2.124, .45, 'brown') solar_system.addPlanet(venus) saturn = body.Body('Saturn', 224.4375, 476000, 1.5, 0, np.sqrt( (.1 * 10) / 1.5), 0.7, 'yellow')
def draw(self, surface): # rectangle to fill the background # sky = pygame.Rect(0, 0, self.mWidth, self.mHeight) # pygame.draw.rect( surface, (66, 215, 245), sky, 0 ) # grass = pygame.Rect( 0, self.mWidth//2, self.mWidth, self.mHeight//2) # pygame.draw.rect( surface, (164, 254, 66), grass, 0 ) # must have 5/6 0f these # i have ract, circle, ellipse # rect(), polygon(), circle(), ellipse(), arc(), line() # Drawing the Sky 1/6 Classes complete theSky = sky.Sky(700, 600) theSky.draw(surface) # Drawing the Grass 2/6 Classed complete theGrass = grass.Grass(700, 600) theGrass.draw(surface) # Drawing the Cloud 3/6 Classed complete theCloud = cloud.Cloud(50, 50, 125, 75) theCloud.draw(surface) # right cloud theCloud2 = cloud.Cloud(500, 100, 125, 75) theCloud2.draw(surface) theSun = sun.Sun(350, 100, 70) theSun.draw(surface) house = square.Square(200, 300, 300, 190, (50, 100, 200)) house.draw(surface) # surface, self.mColor, self.mPoint, 0) HouseRoof = roof.Roof(((170, 300), (350, 200), (530, 300)), (115, 47, 0)) HouseRoof.draw(surface) # door door = square.Square(325, 410, 50, 80, (255, 255, 255)) door.draw(surface) # left window # self.mX, self.mY, self.mWidth, self.mHeight leftWindow = square.Square(242, 330, 40, 40, (255, 191, 0)) leftWindow.draw(surface) # right window rightWindow = square.Square(420, 330, 40, 40, (255, 191, 0)) rightWindow.draw(surface) # walk way stone1 = square.Square(333, 500, 35, 35, (90, 90, 90)) stone1.draw(surface) stone2 = square.Square(333, 545, 35, 35, (90, 90, 90)) stone2.draw(surface) stone2 = square.Square(333, 590, 35, 35, (90, 90, 90)) stone2.draw(surface) bird1 = bird.Bird(75, 200, 50, 50) bird1.draw(surface) return
sun.print(start_secs, start_secs + 3600*24) if rain != None: rain.print(start_secs, start_secs + 3600*24) if moon != None: moon.print(start_secs, start_secs + 3600*24) if seatemp != None: seatemp.print(start_secs, start_secs + 3600*24) if tide != None: tide.print(start_secs, start_secs + 3600*24) if swell_wind != None: swell_wind.print(start_secs, start_secs + 3600*24) print("") location = "sydney" locations = ["sydney", "newcastle", "wollongong", "frazer_beach", "boat_harbour"] if len(sys.argv) >= 1 and sys.argv[1] in locations: location = sys.argv[1] suni = sun.Sun(willy_uri_get("sun", location)) raini = rain.Rain(willy_uri_get("rain", location)) mooni = moon.Moon(willy_uri_get("moon", location)) seatempi = seatempnet.Seatempnet(seatemp_page[location]) tidei = tide.Tide(willy_uri_get("tide", location)) swelli = swell.Swell(willy_uri_get("swell", location)) windi = wind.Wind(willy_uri_get("wind", location)) swell_windi = swell_wind.SwellWind(swelli.get(), windi.get()) for i in range(0, 7): secs = now + 3600 * 24 * i print_a_day(secs, suni, raini, mooni, seatempi, tidei, swell_windi)
from enum import Enum from gpiozero import LED, Button import signal import sun from datetime import datetime, time, timedelta from time import sleep # Coordinates LAT = 50.905505 LONG = 4.6754048 SUN = sun.Sun(lat=LAT, long=LONG) # Default times (in seconds) DEFAULT_SLEEP = 10 OPENING_THRESHOLD = timedelta(seconds=2) CLOSING_THRESHOLD = timedelta(seconds=2) class State(Enum): opening = 1 opening_stopped = 2 open = 3 closing = 4 closing_stopped = 5 closed = 6 unknown = 7 error = 8 def blink(led, state): # led.blink(on_seconds, off_seconds)
def __render_map(self): now = datetime.datetime.utcnow() year = now.year month = now.month day = now.day hours = now.hour mins = now.minute secs = now.second the_sun = sun.Sun() time_in_minutes = hours * 60.0 + (1.0 / 60.0 * mins) # compute declination of the sun n_days = the_sun.daysSince2000Jan0(year, month, day) res = the_sun.sunRADec(n_days) dec = res[1] # compute longitude position of the sun in degrees std = hours + mins / 60.0 + secs / 3600.0 tau = the_sun.computeGHA(day, month, year, std) # (x0, y0) is the center of the map (0 deg, 0 deg) k = math.pi / 180.0 x0 = 180 y0 = 90 scale = 400 / 180.0 # walk around the world and compute illumination vertices = [] for i in range(-180, 180, 1): longitude = i + tau tanlat = - math.cos(longitude * k) / math.tan(dec * k) arctanlat = math.atan(tanlat) / k y1 = y0 - int(arctanlat + 0.5) longitude += 1 tanlat = - math.cos(longitude * k) / math.tan(dec * k) arctanlat = math.atan(tanlat) / k y2 = y0 - int(arctanlat + 0.5) v1 = (int(scale * (x0 + i)), int(scale * y1)) v2 = (int(scale * (x0 + i + 1)), int(scale * y2)) if (dec > 0): v3 = (int(scale * (x0 + i + 1)), 400) v4 = (int(scale * (x0 + i)), 400) else: v3 = (int(scale * (x0 + i + 1)), 0) v4 = (int(scale * (x0 + i)), 0) vertices.append((v1, v2, v3, v4)) #end for sun_x = 400 - int(scale * tau) sun_y = 200 - int(scale * dec) if (sun_x < 0): sun_x = 800 + sun_x map_file = _MAPS[self.__get_current_map()] map_pbuf = gtk.gdk.pixbuf_new_from_file(os.path.join(_PATH, map_file)) self.__clear_mask() self.__draw_mask(vertices) self.__map.draw_pixbuf(map_pbuf, 0, 0) self.__map.set_clip_mask(self.__mask) self.__map.draw_pixbuf(self.__night, 0, 0) self.__map.set_clip_mask() self.__map.draw_line(0, 200, 800, 200, "#0000ff") self.__map.draw_pixbuf(self.__sun, sun_x - self.__sun.get_width() / 2, sun_y - self.__sun.get_height() / 2) del map_pbuf import gc; gc.collect()