Exemplo n.º 1
0
def test_weight_table_with_area_id():
    """
    Checks generating weight table with area id
    """
    print("TEST 17: TEST GENERATE WEIGHT TABLE WITH INVALID POLYGON")
    generated_weight_table_file = os.path.join(OUTPUT_DATA_PATH,
                                               "weight_area.csv")
    # rapid_connect
    rapid_connect_file = os.path.join(COMPARE_DATA_PATH, "x-x",
                                      "rapid_connect.csv")

    lsm_grid = os.path.join(LSM_INPUT_DATA_PATH, "gldas2",
                            "GLDAS_NOAH025_3H.A20101231.0000.020.nc4")
    CreateWeightTableLDAS(in_ldas_nc=lsm_grid,
                          in_nc_lon_var="lon",
                          in_nc_lat_var="lat",
                          in_catchment_shapefile=os.path.join(
                              GIS_INPUT_DATA_PATH, 'test_catchments.shp'),
                          river_id="DrainLnID",
                          area_id="Shape_Area",
                          in_connectivity_file=rapid_connect_file,
                          out_weight_table=generated_weight_table_file)

    generated_weight_table_file_solution = os.path.join(
        COMPARE_DATA_PATH, "x-x", "weight_area.csv")
    assert (compare_csv_decimal_files(generated_weight_table_file,
                                      generated_weight_table_file_solution))

    remove_files(generated_weight_table_file)
Exemplo n.º 2
0
def test_gen_weight_table_joules():
    """
    Checks generating weight table for Joules grid
    """
    print("TEST 9: TEST GENERATE WEIGHT TABLE FOR Joules GRIDS")
    generated_weight_table_file = os.path.join(OUTPUT_DATA_PATH,
                                               "weight_joules.csv")
    #rapid_connect
    rapid_connect_file = os.path.join(COMPARE_DATA_PATH, "u-k",
                                      "rapid_connect.csv")

    lsm_grid = os.path.join(LSM_INPUT_DATA_PATH, "joules",
                            "ukv_test.runoff.20080803_00.nc")
    CreateWeightTableLDAS(in_ldas_nc=lsm_grid,
                          in_nc_lon_var="east_west",
                          in_nc_lat_var="north_south",
                          in_catchment_shapefile=os.path.join(
                              GIS_INPUT_DATA_PATH, 'u-k',
                              'CatchmentSubset.shp'),
                          river_id="DrainLnID",
                          in_connectivity_file=rapid_connect_file,
                          out_weight_table=generated_weight_table_file)

    generated_weight_table_file_solution = os.path.join(
        COMPARE_DATA_PATH, "u-k", "weight_joules.csv")
    assert (compare_csv_decimal_files(generated_weight_table_file,
                                      generated_weight_table_file_solution))

    remove_files(generated_weight_table_file)
Exemplo n.º 3
0
def test_gen_weight_table_lis_no_intersect():
    """
    Checks generating weight table for LIS grid with no intersect
    """
    print("TEST 8: TEST GENERATE WEIGHT TABLE FOR LIS GRIDS WITH NO INTERSECT")
    generated_weight_table_file = os.path.join(OUTPUT_DATA_PATH,
                                               "weight_lis_no_intersect.csv")
    #rapid_connect
    rapid_connect_file = os.path.join(GIS_INPUT_DATA_PATH, "uk-no_intersect",
                                      "rapid_connect_45390.csv")

    lsm_grid = os.path.join(LSM_INPUT_DATA_PATH, "lis",
                            "LIS_HIST_201101210000.d01.nc")
    CreateWeightTableLDAS(in_ldas_nc=lsm_grid,
                          in_nc_lon_var="lon",
                          in_nc_lat_var="lat",
                          in_catchment_shapefile=os.path.join(
                              GIS_INPUT_DATA_PATH, 'uk-no_intersect',
                              'Catchment_thames_drainID45390.shp'),
                          river_id="DrainLnID",
                          in_connectivity_file=rapid_connect_file,
                          out_weight_table=generated_weight_table_file)

    generated_weight_table_file_solution = os.path.join(
        COMPARE_DATA_PATH, "uk-no_intersect", "weight_lis_no_intersect.csv")
    assert (compare_csv_decimal_files(generated_weight_table_file,
                                      generated_weight_table_file_solution))

    remove_files(generated_weight_table_file)
