Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.
Andrew Player edited this page Aug 17, 2022 · 1 revision

module src.io

Created By: Andrew Player
File Name: io.py
Date Created: 05-01-2022
Description: Functions to handle file read/write.


function save_dataset

save_dataset(save_path: Path, mask: ndarray, wrapped: ndarray) → None

Saves event-mask and wrapped ndarrays to a single .npz file.


function load_dataset

load_dataset(load_path: Path) → Tuple[ndarray, ndarray]

Loads event-mask and wrapped ndarrays from .npz file.

Parameters:

  • load_path : Path
    The path to the data example that should be loaded.

Returns:

  • mask : np.ndarray
    The array of the event-mask loaded from the .npz.
  • wrapped : np.ndarray
    The array of the wrapped interferogram loaded from the .npz.

function create_directories

create_directories() → None

Creates the directories for storing our data.


function get_image_array

get_image_array(image_path: str) → ndarray

Load a interferogram .tif from storage into an array.

Parameters:

  • image_path : str
    The path to the interferogram .tif to be opened.

Returns:

  • arr : np.ndarray
    The interferogram array.

function get_dataset_arrays

get_dataset_arrays(product_path: str) → Tuple[ndarray, ndarray, ndarray]

Load wrapped, unwrapped, and correlation .tifs from storage into arrays.

Parameters:

  • product_path : str
    The path to the InSAR product folder containing the images.

Returns:

  • wrapped : np.ndarray
    The array of the wrapped interferogram loaded from the .tif.
  • unwrapped : np.ndarray
    The array of the unwrapped interferogram loaded from the .tif.
  • correlation : np.ndarray
    The correlation map array loaded from the .tif,

function get_product_arrays

get_product_arrays(product_path: str) → Tuple[ndarray, ndarray, ndarray]

Load wrapped, unwrapped, and correlation .tifs from storage into arrays.

Parameters:

  • product_path : str
    The path to the InSAR product folder containing the images.

Returns:

  • wrapped : np.ndarray
    The array of the wrapped interferogram loaded from the .tif.
  • unwrapped : np.ndarray
    The array of the unwrapped interferogram loaded from the .tif.
  • correlation : np.ndarray
    The correlation map array loaded from the .tif,

function dataset_from_pngs

dataset_from_pngs(
    dataset_name: str,
    dataset_path: str,
    save_path: str,
    tile_size: int,
    crop_size: int
) → int

Creates a dataset from a folder containing real interferogram products.

Parameters:

  • dataset_name : str
    The name for the folder that will contain the dataset.
  • product_path : str
    The path to the folder containing sar product folders
  • save_path : str
    The path to the folder where the dataset should be saved.
  • tile_size : int
    The width and height of the tiles that the image will be broken into, this needs to match the input shape of the model.
  • crop_size : int
    If the models output shape is different than the input shape, this value needs to be equal to the output shape.

Returns:

  • dataset_size : int
    The size of the dataset that was created.

function dataset_from_products

dataset_from_products(
    dataset_name: str,
    product_path: str,
    save_path: str,
    tile_size: int,
    crop_size: int
) → int

Creates a dataset from a folder containing real interferogram products.

Parameters:

  • dataset_name : str
    The name for the folder that will contain the dataset.
  • product_path : str
    The path to the folder containing sar product folders
  • save_path : str
    The path to the folder where the dataset should be saved.
  • tile_size : int
    The width and height of the tiles that the image will be broken into, this needs to match the input shape of the model.
  • crop_size : int
    If the models output shape is different than the input shape, this value needs to be equal to the output shape.
  • cutoff : int
    Set point in wrapped array to 0 if the correlation is below this value at that point.

Returns:

  • dataset_size : int
    The size of the dataset that was created.

function make_synthetic_dataset

make_synthetic_dataset(
    name: str,
    output_dir: str,
    amount: int,
    seed: int,
    tile_size: int,
    crop_size: int,
    min_amp: float,
    max_amp: float,
    min_x_mean: float,
    max_x_mean: float,
    min_y_mean: float,
    max_y_mean: float,
    min_x_stddev: float,
    max_x_stddev: float,
    min_y_stddev: float,
    max_y_stddev: float
) → Tuple[int, int, str]

Generate a dataset containing pairs of synthetic wrapped interferograms along with their event-masks

Parameters:

  • name : str
    The name of the dataset to be generate. The saved name will be formatted like _amount_seed.
  • output_dir : str
    The directory to save the generated dataset to.
  • amount : int
    The amount of simulated interferogram pairs to be generated.
  • seed : int
    A seed for the random functions. For the same seed, with all other values the same as well, the interferogram generation will have the same results. If left at 0, a seed will be generated and the results will be different every time.
  • tile_size : int
    The size of the simulated interferograms, which should match the desired tile sizes of of the real interferograms. This also needs to match the input shape of the model.
  • crop_size : int
    If the model's output shape does not match its input shape, this should be set to match the output shape. The unwrapped interferogram will be cropped to this.

Returns:

  • seed : int
    The generated or inputed seed.
  • count : int
    The number of samples that were generated.
  • dir_name : str
    The generated name of the dataset directory.

function make_simulated_dataset

make_simulated_dataset(
    name: str,
    output_dir: str,
    amount: int,
    seed: int,
    tile_size: int
) → Tuple[int, int, str]

Generate a dataset containing pairs of wrapped interferograms from simulated deformation along with their event-masks

Parameters:

  • name : str
    The name of the dataset to be generate. The saved name will be formatted like _amount_seed.
  • output_dir : str
    The directory to save the generated dataset to.
  • amount : int
    The amount of simulated interferogram pairs to be generated.
  • seed : int
    A seed for the random functions. For the same seed, with all other values the same as well, the interferogram generation will have the same results. If left at 0, a seed will be generated and the results will be different every time.
  • tile_size : int
    The size of the simulated interferograms, which should match the desired tile sizes of of the real interferograms. This also needs to match the input shape of the model.

Returns:

  • seed : int
    The generated or inputed seed.
  • count : int
    The number of samples that were generated.
  • dir_name : str
    The generated name of the dataset directory.

function split_dataset

split_dataset(dataset_path: str, split: float) → Tuple[int, int]

Split the dataset into train and test folders

Parameters:

  • dataset_path : str
    The path to the dataset to be split
  • split : float
    The train/test split, 0 < Split < 1, size(validation) <= split

Returns:

  • num_train : int
    The number of elements that went to the training set.
  • num_validation : int
    The number of elements that went to the validation set.

This file was automatically generated via andrewplayer3's fork of lazydocs.