Esempio n. 1
0
def run_simmod(run_start_year,
               run_end_year,
               dt,
               rcp,
               c_sens=c_sens,
               add_start=0,
               add_end=0,
               c_add=0,
               ch4_add=0,
               n2o_add=0):

    warnings.simplefilter(action='ignore', category=FutureWarning)
    pd.set_option('mode.chained_assignment', None)
    """
    Run the various parts of SimMod and export images and CSV files.
    """
    run_years = (run_end_year - run_start_year + 1)
    emission_vals = emissions(run_start_year, run_end_year, dt, rcp, add_start,
                              add_end, c_add, ch4_add, n2o_add)
    conc = pulse_decay_runner(run_years, dt, emission_vals)

    #    if carbon_model == 'BEAM':
    #        beam._initial_carbon = np.array([596., 713., 35625.])
    #        beam.intervals = SUBSTEPS
    #        beam.time_step = dt
    #        beam.emissions = emission_vals['co2_pg'] / C_TO_CO2
    #        beam_results = pd.melt(beam.run()[0:1])
    #        conc['co2_ppm'] = beam_results['value'] * PGC_TO_MOL * 1e6 / MOLES_IN_ATMOSPHERE

    #    if carbon_model == 'box diffusion':
    #        box_diffusion_results = box_diffusion_model(
    #            emission_vals,
    #            dt,
    #            DZ,
    #            MIXING
    #        )
    #        conc['co2_ppm'] = box_diffusion_results['co2ppm']

    if normalize_2000_conc == True:
        conc['co2_ppm'] = (conc['co2_ppm'] -
                           conc.loc[conc['year'] == 2000, 'co2_ppm'].min() +
                           emission_vals.loc[emission_vals['year'] == 2000,
                                             'rcp_co2_ppm'].min())
        conc['ch4_ppb'] = (conc['ch4_ppb'] -
                           conc.loc[conc['year'] == 2000, 'ch4_ppb'].min() +
                           emission_vals.loc[emission_vals['year'] == 2000,
                                             'rcp_ch4_ppb'].min())
        conc['n2o_ppb'] = (conc['n2o_ppb'] -
                           conc.loc[conc['year'] == 2000, 'n2o_ppb'].min() +
                           emission_vals.loc[emission_vals['year'] == 2000,
                                             'rcp_n2o_ppb'].min())

    forcing = calc_radiative_forcing(conc)
    warming = continuous_diffusion_model(forcing, run_years, dt, c_sens)
    return warming


#results = run_simmod(run_start_year, run_end_year, dt, rcp, c_sens)
#results.to_csv('results/simmod_run_'+rcp+' '+carbon_model+'.csv')
Esempio n. 2
0
def run_simmod(run_start_year,
               run_end_year,
               dt,
               rcp,
               c_sens=c_sens,
               add_start=0,
               add_end=0,
               c_add=0,
               ch4_add=0,
               n2o_add=0):
    """
    Run the various parts of SimMod and export images and CSV files.
    """
    run_years = (run_end_year - run_start_year + 1)
    emission_vals = emissions(run_start_year, run_end_year, dt, rcp, add_start,
                              add_end, c_add, ch4_add, n2o_add)
    conc = pulse_decay_runner(run_years, dt, emission_vals)

    if carbon_model == 'BEAM':
        beam._initial_carbon = np.array([596., 713., 35625.])
        beam.intervals = SUBSTEPS
        beam.time_step = dt
        beam.emissions = emission_vals['co2_pg'] / C_TO_CO2
        beam_results = pd.melt(beam.run()[0:1])
        conc['co2_ppm'] = beam_results[
            'value'] * PGC_TO_MOL * 1e6 / MOLES_IN_ATMOSPHERE

    if carbon_model == 'box diffusion':
        box_diffusion_results = box_diffusion_model(emission_vals, dt, DZ,
                                                    MIXING)
        conc['co2_ppm'] = box_diffusion_results['co2ppm']

    if normalize_2000_conc == True:
        conc['co2_ppm'] = (conc['co2_ppm'] -
                           conc.loc[conc['year'] == 2000, 'co2_ppm'].min() +
                           emission_vals.loc[emission_vals['year'] == 2000,
                                             'rcp_co2_ppm'].min())
        conc['ch4_ppb'] = (conc['ch4_ppb'] -
                           conc.loc[conc['year'] == 2000, 'ch4_ppb'].min() +
                           emission_vals.loc[emission_vals['year'] == 2000,
                                             'rcp_ch4_ppb'].min())
        conc['n2o_ppb'] = (conc['n2o_ppb'] -
                           conc.loc[conc['year'] == 2000, 'n2o_ppb'].min() +
                           emission_vals.loc[emission_vals['year'] == 2000,
                                             'rcp_n2o_ppb'].min())

    forcing = calc_radiative_forcing(conc)
    warming = continuous_diffusion_model(forcing, run_years, dt, c_sens)
    return warming
