Exemplo n.º 1
0
 def test_series(self):
     """Create scatter plot"""
     fig_df = Plot(outpath=self.outpath, save_image=self.save_image).series(
         self.df, outfile="series_df.png")
     fig_list = Plot(outpath=self.outpath,
                     save_image=self.save_image).series(
                         self.list, outfile="series_list.png")
Exemplo n.º 2
0
 def test_scatter(self):
     """Create scatter plot
     """
     fig_df = Plot(outpath=self.outpath,
                   save_image=self.save_image).scatter(
                       self.df, outfile='scatter_df.png')
     fig_list = Plot(outpath=self.outpath,
                     save_image=self.save_image).scatter(
                         self.list, outfile='scatter_list.png')
Exemplo n.º 3
0
    def test_solar_thermal_community_new(self):
        """Test solar thermal project level model with a
        tankless backup heater
        """
        # Default parameters, sizing and load for a 4 person
        # household.
        cons_total, proj_total, \
            [proj_total_dict, sol_fra, pump_el_use, pump_op_hour, ts_res,
             backup_ts_cons, rel_err] = \
            self.sol_wh_com_new.solar_thermal(backup='gas')

        self.assertAlmostEqual(proj_total[self.r['q_del_bckp']],
                               cons_total[self.r['q_del_bckp']].sum(),
                               places=1)

        self.assertAlmostEqual(proj_total[self.r['q_del_bckp']],
                               cons_total[self.r['q_del_bckp']].sum(),
                               places=1)

        self.assertAlmostEqual(proj_total[self.r['el_use']],
                               138084.38,
                               places=1)

        self.assertAlmostEqual(proj_total[self.r['q_del_tank']],
                               10475486.74,
                               places=1)

        self.assertAlmostEqual(ts_res[self.r['q_dump']].sum(),
                               proj_total[self.r['q_dump']],
                               places=1)

        self.assertAlmostEqual(sol_fra['annual'],
                               cons_total.at[1, self.r['sol_fra']],
                               places=1)

        if self.plot_results:
            Plot(data_headers=['Demand', 'Delivered', 'Unmet', 'Coil'],
                 outpath=self.outpath,
                 save_image=self.plot_results,
                 title='Solar tank',
                 label_v='Heat rate [W]').series(
                     ts_res.loc[4900:5000, [
                         self.r['q_dem'], self.r['q_del_tank'], self.
                         r['q_unmet_tank'], self.r['q_del_sol']
                     ]],
                     outfile='img/sol_tank_com_new_heatrate_defpars_4per.png',
                     modes='lines')

            Plot(data_headers=[self.r['t_tank_up'], self.r['t_tank_low']],
                 outpath=self.outpath,
                 save_image=self.plot_results,
                 title='Solar tank',
                 label_v='Temperature [K]').series(
                     ts_res.loc[4900:5000,
                                [self.r['t_tank_up'], self.r['t_tank_low']]],
                     outfile='img/sol_tank_com_new_temp_defpars_4per.png',
                     modes='lines')
Exemplo n.º 4
0
    def test_solar_thermal_individual_retrofit(self):
        """Tests solar thermal project level model with
        a gas tank backup heater
        """
        cons_total, proj_total, \
            [proj_total_dict, sol_fra, pump_el_use, pump_op_hour, ts_res,
             backup_ts_cons, rel_err] = \
            self.sol_wh_indiv_retr.solar_thermal(backup='retrofit')

        self.assertAlmostEqual(proj_total[self.r['q_del_bckp']],
                               cons_total[self.r['q_del_bckp']].sum(),
                               places=1)

        self.assertAlmostEqual(proj_total[self.r['q_del_bckp']],
                               214742.0,
                               places=1)

        self.assertAlmostEqual(proj_total[self.r['el_use']],
                               cons_total[self.r['el_use']].sum(),
                               places=1)

        self.assertAlmostEqual(proj_total[self.r['el_use']],
                               54490.14,
                               places=1)

        self.assertAlmostEqual(ts_res[self.r['q_dump']].sum(),
                               proj_total[self.r['q_dump']],
                               places=1)

        self.assertAlmostEqual(sol_fra['annual'],
                               cons_total.at[0, self.r['sol_fra']],
                               places=1)

        if self.plot_results:
            Plot(data_headers=['Demand', 'Delivered', 'Unmet', 'Coil'],
                 outpath=self.outpath,
                 save_image=self.plot_results,
                 title='Solar tank',
                 label_v='Heat rate [W]').series(
                     ts_res.loc[4900:5000, [
                         self.r['q_dem'], self.r['q_del_tank'], self.
                         r['q_unmet_tank'], self.r['q_del_sol']
                     ]],
                     outfile='img/sol_tank_retr_heatrate_defpars_4per.png',
                     modes='lines')

            Plot(data_headers=[self.r['t_tank_up'], self.r['t_tank_low']],
                 outpath=self.outpath,
                 save_image=self.plot_results,
                 title='Solar tank',
                 label_v='Temperature [K]').series(
                     ts_res.loc[4900:5000,
                                [self.r['t_tank_up'], self.r['t_tank_low']]],
                     outfile='img/sol_tank_retr_temp_defpars_4per.png',
                     modes='lines')