Exemplo n.º 4
0
def test_gen_weight_table_gldas2():
    """
    Checks generating weight table for GLDAS V2 grid
    """
    print("TEST 6: TEST GENERATE WEIGHT TABLE FOR GLDAS V2 GRIDS")
    generated_weight_table_file = os.path.join(OUTPUT_DATA_PATH,
                                               "weight_gldas2.csv")
    #rapid_connect
    rapid_connect_file = os.path.join(COMPARE_DATA_PATH, "x-x",
                                      "rapid_connect.csv")

    lsm_grid = os.path.join(LSM_INPUT_DATA_PATH, "gldas2",
                            "GLDAS_NOAH025_3H.A20101231.0000.020.nc4")
    CreateWeightTableLDAS(in_ldas_nc=lsm_grid,
                          in_nc_lon_var="lon",
                          in_nc_lat_var="lat",
                          in_catchment_shapefile=os.path.join(
                              GIS_INPUT_DATA_PATH, 'catchment.shp'),
                          river_id="FEATUREID",
                          in_connectivity_file=rapid_connect_file,
                          out_weight_table=generated_weight_table_file)

    generated_weight_table_file_solution = os.path.join(
        COMPARE_DATA_PATH, "x-x", "weight_gldas2.csv")
    assert (compare_csv_decimal_files(generated_weight_table_file,
                                      generated_weight_table_file_solution))

    remove_files(generated_weight_table_file)
Exemplo n.º 5
0
def test_gen_weight_table_lis():
    """
    Checks generating weight table for LIS grid
    """
    print("TEST 7: TEST GENERATE WEIGTH TABLE FOR LIS GRIDS")
    generated_weight_table_file = os.path.join(OUTPUT_DATA_PATH, 
                                               "weight_lis.csv")
    #rapid_connect
    rapid_connect_file = os.path.join(COMPARE_DATA_PATH, "u-k",
                                      "rapid_connect.csv")

    lsm_grid = os.path.join(LSM_INPUT_DATA_PATH, "lis", "LIS_HIST_201101210000.d01.nc")
    CreateWeightTableLDAS(in_ldas_nc=lsm_grid,
                          in_nc_lon_var="lon",
                          in_nc_lat_var="lat", 
                          in_catchment_shapefile=os.path.join(GIS_INPUT_DATA_PATH, 'u-k', 'CatchmentSubset.shp'), 
                          river_id="DrainLnID", 
                          in_connectivity_file=rapid_connect_file, 
                          out_weight_table=generated_weight_table_file)
                                                         
    generated_weight_table_file_solution = os.path.join(COMPARE_DATA_PATH, "u-k",
                                                        "weight_lis.csv")
    ok_(compare_csv_decimal_files(generated_weight_table_file, 
                                  generated_weight_table_file_solution))

    remove_files(generated_weight_table_file)
Exemplo n.º 6
0
def test_gen_weight_table_lis_land_mask():
    """
    Checks generating weight table for LIS grid with land mask.
    """
    print("TEST 20: TEST GENERATE WEIGHT TABLE FOR LIS GRID WITH LAND MASK.")
    generated_weight_table_file = os.path.join(
        OUTPUT_DATA_PATH, "weight_lis_land_fraction_mendocino_subset.csv")

    #rapid_connect
    rapid_connect_file = os.path.join(
        COMPARE_DATA_PATH, "mendocino_nhdplus_catchment",
        "rapid_connectivity_mendocino_sample.csv")

    lsm_grid = os.path.join(LSM_INPUT_DATA_PATH, "lis_land_mask",
                            "lisglobalmask557ww_mendocino_subset.nc")

    CreateWeightTableLDAS(in_ldas_nc=lsm_grid,
                          in_nc_lon_var='lon',
                          in_nc_lat_var='lat',
                          in_catchment_shapefile=os.path.join(
                              GIS_INPUT_DATA_PATH,
                              'mendocino_nhdplus_catchment',
                              'NHDCat_mendocino_watershed_hopland_sample.shp'),
                          river_id='FEATUREID',
                          in_connectivity_file=rapid_connect_file,
                          out_weight_table=generated_weight_table_file,
                          in_land_area_fraction_var='LANDMASK')

    generated_weight_table_file_solution = os.path.join(
        COMPARE_DATA_PATH, 'mendocino_nhdplus_catchment',
        'weight_lis_land_fraction_mendocino_subset.csv')

    assert (compare_csv_decimal_files(generated_weight_table_file,
                                      generated_weight_table_file_solution))

    remove_files(generated_weight_table_file)