From d17d6f3a6b0678b43bdf2a4536ae7d692eedb5ba Mon Sep 17 00:00:00 2001 From: grahamstark Date: Sun, 8 Dec 2024 19:18:41 +0000 Subject: [PATCH] struggling with LADATA --- Artifacts.toml | 16 ++++++++-------- src/LegalAidData.jl | 33 +++++++++++++++------------------ src/Runner.jl | 3 --- 3 files changed, 23 insertions(+), 29 deletions(-) diff --git a/Artifacts.toml b/Artifacts.toml index 4f3a0f34..4d4c127c 100644 --- a/Artifacts.toml +++ b/Artifacts.toml @@ -22,14 +22,6 @@ lazy = true sha256 = "c426f605704bde8c79df3573a4f150512614480aa00f900893accaf75408463c" url = "https://virtual-worlds.biz/artifacts//exampledata.tar.gz" -[legalaid] -git-tree-sha1 = "3518935453a2ed48612f94a4f7ef8fe77f56aace" -lazy = true - - [[legalaid.download]] - sha256 = "fb9a643138fea7669fceda20ef9b4f65b2646d2e8c27d4a0ecbb7306908cb3a9" - url = "http://stb-artifacts/legalaid.tar.gz" - [scottish-frs-data] git-tree-sha1 = "703eca3d0bf0e2f36ed0481e9b5078201808b45c" lazy = true @@ -46,6 +38,14 @@ lazy = true sha256 = "66231a2f9d4cf75d373812e6969e40ffe1dd386dc0b8c577aa3ed67f75e4cc1c" url = "http://stb-artifacts/scottish-lcf-expenditure.tar.gz" +[scottish-slab-legalaid] +git-tree-sha1 = "6ac253d4e01462d5fb25ba410a91504186c46f9d" +lazy = true + + [[scottish-slab-legalaid.download]] + sha256 = "ec6dfe097d4dcceadb457261ff4ca1223f2c95a2642d541766ada87cfb6932e0" + url = "http://stb-artifacts//scottish-slab-legalaid.tar.gz" + [scottish-synthetic-data] git-tree-sha1 = "2bcdf3e7a62bb4bcd282f05008adbe6b63228ab9" lazy = true diff --git a/src/LegalAidData.jl b/src/LegalAidData.jl index f1fa930b..a879b211 100644 --- a/src/LegalAidData.jl +++ b/src/LegalAidData.jl @@ -280,7 +280,7 @@ CIVIL_COSTS_GRP4 = DataFrame() CIVIL_SUBJECTS = DataFrame() -function initialise() +function init(settings::Settings; reset=false) global CIVIL_COSTS global AA_COSTS @@ -300,11 +300,17 @@ function initialise() global CIVIL_COSTS_GRP3 global CIVIL_COSTS_GRP4 global CIVIL_SUBJECTS - + global LA_PROB_DATA + # FIXME DUPS if size( CIVIL_COSTS ) == (0,0) || size(AA_COSTS) == (0,0) || size(CIVIL_AWARDS) == (0.0) - CIVIL_COSTS = load_costs( joinpath(artifact"legalaid", "civil-legal-aid-case-costs.tab" )) - AA_COSTS = load_aa_costs( joinpath( artifact"legalaid", "aa-case-costs.tab" )) - CIVIL_AWARDS = load_awards( joinpath( artifact"legalaid", "civil-applications.tab" )) + l_artifact = RunSettings.get_artifact(; + name="legalaid", + source=settings.data_source == SyntheticSource ? "synthetic" : "slab", + scottish=settings.target_nation == N_Scotland ) + + CIVIL_COSTS = load_costs( joinpath( l_artifact, "civil-legal-aid-case-costs.tab" )) + AA_COSTS = load_aa_costs( joinpath( l_artifact, "aa-case-costs.tab" )) + CIVIL_AWARDS = load_awards( joinpath( l_artifact, "civil-applications.tab" )) CIVIL_AWARDS_GRP_NS = groupby(CIVIL_AWARDS, [:hsm, :age2, :sex]) CIVIL_AWARDS_GRP1 = groupby(CIVIL_AWARDS, [:hsm]) @@ -320,6 +326,9 @@ function initialise() CIVIL_COSTS_GRP3 = groupby(CIVIL_COSTS, [:hsm, :la_status, :sex]) CIVIL_COSTS_GRP4 = groupby(CIVIL_COSTS, [:hsm, :la_status, :age2, :sex]) CIVIL_SUBJECTS = sort(levels( CIVIL_AWARDS.hsm )) + #= FIXME legal aid prob data is NOT NEEDED ANYMORE (but should be)- scottish crime survey probs unused at SLAB request. =# + LA_PROB_DATA = CSV.File( joinpath( l_artifact, "$(settings.legal_aid_probs_data).tab"))|>DataFrame + end end @@ -409,10 +418,7 @@ function make_key(; return k end - - - -# NOT NEEDED +# FIXME NOT NEEDED as the scjs data is unused at slab request function add_la_probs!( hh :: Household ) global LA_PROB_DATA la_hhdata = LA_PROB_DATA[ (LA_PROB_DATA.data_year .== hh.data_year) .& (LA_PROB_DATA.hid.==hh.hid),: ] @@ -423,13 +429,4 @@ function add_la_probs!( hh :: Household ) end end -function init( settings::Settings; reset=false ) - global LA_PROB_DATA - if settings.do_legal_aid - if(size( LA_PROB_DATA )[1] == 0) || reset - LA_PROB_DATA = CSV.File( joinpath( MODEL_DATA_DIR, "legalaid", "$(settings.legal_aid_probs_data).tab"))|>DataFrame - end - end -end - end # module \ No newline at end of file diff --git a/src/Runner.jl b/src/Runner.jl index 05563681..5494ab87 100644 --- a/src/Runner.jl +++ b/src/Runner.jl @@ -80,9 +80,6 @@ module Runner BenefitGenerosity.initialise( artifact"disability" ) end end - if settings.do_legal_aid - LegalAidData.initialise() - end full_results = Array{HouseholdResult}(undef,0,0) # fixme if we have one are threads OK? I think yes if settings.export_full_results