Exemplo n.º 5
0
    def test_conventional_gas_tank(self):
        """Tests project level gas tank wh model"""

        cons_total, proj_total, ts_proj = self.conv_wh.conventional_gas_tank()

        Plot(
            data_headers=["Gas use"],
            outpath=self.outpath,
            save_image=self.plot_results,
            title="Gas tank water heater (WHAM)",
            label_v="Heat rate [W]",
        ).series(
            [ts_proj[self.r["gas_use"]][4900:5000]],
            outfile="img/gas_use_4per.png",
            modes="lines",
        )

        # Gas use
        self.assertAlmostEqual(cons_total[self.r["gas_use"]][0],
                               4727451.89,
                               places=1)

        # Seasonal gas use
        self.assertAlmostEqual(
            cons_total[self.r["gas_use"]][0],
            (cons_total[self.r["gas_use_s"]][0] +
             cons_total[self.r["gas_use_w"]][0]),
            places=1,
        )
Exemplo n.º 6
0
    def test_conventional_gas_tank(self):
        """Tests project level gas tank wh model
        """

        cons_total, proj_total, ts_proj = \
            self.conv_wh.conventional_gas_tank()

        Plot(data_headers=['Gas use'],
             outpath=self.outpath,
             save_image=self.plot_results,
             title='Gas tank water heater (WHAM)',
             label_v='Heat rate [W]').series(
                 [ts_proj[self.r['gas_use']][4900:5000]],
                 outfile='img/gas_use_4per.png',
                 modes='lines')

        # Gas use
        self.assertAlmostEqual(cons_total[self.r['gas_use']][0],
                               4727451.89,
                               places=1)

        # Seasonal gas use
        self.assertAlmostEqual(cons_total[self.r['gas_use']][0],
                               (cons_total[self.r['gas_use_s']][0] +
                                cons_total[self.r['gas_use_w']][0]),
                               places=1)
Exemplo n.º 7
0
    def test_solar_electric(self):
        """Test solar electric project level model
        """
        # Default parameters, sizing and load for a 4 person household.

        cons_total, proj_total, \
            [proj_total_dict, sol_fra, pump_el_use,
             pump_op_hour, ts_res, rel_err] = \
            self.hp_wh.solar_electric()

        if self.plot_results:
            Plot(
                data_headers=['Demand', 'HP del', 'Aux del',
                              'Tank del', 'Unmet', 'Error',
                              'PV', 'HP el. use', 'Aux el. use'],
                outpath=self.outpath,
                save_image=self.plot_results,
                title='Heat pump tank with PV',
                label_v='Power / Heatrate [W]').series(
                    ts_res.loc[4920:5000, [self.r['q_dem'],
                    self.r['q_del_hp'],
                    self.r['q_del_bckp'],
                    self.r['q_del_tank'],
                    self.r['q_unmet_tank'],
                    self.r['q_err_tank'],
                    self.r['p_pv_ac'],
                    self.r['p_hp_el_use'],
                    self.r['p_el_res_use']]],
                    outfile='img/'\
                    'hp_tank_pv_heatrate_defpars_4per_80gallons.png',
                    modes='lines')

            Plot(data_headers=['T_upper', 'T_lower'],
                 outpath=self.outpath,
                 save_image=self.plot_results,
                 title='Heat pump tank',
                 label_v='Temperature [K]').series(
                     ts_res.loc[4920:5000,
                                [self.r['t_tank_up'], self.r['t_tank_low']]],
                     outfile='img/hp_tank_temp_defpars_4per_80gallons.png',
                     modes='lines')

        self.assertAlmostEqual(sol_fra['annual'], 0.328, places=2)
