예제 #1
0
def test_make_dir():
    
    directory_list = ["/permmnt/cropmaskperm/pytest_dir"]
    make_dirs(directory_list)
    try: 
        assert os.path.exists(directory_list[0])
    except AssertionError: 
        remove_dirs(directory_list)
        print("The directory was not created.")
    remove_dirs(directory_list)
예제 #2
0
def test_make_dirs(wflow):
    
    directory_list = wflow.setup_dirs()
    
    for i in directory_list:
        try: 
            assert os.path.exists(i)
        except AssertionError:
            remove_dirs(directory_list)
            print("The directory "+i+" was not created.")
    
    remove_dirs(directory_list)
예제 #3
0
def test_grid_images(wflow):
    
    directory_list = wflow.setup_dirs()
    
    band_list = wflow.yaml_to_band_index()
    
    product_list = wflow.get_product_paths(band_list)
    
    meta, bounds = wflow.load_meta_and_bounds(product_list)
    
    wflow.stack_and_save_bands()
    
    wflow.negative_buffer_and_small_filter(-31, 100)
    try: 
        img_paths, label_paths = wflow.grid_images()
        assert len(img_paths) > 0
        assert len(img_paths) == len(label_paths)
    except AssertionError:
        remove_dirs(directory_list)
        print("Less than one chip was saved") 
예제 #4
0
def test_move_chips_to_folder(wflow):
        
    directory_list = wflow.setup_dirs()
    
    band_list = wflow.yaml_to_band_index()
    
    product_list = wflow.get_product_paths(band_list)
    
    meta, bounds = wflow.load_meta_and_bounds(product_list)
        
    wflow.stack_and_save_bands()
    
    wflow.negative_buffer_and_small_filter(-31, 100)
    
    img_paths, label_paths = wflow.grid_images()
    try: 
        assert wflow.move_chips_to_folder()
        assert len(os.listdir(wflow.TRAIN)) > 1
        assert len(os.listdir(os.listdir(wflow.TRAIN))[0]) > 0
    except AssertionError:
        remove_dirs(directory_list)
        print("Less than one chip directory was made") 
예제 #5
0
def test_stack_and_save_bands(wflow):
    
    directory_list = wflow.setup_dirs()
    
    band_list = wflow.yaml_to_band_index()
    
    product_list = wflow.get_product_paths(band_list)
    
    meta, bounds = wflow.load_meta_and_bounds(product_list)
    
    try: 
        wflow.stack_and_save_bands()
    except:
        remove_dirs(directory_list)
        print("The function didn't complete.")
    
    try: 
        assert os.path.exists(wflow.scene_path)
        remove_dirs(directory_list)
    except AssertionError:
        remove_dirs(directory_list)
        print("The stacked tif was not saved at the location "+wflow.scene_path)
예제 #6
0
def test_negative_buffer_and_small_filter(wflow):
    
    directory_list = wflow.setup_dirs()
    
    band_list = wflow.yaml_to_band_index()
    
    product_list = wflow.get_product_paths(band_list)
    
    meta, bounds = wflow.load_meta_and_bounds(product_list)
    
    wflow.stack_and_save_bands()
    
    try: 
        assert wflow.negative_buffer_and_small_filter(-31, 100) == np.array([0, 1]) # for the single class case, where 1 are cp pixels
    except:
        remove_dirs(directory_list)
        print("The function didn't complete.")
    
    try: 
        assert os.path.exists(wflow.rasterized_label_path)
        remove_dirs(directory_list)
    except AssertionError:
        remove_dirs(directory_list)
        print("The rasterized label tif was not saved at the location "+wflow.rasterized_label_path)