def main(): pygame.init() # Инициация PyGame, обязательная строчка screen = pygame.display.set_mode(DISPLAY) # Создаем окошко pygame.display.set_caption("ILITA!") # Пишем в шапку bg = Surface((WIN_WIDTH, WIN_HEIGHT)) # Создание видимой поверхности # будем использовать как фон bg.fill(Color(BACKGROUND_COLOR)) # Заливаем поверхность сплошным цветом bg = image.load("%s/pictures/kosmos.jpg" % ICON_DIR) sun = Sun( 560, 320) # Объявляем о существовании солнышка с координатами 560, 320 earth = Earth(860, 320) while 1: # Основной цикл программы for e in pygame.event.get(): # Обрабатываем события if e.type == QUIT: raise SystemExit, "QUIT" screen.blit(bg, (0, 0)) # Каждую итерацию необходимо всё перерисовывать sun.draw(screen) # Солнышко рисуй earth.update() # Обновляй по апдейту землю earth.draw(screen) pygame.display.update() # обновление и вывод всех изменений на экран
def simulate(H, H0=5e5, P0=0.01, T0=5e5, dt=12): N = np.size(H) A = H0/P0#**2 l = S.h_t(T0) #l=1e9 P=P0 I1 = np.zeros(N) #I1[0] = 2*AIA.cresp(T0,'A171')*H0/lambda0*np.sqrt(T_tr) I1[0] = AIA.cresp(T0,'A171')*H0/(6*lambda0)#*q+AIA.tresp(T0,'A171')*(P0/(2*S.k_b*T0))**2*l*(1-q) #I2 = np.zeros(N) #I2[0] = 2*AIA.cresp(T0,'A193')*H0/lambda0*np.sqrt(T_tr) #I2[0] = AIA.tresp(T0,'A193')*1e5*H0/(6*lambda0)#*q+AIA.tresp(T0,'A193')*(P0/(2*S.k_b*T0))**2*l*(1-q) #I3 = np.zeros(N) #I3[0] = 3*2.5e-20*H0/(6*lambda0)#*q+3*AIA.tresp(T0,'A131')*(P0/(2*S.k_b*T0))**2*l*(1-q) #I3[0] = 0#AIA.tresp(T0,'A193')*1e5*H0/(6*lambda0) for i in range (1,N): #dP = 2./3*(H[i] - A*P**2)/l*dt dP = 2./3*(H[i] - A*P)/l*dt P = P + dP #T = T0*(1+(P-P0)/P0*beta) T = T0*(P/P0)**beta l = S.h_t(T) #I1[i] = 2*AIA.cresp(T, 'A171')*A*P**2/lambda0*np.sqrt(T_tr) #I2[i] = 2*AIA.cresp(T, 'A193')*A*P**2/lambda0*np.sqrt(T_tr) I1[i] = AIA.cresp(T,'A171')*A*P/(6*lambda0) #I2[i] = AIA.tresp(T,'A193')*1e5*A*P/(6*lambda0) #I3[i] = 3*2.5e-20*A*P/(6*lambda0) #I3[i] = 0#AIA.tresp(T,'A193')*1e5*A*P/(6*lambda0) return (I1)
def draw_picture(): # window wn.clearscreen() wn.bgcolor("light blue") # sun sun_size_range = [100,200,150,125,175] random_number = random.randint(0,4) sun_size = sun_size_range[random_number] sun_pos_range = [150 ,100, 0, -100, -150] sun_pos = sun_pos_range[random_number] sun = Sun() sun.pen.penup() sun.pen.goto(sun_pos, 100) sun.draw(sun_size, "yellow") # trees positions = [-250, -100, 0, 100, 200] sizes = [100, 150, 200, 125, 175] tree_amount_range = [1,3,4,5,6,] random_number = random.randint(0,4) tree_amount = tree_amount_range[random_number] random_track = 0 for i in range(tree_amount): random_number = random.randint(0, 4) random_track = random_number while (random_number == random_track): random_number = random.randint(0, 4) random_position = positions[random_number] tree_size = sizes[random_number] tree = Tree() tree.pen.goto(random_position, -300) tree.draw(tree_size) # Houses house = House() house.pen.penup() house.pen.goto(-300, -300) size = [100, 50, 200, 25, 75] space = [50, 100, 10, 25, 75] house_amount_range = [1,2,3,4,5] random_number = random.randint(0,4) house_amount = house_amount_range[random_number] color = ["blue", "orange", "cyan", "purple", "pink"] for i in range(house_amount): random_number = random.randint(0, 4) house_color = color[random_number] house_size = size[random_number] house_space = space[random_number] house.draw(house_size, house_color, house_space) wn.listen() wn.onkeypress(draw_picture, 'Up') wn.mainloop()
def calculate(s): geolocator = Nominatim() location = geolocator.geocode(s) w = tzwhere.tzwhere() if str(location) != 'None': timezone_str = w.tzNameAt(location.latitude, location.longitude) timezone = pytz.timezone(timezone_str) dt = datetime.datetime.now() s = str(timezone.utcoffset(dt)).split(",") offsethr = 0 if s[0] == '-1 day': offsethr -= 24 s.pop(0) tme = s[0].split(':') offsethr += int(tme[0]) offsetmin = int(tme[1]) coords = { 'longitude': location.longitude, 'latitude': location.latitude } sun = Sun() sunrise = sun.getSunriseTime(coords) risehr = sunrise['hr'] + offsethr risemin = int(sunrise['min'] + offsetmin) sunset = sun.getSunsetTime(coords) sethr = sunset['hr'] + offsethr - 12 setmin = int(sunset['min'] + offsetmin) if risemin >= 60: risemin -= 60 risehr += 1 if setmin >= 60: setmin -= 60 sethr += 1 if sethr < 0: sethr += 24 if risehr < 0: risehr += 24 risemin = str(risemin) setmin = str(setmin) if len(risemin) == 1: risemin = '0' + risemin if len(setmin) == 1: setmin = '0' + setmin sunrise = 'Sunrise: ' + str(risehr) + ":" + str(risemin) + ' AM' sunset = "Sunset: " + str(sethr) + ":" + str(setmin) + ' PM' return [sunrise, sunset, str(location)] else: return []
def getDayNightTransitions(start_ts, end_ts, lat, lon): """Return the day-night transitions between the start and end times. start_ts: A timestamp (UTC) indicating the beginning of the period end_ts: A timestamp (UTC) indicating the end of the period returns: indication of whether the period from start to first transition is day or night, plus array of transitions (UTC). """ first = None values = [] for t in range(start_ts - 3600 * 24, end_ts + 3600 * 24 + 1, 3600 * 24): x = startOfDayUTC(t) x_tt = time.gmtime(x) y, m, d = x_tt[:3] (sunrise_utc, sunset_utc) = Sun.sunRiseSet(y, m, d, lon, lat) daystart_ts = calendar.timegm((y, m, d, 0, 0, 0, 0, 0, -1)) sunrise_ts = int(daystart_ts + sunrise_utc * 3600.0 + 0.5) sunset_ts = int(daystart_ts + sunset_utc * 3600.0 + 0.5) if start_ts < sunrise_ts < end_ts: values.append(sunrise_ts) if first is None: first = 'night' if start_ts < sunset_ts < end_ts: values.append(sunset_ts) if first is None: first = 'day' return first, values
def get_night_or_day(npTime, fLat, fLon): """ npTime (numpy): Array of ctime(?) of the station fLat (float): Latitude of the station fLon (float): Longitude of the station Return npNightDay (numpy), containing '1' for day, '0' for night, for the the corresponding time in npTime. """ ctimeFirstForecast = npTime[0] # Get the sunrise and the sunset nStartYear = metro_date.get_year(ctimeFirstForecast) nStartMonth = metro_date.get_month(ctimeFirstForecast) nStartDay = metro_date.get_day(ctimeFirstForecast) cSun = Sun.Sun() (fSunriseTimeUTC, fSunsetTimeUTC) = cSun.sunRiseSet(\ nStartYear, nStartMonth, nStartDay, fLon, fLat) npNightDay = numpy.zeros(len(npTime)) for i in range(len(npNightDay)): cTimeCurrent = npTime[i] nCurrentHour = metro_date.get_hour(cTimeCurrent) nCurrentMinute = metro_date.get_minute(cTimeCurrent) fCurrentHourMinute = nCurrentHour + nCurrentMinute/60.0 if metro_date.in_the_dark(fCurrentHourMinute, fSunriseTimeUTC, \ fSunsetTimeUTC): npNightDay[i]=1 return npNightDay
def getDayNightTransitions(start_ts, end_ts, lat, lon): """Return the day-night transitions between the start and end times. start_ts: A timestamp (UTC) indicating the beginning of the period end_ts: A timestamp (UTC) indicating the end of the period returns: indication of whether the period from start to first transition is day or night, plus array of transitions (UTC). """ first = None values = [] for t in range(start_ts-3600*24, end_ts+3600*24+1, 3600*24): x = startOfDayUTC(t) x_tt = time.gmtime(x) y, m, d = x_tt[:3] (sunrise_utc, sunset_utc) = Sun.sunRiseSet(y, m, d, lon, lat) daystart_ts = calendar.timegm((y,m,d,0,0,0,0,0,-1)) sunrise_ts = int(daystart_ts + sunrise_utc * 3600.0 + 0.5) sunset_ts = int(daystart_ts + sunset_utc * 3600.0 + 0.5) if start_ts < sunrise_ts < end_ts: values.append(sunrise_ts) if first is None: first = 'night' if start_ts < sunset_ts < end_ts: values.append(sunset_ts) if first is None: first = 'day' return first, values
def getDayNightTransitions(start_ts, end_ts, lat, lon): """Return the day-night transitions between the start and end times. start_ts: A timestamp (UTC) indicating the beginning of the period end_ts: A timestamp (UTC) indicating the end of the period returns: indication of whether the period from start to first transition is day or night, plus array of transitions (UTC). """ first = 'day' values = [] for t in range(start_ts, end_ts+1, 3600*24): x = startOfDay(t) + 7200 if lon > 0: x += 24*3600 x_tt = time.gmtime(x) y, m, d = x_tt[:3] (sunrise_utc, sunset_utc) = Sun.sunRiseSet(y, m, d, lon, lat) sunrise_tt = utc_to_local_tt(y, m, d, sunrise_utc) sunset_tt = utc_to_local_tt(y, m, d, sunset_utc) sunrise_ts = time.mktime(sunrise_tt) sunset_ts = time.mktime(sunset_tt) if start_ts < sunrise_ts < end_ts: values.append(sunrise_ts) if start_ts < sunset_ts < end_ts: values.append(sunset_ts) if t == start_ts and (start_ts < sunrise_ts or sunset_ts < start_ts): first = 'night' return first, values
def createSuns(self): i = 0 for i in range(self.sunnumb): x = random.randrange(-(self.size-1)*self.res[0], self.size*self.res[0]) y = random.randrange(-(self.size-1)*self.res[1], self.size*self.res[1]) temp= Sun(x, y) self.Suns.append(temp) i += 1 self.sunsCreated = True
def getTwilightSunriseSunset(self, date): """ Compute the time of the astronomical twilight for Sun raise and set times at the location on Earth specified by (self.latitude_RAD, self.longitude_RAD). Input date: date in seconds from Jan 1 of the simulated year. Return A four-element array: (sunriseTime, sunsetTime, sunriseMJD, sunsetMJD) sunriseTime & sunsetTime are in seconds from Jan 1 of simulated year; sunriseMJD and sunsetMJD are MJD equivalents. """ # Convert date in MJD mjd = (float(self.date) / float(DAY)) + self.simEpoch #mjd=49353. # MJD -> calendar date #mjd=self.mjd (yy, mm, dd, hh, min, sec) = self.mjd2gre(mjd)[:6] #print 'hello',yy,mm,dd,hh,min,sec # Compute sunset and sunrise at twilight. Return values are in # decimal hours. import Sun s = Sun.Sun() #(sunRise, sunSet) = s.sunRiseSet(yy, mm, dd, # self.longitude_RAD * RAD2DEG, self.latitude_RAD * RAD2DEG) # Following set to nauticalTwilight (sunRise, sunSet) = s.__sunriset__(yy, mm, dd, self.lon_RAD * RAD2DEG, self.lat_RAD * RAD2DEG, self.SunAltitudeNightLimit, 0) # -12.0, 0) (sunRiseTwil, sunSetTwil) = s.__sunriset__(yy, mm, dd, self.lon_RAD * RAD2DEG, self.lat_RAD * RAD2DEG, self.SunAltitudeTwilightLimit, 0) # -18.0, 0) # Compute MJD values for sunrise and sunset sunSetMJD = int(mjd) + (sunSet / 24.) sunRiseMJD = int(mjd) + (sunRise / 24.) self.sunSetTwilMJD = int(mjd) + (sunSetTwil / 24.) self.sunRiseTwilMJD = int(mjd) + (sunRiseTwil / 24.) #print 'ici', sunSetTwilMJD,sunRiseTwilMJD # MJD -> simulated seconds sunsetDate = (sunSetMJD - self.simEpoch) * float(DAY) sunriseDate = (sunRiseMJD - self.simEpoch) * float(DAY) sunsetTwilDate = (self.sunSetTwilMJD - self.simEpoch) * float(DAY) sunriseTwilDate = (self.sunRiseTwilMJD - self.simEpoch) * float(DAY) #print 'twilight',self.mjd2gre(sunSetTwilMJD)[:6],self.mjd2gre(sunRiseTwilMJD)[:6] return (sunriseDate, sunsetDate, sunRiseMJD, sunSetMJD, sunriseTwilDate, sunsetTwilDate)
def on_activated(self, view): """ Checking to toggle color schemes is done after every view activation, which is not very efficient but ensures switches both at runtime and at startup. """ curr_time = time.localtime(time.time()) times = Sun.Sun().sunRiseSet(curr_time.tm_year, curr_time.tm_mon, curr_time.tm_mday, lon, lat) daylight = map(lambda x: (x + gmt_offset) * 60, times) current_min = (curr_time.tm_hour * 60 + curr_time.tm_min) color_scheme = "day" if (current_min >= daylight[0] and current_min <= daylight[1]) else "night" view.settings().set('color_scheme', schemes[color_scheme])
def __init__(self, screen, width, height, master_name='Master Example', character_path='../characters/sprites/ordan.png'): self.mouse_pos_right_click = None self.width = width self.height = height self.clock = pygame.time.Clock() self.frame = Screen.Screen(screen, width, height) self.txt = self.frame.txt self.sound = Sound.Sound() self.arrow_states = { K_UP: [False, -1], K_DOWN: [False, 1], K_LEFT: [False, -1], K_RIGHT: [False, 1], } self.arrow = [0, 0] self.sun = Sun.Sun() self.p = Person.Person.getNewPlayer(733, 896, master_name, character_path) Person.Person.setMaster(self.p.getId()) self.path_deque = deque() # Bot.BotController.putNewBot((1700, 1700), '../characters/skeleton.png') Bot.BotController.putNewBot((912, 482), '../characters/sprites/black_man.png') Bot.BotController.putNewBot((739, 498), '../characters/sprites/blond_man.png') Bot.BotController.putNewBot((935, 602), '../characters/sprites/dumb_woman.png') Bot.BotController.putNewBot((981, 633), '../characters/sprites/blond_man.png') Bot.BotController.putNewBot((975, 597), '../characters/sprites/blond_woman.png') Bot.BotController.putNewBot((1029, 622), '../characters/sprites/brunette_woman.png') # Bot.BotController.putNewBot((600, 800)) # Bot.BotController.putNewBot((1000, 2000)) """ self.client = ClientSocket.ClientSocket() """
def setTime(self, time_ts): """Reset the observer's time for the almanac. If the date differs from the previous date, then it will recalculate the astronomical data. """ _newdate_tt = time.localtime(time_ts) if _newdate_tt[0:3] != self.date_tt[0:3] : (y,m,d) = _newdate_tt[0:3] (sunrise_utc, sunset_utc) = Sun.sunRiseSet(y, m, d, self.lon, self.lat) # The above function returns its results in UTC hours. Convert # to a local time tuple self.sunrise_loc_tt = Almanac._adjustTime(y, m, d, sunrise_utc) self.sunset_loc_tt = Almanac._adjustTime(y, m, d, sunset_utc) self.sunrise = time.strftime(self.timeformat, self.sunrise_loc_tt) self.sunset = time.strftime(self.timeformat, self.sunset_loc_tt) (moon_index, self.moon_fullness) = Moon.moon_phase(y, m, d) self.moon_phase = self.moon_phases[moon_index] if self.moon_phases is not None else '' self.date_tt = _newdate_tt
def __set_sunrise_sunset(self, wf_controlled_data): """ Description: Get the value of sunrise/sunset for the first day of forecast. Parameters: wf_controlled_data (metro_data) : controlled data. Read-only Set the attribute for sunrise/sunset """ ctimeFirstForecast = wf_controlled_data.get_matrix_col\ ('FORECAST_TIME')[0] # Get the sunrise and the sunset self.nStartYear = metro_date.get_year(ctimeFirstForecast) self.nStartMonth = metro_date.get_month(ctimeFirstForecast) self.nStartDay = metro_date.get_day(ctimeFirstForecast) cSun = Sun.Sun() (fSunriseTimeUTC, fSunsetTimeUTC) = cSun.sunRiseSet(\ self.nStartYear, self.nStartMonth, self.nStartDay,\ self.fLon, self.fLat) self.fSunrise = fSunriseTimeUTC self.fSunset = fSunsetTimeUTC
firstArg = False elif arg == "-d": DEBUG = True elif arg.startswith("-s"): parts = string.split(arg[2:], ":") startHour = int(parts[0]) startMinute = int(parts[1]) startTimeArg = True elif arg.startswith("-e"): parts = string.split(arg[2:], ":") endHour = int(parts[0]) endMinute = int(parts[1]) else: sys.exit("Invalid parm " + arg + ". Format is controller [-sHH:MM] [-eHH:MM] -d") mySun = Sun.Sun() currTime = datetime.datetime.now() startTime = currTime.replace(hour=startHour, minute=startMinute, second=0) if startTimeArg == False: getSunriseSunset() # will be set to 15 minutes before sunset endTime = currTime.replace(hour=endHour, minute=endMinute, second=0) if ((endHour < startHour) or (endHour == startHour and endMinute < startMinute)): endTime = endTime + datetime.timedelta(days = 1) print "Start time is " + startTime.strftime("%Y %m %d, %H:%M") print "End time is " + endTime.strftime("%Y %m %d, %H:%M") print "Debug is " + str(DEBUG) lastMin = datetime.datetime.now().minute
def updateTargetList(self, dateProfile, obsProfile, sky, fov): """ Update the list of potentially visible fields given a LST and a latitude. The range in coordinates of the selected fields is RA: [LST-60; LST+60] (degrees) Dec: [lat-60; lat+60] (degrees) This version uses Sun.py and computes RA limits at the nautical twilight. Input: dateProfile .... obsProfile .... sky AstronomicalSky instance fov Field of view of the telescope Return fields A dictionary of the form {fieldID: (ra, dec)} """ ## Benchmark memory use - start #m0 = memory() #r0 = resident() #s0 = stacksize() ##self.log.info("WL: updateTargetList entry: mem: %d resMem: %d stack: %d" % (m0, r0, s0)) if self.log: self.log.info('Proposal:updateTargetList propID=%d' % (self.propID)) dbFov = 'fieldFov' dbRA = 'fieldRA' dbDec = 'fieldDec' #dbL = 'fieldGL' #dbB = 'fieldGB' dbID = 'fieldID' (date, mjd, lst_RAD) = dateProfile (lon_RAD, lat_RAD, elev_M, epoch_MJD, d1, d2, d3) = obsProfile # MJD -> calendar date (yy, mm, dd) = mjd2gre(mjd)[:3] # determine twilight times based on user param: TwilightBoundary import Sun s = Sun.Sun() (sunRise, sunSet) = s.__sunriset__(yy, mm, dd, lon_RAD * RAD2DEG, lat_RAD * RAD2DEG, self.twilightBoundary, 0) #(sunRise, sunSet) = s.nauticalTwilight (yy, mm, dd, lon_RAD*RAD2DEG, lat_RAD*RAD2DEG) # RAA following overkill for simulation #if (date >= sunSet): # Beginning of the night # (sunRise, dummy) = s.nauticalTwilight (yy, mm, dd+1, lon_DEG, lat_DEG) #else: # End of the night # (dummy, sunSet) = s.nauticalTwilight (yy, mm, dd-1, lon_DEG, lat_DEG) # Compute RA min (at twilight) date_MJD = int(mjd) + (sunSet / 24.) #raMin = ((slalib.sla_gmst(date_MJD) + lon_RAD) * RAD2DEG) - self.deltaLST raMin = ((pal.gmst(date_MJD) + lon_RAD) * RAD2DEG) - self.deltaLST # Compute RA max (at twilight) date_MJD = int(mjd) + (sunRise / 24.) #raMax = ((slalib.sla_gmst(date_MJD) + lon_RAD) * RAD2DEG) + self.deltaLST raMax = ((pal.gmst(date_MJD) + lon_RAD) * RAD2DEG) + self.deltaLST # Make sure that both raMin and raMax are in the [0; 360] range raMin = normalize(angle=raMin, min=0., max=360, degrees=True) raMax = normalize(angle=raMax, min=0., max=360, degrees=True) raAbsMin = normalize(angle=self.minAbsRA, min=0., max=360, degrees=True) raAbsMax = normalize(angle=self.maxAbsRA, min=0., max=360, degrees=True) # self.targets is a convenience dictionary. Its keys are # fieldIDs, its values are the corresponding RA and Dec. fields = {} fovEpsilon1 = fov - .01 fovEpsilon2 = fov + .01 sql = 'SELECT %s, %s, %s from %s ' % (dbRA, dbDec, dbID, self.dbField) sql += 'WHERE %s BETWEEN %f AND %f AND ' % (dbFov, fovEpsilon1, fovEpsilon2) # subtract galactic exclusion zone taperB = self.taperB taperL = self.taperL peakL = self.peakL band = peakL - taperL if taperB != 0. and taperL != 0.: sql += '( (fieldGL < 180. AND abs(fieldGB) > (%f - (%f * abs(fieldGL)) / %f) ) OR ' %\ (peakL, band, taperB) sql += '(fieldGL > 180. AND abs(fieldGB) > (%f - (%f * abs(fieldGL-360.)) / %f))) AND ' %\ (peakL, band, taperB) # subtract un-viewable sky if raMax > raMin: sql += '%s BETWEEN %f AND %f AND ' % (dbRA, raMin, raMax) elif (raMax < raMin): sql += '(%s BETWEEN %f AND 360.0 OR ' % (dbRA, raMin) sql += '%s BETWEEN 0.0 AND %f) AND ' % (dbRA, raMax) else: sql += '%s BETWEEN 0.0 AND 360.0 AND ' % (dbRA) if raAbsMax >= raAbsMin: sql += '%s BETWEEN %f AND %f AND ' % (dbRA, raAbsMin, raAbsMax) else: sql += '(%s BETWEEN %f AND 360.0 OR ' % (dbRA, raAbsMin) sql += '%s BETWEEN 0.0 AND %f) AND ' % (dbRA, raAbsMax) DecLimit = math.acos(1. / float(self.maxAirmass)) * RAD2DEG latRad = lat_RAD * RAD2DEG sql += '%s BETWEEN %f AND %f and %f < %s < %f order by FieldRA,FieldDec' % ( dbDec, latRad - DecLimit, latRad + DecLimit, -abs(self.maxReach), dbDec, abs(self.maxReach)) # Send the query to the DB (n, res) = self.lsstDB.executeSQL(sql) # Build the output dictionary for (ra, dec, fieldID) in res: fields[fieldID] = (ra, dec) self.targets = fields self.computeTargetsHAatTwilight(lst_RAD) self.NumberOfFieldsTonight = len(self.targets) #print('NumberOfFieldsTonight = %i' % (self.NumberOfFieldsTonight)) self.GoalVisitsTonight = self.GoalVisitsField * self.NumberOfFieldsTonight #print('Goal Visits with Tonight targets = %i' % (self.GoalVisitsTonight)) self.VisitsTonight = 0 for filter in self.visits.keys(): #print('visits in %s = %i' % (filter, len(self.visits[filter].keys()))) for field in self.visits[filter].keys(): if field in self.targets: self.VisitsTonight += self.visits[filter][field] #print field # print('Visits up to Tonight for propID=%d for current targets = %i' % # (self.propID, self.VisitsTonight)) print('*** Found %d WL fields for propID=%d ***' % (len(res), self.propID)) ## Benchmark memory use - exit #m1 = memory() #r1 = resident() #s1 = stacksize() # self.log.info("WL: updateTargetList:(entry:exit) mem: %d:%d resMem: %d:%d stack: %d:%d" % # (m0, m1, r0, r1, s0, s1)) # print("WL: updateTargetList:(entry:exit) mem: %d:%d resMem: %d:%d stack: %d:%d" % # (m0, m1, r0, r1, s0, s1)) self.schedulingData.updateTargets(fields, self.propID, dateProfile, self.maxAirmass, self.FilterMinBrig, self.FilterMaxBrig) return fields
# $Id$ import time import string import Sun calculator = Sun.Sun() class imagesummary: def __init__(self,timestamp,lineremainder): [red,redstddev,green,greenstddev,blue,bluestddev] = lineremainder self.timestamp = timestamp self.red = string.atof(red) self.redstddev = string.atof(redstddev) self.blue = string.atof(blue) self.bluestddev = string.atof(bluestddev) self.green = string.atof(green) self.greenstddev = string.atof(greenstddev) class mean: def __init__(self,imagesummaries): (red,blue,green) = (0.0,0.0,0.0) for img in imagesummaries: (red,blue,green) = (red + img.red,blue + img.blue,green + img.green) (self.red,self.blue,self.green) = (red / len(imagesummaries), blue / len(imagesummaries), green / len(imagesummaries)) (reddev,bluedev,greendev) = (0.0,0.0,0.) for img in imagesummaries: reddev = reddev + (self.red - img.red) ** 2
print 'land occupation:', str(round(occupation, 2)), '%' print 'Total mirror surface in shade:', str(round(absShadedSurface, 2)), 'm2' print 'Relative mirror surface in shade:', str(round(relShadedSurface, 2)), '%' print 'Cosine effect:', str(round(averageCosine, 2)), '%' print print 'Optical performance:', str(round(averageOptical, 2)), '%' print 'Air performance:', str(round(averageAir, 2)), '%' print 'Wall performance:', str(round(averageWall, 2)), '%' ########################### SIMULACIÓN ################################ # Objetos previos a la simulación: sun = sn.Sun(B, latitude, day) field = fd.Field(baseHeight, apertureAngle, firstRowDist) photons = sun.generatePhotons(numberOfPhotons) solarAngles = sun.getSolarAngles() solarVector = np.transpose(sun.getSolarVector())[0] # Contadores: surfacesInShadow = [] opticPerformances = [] airPerformances = [] wallPerformances = [] cosineEffects = [] # Alimentar al evaporador: boilerTargets = field.getTargetCoords()[:8] boilerPowerRequired = boilerPower * surfaceSection
def __call__(self, Rsun, DOY, heureTU, lat): s = Sun.Sun() s.Rsun = Rsun s._set_pos_astro(DOY, heureTU, 3.14 / 180 * lat) return s
def run(): while True: Sun.rise() Sun.set()