Exemplo n.º 8
0
    def test_box(self):
        """Create box plot"""

        df1 = pd.DataFrame(data=np.random.rand(120, 2),
                           columns=["df1_1", "df1_2"])
        df2 = pd.DataFrame(data=np.random.rand(100, 2) + 0.2,
                           columns=["df2_1", "df2_2"])
        df3 = pd.DataFrame(data=np.random.rand(80, 2) + 0.4,
                           columns=["df3_1", "df3_2"])
        df1["x"] = np.random.choice(3, 120)
        df2["x"] = np.random.choice(3, 100)
        df3["x"] = np.random.choice(3, 80)

        fig = Plot(outpath=self.outpath, save_image=self.save_image).box(
            dfs=[df1, df2, df3],
            plot_cols=["df1_1", "df2_1", "df3_1"],
            groupby_cols=["x", "x", "x"],
            df_cat=["red", "blu", "gre"],
            outfile="box.png",
        )
Exemplo n.º 9
0
    def test_box(self):
        """Create box plot
        """

        df1 = pd.DataFrame(data=np.random.rand(120, 2),
                           columns=['df1_1', 'df1_2'])
        df2 = pd.DataFrame(data=np.random.rand(100, 2) + 0.2,
                           columns=['df2_1', 'df2_2'])
        df3 = pd.DataFrame(data=np.random.rand(80, 2) + 0.4,
                           columns=['df3_1', 'df3_2'])
        df1['x'] = np.random.choice(3, 120)
        df2['x'] = np.random.choice(3, 100)
        df3['x'] = np.random.choice(3, 80)

        fig = Plot(outpath=self.outpath, save_image=self.save_image).box(
            dfs=[df1, df2, df3],
            plot_cols=['df1_1', 'df2_1', 'df3_1'],
            groupby_cols=['x', 'x', 'x'],
            df_cat=['red', 'blu', 'gre'],
            outfile='box.png')
Exemplo n.º 10
0
    def test_solar_electric(self):
        """Test solar electric project level model"""
        # Default parameters, sizing and load for a 4 person household.

        (
            cons_total,
            proj_total,
            [
                proj_total_dict,
                sol_fra,
                pump_el_use,
                pump_op_hour,
                ts_res,
                rel_err,
            ],
        ) = self.hp_wh.solar_electric()

        if self.plot_results:
            Plot(
                data_headers=[
                    "Demand",
                    "HP del",
                    "Aux del",
                    "Tank del",
                    "Unmet",
                    "PV",
                    "HP el. use",
                    "Aux el. use",
                ],
                outpath=self.outpath,
                save_image=self.plot_results,
                title="Heat pump tank with PV",
                label_v="Power / Heatrate [W]",
            ).series(
                ts_res.loc[4920:5000, [
                    self.r["q_dem"],
                    self.r["q_del_hp"],
                    self.r["q_del_bckp"],
                    self.r["q_del_tank"],
                    self.r["q_unmet_tank"],
                    self.r["p_pv_ac"],
                    self.r["p_hp_el_use"],
                    self.r["p_el_res_use"],
                ], ],
                outfile="img/"
                "hp_tank_pv_heatrate_defpars_4per_80gallons.png",
                modes="lines",
            )

            Plot(
                data_headers=["T_upper", "T_lower"],
                outpath=self.outpath,
                save_image=self.plot_results,
                title="Heat pump tank",
                label_v="Temperature [K]",
            ).series(
                ts_res.loc[4920:5000,
                           [self.r["t_tank_up"], self.r["t_tank_low"]]],
                outfile="img/hp_tank_temp_defpars_4per_80gallons.png",
                modes="lines",
            )

        self.assertAlmostEqual(sol_fra["annual"], 0.328, places=2)
