Exemplo n.º 1
0
    def now(self, timestamp = None, weatherData = None, model = 'STC'):
        #Preditive
        if timestamp is None:
            timestamp = datetime.datetime.now() - datetime.timedelta(hours=self.tz)

        if model != 'STC' and  weatherData == None:
                weatherData = forecast.data(self.place)['currently']

        if model == 'CC':
            record = irradiation.blave(timestamp,self.place,self.tilt,
                    self.azimuth, cloudCover=weatherData['cloudCover'])
        else:
            record = irradiation.blave(timestamp,self.place,self.tilt,
                    self.azimuth)

        irradiance = irradiation.irradiation(record, self.place, self.horizon,\
                t = self.tilt, array_azimuth = self.azimuth, model = 'p9')

        if model == 'STC':
            return self.Pac(irradiance)
        else:
            tModule = irradiation.moduleTemp(irradiance, weatherData)
            return self.Pac(irradiance, tModule)
Exemplo n.º 2
0
    def forecastOutput(self, daylightSavings = False, source = None, hours = 24):
    #def powerToday(self, daylightSavings = False, source = None, hours = 24):
        #default is forecast with solpy.blave 
        #this is ugly code... sorry
        d = datetime.date.today()
        endTimeUTC = datetime.datetime(d.year,d.month,d.day)\
                + datetime.timedelta(hours=hours-self.tz)
        if source == 'noaa':
            wseries = noaa.herpDerpInterp(self.place)
            ts = []
            irr = []
            for i in wseries:
                if i['utc_datetime'] > endTimeUTC:
                    break
                rec = irradiation.blave(i['utc_datetime'],self.place, \
                        self.tilt, self.azimuth, cloudCover = i['cloudCover'])
                irradiance = irradiation.irradiation(rec,self.place,\
                        t=self.tilt, array_azimuth=self.azimuth, model='p90')
                tModule = irradiation.moduleTemp(irradiance, i)
                irr.append(self.Pac(irradiance,tModule))
                ts.append(i['utc_datetime'])

            rs = resultSet()
            rs.values = irr
            rs.timeseries = ts
            return rs

        if source == 'forecast':
            wseries = forecast.hourly(self.place)
            ts = []
            irr = []
            for i in wseries:
                if i['utc_datetime'] > endTimeUTC:
                    break
                irradiance = irradiation.irradiation(i,self.place,\
                        t=self.tilt, array_azimuth=self.azimuth, model='p90')
                tModule = irradiation.moduleTemp(irradiance, i)
                irr.append(self.Pac(irradiance,tModule))
                ts.append(i['utc_datetime'])

            rs = resultSet()
            rs.values = irr
            rs.timeseries = ts
            return rs

        if source =='blave':
            wseries = forecast.hourly(self.place)
            ts = []
            irr = []
            for i in wseries:
                if i['utc_datetime'] > endTimeUTC:
                    break
                rec = irradiation.blave(i['utc_datetime'],self.place, \
                        self.tilt, self.azimuth, cloudCover = i['cloudCover'])
                irradiance = irradiation.irradiation(rec,self.place,\
                        t=self.tilt, array_azimuth=self.azimuth, model='p90')
                tModule = irradiation.moduleTemp(irradiance, i)
                irr.append(self.Pac(irradiance,tModule))
                ts.append(i['utc_datetime'])

            rs = resultSet()
            rs.values = irr
            rs.timeseries = ts
            return rs
        else:
            #blave
            stime = datetime.datetime.today().timetuple()
            tzOff = datetime.timedelta(hours=self.tz)
            if daylightSavings:
                tzOff += datetime.timedelta(hours=1)
            else:
                tzOff += datetime.timedelta(hours=0)
            initTime = datetime.datetime(stime[0],stime[1],stime[2]) - tzOff
            timeseries = []
            values = []
            ts = initTime
            while ts < datetime.datetime.now()-tzOff:
                ts +=  datetime.timedelta(minutes=5)
                currentPower = self.now(ts)
                values.append(currentPower)
                timeseries.append(ts)
            rs = resultSet()
            rs.values = values
            rs.timeseries = timeseries
            return rs