예제 #1
0
            pgb.widgets.SimpleProgress(
                format='(%s)' % pgb.widgets.SimpleProgress.DEFAULT_FORMAT),
            ' ',
            pgb.widgets.Bar(), ' ',
            pgb.widgets.Timer(), ' ',
            pgb.widgets.ETA()
        ]
        progressbar = pgb.ProgressBar(prefix='Compute GIS potentials: ',
                                      widgets=widgets,
                                      max_value=len(regions))
        matrix = vstack(
            list(progressbar(pool.imap(calculate_potential, regions.index))))

    potentials = config['capacity_per_sqkm'] * vlanduse._cutout_cell_areas(
        cutout)
    potmatrix = matrix * spdiag(potentials.ravel())
    potmatrix.data[
        potmatrix.data <
        1.] = 0  # ignore weather cells where only less than 1 MW can be installed
    potmatrix.eliminate_zeros()

    resource = config['resource']
    func = getattr(cutout, resource.pop('method'))
    correction_factor = config.get('correction_factor', 1.)
    if correction_factor != 1.:
        logger.warning(
            'correction_factor is set as {}'.format(correction_factor))
    capacity_factor = correction_factor * func(
        capacity_factor=True,
        show_progress='Compute capacity factors: ',
        **resource).stack(spatial=('y', 'x')).values
예제 #2
0
    widgets = [
        pgb.widgets.Percentage(),
        ' ', pgb.widgets.SimpleProgress(format='(%s)' % pgb.widgets.SimpleProgress.DEFAULT_FORMAT),
        ' ', pgb.widgets.Bar(),
        ' ', pgb.widgets.Timer(),
        ' ', pgb.widgets.ETA()
    ]
    progressbar = pgb.ProgressBar(prefix='Compute GIS potentials: ', widgets=widgets, max_value=len(countries))

    if not os.path.isdir(snakemake.output.exclusion):
        os.makedirs(snakemake.output.exclusion)

    matrix = vstack([calculate_potential(i, save_map=os.path.join(snakemake.output.exclusion, countries[i]))
                     for i in progressbar(regions.index)])

    areamatrix = matrix * spdiag(vlanduse._cutout_cell_areas(cutout).ravel())
    areamatrix.data[areamatrix.data < 1.] = 0 # ignore weather cells where only less than 1 km^2 can be installed
    areamatrix.eliminate_zeros()

    resource = config['resource']
    func = getattr(cutout, resource.pop('method'))
    correction_factor = config.get('correction_factor', 1.)

    capacity_factor = func(capacity_factor=True, show_progress='Compute capacity factors: ', **resource).stack(spatial=('y', 'x'))
    flh_uncorr = capacity_factor * 8760
    flh_corr = correction_factor * flh_uncorr

    if snakemake.wildcards.technology == 'solar':
        pietzcker = pd.read_excel(snakemake.input.pietzker, sheet_name="PV on all area", skiprows=2, header=[0,1]).iloc[1:177]
        p_area1_50 = pietzcker['Usable Area at given FLh in 1-50km distance to settlement '].dropna(axis=1)
        p_area1_50.columns = p_area1_50.columns.str.split(' ').str[0]
예제 #3
0
 def test_only_lvals(self):
     # bug reported by sarah on 29/05/15
     ex = GbVecExpr(lvals=[spdiag(np.ones(len(self.v1)))], lvecs=[self.v1])
     self.assertEqual(len(list(ex)), len(self.v1))