Exemplo n.º 11
0
    def test_solar_thermal_community_retrofit(self):
        """Tests solar thermal project level model with
        a gas tank backup heater
        """
        # Default parameters, sizing and load for a 4 person
        # household, retrofit
        (
            cons_total,
            proj_total,
            [
                proj_total_dict,
                sol_fra,
                pump_el_use,
                pump_op_hour,
                ts_res,
                backup_ts_cons,
                rel_err,
            ],
        ) = self.sol_wh_com_retr.solar_thermal(backup="retrofit")

        self.assertAlmostEqual(
            proj_total[self.r["q_del_bckp"]],
            cons_total[self.r["q_del_bckp"]].sum(),
            places=1,
        )

        self.assertAlmostEqual(proj_total[self.r["q_del_bckp"]],
                               846306.03,
                               places=1)

        self.assertAlmostEqual(
            proj_total[self.r["el_use"]],
            cons_total[self.r["el_use"]].sum(),
            places=1,
        )

        self.assertAlmostEqual(proj_total[self.r["el_use"]],
                               138084.38,
                               places=1)

        self.assertAlmostEqual(proj_total[self.r["q_del_bckp"]],
                               846306.03,
                               places=1)

        self.assertAlmostEqual(
            ts_res[self.r["q_dump"]].sum(),
            proj_total[self.r["q_dump"]],
            places=1,
        )

        self.assertAlmostEqual(sol_fra["annual"],
                               cons_total.at[1, self.r["sol_fra"]],
                               places=1)

        if self.plot_results:
            Plot(
                data_headers=["Demand", "Delivered", "Unmet", "Coil"],
                outpath=self.outpath,
                save_image=self.plot_results,
                title="Solar tank",
                label_v="Heat rate [W]",
            ).series(
                ts_res.loc[4900:5000, [
                    self.r["q_dem"],
                    self.r["q_del_tank"],
                    self.r["q_unmet_tank"],
                    self.r["q_del_sol"],
                ], ],
                outfile="img/"
                "sol_tank_com_retr_heatrate_defpars_4per.png",
                modes="lines",
            )

            Plot(
                data_headers=[self.r["t_tank_up"], self.r["t_tank_low"]],
                outpath=self.outpath,
                save_image=self.plot_results,
                title="Solar tank",
                label_v="Temperature [K]",
            ).series(
                ts_res.loc[4900:5000,
                           [self.r["t_tank_up"], self.r["t_tank_low"]]],
                outfile="img/sol_tank_com_retr_temp_defpars_4per.png",
                modes="lines",
            )
Exemplo n.º 12
0
    def test_solar_thermal_individual_new(self):
        """Test solar thermal project level model with a
        tankless backup heater
        """

        # Default parameters, sizing and load for a 4 person
        # household.
        (
            cons_total,
            proj_total,
            [
                proj_total_dict,
                sol_fra,
                pump_el_use,
                pump_op_hour,
                ts_res,
                backup_ts_cons,
                rel_err,
            ],
        ) = self.sol_wh_indiv_new.solar_thermal(backup="gas")

        self.assertAlmostEqual(proj_total[self.r["q_del_tank"]],
                               2451283.75,
                               places=1)

        self.assertAlmostEqual(proj_total[self.r["q_dump"]],
                               1370147.25,
                               places=1)

        self.assertAlmostEqual(proj_total[self.r["el_use"]],
                               54490.14,
                               places=1)

        self.assertAlmostEqual(
            proj_total[self.r["q_del_bckp"]],
            cons_total.at[0, self.r["q_del_bckp"]],
            places=1,
        )

        self.assertAlmostEqual(proj_total[self.r["q_del_bckp"]],
                               215101.34,
                               places=1)

        self.assertAlmostEqual(sol_fra["annual"],
                               cons_total.at[0, self.r["sol_fra"]],
                               places=1)

        # Seasonal energy use
        self.assertAlmostEqual(
            cons_total[self.r["gas_use"]][0],
            (cons_total[self.r["gas_use_s"]][0] +
             cons_total[self.r["gas_use_w"]][0]),
            places=1,
        )

        self.assertAlmostEqual(
            cons_total[self.r["el_use"]][0],
            (cons_total[self.r["el_use_s"]][0] +
             cons_total[self.r["el_use_w"]][0]),
            places=1,
        )

        if self.plot_results:
            Plot(
                data_headers=["Demand", "Delivered", "Unmet", "Coil"],
                outpath=self.outpath,
                save_image=self.plot_results,
                title="Solar tank",
                label_v="Heat rate [W]",
            ).series(
                ts_res.loc[5112:5232, [
                    self.r["q_dem"],
                    self.r["q_del_tank"],
                    self.r["q_unmet_tank"],
                    self.r["q_del_sol"],
                ], ],
                outfile="img/"
                "sol_tank_ind_new_heatrate_defpars_4per_summer.png",
                modes="lines",
            )

            Plot(
                data_headers=[self.r["t_tank_up"], self.r["t_tank_low"]],
                outpath=self.outpath,
                save_image=self.plot_results,
                title="Solar tank",
                label_v="Temperature [K]",
            ).series(
                ts_res.loc[5112:5232,
                           [self.r["t_tank_up"], self.r["t_tank_low"]]],
                outfile="img/"
                "sol_tank_ind_new_temp_defpars_4per_summer.png",
                modes="lines",
            )

        if self.plot_results:
            Plot(
                data_headers=["Demand", "Delivered", "Unmet", "Coil"],
                outpath=self.outpath,
                save_image=self.plot_results,
                title="Solar tank",
                label_v="Heat rate [W]",
            ).series(
                ts_res.loc[480:600, [
                    self.r["q_dem"],
                    self.r["q_del_tank"],
                    self.r["q_unmet_tank"],
                    self.r["q_del_sol"],
                ], ],
                outfile="img/"
                "sol_tank_ind_new_heatrate_defpars_4per_winter.png",
                modes="lines",
            )

            Plot(
                data_headers=[self.r["t_tank_up"], self.r["t_tank_low"]],
                outpath=self.outpath,
                save_image=self.plot_results,
                title="Solar tank",
                label_v="Temperature [K]",
            ).series(
                ts_res.loc[480:600,
                           [self.r["t_tank_up"], self.r["t_tank_low"]]],
                outfile="img/"
                "sol_tank_ind_new_temp_defpars_4per_winter.png",
                modes="lines",
            )
