<commit_before># written by <NAME>
# jeff [at] stat [dot] berkeley [dot] edu

module ModelInit

export sample_prior, cat_init, peak_init

using FITSIO
using Distributions
using WCSLIB
using Util
using CelesteTypes


function sample_prior()
    const dat_dir = joinpath(Pkg.dir("Celeste"), "dat")

    stars_file = open("$dat_dir/priors/stars.dat")
    r_fit1, k1, cmean1, ccov1 = deserialize(stars_file)
    close(stars_file)

    gals_file = open("$dat_dir/priors/gals.dat")
    r_fit2, k2, cmean2, ccov2 = deserialize(gals_file)
    close(gals_file)

    # TODO: use r_fit1 and r_fit2 instead of magic numbers ?

    # magic numbers below determined from the output of primary
    # on the test set of stamps
    PriorParams(
        [0.28, 0.72],                       # a
        [(0.47, 0.012), (1.28, 0.11)],      # r
        Vector{Float64}[k1, k2],            # k
        [(cmean1, ccov1), (cmean2, ccov2)]) # c
end


#TODO: use blob (and perhaps priors) to initialize these sensibly
function init_source(init_pos::Vector{Float64})
    ret = Array(Float64, length(CanonicalParams))
    ret[ids.a[2]] = 0.5
    ret[ids.a[1]] = 1.0 - ret[ids.a[2]]
    ret[ids.u[1]] = init_pos[1]
    ret[ids.u[2]] = init_pos[2]
    ret[ids.r1] = 1e3
    ret[ids.r2] = 2e-3
    ret[ids.e_dev] = 0.5
    ret[ids.e_axis] = 0.5<commit_msg>fixed bug: wrong parameterization of gamma dist in prior<commit_after># written by <NAME>
# jeff [at] stat [dot] berkeley [dot] edu

module ModelInit

export sample_prior, cat_init, peak_init

using FITSIO
using Distributions
using WCSLIB
using Util
using CelesteTypes


function sample_prior()
    const dat_dir = joinpath(Pkg.dir("Celeste"), "dat")

    stars_file = open("$dat_dir/priors/stars.dat")
    r_fit1, k1, cmean1, ccov1 = deserialize(stars_file)
    close(stars_file)

    gals_file = open("$dat_dir/priors/gals.dat")
    r_fit2, k2, cmean2, ccov2 = deserialize(gals_file)
    close(gals_file)

    # TODO: use r_fit1 and r_fit2 instead of magic numbers ?

    # magic numbers below determined from the output of primary
    # on the test set of stamps
    PriorParams(
        [0.28, 0.72],                       # a
        [(0.47, 1. / 0.012), (1.28, 1. / 0.11)], # r
        Vector{Float64}[k1, k2],            # k
        [(cmean1, ccov1), (cmean2, ccov2)]) # c
end


#TODO: use blob (and perhaps priors) to initialize these sensibly
function init_source(init_pos::Vector{Float64})
    ret = Array(Float64, length(CanonicalParams))
    ret[ids.a[2]] = 0.5
    ret[ids.a[1]] = 1.0 - ret[ids.a[2]]
    ret[ids.u[1]] = init_pos[1]
    ret[ids.u[2]] = init_pos[2]
    ret[ids.r1] = 1e3
    ret[ids.r2] = 2e-3
    ret[ids.e_dev] = 0.5
    ret[ids.e_axis] = 0.5
{'fraction_non_alphanumeric': 0.13454410674573758, 'fraction_numerical': 0.04670126019273536, 'mean_word_length': 2.9574780058651027, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6110388', 'n_tokens_mistral': 1113, 'n_tokens_neox': 1039, 'n_words': 255}