示例#1
0
def test_gen_weight_table_era5_land_mask():
    """
    Checks generating weight table for ERA5 grid with land mask.
    """
    print("TEST 18: TEST GENERATE WEIGHT TABLE FOR ERA5 GRID WITH LAND MASK.")
    generated_weight_table_file = os.path.join(
        OUTPUT_DATA_PATH, "weight_mendocino_era5_land_mask.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, "era5_land_mask",
                            "era5_land-sea_mask_mendocino_subset.nc")

    CreateWeightTableECMWF(
        in_ecmwf_nc=lsm_grid,
        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_ecmwf_mask_var='lsm')

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

    assert (compare_csv_decimal_files(generated_weight_table_file,
                                      generated_weight_table_file_solution))

    remove_files(generated_weight_table_file)
示例#2
0
def test_gen_weight_table_era_t511_24hr():
    """
    Checks generating weight table for ERA T511 24hr grid
    """
    print("TEST 5: TEST GENERATE WEIGHT TABLE FOR ERA T511 24hr GRIDS")
    generated_weight_table_file = os.path.join(OUTPUT_DATA_PATH,
                                               "weight_era_t511.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, "erai24",
                            "19990109_erai_runoff.grib.nc")
    CreateWeightTableECMWF(in_ecmwf_nc=lsm_grid,
                           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_era_t511.csv")
    assert (compare_csv_decimal_files(generated_weight_table_file,
                                      generated_weight_table_file_solution))

    remove_files(generated_weight_table_file)
示例#3
0
def test_gen_weight_table_era_t255():
    """
    Checks generating weight table for ERA T255 grid
    """
    print("TEST 4: TEST GENERATE WEIGTH TABLE FOR ERA T255 GRIDS")
    generated_weight_table_file = os.path.join(OUTPUT_DATA_PATH, 
                                               "weight_era_t255.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, "erai3t255", "era_interim_runoff_20140820.nc")
    CreateWeightTableECMWF(in_ecmwf_nc=lsm_grid, 
                           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_era_t255.csv")
    ok_(compare_csv_decimal_files(generated_weight_table_file, 
                                  generated_weight_table_file_solution))

    remove_files(generated_weight_table_file)