Exemplo n.º 13
0
    def test_solar_thermal_individual_new(self):
        """Test solar thermal project level model with a
        tankless backup heater
        """

        # Default parameters, sizing and load for a 4 person
        # household.
        cons_total, proj_total, \
            [proj_total_dict, sol_fra, pump_el_use, pump_op_hour, ts_res,
             backup_ts_cons, rel_err] = self.sol_wh_indiv_new.solar_thermal(
                 backup='gas')

        self.assertAlmostEqual(proj_total[self.r['q_del_tank']],
                               2451283.75,
                               places=1)

        self.assertAlmostEqual(proj_total[self.r['q_dump']],
                               1370147.25,
                               places=1)

        self.assertAlmostEqual(proj_total[self.r['el_use']],
                               54490.14,
                               places=1)

        self.assertAlmostEqual(proj_total[self.r['q_del_bckp']],
                               cons_total.at[0, self.r['q_del_bckp']],
                               places=1)

        self.assertAlmostEqual(proj_total[self.r['q_del_bckp']],
                               215101.34,
                               places=1)

        self.assertAlmostEqual(sol_fra['annual'],
                               cons_total.at[0, self.r['sol_fra']],
                               places=1)

        # Seasonal energy use
        self.assertAlmostEqual(cons_total[self.r['gas_use']][0],
                               (cons_total[self.r['gas_use_s']][0] +
                                cons_total[self.r['gas_use_w']][0]),
                               places=1)

        self.assertAlmostEqual(cons_total[self.r['el_use']][0],
                               (cons_total[self.r['el_use_s']][0] +
                                cons_total[self.r['el_use_w']][0]),
                               places=1)

        if self.plot_results:
            Plot(data_headers=['Demand', 'Delivered', 'Unmet', 'Coil'],
                 outpath=self.outpath,
                 save_image=self.plot_results,
                 title='Solar tank',
                 label_v='Heat rate [W]').series(
                     ts_res.loc[5112:5232, [self.r['q_dem'],
                      self.r['q_del_tank'],
                      self.r['q_unmet_tank'],
                      self.r['q_del_sol']]],
                      outfile='img/'\
                      'sol_tank_ind_new_heatrate_defpars_4per_summer.png',
                      modes='lines')

            Plot(data_headers=[self.r['t_tank_up'], self.r['t_tank_low']],
                 outpath=self.outpath,
                 save_image=self.plot_results,
                 title='Solar tank',
                 label_v='Temperature [K]').series(
                     ts_res.loc[5112:5232, [self.r['t_tank_up'],
                     self.r['t_tank_low']]],
                     outfile='img/'\
                     'sol_tank_ind_new_temp_defpars_4per_summer.png',
                     modes='lines')

        if self.plot_results:
            Plot(data_headers=['Demand', 'Delivered', 'Unmet', 'Coil'],
                 outpath=self.outpath,
                 save_image=self.plot_results,
                 title='Solar tank',
                 label_v='Heat rate [W]').series(
                     ts_res.loc[480:600, [self.r['q_dem'],
                     self.r['q_del_tank'],
                     self.r['q_unmet_tank'], self.r['q_del_sol']]],
                     outfile='img/'\
                     'sol_tank_ind_new_heatrate_defpars_4per_winter.png',
                     modes='lines')

            Plot(data_headers=[self.r['t_tank_up'], self.r['t_tank_low']],
                 outpath=self.outpath,
                 save_image=self.plot_results,
                 title='Solar tank',
                 label_v='Temperature [K]').series(
                     ts_res.loc[480:600, [self.r['t_tank_up'],
                     self.r['t_tank_low']]],
                     outfile='img/'\
                     'sol_tank_ind_new_temp_defpars_4per_winter.png',
                     modes='lines')