예제 #1
0
def make_and_save(pi,
                  lambda_,
                  wses=None,
                  nperiods=4,
                  log=True,
                  figkwargs=None,
                  axkwargs=None):
    """
    Wrapper for all the plotting funcitonality.

    Returns an axes and does IO.
    """
    if wses is None:
        params = load_params()
        all_files = ar.get_all_files(params)
        wses = ar.read_output(all_files, kind='ws')

    df = get_df(pi, lambda_, wses[pi, lambda_], params)
    fig, ax = plot_wage_change_dist(df,
                                    pi,
                                    lambda_,
                                    nperiods=nperiods,
                                    log=log,
                                    figkwargs=figkwargs,
                                    axkwargs=axkwargs)
    savefig_(fig, pi, lambda_, nperiods=nperiods, log=log)
    return fig, ax
예제 #2
0
def main():
    params = load_params()
    all_files = ar.get_all_files(params)
    wses = ar.read_output(all_files, kind='ws')
    keys = wses.keys()
    pis, lambdas = zip(*keys)  # FTW
    pis_u, lambdas_u = sorted(set(pis)), sorted(set(lambdas))  # unique

    for pi, lambda_ in keys:
        make_and_save(pi, lambda_)
        print('Saved {}, {}'.format(pi, lambda_))
예제 #3
0
def main():
    params = load_params()
    all_files = ar.get_all_files(params)
    wses = ar.read_output(all_files, kind='ws')
    keys = wses.keys()
    pis, lambdas = zip(*keys)  # FTW
    pis_u, lambdas_u = sorted(set(pis)), sorted(set(lambdas))  # unique

    for pi, lambda_ in keys:
        make_and_save(pi, lambda_)
        print('Saved {}, {}'.format(pi, lambda_))
예제 #4
0
def wage_dist_ecdf_refactor():
    """
    This implements the refactor of gp's to ecdfs.

    Also takes care of the output.
    """
    with open('results/fixup_notice.txt', 'a') as f:
        t = str(datetime.datetime.now())
        f.write("FIXED gps AT {}\n".format(t))

    params = load_params()
    params['results_path/'] = 'results/', 'a'
    all_files = ar.get_all_files(params)
    gps = ar.read_output(all_files, kind='gp')
    wses = ar.read_output(all_files, kind='ws')
    z_grid = params['z_grid'][0]
    flex_ws = Interp(z_grid, ss_wage_flexible(params, shock=z_grid))

    for key in gps.iterkeys():
        piname, lambda_ = [str(x).replace('.', '') for x in key]
        out_name = 'results/gp_' + piname + '_' + lambda_ + '.pkl'
        shutil.copy2(out_name, 'results/replaced_results/')
        ws = wses[key]
        params['pi'] = key[0], 'you'
        params['lambda_'] = key[1], 'idiot'
        new_g, shocks = get_new_g(ws, params)

        with open(out_name, 'w') as f:
            cPickle.dump(new_g, f)

        print("Fixed wage distribution for {}.".format(key))

        new_rigid_out = get_rigid_output(ws, params, flex_ws, new_g, shocks)

        out_name = 'results/rigid_output_' + piname + '_' + lambda_ + '_.txt'
        with open(out_name, 'w') as f:
            f.write(str(new_rigid_out))

        with open('results/fixup_notice.txt', 'a') as f:
            f.write("Fixed {}\n".format(key))
예제 #5
0
def make_and_save(pi, lambda_, wses=None, nperiods=4, log=True, figkwargs=None,
                  axkwargs=None):
    """
    Wrapper for all the plotting funcitonality.

    Returns an axes and does IO.
    """
    if wses is None:
        params = load_params()
        all_files = ar.get_all_files(params)
        wses = ar.read_output(all_files, kind='ws')

    df = get_df(pi, lambda_, wses[pi, lambda_], params)
    fig, ax = plot_wage_change_dist(df, pi, lambda_, nperiods=nperiods,
                                    log=log, figkwargs=figkwargs,
                                    axkwargs=axkwargs)
    savefig_(fig, pi, lambda_, nperiods=nperiods, log=log)
    return fig, ax
예제 #6
0
def get_g(pi, lambda_, period=28):
    """
    Helper function to get to a wage distribution.

    Warning: Will not touch the params in your global state.
    If you go on the to more things make sure to adjust those params.
    """
    import analyze_run as ar
    params = load_params()
    params['pi'] = pi, 'a'
    params['lambda_'] = lambda_, 'b'

    all_files = ar.get_all_files(params)
    wses = ar.read_output(all_files, kind='ws')
    ws = wses[(pi, lambda_)]
    pths, shks = sample_path(ws, params, nseries=1000, nperiods=30, seed=42)

    pth, shocks = pths[28], shks[28]
    shocks = np.sort(shocks)
    g = ecdf(np.sort(pth))
    return g, shocks
예제 #7
0
def get_g(pi, lambda_, period=28):
    """
    Helper function to get to a wage distribution.

    Warning: Will not touch the params in your global state.
    If you go on the to more things make sure to adjust those params.
    """
    import analyze_run as ar
    params = load_params()
    params['pi'] = pi, 'a'
    params['lambda_'] = lambda_, 'b'

    all_files = ar.get_all_files(params)
    wses = ar.read_output(all_files, kind='ws')
    ws = wses[(pi, lambda_)]
    pths, shks = sample_path(ws, params, nseries=1000, nperiods=30, seed=42)

    pth, shocks = pths[28], shks[28]
    shocks = np.sort(shocks)
    g = ecdf(np.sort(pth))
    return g, shocks