Skip to content

Commit

Permalink
ladata
Browse files Browse the repository at this point in the history
  • Loading branch information
grahamstark committed Dec 5, 2024
1 parent bbfc50c commit 33ad86b
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 33 deletions.
10 changes: 5 additions & 5 deletions Artifacts.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[augdata]
git-tree-sha1 = "ae33729ba3c17c9671e7e793cec06881784c60a8"
git-tree-sha1 = "fd7f8af9e3146d055401e57a8790a4d4bcba7a56"
lazy = true

[[augdata.download]]
sha256 = "3673fda5d3137182f14e7ce525b2fec8136eeea08b124a45210bcb0859ef3374"
sha256 = "83c2ab0754069d0baee2ee5b67d1b3636a9bec312c99da12d060ed0f7c9437f5"
url = "https://virtual-worlds.biz/artifacts//augdata.tar.gz"

[disability]
Expand Down Expand Up @@ -31,12 +31,12 @@ lazy = true
url = "http://stb-artifacts/legalaid.tar.gz"

[scottish-frs-data]
git-tree-sha1 = "9c5c1e8a29e8f82d861100579cee3e3e49cae464"
git-tree-sha1 = "703eca3d0bf0e2f36ed0481e9b5078201808b45c"
lazy = true

[[scottish-frs-data.download]]
sha256 = "5bc1607882203127bd0c13ddeeb22deb0f51156cd65aa9f4c14af3c1df175ef2"
url = "http://stb-artifacts/model-data-scotland-2015-2021-v2.tar.gz"
sha256 = "6b413446a64d6555a1a75d44562447ef1fe7182ad61006a98b0cd9a9ef1a6f7e"
url = "http://stb-artifacts//scottish-frs-data.tar.gz"

[scottish-lcf-expenditure]
git-tree-sha1 = "bf18d73b3f48bea065528bf63e43e522f85f5e4b"
Expand Down
4 changes: 3 additions & 1 deletion LocalPreferences.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

public-artifact_server_upload = "[email protected]:public_html/artifacts/"
public-artifact_server_url = "https://virtual-worlds.biz/artifacts/"
local-artifact_server_upload = "stb-artifacts:"
local-artifact_server_upload = "stb-artifacts:/var/www/stb-artifacts/"
local-artifact_server_url = "http://stb-artifacts/"

auto_weight = true
Expand Down Expand Up @@ -47,4 +47,6 @@ export_full_results = false
do_dodgy_takeup_corrections = false
data_source = "FRSSource"
skiplist = ""
do_local_run = false
ccode = ""

5 changes: 3 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
[preferences.ScottishTaxBenefitModel]
public-artifact_server_upload = "[email protected]:public_html/artifacts/"
public-artifact_server_url = "https://virtual-worlds.biz/artifacts/"
local-artifact_server_upload = "stb-artifacts:"
local-artifact_server_upload = "stb-artifacts:/var/www/stb-artifacts/"
local-artifact_server_url = "http://stb-artifacts/"

auto_weight = true
Expand All @@ -134,6 +134,7 @@ to_q = 4
to_y = 2024
use_weighting = true
do_legal_aid = false

do_local_run = false
ccode = ""
[targets]
test = ["Test"]
35 changes: 13 additions & 22 deletions src/FRSHouseholdGetter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,14 @@ module FRSHouseholdGetter

using .RunSettings

using .Weighting:
generate_weights

using .Uprating: load_prices

using .Utils:get_quantiles

using .LegalAidData
using .ConsumptionData
using .WealthData
using .WeightingData

export
initialise,
Expand Down Expand Up @@ -69,7 +67,7 @@ module FRSHouseholdGetter

