From 33ad86ba1215dc88d8d37fe23afe68b0b46193c6 Mon Sep 17 00:00:00 2001 From: Graham Stark Date: Thu, 5 Dec 2024 19:30:02 +0000 Subject: [PATCH] ladata --- Artifacts.toml | 10 +++++----- LocalPreferences.toml | 4 +++- Project.toml | 5 +++-- src/FRSHouseholdGetter.jl | 35 +++++++++++++--------------------- src/LocalTaxRunner.jl | 2 +- src/RunSettings.jl | 3 ++- src/STBParameters.jl | 2 +- src/ScottishTaxBenefitModel.jl | 3 +++ 8 files changed, 31 insertions(+), 33 deletions(-) diff --git a/Artifacts.toml b/Artifacts.toml index 0f7b0eeb..a58b096c 100644 --- a/Artifacts.toml +++ b/Artifacts.toml @@ -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] @@ -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" diff --git a/LocalPreferences.toml b/LocalPreferences.toml index a2ad7e6c..af3e2387 100644 --- a/LocalPreferences.toml +++ b/LocalPreferences.toml @@ -2,7 +2,7 @@ public-artifact_server_upload = "vw@virtual-worlds.biz: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 @@ -47,4 +47,6 @@ export_full_results = false do_dodgy_takeup_corrections = false data_source = "FRSSource" skiplist = "" +do_local_run = false +ccode = "" diff --git a/Project.toml b/Project.toml index eb56b556..e46ed93d 100644 --- a/Project.toml +++ b/Project.toml @@ -115,7 +115,7 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [preferences.ScottishTaxBenefitModel] public-artifact_server_upload = "vw@virtual-worlds.biz: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 @@ -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"] diff --git a/src/FRSHouseholdGetter.jl b/src/FRSHouseholdGetter.jl index 547243bc..5bd46b42 100644 --- a/src/FRSHouseholdGetter.jl +++ b/src/FRSHouseholdGetter.jl @@ -25,9 +25,6 @@ module FRSHouseholdGetter using .RunSettings - using .Weighting: - generate_weights - using .Uprating: load_prices using .Utils:get_quantiles @@ -35,6 +32,7 @@ module FRSHouseholdGetter using .LegalAidData using .ConsumptionData using .WealthData + using .WeightingData export initialise, @@ -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} @@ -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}(), @@ -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 @@ -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 @@ -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 diff --git a/src/LocalTaxRunner.jl b/src/LocalTaxRunner.jl index 755983d5..1c94f3a9 100644 --- a/src/LocalTaxRunner.jl +++ b/src/LocalTaxRunner.jl @@ -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( ; diff --git a/src/RunSettings.jl b/src/RunSettings.jl index e2c36006..630ef120 100644 --- a/src/RunSettings.jl +++ b/src/RunSettings.jl @@ -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 diff --git a/src/STBParameters.jl b/src/STBParameters.jl index 790f0c3c..392642ee 100644 --- a/src/STBParameters.jl +++ b/src/STBParameters.jl @@ -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 diff --git a/src/ScottishTaxBenefitModel.jl b/src/ScottishTaxBenefitModel.jl index b62af361..1aef46cd 100644 --- a/src/ScottishTaxBenefitModel.jl +++ b/src/ScottishTaxBenefitModel.jl @@ -49,6 +49,9 @@ export ModelHousehold include("Weighting.jl" ) export Weighting +include( "WeightingData.jl") +export WeightingData + include( "HistoricBenefits.jl") export HistoricBenefits