pyphoon.clean_satellite

Content

module Description
pyphoon.clean_satellite.fix Used to define the Fixing algorithm .
pyphoon.clean_satellite.detection Provides set of algorithms to detect corrupted frames.
pyphoon.clean_satellite.correction Provides set of algorithms to correct corrupted frames.
pyphoon.clean_satellite.generation Provides set of algorithms to fill the temporal gaps.
pyphoon.clean_satellite.utils Generic tools.

pyphoon.clean_satellite.fix

class pyphoon.clean_satellite.fix.TyphoonListImageFixAlgorithm(detect_fct=None, correct_fct=None, generate_fct=None, detect_params=None, n_frames_th=None)

Bases: object

Encapsulates an algorithm to correct and clean the images from a typhoon sequence.

Parameters:
  • detect_fct (callable) – Method used to detect corrupted frames (more details in detection)
  • correct_fct (callable) – Method used to correct corrupted frames (more details in correction)
  • generate_fct (callable) – Method used to fill gaps in a sequence (more details in generation)
  • detect_params (dict) – Parameters required to assist the detection method. More details can be found in the specific detection method (see from detection)
  • n_frames_th (int) – Largest temporal gap to fill with newly generated image frames (measured in slots of 1h). In other words, if there is a temporal gap of more than n_frames_th hours no new image frames are generated.
apply(images, images_ids)

Applies the defined fix algorithm to all image samples in images.

Parameters:
  • images (list) – List of image frames.
  • images_ids (list) – List of image ids.
Returns:

Tuple with two elements:

  • New list of images.
  • New list of the corresponding ids.

Return type:

tuple

clear()

Resets the list of corrected/generated frame ids.

detect_and_correct(images, images_ids)

Detects and tries to correct irregularities found in the image frames in the list images using the methods specified by class attributes detect_fct and correct_fct, respectively.

Parameters:
  • images (list) – List with image arrays. Each element of the list must be an array of 2 dimensions.
  • images_ids – Image ids.

images. :type images_ids: list :return: Ids of the corrected images :rtype: list

generate(images, images_ids)

Fills the gaps in the given typhoon sequence using the method specified by class attribute generate_fct.

Parameters:
  • images (list) – List of image frames.
  • images_ids (list) – List of image ids.
Returns:

Dictionary with the ids of the new generated frames. Keys:

  • original: Frame position in original image list.
  • fixed: Frame position in fixed image list.

Return type:

dict

See also

generation

pyphoon.clean_satellite.fix.generate_new_image_dataset(images_orig_dir, fix_algorithm, images_corrected_dir=None, images_generated_dir=None, display=False, folders=None)

Inspects the original image data (assuming architecture explained in section Data and corrects the detected corrupted images and/or generates the missing image data according to the algorithm defined by fix_algorithm. Note that only the new corrected/generated images are stored.

Parameters:
  • images_orig_dir (str) – Directory of the original image data.
  • fix_algorithm (TyphoonListImageFixAlgorithm) – Algorithm used to correct/generate the images.
  • images_corrected_dir (str, default None) – Directory for the corrected image data. If not used, corrected images are not
  • images_generated_dir (str, default None) – Directory for the generated image data.
  • display (bool) – Set to True to get information as the method is executed.
  • folders (list, default None.) – List of the typhoon sequences to generate/correct. If not used, all sequences are used.
Raises:

Exception


pyphoon.clean_satellite.detection

This submodule contains different methods to detect corrupted images. The standard notation is detect_corrupted_pixels_<method index>.

pyphoon.clean_satellite.detection.detect_corrupted_pixels_1(image_frame, params)

Detects pixel positions that are corrupted using a rather simple approach. It forces all pixels to be within the range defined by [min_th, max_th].

Parameters:
  • image_frame (numpy.array) – Image frame
  • params (dict) –

    Should contain two keys:

    • min_th: Minimum tolerated pixel intensity (temperature) value.
    • max_th: Maximum tolerated pixel intensity (temperature) value.
Returns:

Matrix of the same size as image_frame. Elements with value True indicate that pixel values in the original image at that position are corrupted.

Return type:

numpy.array


pyphoon.clean_satellite.correction

This submodule contains different methods to correct corrupted images. The standard notation is correct_corrupted_pixels_<method index>.

pyphoon.clean_satellite.correction.correct_corrupted_pixels_1(images, index, pos, detect_fct, params, display=False)

Corrects the pixels in region pos from the image frame at position index of the list images. To this end, it uses interpolation of the pixel values in this region from temporally nearby image frames.

Parameters:
  • images (list) – List with image arrays. Each element of the list must be an array of 2 dimensions.
  • index (int) – Frame index from list images.
  • pos (numpy.array) – Numpy array of same dimensionality than image[index] with True values in regions containing corrupted pixels and False values in the remaining pixel locations.
  • detect_fct (callable) – Callable function that detects corrupted values from an array according to some given rules.
  • params (dict) – Parameters for detection function
  • display (True) – Set to True if execution information should be printed.
Returns:

Array with the corrected pixel values.

Return type:

numpy.array


pyphoon.clean_satellite.generation

This submodule contains different methods to fill the temporal gaps with new synthetic images. The standard notation is generate_new_frames_<method index>.

pyphoon.clean_satellite.generation.generate_new_frames_1(images, frame_idx_0, frame_idx_1, n_frames=1)

Linearly interpolates two frames from a typhoon sequence.

Parameters:
  • images (list) – List with image arrays. Each element of the list must be an array of 2 dimensions.
  • frame_idx_0 (int) – First frame index.
  • frame_idx_1 (int) – Second frame index.
  • n_frames (int) – Number of frames to generate using interpolation.
Returns:

List with the new generated frames.

Return type:

list