In [1]:
import matplotlib
import matplotlib.pyplot as plt
%matplotlib inline

In [2]:
from openfisca_france.tests.base import tax_benefit_system

In [3]:
from datetime import date  # module nécessaire pour la définition des dates, dont notamment les dates de naissances
from openfisca_france.tests.base import tax_benefit_system




def make_couple_with_child_scenario(nombre_enfants = 0, year = None, tax_benefit_system = tax_benefit_system,
                                    axes_variable = 'salaire_de_base',  ax_variable_max = 150000, count = 5000):
    enfant = [dict(
        birth = date(2005, 1, 1),
        )]
    enfants = enfant * nombre_enfants
    scenario = tax_benefit_system.new_scenario().init_single_entity(
        axes = [[
            dict(
                count = count,
                min = 0,
                max = ax_variable_max,
                name = axes_variable,
                period = year-2,
                ),
            dict(
                count = count,
                min = 0,
                max = ax_variable_max,
                name = axes_variable,
                period = year-1,
                ),
            dict(
                count = count,
                min = 0,
                max = ax_variable_max,
                name = axes_variable,
                period = year,
                ),
            ]],
        period = year,
        parent1 = dict(
            birth = date(1980, 1, 1),
            statmarit = 5, #pacsés
            ),
        parent2 = dict(
            birth = date(1980, 1, 1),
            statmarit = 5,
            ),
        enfants = enfants,
        menage = dict(
            loyer = 1000,
            statut_occupation = 4,
            ),
        )
    return scenario
def make_single_with_child_scenario(nombre_enfants = 0, year = None, tax_benefit_system = tax_benefit_system,
                                    axes_variable = 'salaire_de_base',  ax_variable_max = 150000, count = 5000):
    enfant = [dict(
        birth = date(2005, 1, 1),
        )]
    enfants = enfant * nombre_enfants
    scenario = tax_benefit_system.new_scenario().init_single_entity(
        axes = [[
            dict(
                count = count,
                min = 0,
                max = ax_variable_max,
                name = axes_variable,
                period = year-2,
                ),
            dict(
                count = count,
                min = 0,
                max = ax_variable_max,
                name = axes_variable,
                period = year-1,
                ),
            dict(
                count = count,
                min = 0,
                max = ax_variable_max,
                name = axes_variable,
                period = year,
                ),
            ]],
        period = year,
        parent1 = dict(
            birth = date(1980, 1, 1),
            ),
        enfants = enfants,
        menage = dict(
            loyer = 1000,
            statut_occupation = 4,
            ),
        )
    return scenario

In [4]:
scenario_couple_sans_enfants = make_couple_with_child_scenario(0, 2014)

In [7]:
from openfisca_core import web_tools
print web_tools.get_trace_tool_link(scenario_couple_sans_enfants, ["salaire_de_base"], api_url="http://api.openfisca.fr")


http://www.openfisca.fr/outils/trace?api_url=http%3A%2F%2Fapi.openfisca.fr&simulation=%7B%22scenarios%22%3A+%5B%7B%22axes%22%3A+%5B%5B%7B%22count%22%3A+5000%2C+%22index%22%3A+0%2C+%22name%22%3A+%22salaire_de_base%22%2C+%22min%22%3A+0%2C+%22max%22%3A+150000%2C+%22period%22%3A+%5B%22year%22%2C+%5B2012%2C+1%2C+1%5D%2C+1%5D%7D%2C+%7B%22count%22%3A+5000%2C+%22index%22%3A+0%2C+%22name%22%3A+%22salaire_de_base%22%2C+%22min%22%3A+0%2C+%22max%22%3A+150000%2C+%22period%22%3A+%5B%22year%22%2C+%5B2013%2C+1%2C+1%5D%2C+1%5D%7D%2C+%7B%22count%22%3A+5000%2C+%22index%22%3A+0%2C+%22name%22%3A+%22salaire_de_base%22%2C+%22min%22%3A+0%2C+%22max%22%3A+150000%2C+%22period%22%3A+%5B%22year%22%2C+%5B2014%2C+1%2C+1%5D%2C+1%5D%7D%5D%5D%2C+%22period%22%3A+%222014%22%2C+%22test_case%22%3A+%7B%22familles%22%3A+%5B%7B%22id%22%3A+0%2C+%22parents%22%3A+%5B%22ind0%22%2C+%22ind1%22%5D%7D%5D%2C+%22foyers_fiscaux%22%3A+%5B%7B%22id%22%3A+0%2C+%22declarants%22%3A+%5B%22ind0%22%2C+%22ind1%22%5D%7D%5D%2C+%22individus%22%3A+%5B%7B%22id%22%3A+%22ind0%22%2C+%22statmarit%22%3A+5%2C+%22birth%22%3A+%221980-01-01%22%7D%2C+%7B%22id%22%3A+%22ind1%22%2C+%22statmarit%22%3A+5%2C+%22birth%22%3A+%221980-01-01%22%7D%5D%2C+%22menages%22%3A+%5B%7B%22id%22%3A+0%2C+%22personne_de_reference%22%3A+%22ind0%22%2C+%22conjoint%22%3A+%22ind1%22%2C+%22loyer%22%3A+1000.0%2C+%22statut_occupation%22%3A+4%7D%5D%7D%7D%5D%2C+%22variables%22%3A+%5B%22salaire_de_base%22%5D%7D

In [5]:
simulation_couple_sans_enfants = scenario_couple_sans_enfants.new_simulation()

In [16]:
salaire_net = simulation_couple_sans_enfants.calculate_add("salaire_net")
salaire_de_base = simulation_couple_sans_enfants.calculate_add("salaire_de_base")

In [7]:
revenu_disponible = simulation_couple_sans_enfants.calculate_add("revdisp")

In [1]:
import matplotlib.pyplot as plt

In [12]:
plt.plot(salaire_net[::2],
        revenu_disponible)


Out[12]:
[<matplotlib.lines.Line2D at 0x7f7a6fc3ac50>]

In [15]:
from openfisca_core import rates

In [27]:
taux_marginal = rates.marginal_rate(revenu_disponible, salaire_de_base[::2])

In [39]:
plt.plot(salaire_de_base[2::2],
        taux_marginal)
plt.ylim(0,0.7)
plt.xlim(0,150000)


Out[39]:
(0, 150000)

In [ ]: