Пример #1
0
def incidence_grabby(expname, hfca, rank, output_fname=None) :
    calib_folder = calib_base + expname +"/"
    if not output_fname:
        output_fname = calib_folder + "rank{}_cases".format(rank)

    LL_fname = calib_folder + "_plots/LL_all.csv"
    LL_df = pd.read_csv(LL_fname)
    LL_df.sort_values(by='total', ascending=False, inplace=True)
    LL_df.reset_index(inplace=True)

    sample = LL_df.loc[rank, 'sample']
    iteration = LL_df.loc[rank, 'iteration']

    am = AnalyzeManager()
    # am.add_analyzer(IncidencePlotter(GriddedCalibSite(hfca),save_file=output_fname))
    am.add_analyzer(IncidencePlotter(hfca, save_file=output_fname, save_csv=True))

    with open(calib_folder+"iter{}/IterationState.json".format(iteration)) as fin:
        iteration_state = json.loads(fin.read())
    siminfo = OrderedDict(iteration_state['simulations'])
    for item in list(siminfo.items()) :
        if item[1]['__sample_index__'] == sample :
            simid = item[0]
            am.add_simulation(simid)
    am.analyze()
Пример #2
0
def RDT_grabby(expname, rank, output_fname=None, plot_bairros=True) :
    calib_folder = calib_base + expname +"/"
    if not output_fname:
        output_fname = calib_folder + "rank{}_rdt".format(rank)

    LL_fname = calib_folder + "_plots/LL_all.csv"
    LL_df = pd.read_csv(LL_fname)
    LL_df.sort_values(by='total', ascending=False, inplace=True)
    LL_df.reset_index(inplace=True)

    sample = LL_df.loc[rank, 'sample']
    iteration = LL_df.loc[rank, 'iteration']

    start_date = "2009-01-01"

    am = AnalyzeManager()
    am.add_analyzer(PrevAnalyzer(start_date=start_date,
                                 save_file=output_fname,
                                 cait_output_mode=True,
                                 plot_bairros=plot_bairros))

    with open(calib_folder+"iter{}/IterationState.json".format(iteration)) as fin:
        iteration_state = json.loads(fin.read())
    siminfo = OrderedDict(iteration_state['simulations'])
    for item in list(siminfo.items()) :
        if item[1]['__sample_index__'] == sample :
            simid = item[0]
            # print("Sim ID: ",simid)
            am.add_simulation(simid)
    am.analyze()
Пример #3
0
def vector(expname, calib_stage, rank) :
    calib_folder = calib_base + expname +"/"
    output_fname = calib_folder + "rank{}_vectors".format(rank)

    LL_fname = calib_folder + "_plots/LL_all.csv"
    LL_df = pd.read_csv(LL_fname)
    LL_df.sort_values(by='total', ascending=False, inplace=True)
    LL_df.reset_index(inplace=True)

    sample = LL_df.loc[rank, 'sample']
    iteration = LL_df.loc[rank, 'iteration']

    am = AnalyzeManager()
    am.add_analyzer(VectorSpeciesReportAnalyzer(save_file=output_fname, channel='Daily HBR'))

    with open(calib_folder+"iter{}/IterationState.json".format(iteration)) as fin:
        iteration_state = json.loads(fin.read())
    siminfo = OrderedDict(iteration_state['simulations'])
    for item in list(siminfo.items()) :
        if item[1]['__sample_index__'] == sample :
            simid = item[0]
    am.add_simulation(simid)
    am.analyze()
Пример #4
0
        selected = [
            p.selected_data[id(self)] for p in parsers.values()
            if id(self) in p.selected_data
        ]
        self.data = pd.concat(selected)

    def finalize(self):
        import seaborn as sns
        sns.set_style("darkgrid")

        fig = plt.figure(figsize=(10, 6))
        ax = fig.gca()
        for a, adf in self.data.groupby('sim_id'):
            for s, sdf in adf.groupby('species'):
                ax.plot(sdf['date'], sdf[self.channel], label=s)
        ax.legend()
        plt.ylabel(self.channel)
        if self.save_file:
            plt.savefig(self.save_file + ".png")
            plt.savefig(self.save_file + ".pdf")
        else:
            plt.show()


if __name__ == '__main__':

    am = AnalyzeManager()
    am.add_analyzer(VectorSpeciesReportAnalyzer())
    am.add_simulation('4047a20f-b33d-e811-a2bf-c4346bcb7274')
    am.analyze()