Skip to content

Commit

Permalink
struggling with LADATA
Browse files Browse the repository at this point in the history
  • Loading branch information
grahamstark committed Dec 8, 2024
1 parent 3ca8f77 commit d17d6f3
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 29 deletions.
16 changes: 8 additions & 8 deletions Artifacts.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
33 changes: 15 additions & 18 deletions src/LegalAidData.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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])
Expand All @@ -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

Expand Down Expand Up @@ -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),: ]
Expand All @@ -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
3 changes: 0 additions & 3 deletions src/Runner.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d17d6f3

Please sign in to comment.