def run_simmod(*, run_start_year, run_end_year, dt, rcp, add_start, add_end,
               c_add, ch4_add, n2o_add, carbon_model, cfg_beam,
               normalize_2000_conc, c_sens):
    """
    Run the various parts of SimMod and save the results.
    """
    run_years = (run_end_year - run_start_year + 1)
    emission_vals = emissions(run_start_year, run_end_year, dt, rcp, add_start,
                              add_end, c_add, ch4_add, n2o_add)
    conc = pulse_decay_runner(run_years, dt, emission_vals)

    if carbon_model == 'BEAM':
        try:
            from beam_carbon.beam import BEAMCarbon
        except ImportError as err:
            raise RuntimeError("No BEAMCarbon model found! Please run the "
                               "installation procedure for the BEAMCarbon "
                               "model in '/beam_carbon/'.") from err

        beam = BEAMCarbon()
        beam._temperature_dependent = cfg_beam['temperature_dependent']
        beam._initial_carbon = np.array(
            [cfg_beam['INIT_MAT'], cfg_beam['INIT_MUP'], cfg_beam['INIT_MLO']])
        beam.intervals = cfg_beam['SUBSTEPS']
        beam.time_step = dt
        beam.emissions = emission_vals['co2_pg'] / C_TO_CO2
        beam_results = pd.melt(beam.run()[0:1])
        conc['co2_ppm'] = beam_results[
            'value'] * PGC_TO_MOL * 1e6 / MOLES_IN_ATMOSPHERE

    if normalize_2000_conc == True:
        conc['co2_ppm'] = (conc['co2_ppm'] -
                           conc.loc[conc['year'] == 2000, 'co2_ppm'].min() +
                           emission_vals.loc[emission_vals['year'] == 2000,
                                             'rcp_co2_ppm'].min())
        conc['ch4_ppb'] = (conc['ch4_ppb'] -
                           conc.loc[conc['year'] == 2000, 'ch4_ppb'].min() +
                           emission_vals.loc[emission_vals['year'] == 2000,
                                             'rcp_ch4_ppb'].min())
        conc['n2o_ppb'] = (conc['n2o_ppb'] -
                           conc.loc[conc['year'] == 2000, 'n2o_ppb'].min() +
                           emission_vals.loc[emission_vals['year'] == 2000,
                                             'rcp_n2o_ppb'].min())

    forcing = calc_radiative_forcing(conc)
    warming = continuous_diffusion_model(forcing, run_years, dt, c_sens)
    return warming
def run_simmod(*, run_start_year, run_end_year, dt, rcp, add_start, add_end,
               c_add, ch4_add, n2o_add, carbon_model, cfg_beam,
               normalize_2000_conc, c_sens):
    """
    Run the various parts of SimMod and export images and CSV files.
    """
    run_years = (run_end_year - run_start_year + 1)
    emission_vals = emissions(run_start_year, run_end_year, dt, rcp, add_start,
                              add_end, c_add, ch4_add, n2o_add)
    conc = pulse_decay_runner(run_years, dt, emission_vals)

    if carbon_model == 'BEAM':
        beam = BEAMCarbon()
        beam._temperature_dependent = cfg_beam['temperature_dependent']
        beam._initial_carbon = np.array(
            [cfg_beam['INIT_MAT'], cfg_beam['INIT_MUP'], cfg_beam['INIT_MLO']])
        beam.intervals = cfg_beam['SUBSTEPS']
        beam.time_step = dt
        beam.emissions = emission_vals['co2_pg'] / C_TO_CO2
        beam_results = pd.melt(beam.run()[0:1])
        conc['co2_ppm'] = beam_results[
            'value'] * PGC_TO_MOL * 1e6 / MOLES_IN_ATMOSPHERE

    if normalize_2000_conc == True:
        conc['co2_ppm'] = (conc['co2_ppm'] -
                           conc.loc[conc['year'] == 2000, 'co2_ppm'].min() +
                           emission_vals.loc[emission_vals['year'] == 2000,
                                             'rcp_co2_ppm'].min())
        conc['ch4_ppb'] = (conc['ch4_ppb'] -
                           conc.loc[conc['year'] == 2000, 'ch4_ppb'].min() +
                           emission_vals.loc[emission_vals['year'] == 2000,
                                             'rcp_ch4_ppb'].min())
        conc['n2o_ppb'] = (conc['n2o_ppb'] -
                           conc.loc[conc['year'] == 2000, 'n2o_ppb'].min() +
                           emission_vals.loc[emission_vals['year'] == 2000,
                                             'rcp_n2o_ppb'].min())

    forcing = calc_radiative_forcing(conc)
    warming = continuous_diffusion_model(forcing, run_years, dt, c_sens)
    return warming
Esempio n. 5
0
def run_simmod_orig(run_start_year,
                    run_end_year,
                    dt,
                    rcp,
                    CO2_PPM_1750,
                    CH4_PPB_1750,
                    N2O_PPB_1750,
                    c_sens,
                    add_start=0,
                    add_end=0,
                    c_add=0,
                    ch4_add=0,
                    n2o_add=0):
    """
    Run the various parts of SimMod and export images and CSV files.
    """
    run_years = (run_end_year - run_start_year + 1)
    emission_vals = emissions(run_start_year, run_end_year, dt, rcp,
                              CO2_PPM_1750, CH4_PPB_1750, N2O_PPB_1750,
                              add_start, add_end, c_add, ch4_add, n2o_add)
    conc = pulse_decay_runner(run_years, dt, emission_vals)

    if normalize_2000_conc == True:
        conc['co2_ppm'] = (conc['co2_ppm'] -
                           conc.loc[conc['year'] == 2000, 'co2_ppm'].min() +
                           emission_vals.loc[emission_vals['year'] == 2000,
                                             'rcp_co2_ppm'].min())
        conc['ch4_ppb'] = (conc['ch4_ppb'] -
                           conc.loc[conc['year'] == 2000, 'ch4_ppb'].min() +
                           emission_vals.loc[emission_vals['year'] == 2000,
                                             'rcp_ch4_ppb'].min())
        conc['n2o_ppb'] = (conc['n2o_ppb'] -
                           conc.loc[conc['year'] == 2000, 'n2o_ppb'].min() +
                           emission_vals.loc[emission_vals['year'] == 2000,
                                             'rcp_n2o_ppb'].min())

    forcing = calc_radiative_forcing(conc, CO2_PPM_1750, CH4_PPB_1750,
                                     N2O_PPB_1750)
    warming = continuous_diffusion_model(forcing, run_years, dt, c_sens)
    return warming