Example #1
0
def test_gwp():
    """Checks that GWP calculator produces correct GWPs."""

    # methane uses "perturbation lifetime" for GWP calculations and feedback
    # factor
    assert np.round(gwp(100, 12.4, radeff.CH4, molwt.CH4, f=0.65)) == 28

    # for N2O, I think the IPCC AR5 value is out by one year. Most likely
    # explanation is that they have rounded off the feedback somewhere.
    # This is calculated as 1-(1-0.36*(1.65)*radeff.CH4/radeff.N2O). See
    # eq. 8.SM.20 in the supplement to Chapter 8, AR5
    assert np.round(gwp(20, lifetime.N2O, radeff.N2O, molwt.N2O,
                        f=-0.071874)) == 263
    assert np.round(gwp(100, lifetime.N2O, radeff.N2O, molwt.N2O,
                        f=-0.071874)) == 264

    # Now check a nice straightforward example
    assert np.round(gwp(100, lifetime.CFC11, radeff.CFC11, molwt.CFC11),
                    decimals=-1) == 4660
Example #2
0
def test_gwp_newghgs():
    """Test CMIP6 GHGs recreate AR5 GWPs.

    Possibly due to numerical precision, these do not agree with IPCC values 
    to 3 significant figures in all cases. The original GWPs were calculated
    by Hodnebrog et al., using an excel spreadsheet. In many cases the
    radiative efficiency in Hodnebrog is given to a high precision whereas in
    the IPCC report it is typically only 2 decimal places. For the new gases
    we use the high-precision values from Hodnebrog (precise, but accurate?)
    but even so, differences in numerics between numpy and Excel sometimes 
    cause values to disagree in the third significant figure (also we don't
    know the precise value of molecular weight Hodnebrog used).

    So, if these calculated values agree to IPCC within 1%, they pass the test.
    """
    assert 0.99 * 8900 < gwp(100, lifetime.C3F8, radeff.C3F8,
                             molwt.C3F8) < 1.01 * 8900
    assert 0.99 * 9200 < gwp(100, lifetime.C4F10, radeff.C4F10,
                             molwt.C4F10) < 1.01 * 9200
    assert 0.99 * 8550 < gwp(100, lifetime.C5F12, radeff.C5F12,
                             molwt.C5F12) < 1.01 * 8550
    assert 0.99 * 7820 < gwp(100, lifetime.C7F16, radeff.C7F16,
                             molwt.C7F16) < 1.01 * 7820
    assert 0.99 * 7620 < gwp(100, lifetime.C8F18, radeff.C8F18,
                             molwt.C8F18) < 1.01 * 7620
    assert 0.99 * 9540 < gwp(100, lifetime.C_C4F8, radeff.C_C4F8,
                             molwt.C_C4F8) < 1.01 * 9540
    assert 0.99 * 1650 < gwp(100, lifetime.HFC43_10MEE, radeff.HFC43_10MEE,
                             molwt.HFC43_10MEE) < 1.01 * 1650
    assert 0.99 * 138 < gwp(100, lifetime.HFC152A, radeff.HFC152A,
                            molwt.HFC152A) < 1.01 * 138
    assert 0.99 * 8060 < gwp(100, lifetime.HFC236FA, radeff.HFC236FA,
                             molwt.HFC236FA) < 1.01 * 8060
    assert 0.99 * 804 < gwp(100, lifetime.HFC365MFC, radeff.HFC365MFC,
                            molwt.HFC365MFC) < 1.01 * 804
    assert 0.99 * 16100 < gwp(100, lifetime.NF3, radeff.NF3,
                              molwt.NF3) < 1.01 * 16100
    assert 0.99 * 4090 < gwp(100, lifetime.SO2F2, radeff.SO2F2,
                             molwt.SO2F2) < 1.01 * 4090
    assert 0.99 * 160 < gwp(100, lifetime.CH3CCL3, radeff.CH3CCL3,
                            molwt.CH3CCL3) < 1.01 * 160

    # these are only given to low precision in AR5 so give more generous tolerance
    assert 8.5 < gwp(100, lifetime.CH2CL2, radeff.CH2CL2, molwt.CH2CL2) < 9.5
    assert 15.5 < gwp(100, lifetime.CHCL3, radeff.CHCL3, molwt.CHCL3) < 16.5