def get_mask_for_station(directions_file = 'data/hydrosheds/directions_for_streamflow9.nc',
                          i_index = -1, j_index = -1):


    import diagnose_ccc.compare_swe as compare_swe

    cells = get_connected_cells(directions_file)

    nx = len(cells)
    ny = len(cells[0])

    the_mask = np.zeros((nx, ny))

    theCell = cells[i_index][j_index]
    the_mask[theCell.coords()] = 1 #of course include the current cell

    # @type theCell Cell
    upstream_cells = theCell.get_upstream_cells()
    for c in upstream_cells:
        the_mask[c.coords()] = 1

    domain_mask = compare_swe.get_domain_mask()

    the_mask *= domain_mask
    return the_mask
def main():

    fig = plt.figure()
    ax = fig.add_subplot(1,1,1)
    for i in xrange(3):
        members.all_current.pop()

    domain_mask = compare_swe.get_domain_mask()

    #plot runoff evol for members
    for the_id in members.all_current:
        times, data = get_mean_over_domain(the_id, mask = domain_mask)
        ax.plot(times, data, "--", label = the_id)
        print "finished: %s " % the_id

    times, data = get_mean_over_domain(members.control_id, mask = domain_mask)
    ax.plot(times, data, label = members.control_id)



    ax.xaxis.set_major_locator(
            mpl.dates.MonthLocator(bymonth = range(2,13,2))
    )


    ax.xaxis.set_major_formatter(
            mpl.dates.DateFormatter('%b')
    )


    plt.legend(ncol = 3)
    plt.savefig("runoff_evol.pdf")

    pass
Ejemplo n.º 3
0
    def main(cls, path_to_spinups_dir = "data/spinup_testing"):
        data_list = []

        domain_mask = compare_swe.get_domain_mask()

        for fileName in os.listdir(path_to_spinups_dir):
            spinup = fileName.split("_")[-1].split("yrs")[0]
            spinup = int(spinup)
            filePath = os.path.join(path_to_spinups_dir, fileName)
            data_list += [FirstYearData(path=filePath, spinup_years=spinup)]
        data_list.sort(key = lambda x: x.spinup_years)

        plotter = Plotter(first_year_data_list=data_list)
        plotter.plot_all_on_one(domain_mask=domain_mask)