예제 #1
0
def run_all(fit_empirical_priors=False):
    """ Enqueues all jobs necessary to fit model

    Example
    -------
    >>> import run_all
    >>> run_all.run_all()
    """

    if fit_empirical_priors:
        # fit empirical priors (by pooling data from all regions)
        import emp_priors, graphics

        emp_priors.admin_err_and_bias(recompute=True)
        emp_priors.llin_discard_rate(recompute=True)
        emp_priors.neg_binom(recompute=True)
        emp_priors.survey_design(recompute=True)
    
        graphics.plot_neg_binom_fits()
        

    #fit each region individually for this model
    from data import Data
    data = Data()
    post_names = []
    dir = settings.PATH
    for ii, r in enumerate(sorted(data.countries)):
        o = '%s/%s-stdout.txt' % (dir, r[0:3])
        e = '%s/%s-stderr.txt' % (dir, r[0:3])
        name_str = 'ITN%s-%d' % (r[0:3].strip(), ii)
        post_names.append(name_str)
        call_str = 'qsub -cwd -o %s -e %s ' % (o,e) \
                   + '-N %s ' % name_str \
                   + 'fit.sh %d' % ii
        subprocess.call(call_str, shell=True)
        
    # TODO: after all posteriors have finished running, notify me via email
    hold_str = '-hold_jid %s ' % ','.join(post_names)
    o = '%s/summarize.stdout' % dir
    e = '%s/summarize.stderr' % dir
    call_str = 'qsub -cwd -o %s -e %s ' % (o,e) \
               + hold_str \
               + '-N netsdone ' \
               + 'fit.sh summarize'
    subprocess.call(call_str, shell=True)
예제 #2
0
def run_all(fit_empirical_priors=False):
    """ Enqueues all jobs necessary to fit model

    Example
    -------
    >>> import run_all
    >>> run_all.run_all()
    """

    if fit_empirical_priors:
        # fit empirical priors (by pooling data from all regions)
        import emp_priors, graphics

        emp_priors.admin_err_and_bias(recompute=True)
        emp_priors.llin_discard_rate(recompute=True)
        emp_priors.neg_binom(recompute=True)
        emp_priors.survey_design(recompute=True)

        graphics.plot_neg_binom_fits()

    #fit each region individually for this model
    from data import Data
    data = Data()
    post_names = []
    dir = settings.PATH
    for ii, r in enumerate(sorted(data.countries)):
        o = '%s/%s-stdout.txt' % (dir, r[0:3])
        e = '%s/%s-stderr.txt' % (dir, r[0:3])
        name_str = 'ITN%s-%d' % (r[0:3].strip(), ii)
        post_names.append(name_str)
        call_str = 'qsub -cwd -o %s -e %s ' % (o,e) \
                   + '-N %s ' % name_str \
                   + 'fit.sh %d' % ii
        subprocess.call(call_str, shell=True)

    # TODO: after all posteriors have finished running, notify me via email
    hold_str = '-hold_jid %s ' % ','.join(post_names)
    o = '%s/summarize.stdout' % dir
    e = '%s/summarize.stderr' % dir
    call_str = 'qsub -cwd -o %s -e %s ' % (o,e) \
               + hold_str \
               + '-N netsdone ' \
               + 'fit.sh summarize'
    subprocess.call(call_str, shell=True)
예제 #3
0
        return json.load(f)

    obs = [d['itncomplex_to_simpleratio'] for d in data.design] + \
        [d['llincomplex_to_simpleratio'] for d in data.design if d['llincomplex_to_simpleratio']]
    emp_prior_dict = dict(mu=mean(obs), std=std(obs), tau=1 / var(obs))

    f = open(settings.PATH + fname, 'w')
    json.dump(emp_prior_dict, f)

    graphics.plot_survey_design_prior(emp_prior_dict, obs)

    return emp_prior_dict


if __name__ == '__main__':
    import optparse

    usage = 'usage: %prog [options]'
    parser = optparse.OptionParser(usage)
    (options, args) = parser.parse_args()

    if len(args) != 0:
        parser.error('incorrect number of arguments')

    admin_err_and_bias()
    llin_discard_rate()
    neg_binom()
    survey_design()

    graphics.plot_neg_binom_fits()
예제 #4
0
        return json.load(f)

    obs = [d['itncomplex_to_simpleratio'] for d in data.design] + \
        [d['llincomplex_to_simpleratio'] for d in data.design if d['llincomplex_to_simpleratio']]
    emp_prior_dict = dict(mu=mean(obs), std=std(obs), tau=1/var(obs))

    f = open(settings.PATH + fname, 'w')
    json.dump(emp_prior_dict, f)

    graphics.plot_survey_design_prior(emp_prior_dict, obs)

    return emp_prior_dict


if __name__ == '__main__':
    import optparse
    
    usage = 'usage: %prog [options]'
    parser = optparse.OptionParser(usage)
    (options, args) = parser.parse_args()

    if len(args) != 0:
        parser.error('incorrect number of arguments')

    admin_err_and_bias()
    llin_discard_rate()
    neg_binom()
    survey_design()
    
    graphics.plot_neg_binom_fits()