diff --git a/ogcore/default_parameters.json b/ogcore/default_parameters.json index 2922d15f3..56d119b6b 100644 --- a/ogcore/default_parameters.json +++ b/ogcore/default_parameters.json @@ -13,7 +13,7 @@ "section_1": "Household Parameters", "section_2": "Behavioral Assumptions", "notes": "See Altonji (JPE, 1986) and Peterman (Econ Inquiry, 2016) for estimates of the Frisch elasticity.", - "type": "float", + "type": "float32", "value": [ { "value": 0.4 @@ -31,7 +31,7 @@ "description": "Growth rate of labor augmenting technological change.", "section_1": "Economic Assumptions", "notes": "", - "type": "float", + "type": "float32", "value": [ { "value": 0.03 @@ -50,7 +50,7 @@ "section_1": "Household Parameters", "section_2": "Model Dimensions", "notes": "", - "type": "int", + "type": "int32", "value": [ { "value": 80 @@ -69,7 +69,7 @@ "section_1": "Household Parameters", "section_2": "Model Dimensions", "notes": "", - "type": "int", + "type": "int32", "value": [ { "value": 7 @@ -88,7 +88,7 @@ "section_1": "Household Parameters", "section_2": "Model Dimensions", "notes": "", - "type": "int", + "type": "int32", "value": [ { "value": 320 @@ -107,7 +107,7 @@ "section_1": "Firm Parameters", "section_2": "Model Dimensions", "notes": "", - "type": "int", + "type": "int32", "value": [ { "value": 1 @@ -126,7 +126,7 @@ "section_1": "Household Parameters", "section_2": "Model Dimensions", "notes": "", - "type": "int", + "type": "int32", "value": [ { "value": 1 @@ -145,7 +145,7 @@ "section_1": "Household Parameters", "section_2": "Model Dimensions", "notes": "", - "type": "float", + "type": "float32", "number_dims": 1, "value": [ { @@ -173,7 +173,7 @@ "section_1": "Household Parameters", "section_2": "Endowments", "notes": "", - "type": "float", + "type": "float32", "number_dims": 2, "value": [ { @@ -289,7 +289,7 @@ "section_1": "Household Parameters", "section_2": "Model Dimensions", "notes": "", - "type": "int", + "type": "int32", "value": [ { "value": 20 @@ -308,7 +308,7 @@ "section_1": "Household Parameters", "section_2": "Model Dimensions", "notes": "", - "type": "int", + "type": "int32", "value": [ { "value": 100 @@ -343,7 +343,7 @@ "section_1": "Household Parameters", "section_2": "Behavioral Assumptions", "notes": "Default value from Carroll (JME, 2009). Allows for each type to have a different value.", - "type": "float", + "type": "float32", "number_dims": 1, "value": [ { @@ -371,7 +371,7 @@ "section_1": "Household Parameters", "section_2": "Behavioral Assumptions", "notes": "Default value from Attanasio, Banks, Meghir and Weber (JEBS, 1999).", - "type": "float", + "type": "float32", "value": [ { "value": 1.5 @@ -390,7 +390,7 @@ "section_1": "Household Parameters", "section_2": "Behavioral Assumptions", "notes": "", - "type": "float", + "type": "float32", "number_dims": 1, "value": [ { @@ -410,7 +410,7 @@ "section_1": "Firm Parameters", "section_2": "Production Function", "notes": "Historical value in U.S. is about 0.33, but Elsby, Hobijn, and Sahin (BPEA, 2013) find capital's share is increasing, so default value is above this.", - "type": "float", + "type": "float32", "number_dims": 1, "value": [ { @@ -430,7 +430,7 @@ "section_1": "Firm Parameters", "section_2": "Production Function", "notes": "", - "type": "float", + "type": "float32", "number_dims": 1, "value": [ { @@ -452,7 +452,7 @@ "section_1": "Firm Parameters", "section_2": "Production Function", "notes": "If epsilon=1, then production function is Cobb-Douglas. If epsilon=0, then production function is perfect substitutes.", - "type": "float", + "type": "float32", "number_dims": 1, "value": [ { @@ -472,7 +472,7 @@ "section_1": "Firm Parameters", "section_2": "Production Function", "notes": "", - "type": "float", + "type": "float32", "number_dims": 2, "value": [ { @@ -494,7 +494,7 @@ "section_1": "Firm Parameters", "section_2": "Production Function", "notes": "", - "type": "float", + "type": "float32", "number_dims": 2, "value": [ { @@ -516,7 +516,7 @@ "section_1": "Firm Parameters", "section_2": "Capital Accumulation", "notes": "Approximately the value from Kehoe calibration exercise: http://www.econ.umn.edu/~tkehoe/classes/calibration-04.pdf.", - "type": "float", + "type": "float32", "value": [ { "value": 0.05 @@ -535,7 +535,7 @@ "section_1": "Government Parameters", "section_2": "", "notes": "", - "type": "float", + "type": "float32", "value": [ { "value": 0.02 @@ -554,7 +554,7 @@ "section_1": "Household Parameters", "section_2": "Endowments", "notes": "Can be normalized to 1.0 without loss of generality.", - "type": "float", + "type": "float32", "value": [ { "value": 1.0 @@ -572,7 +572,7 @@ "description": "Exogenous annual world interest rate to be used when modeling a small open economy. Set value for base year, click '+' to add value for next year. All future years not specified are set to last value entered.", "section_1": "Open Economy Parameters", "notes": "", - "type": "float", + "type": "float32", "number_dims": 1, "value": [ { @@ -593,7 +593,7 @@ "description": "Share of government debt held by foreigners in model start year.", "section_1": "Open Economy Parameters", "notes": "", - "type": "float", + "type": "float32", "value": [ { "value": 0.4 @@ -611,7 +611,7 @@ "description": "Share of new debt issues from government that are purchased by foreigners. Set value for base year, click '+' to add value for next year. All future years not specified are set to last value entered.", "section_1": "Open Economy Parameters", "notes": "This value is about 0.4 historically for the U.S., set to zero to have closed econ as default.", - "type": "float", + "type": "float32", "number_dims": 1, "value": [ { @@ -632,7 +632,7 @@ "description": "Share of excess demand for capital that is supplied by foreigners. Set value for base year, click '+' to add value for next year. All future years not specified are set to last value entered.", "section_1": "Open Economy Parameters", "notes": "Set to 0.1 when running large-open verion of US economy, but hard to find data to pin this down.", - "type": "float", + "type": "float32", "number_dims": 1, "value": [ { @@ -654,7 +654,7 @@ "section_1": "Fiscal Policy Parameters", "section_2": "Fiscal Closure Rules", "notes": "It may make sense for this tG1 to exceed the length of the budget window one is looking at. But it must also not be too late into the time path that a steady-state won't be reached by time T.", - "type": "int", + "type": "int32", "value": [ { "value": 20 @@ -673,7 +673,7 @@ "section_1": "Fiscal Policy Parameters", "section_2": "Fiscal Closure Rules", "notes": "The number of periods until the closure rule ends must not exceed T, the time at which the model is assumed to reach the steady-state.", - "type": "int", + "type": "int32", "value": [ { "value": 256 @@ -692,7 +692,7 @@ "section_1": "Fiscal Policy Parameters", "section_2": "Spending", "notes": "", - "type": "float", + "type": "float32", "number_dims": 1, "value": [ { @@ -714,7 +714,7 @@ "section_1": "Fiscal Policy Parameters", "section_2": "Spending", "notes": "", - "type": "float", + "type": "float32", "number_dims": 1, "value": [ { @@ -736,7 +736,7 @@ "section_1": "Fiscal Policy Parameters", "section_2": "Spending", "notes": "", - "type": "float", + "type": "float32", "number_dims": 1, "value": [ { @@ -758,7 +758,7 @@ "section_1": "Fiscal Policy Parameters", "section_2": "Spending", "notes": "", - "type": "float", + "type": "float32", "number_dims": 1, "value": [ { @@ -780,7 +780,7 @@ "section_1": "Fiscal Policy Parameters", "section_2": "Spending", "notes": "", - "type": "float", + "type": "float32", "number_dims": 1, "value": [ { @@ -802,7 +802,7 @@ "section_1": "Fiscal Policy Parameters", "section_2": "Spending", "notes": "", - "type": "float", + "type": "float32", "number_dims": 1, "value": [ { @@ -824,7 +824,7 @@ "section_1": "Fiscal Policy Parameters", "section_2": "Fiscal Closure Rules", "notes": "Lower rho_G => slower convergence.", - "type": "float", + "type": "float32", "value": [ { "value": 0.1 @@ -843,7 +843,7 @@ "section_1": "Household Parameters", "section_2": "Endowments", "notes": "", - "type": "float", + "type": "float32", "value": [ { "value": 0.0 @@ -862,7 +862,7 @@ "section_1": "Household Parameters", "section_2": "Endowments", "notes": "", - "type": "float", + "type": "float32", "value": [ { "value": 0.0 @@ -881,7 +881,7 @@ "section_1": "Household Parameters", "section_2": "Endowments", "notes": "", - "type": "float", + "type": "float32", "number_dims": 1, "value": [ { @@ -903,7 +903,7 @@ "section_1": "Fiscal Policy Parameters", "section_2": "Fiscal Closure Rules", "notes": "Note that depending upon the tax policy parameters, some debt to GDP ratios may not be achievable with positive government spending.", - "type": "float", + "type": "float32", "value": [ { "value": 2.0 @@ -921,7 +921,7 @@ "description": "Debt to GDP ratio in the initial period.", "section_1": "Fiscal Policy Parameters", "notes": "Should be calibrated based on government debt held by the public to GDP in the model start year.", - "type": "float", + "type": "float32", "value": [ { "value": 0.78 @@ -939,7 +939,7 @@ "description": "Government capital (aka infrastructure) to GDP ratio in the initial period.", "section_1": "Fiscal Policy Parameters", "notes": "Should be calibrated based on the value of public infrastructure to GDP in the model start year.", - "type": "float", + "type": "float32", "value": [ { "value": 0.0 @@ -957,7 +957,7 @@ "description": "Parameter to scale the market interest rate to find interest rate on government debt.", "section_1": "Fiscal Policy Parameters", "notes": "", - "type": "float", + "type": "float32", "number_dims": 1, "value": [ { @@ -976,7 +976,7 @@ "section_1": "Fiscal Policy Parameters", "description": "Parameter to shift the market interest rate to find interest rate on government debt.", "notes": "", - "type": "float", + "type": "float32", "number_dims": 1, "value": [ { @@ -996,7 +996,7 @@ "section_1": "Fiscal Policy Parameters", "section_2": "Taxes", "notes": "This is the top marginal corporate income tax rate.", - "type": "float", + "type": "float32", "number_dims": 2, "value": [ { @@ -1018,7 +1018,7 @@ "section_1": "Fiscal Policy Parameters", "section_2": "Taxes", "notes": "This affects the effective corporate income tax rate on the representative firm in the model", - "type": "float", + "type": "float32", "value": [ { "value": 0.55 @@ -1037,7 +1037,7 @@ "section_1": "Fiscal Policy Parameters", "section_2": "Taxes", "notes": "This adjustment is necessary to match corporate income tax receipts found in the data. It is computed as the ratio of the CIT/GDP from US data to CIT/GDP in the model (with this parameter =1)", - "type": "float", + "type": "float32", "number_dims": 1, "value": [ { @@ -1057,7 +1057,7 @@ "section_1": "Fiscal Policy Parameters", "section_2": "Taxes", "notes": "This credit reduced the cost of new investment by the specified rate", - "type": "float", + "type": "float32", "number_dims": 2, "value": [ { @@ -1079,7 +1079,7 @@ "section_1": "Fiscal Policy Parameters", "section_2": "Taxes", "notes": "This policy parameter represents the effective consumption tax rate from sales taxes, VATs, and excise taxes by consumption good. Tax rates cab vary over time. It is thus a TxI array.", - "type": "float", + "type": "float32", "number_dims": 2, "value": [ { @@ -1101,7 +1101,7 @@ "section_1": "Fiscal Policy Parameters", "section_2": "Taxes", "notes": "Cost-of-Capital-Calculator can help to calibrate this parameter.", - "type": "float", + "type": "float32", "number_dims": 2, "value": [ { @@ -1123,7 +1123,7 @@ "section_1": "Fiscal Policy Parameters", "section_2": "Taxes", "notes": "", - "type": "float", + "type": "float32", "number_dims": 1, "value": [ { @@ -1145,7 +1145,7 @@ "section_1": "Fiscal Policy Parameters", "section_2": "Taxes", "notes": "Must be positive to avoid division by zero when computing ETR and MTR for wealth tax", - "type": "float", + "type": "float32", "number_dims": 1, "value": [ { @@ -1167,7 +1167,7 @@ "section_1": "Fiscal Policy Parameters", "section_2": "Taxes", "notes": "Set to 0 to have no wealth tax.", - "type": "float", + "type": "float32", "number_dims": 1, "value": [ { @@ -1189,7 +1189,7 @@ "section_1": "Fiscal Policy Parameters", "section_2": "Taxes", "notes": "", - "type": "float", + "type": "float32", "number_dims": 1, "value": [ { @@ -1211,7 +1211,7 @@ "section_1": "Fiscal Policy Parameters", "section_2": "Taxes", "notes": "Set to zero as default since tax functions include income and payroll taxes.", - "type": "float", + "type": "float32", "number_dims": 1, "value": [ { @@ -1233,7 +1233,7 @@ "section_1": "Household Parameters", "section_2": "Behavioral Assumptions", "notes": "", - "type": "float", + "type": "float32", "number_dims": 1, "value": [ { @@ -1261,7 +1261,7 @@ "section_1": "Household Parameters", "section_2": "Behavioral Assumptions", "notes": "", - "type": "float", + "type": "float32", "number_dims": 1, "value": [ { @@ -1383,7 +1383,7 @@ "section_1": "Fiscal Policy Parameters", "section_2": "Spending", "notes": "The universal basic income (UBI) per child ages 0 through 17 can take positive or negative values (e.g., a negative value may be used to implement a head tax).", - "type": "float", + "type": "float32", "value": [ { "value": 0.0 @@ -1402,7 +1402,7 @@ "section_1": "Fiscal Policy Parameters", "section_2": "Spending", "notes": "The universal basic income (UBI) per adult age 18 through 64 can take positive or negative values (e.g., a negative value may be used to implement a head tax).", - "type": "float", + "type": "float32", "value": [ { "value": 0.0 @@ -1421,7 +1421,7 @@ "section_1": "Fiscal Policy Parameters", "section_2": "Spending", "notes": "The universal basic income (UBI) per adult age 65 can take positive or negative values (e.g., a negative value may be used to implement a head tax).", - "type": "float", + "type": "float32", "value": [ { "value": 0.0 @@ -1440,7 +1440,7 @@ "section_1": "Fiscal Policy Parameters", "section_2": "Spending", "notes": "The maximum dollar (nominal) amount of universal basic income (UBI) per household can range from $0 per year to $40,000 per year ($3,333 per month).", - "type": "float", + "type": "float32", "value": [ { "value": 40000.0 @@ -1459,7 +1459,7 @@ "section_1": "Fiscal Policy Parameters", "section_2": "Spending", "notes": "This SxJ matrix gives the fraction of total aggregate transfers going to each age s and ability type j.", - "type": "float", + "type": "float32", "number_dims": 2, "value": [ { @@ -2200,7 +2200,7 @@ "section_1": "Household Parameters", "section_2": "Endowments", "notes": "This SxJ matrix gives the fraction of total aggregate remittances going to each age s and ability type j.", - "type": "float", + "type": "float32", "number_dims": 2, "value": [ { @@ -2941,7 +2941,7 @@ "section_1": "Household Parameters", "section_2": "Endowments", "notes": "This SxJ matrix gives the fraction of total aggregate bequests going to each age s and ability type j.", - "type": "float", + "type": "float32", "number_dims": 2, "value": [ { @@ -3762,7 +3762,7 @@ "section_1": "Fiscal Policy Parameters", "section_2": "Government Pension Parameters", "notes": "", - "type": "int", + "type": "int32", "number_dims": 1, "value": [ { @@ -3807,7 +3807,7 @@ "section_1": "Fiscal Policy Parameters", "section_2": "Government Pension Parameters", "notes": "", - "type": "float", + "type": "float32", "value": [ { "value": 0.0 @@ -3826,7 +3826,7 @@ "section_1": "Fiscal Policy Parameters", "section_2": "Government Pension Parameters", "notes": "indR = 0.0 for no survivor benefits, indR = 0.5 for survivor benefits", - "type": "float", + "type": "float32", "value": [ { "value": 0.0 @@ -3845,7 +3845,7 @@ "section_1": "Fiscal Policy Parameters", "section_2": "Government Pension Parameters", "notes": "k = 0.5 - (6/13n), where n is the number of payments per year", - "type": "float", + "type": "float32", "value": [ { "value": 0.0 @@ -3864,7 +3864,7 @@ "section_1": "Fiscal Policy Parameters", "section_2": "Government Pension Parameters", "notes": "", - "type": "float", + "type": "float32", "value": [ { "value": 0.0 @@ -3883,7 +3883,7 @@ "section_1": "Fiscal Policy Parameters", "section_2": "Government Pension Parameters", "notes": "", - "type": "float", + "type": "float32", "value": [ { "value": 0.0 @@ -3902,7 +3902,7 @@ "section_1": "Fiscal Policy Parameters", "section_2": "Government Pension Parameters", "notes": "Since there is not exit from the labor force in the model, the number of years of contributions is set exogenously.", - "type": "int", + "type": "int32", "value": [ { "value": 40 @@ -3921,7 +3921,7 @@ "section_1": "Fiscal Policy Parameters", "section_2": "Government Pension Parameters", "notes": "US-styel Social Security AIME is computed using average earnings from the highest earnings years for the number of years specified here.", - "type": "int", + "type": "int32", "value": [ { "value": 35 @@ -3940,7 +3940,7 @@ "section_1": "Fiscal Policy Parameters", "section_2": "Government Pension Parameters", "notes": "", - "type": "float", + "type": "float32", "value": [ { "value": 749.0 @@ -3959,7 +3959,7 @@ "section_1": "Fiscal Policy Parameters", "section_2": "Government Pension Parameters", "notes": "", - "type": "float", + "type": "float32", "value": [ { "value": 4517.0 @@ -3978,7 +3978,7 @@ "section_1": "Fiscal Policy Parameters", "section_2": "Government Pension Parameters", "notes": "", - "type": "float", + "type": "float32", "value": [ { "value": 0.9 @@ -3997,7 +3997,7 @@ "section_1": "Fiscal Policy Parameters", "section_2": "Government Pension Parameters", "notes": "", - "type": "float", + "type": "float32", "value": [ { "value": 0.32 @@ -4016,7 +4016,7 @@ "section_1": "Fiscal Policy Parameters", "section_2": "Government Pension Parameters", "notes": "", - "type": "float", + "type": "float32", "value": [ { "value": 0.15 @@ -4035,7 +4035,7 @@ "section_1": "Fiscal Policy Parameters", "section_2": "Government Pension Parameters", "notes": "", - "type": "float", + "type": "float32", "value": [ { "value": 3501.0 @@ -4054,7 +4054,7 @@ "section_1": "Fiscal Policy Parameters", "section_2": "Government Pension Parameters", "notes": "", - "type": "float", + "type": "float32", "value": [ { "value": 0.0 @@ -4073,7 +4073,7 @@ "section_1": "Fiscal Policy Parameters", "section_2": "Government Pension Parameters", "notes": "This parameter willy only vary along the time path. It is assumed to be one in the steady state. The steady state retirement rate can be adjusted by changing the parameters of the retirement benefits function.", - "type": "float", + "type": "float32", "number_dims": 2, "value": [ { @@ -4153,7 +4153,7 @@ "section_1": "Other Parameters", "section_2": "", "notes": "Calendar year for initial model period", - "type": "int", + "type": "int32", "value": [ { "value": 2025 @@ -4198,7 +4198,7 @@ "section_1": "Fiscal Policy Parameters", "section_2": "Taxes", "notes": "Can be specified to vary by type J and over year T", - "type": "float", + "type": "float32", "number_dims": 2, "value": [ { @@ -4226,7 +4226,7 @@ "section_1": "Fiscal Policy Parameters", "section_2": "Taxes", "notes": "Can be specified to vary by type J and over year T", - "type": "float", + "type": "float32", "number_dims": 2, "value": [ { @@ -4253,7 +4253,7 @@ "description": "Parameter for convergence rate of functional iteration.", "section_1": "Model Solution Parameters", "notes": "", - "type": "float", + "type": "float32", "value": [ { "value": 0.4 @@ -4327,7 +4327,7 @@ "description": "Max iterations for time path iteration.", "section_1": "Model Solution Parameters", "notes": "", - "type": "int", + "type": "int32", "value": [ { "value": 250 @@ -4345,7 +4345,7 @@ "description": "Tolerance for convergence of steady state solution.", "section_1": "Model Solution Parameters", "notes": "", - "type": "float", + "type": "float32", "value": [ { "value": 1e-09 @@ -4363,7 +4363,7 @@ "description": "Tolerance for convergence of time path solution.", "section_1": "Model Solution Parameters", "notes": "", - "type": "float", + "type": "float32", "value": [ { "value": 1e-05 @@ -4381,10 +4381,10 @@ "description": "Tolerance for the resource constraint in the steady state solution.", "section_1": "Model Solution Parameters", "notes": "", - "type": "float", + "type": "float32", "value": [ { - "value": 1e-08 + "value": 1e-07 } ], "validators": { @@ -4399,7 +4399,7 @@ "description": "Tolerance for the resource constraint in the time path solution.", "section_1": "Model Solution Parameters", "notes": "", - "type": "float", + "type": "float32", "value": [ { "value": 1e-04 @@ -4432,7 +4432,7 @@ "description": "Initial guess of r for the SS solution.", "section_1": "Model Solution Parameters", "notes": "", - "type": "float", + "type": "float32", "value": [ { "value": 0.0648 @@ -4450,7 +4450,7 @@ "description": "Initial guess of TR for the SS solution. This value is in model units and can therefore be any large positive number. We may have to adjust the maximum for this parameter from time to time.", "section_1": "Model Solution Parameters", "notes": "", - "type": "float", + "type": "float32", "value": [ { "value": 0.057 @@ -4468,7 +4468,7 @@ "description": "Initial guess of factor for the SS solution.", "section_1": "Model Solution Parameters", "notes": "", - "type": "float", + "type": "float32", "value": [ { "value": 139355.154 @@ -4486,7 +4486,7 @@ "description": "Population distribution (fraction at each age) over the time path.", "section_1": "Demographic Parameters", "notes": "", - "type": "float", + "type": "float32", "number_dims": 2, "value": [ { @@ -4507,7 +4507,7 @@ "description": "Population distribution (fraction at each age) in the steady-state.", "section_1": "Demographic Parameters", "notes": "", - "type": "float", + "type": "float32", "number_dims": 1, "value": [ { @@ -4526,7 +4526,7 @@ "description": "Population distribution (fraction at each age) in the period before the transition path begins.", "section_1": "Demographic Parameters", "notes": "", - "type": "float", + "type": "float32", "number_dims": 1, "value": [ { @@ -4545,7 +4545,7 @@ "description": "Population growth rate over the time path.", "section_1": "Demographic Parameters", "notes": "", - "type": "float", + "type": "float32", "number_dims": 1, "value": [ { @@ -4564,7 +4564,7 @@ "description": "Population growth rate in the steady-state.", "section_1": "Demographic Parameters", "notes": "", - "type": "float", + "type": "float32", "value": [ { "value": 0.0012907765315350872 @@ -4582,7 +4582,7 @@ "description": "Immigration rates over the time path.", "section_1": "Demographic Parameters", "notes": "", - "type": "float", + "type": "float32", "number_dims": 2, "value": [ { @@ -4603,7 +4603,7 @@ "description": "Age-specific mortality rates.", "section_1": "Demographic Parameters", "notes": "", - "type": "float", + "type": "float32", "number_dims": 2, "value": [ { @@ -4623,7 +4623,7 @@ "section_1": "Fiscal Policy Parameters", "section_2": "Taxes", "notes": "", - "type": "float", + "type": "float32", "number_dims": 3, "array_first": false, "value": [ @@ -4646,7 +4646,7 @@ "section_1": "Fiscal Policy Parameters", "section_2": "Taxes", "notes": "", - "type": "float", + "type": "float32", "number_dims": 3, "array_first": false, "value": [ @@ -4669,7 +4669,7 @@ "section_1": "Fiscal Policy Parameters", "section_2": "Taxes", "notes": "", - "type": "float", + "type": "float32", "number_dims": 3, "array_first": false, "value": [ @@ -4692,7 +4692,7 @@ "section_1": "Other Parameters", "section_2": "", "notes": "", - "type": "float", + "type": "float32", "value": [ { "value": 58644.924039576625 @@ -4711,7 +4711,7 @@ "section_1": "Fiscal Policy Parameters", "section_2": "Taxes", "notes": "", - "type": "float", + "type": "float32", "number_dims": 1, "value": [ { diff --git a/ogcore/parameters.py b/ogcore/parameters.py index 0134d21fc..97501bf4a 100644 --- a/ogcore/parameters.py +++ b/ogcore/parameters.py @@ -1,5 +1,6 @@ import os import numpy as np +import marshmallow as ma import scipy.interpolate as si import paramtools import ogcore @@ -14,6 +15,50 @@ CURRENT_PATH = os.path.abspath(os.path.dirname(__file__)) +class Int32(ma.fields.Field): + """ + A custom type for np.int32. + https://numpy.org/devdocs/reference/arrays.dtypes.html + """ + + # minor detail that makes this play nice with array_first + np_type = np.int32 + + def _serialize(self, value, *args, **kwargs): + """Convert np.int32 to basic, serializable Python int.""" + return value.tolist() + + def _deserialize(self, value, *args, **kwargs): + """Cast value from JSON to NumPy Int32.""" + converted = np.int32(value) + return converted + + +class Float32(ma.fields.Field): + """ + A custom type for np.float32. + https://numpy.org/devdocs/reference/arrays.dtypes.html + """ + + # minor detail that makes this play nice with array_first + np_type = np.float32 + + def _serialize(self, value, *args, **kwargs): + """Convert np.float32 to basic, serializable Python float.""" + return value.tolist() + + def _deserialize(self, value, *args, **kwargs): + """Cast value from JSON to NumPy Float32.""" + converted = np.float32(value) + return converted + + +# add int32 type to the paramtools type registry +paramtools.register_custom_type("int32", Int32()) +# add float32 type to the paramtools type registry +paramtools.register_custom_type("float32", Float32()) + + class Specifications(paramtools.Parameters): """ Inherits ParamTools Parameters abstract base class.