struct HHWrapper
hhlds :: Vector{Household{Float64}}
weight :: Vector{Float64}
# weight :: Vector{Float64}
dimensions :: Vector{Int}
hh_map :: Dict{OneIndex,HHPeople}
pers_map :: Dict{OneIndex,OnePos}
Expand All @@ -80,7 +78,7 @@ module FRSHouseholdGetter
const MODEL_HOUSEHOLDS =
HHWrapper(
Vector{Household{Float64}}(undef, 0 ),
zeros(Float64,0),
# zeros(Float64,0),
zeros(Int,3),
Dict{OneIndex,HHPeople}(),
Dict{OneIndex,Int}(),
Expand Down Expand Up @@ -199,8 +197,8 @@ module FRSHouseholdGetter
npeople = 0; # size( people_dataset)[1]
nhhlds = size( hh_dataset )[1]
resize!( MODEL_HOUSEHOLDS.hhlds, nhhlds )
resize!( MODEL_HOUSEHOLDS.weight, nhhlds )
MODEL_HOUSEHOLDS.weight .= 0
# resize!( MODEL_HOUSEHOLDS.weight, nhhlds )
# MODEL_HOUSEHOLDS.weight .= 0

pseq = 0
hseq = 0
Expand Down Expand Up @@ -241,22 +239,15 @@ module FRSHouseholdGetter
end # don't skip
end
resize!( MODEL_HOUSEHOLDS.hhlds, hseq )
resize!( MODEL_HOUSEHOLDS.weight, hseq )
# resize!( MODEL_HOUSEHOLDS.weight, hseq )
nhhlds = size( MODEL_HOUSEHOLDS.hhlds )[1]
# default weighting using current Scotland settings; otherwise do manually
if settings.auto_weight && settings.target_nation == N_Scotland
@time weight = generate_weights(
nhhlds;
weight_type = settings.weight_type,
lower_multiple = settings.lower_multiple,
upper_multiple = settings.upper_multiple )
for i in eachindex( weight ) # just assign weight = weight?
MODEL_HOUSEHOLDS.weight[i] = weight[i]
end
else
for hseq in 1:nhhlds # just assign weight = weight?
MODEL_HOUSEHOLDS.weight[hseq] = MODEL_HOUSEHOLDS.hhlds[hseq].weight
wsizes = WeightingData.init( settings; reset=reset )
for hno in eachindex(MODEL_HOUSEHOLDS.hhlds)
if settings.do_local_run && settings.ccode != :""
MODEL_HOUSEHOLDS.hhlds[hno].council = settings.ccode
# ?? FIXME fixup nhs area??
end
WeightingData.set_weight!( MODEL_HOUSEHOLDS.hhlds[hno], settings )
end
# in case we have skipped some

Expand Down Expand Up @@ -307,7 +298,7 @@ module FRSHouseholdGetter

function get_household( pos :: Integer ) :: Household
hh = MODEL_HOUSEHOLDS.hhlds[pos]
hh.weight = MODEL_HOUSEHOLDS.weight[pos]
# hh.weight = MODEL_HOUSEHOLDS.weight[pos]
return hh
end

Expand Down
2 changes: 1 addition & 1 deletion src/LocalTaxRunner.jl
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ function do_local_level_run(;
hh = get_household(i)
hh.council = ccode
hh.weight = weight[i]
FRSHouseholdGetter.MODEL_HOUSEHOLDS.weight[i] = weight[i]
# FRSHouseholdGetter.MODEL_HOUSEHOLDS.weight[i] = weight[i]
end

base_cost = get_base_cost( ;
Expand Down
3 changes: 2 additions & 1 deletion src/RunSettings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ module RunSettings
do_dodgy_takeup_corrections = @load_preference( "do_dodgy_takeup_corrections", false)
data_source = @load_preference( "data_source", FRSSource)
skiplist = @load_preference( "skiplist", "")

do_local_run = @load_preference( "do_local_run", false )
ccode = Symbol(@load_preference( "ccode", "" ))
end

function get_data_artifact( settings::Settings )::AbstractString
Expand Down
2 changes: 1 addition & 1 deletion src/STBParameters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ end
@with_kw mutable struct LocalTaxes{RT<:Real}
ct = CouncilTax{RT}()
ppt = ProportionalPropertyTax{RT}()
local_income_tax_rates = RateBands{RT} = zeros(RT,1) # [19.0,20.0,21.0,41.0,46.0]
local_income_tax_rates :: RateBands{RT} = zeros(RT,1) # [19.0,20.0,21.0,41.0,46.0]
# other possible local taxes go here
end

Expand Down
3 changes: 3 additions & 0 deletions src/ScottishTaxBenefitModel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ export ModelHousehold
include("Weighting.jl" )
export Weighting

include( "WeightingData.jl")
export WeightingData

include( "HistoricBenefits.jl")
export HistoricBenefits

Expand Down

0 comments on commit 33ad86b

Please sign in to comment.