Example #1
0
    def irradiance(self, time_sequence, ephem_sequence):

        #def irradiance(self, time_sequence):
        location = self.address2llh(self.address)
        solarZenith = ephem_sequence['zenith']
        solarAzi = ephem_sequence['azimuth']
        irradianceSequence = pvlib.clearsky.ineichen(time_sequence, location)
        
        DNI = irradianceSequence['dni']
        DB = SfsLight.directBeam(self.panel_tilt, solarZenith, self.panel_azimuth-solarAzi, DNI)  

        irradianceSequence['DB'] = DB
        self.irradiance_sequence = irradianceSequence

        irradianceSequence.plot()
        pix2_name = 'irrad_' + self.address_slug + '.png' 
        plot_path = MEDIA_ROOT + 'plots/' + pix2_name
        pyplot.savefig(plot_path)

        # Create plot figure file. 
        '''ephemSequence.plot()
        plot_path = MEDIA_ROOT + 'plots/ephemSequence.png'
        pyplot.savefig(plot_path)'''

        return
Example #2
0
    def ephemeris(self, begin, end, frequency):
        location = self.address2llh(self.address)

        # Invoke panda routine.
        strBegin = begin.split(',')
        intBegin = [int(x) for x in strBegin]
        strEnd = end.split(',')
        intEnd = [int(x) for x in strEnd]

        # Avoids the "..." ellipsis that appear in data. 
        pandas.set_option('display.max_rows', 1000000)
    
        timeSequence = pandas.date_range(
            start=datetime.datetime(intBegin[0], intBegin[1], intBegin[2], intBegin[3]), 
            end=datetime.datetime(intEnd[0], intEnd[1], intEnd[2], intEnd[3]), freq = frequency)
        #self.time_sequence = timeSequence

        ##################
        # Solar ephemeris.
        # # # # # # # # # # # # # 
        ephemSequence = pvlib.solarposition.pyephem(
            timeSequence, location).drop(
                ['apparent_elevation', 'apparent_azimuth', 
                'apparent_zenith', 'elevation'], axis=1)
        self.ephem_sequence = ephemSequence
        # Create plot figure file. 
        ephemSequence.plot()
        pix1_name = 'ephem_' + self.address_slug + '.png' 
        plot_path = MEDIA_ROOT + 'plots/' + pix1_name
        pyplot.savefig(plot_path)
        ##################

        # Solar ephemeris. 
        eph_seq = str(ephemSequence)
        eph_seq_lines = eph_seq.split('\n')
        self.time_sequence = eph_seq_lines

        # Compute statistics. 
        self.statistics  = ephemSequence.describe()

        ##################
        # Solar specifications.
        # # # # # # # # # # # # # 
        location = self.address2llh(self.address)
        solarZenith = ephemSequence['zenith']
        solarAzi = ephemSequence['azimuth']
        irradianceSequence = pvlib.clearsky.ineichen(timeSequence, location)
        
        DNI = irradianceSequence['dni']
        DB = SfsLight.directBeam(self.panel_tilt, solarZenith, self.panel_azimuth-solarAzi, DNI)  

        irradianceSequence['DB'] = DB
        self.irradiance_sequence = irradianceSequence

        irradianceSequence.plot()
        pix2_name = 'irrad_' + self.address_slug + '.png' 
        plot_path = MEDIA_ROOT + 'plots/' + pix2_name
        pyplot.savefig(plot_path)
        ##################

        # Create plot figure file. 
        '''ephemSequence.plot()
        plot_path = MEDIA_ROOT + 'plots/ephemSequence.png'
        pyplot.savefig(plot_path)'''

        return