예제 #1
0
def amno_from_index_space_to_lat_lon(ix, iy):
    '''
    ix in [1, IXMAX], iy in [1, IYMAX]
    '''
    model = LatLonHolder()
    print ix, iy
    print model.get_lon_lat(ix, iy)
예제 #2
0
def main():
    # read in data from netCDF file.
    fpin = NetCDFFile(PATH_TO_NETCDF_FILE)
    #print fpin.variables
    #dims: time, cell_index
    discharge = fpin.variables['water discharge'].data

    x_indices = fpin.variables['x-index'].data
    y_indices = fpin.variables['y-index'].data

    time = fpin.variables['time'].data

    holder = LatLonHolder()

    nx = holder.get_num_cells_along_x()
    ny = holder.get_num_cells_along_y()

    longitudes = np.zeros((nx, ny))
    latitudes = np.zeros((nx, ny))
    
    for i in range(nx):
        for j in range(ny):
            #+1 because index starts from 1 in the holder
            lon, lat = holder.get_lon_lat(i + 1, j + 1)
            longitudes[i,j] = lon
            latitudes[i,j] = lat
        
    plot_data(discharge, longitudes, latitudes, time, x_indices, y_indices, adjust_for_qc)
    pass
예제 #3
0
파일: convert.py 프로젝트: guziy/RPN
def amno_from_index_space_to_lat_lon(ix, iy):
    """
    ix in [1, IXMAX], iy in [1, IYMAX]
    """
    model = LatLonHolder()
    print(ix, iy)
    print(model.get_lon_lat(ix, iy))
예제 #4
0
def amno_from_index_space_to_lat_lon(ix, iy):
    '''
    ix in [1, IXMAX], iy in [1, IYMAX]
    '''
    model = LatLonHolder()
    print(ix, iy)
    print(model.get_lon_lat(ix, iy))
예제 #5
0
def main():
    model = LatLonHolder()
    station_manager = StationManager()
    station_manager.read_stations_from_files_rivdis()

    selected_stations = []
    ij_list = []

    composite_index = 0
    for longitude, latitude in zip( model.longitudes, model.latitudes ):
        the_station = station_manager.get_station_closest_to(longitude, latitude)
        if the_station != None:
            selected_stations.append(the_station)
            ix = model.get_ix(composite_index)
            iy = model.get_iy(composite_index)
            ij_list.append([ix, iy])
            
        composite_index += 1

    for station in selected_stations:
        print station.longitude, station.latitude, station.id
    print ij_list
예제 #6
0
def amno_convert_list(the_list):
    holder = LatLonHolder()
    nx = holder.Nx
    print('nx = ', nx)
    result = []
    for pair in the_list:
        composite_index = (pair[1] - 1) * nx + (pair[0] - 1)
        new_pair = [
            holder.longitudes[composite_index],
            holder.latitudes[composite_index]
        ]
        result.append(new_pair)
    return result
예제 #7
0
def plot_monthly_means_with_measurements(model_points):
    years = mdates.YearLocator(5, month=1, day=1)  # every year
    months = mdates.MonthLocator()  # every month
    yearsFmt = mdates.DateFormatter("%Y")

    plt.cla()

    ##holder of longitudes and latitudes of the model grid points
    holder = LatLonHolder()

    # Manager of the measurement data
    station_manager = StationManager()
    station_manager.read_stations_from_files_rivdis()
    station_manager.read_data_from_files_hydat()

    print station_manager.get_station_by_id("02NG005")

    measure_stations = []
    selected_model_points = []
    for model_point in model_points:
        lon, lat = holder.get_lon_lat(model_point.ix, model_point.iy)
        the_station = station_manager.get_station_closest_to(lon, lat)
        if the_station != None:
            measure_stations.append(the_station)
            model_point.set_longitude(lon)
            model_point.set_latitude(lat)
            selected_model_points.append(model_point)

    fig = plt.figure(figsize=(18, 18))

    num_cols = 2
    num_rows = len(selected_model_points) / num_cols
    if len(selected_model_points) % num_cols > 0:
        num_rows += 1

    inches_per_pt = 1.0 / 72.27  # Convert pt to inch
    golden_mean = (sqrt(5) - 1.0) / 2.0  # Aesthetic ratio
    fig_width = 100.0 * inches_per_pt  # width in inches
    fig_height = fig_width * golden_mean  # height in inches
    fig_size = [fig_width, 10 * fig_height]

    params = {
        "axes.labelsize": 14,
        "text.fontsize": 14,
        "font.size": 14,
        "legend.fontsize": 14,
        "xtick.labelsize": 14,
        "ytick.labelsize": 14,
    }

    print "fig_size = ", fig_size

    pylab.rcParams.update(params)

    assert len(selected_model_points) > 0
    model_dates = selected_model_points[0].get_monthly_dates_sorted()

    for i, model_point in enumerate(selected_model_points):
        ax = plt.subplot(num_rows, num_cols, i + 1)
        # plot model data
        values = model_point.get_monthly_means_sorted_by_date()
        ax.plot(model_dates, values, label="model")

        # plot measurement data
        values = measure_stations[i].get_values_for_dates(model_dates)
        ax.plot(model_dates, values, "-", label="measurements", lw=3)

        plt.title(model_point.__str__() + "\n" + measure_stations[i].__str__())

        # format the ticks
        ax.xaxis.set_major_locator(years)
        ax.xaxis.set_major_formatter(yearsFmt)

        ax.legend()
        # ax.xaxis.set_minor_locator(months)

    fig.subplots_adjust(wspace=0.4)
    # fig.autofmt_xdate()
    fig.savefig("comparison.png")

    pass