Sequence Class
DigitalTyphoonSequence
- class pyphoon2.DigitalTyphoonSequence.DigitalTyphoonSequence(seq_str: str, start_season: int, num_images: int, transform_func=None, spectrum='Infrared', verbose=False)
Bases:
object- __init__(seq_str: str, start_season: int, num_images: int, transform_func=None, spectrum='Infrared', verbose=False)
Class representing one typhoon sequence from the DigitalTyphoon dataset
- Parameters
seq_str – str, sequence ID as a string
start_season – int, the season in which the typhoon starts in
num_images – int, number of images in the sequence
transform_func – this function will be called on each image before saving it/returning it. It should take and return a np array
- get_sequence_str() str
Returns the sequence ID as a string
- Returns
string sequence ID
- process_seq_img_dir_into_sequence(directory_path: str, load_imgs_into_mem=False, ignore_list=None, spectrum=None, filter_func=<function DigitalTyphoonSequence.<lambda>>) None
Given a path to a directory containing images of a typhoon sequence, process the images into the current sequence object. If ‘load_imgs_into_mem’ is set to True, the images will be read as numpy arrays and stored in memory. Spectrum refers to what light spectrum the image lies in.
- Parameters
directory_path – Path to the typhoon sequence directory
load_imgs_into_mem – Bool representing if images should be loaded into memory
ignore_list – list of image filenames to ignore
spectrum – string representing what spectrum the image lies in
filter_func – function that accepts an image and returns True or False if it should be included in the sequence
- Returns
None
- get_start_season() int
Get the start season of the sequence
- Returns
int, the start season
- get_num_images() int
Gets the number of images in the sequence
- Returns
int
- get_num_original_images() int
Get the number of images in the sequence
- Returns
int, the number of images
- has_images() bool
Returns true if the sequence currently holds images (or image filepaths). False otherwise.
- Returns
bool
- process_track_data(track_filepath: str, csv_delimiter=',') None
Takes in the track data for the sequence and processes it into the images for the sequence.
- Parameters
track_filepath – str, path to track csv
csv_delimiter – delimiter for the csv file
- Returns
None
- add_track_data(filename: str, csv_delimiter=',') None
Reads and adds the track data to the sequence.
- Parameters
filename – str, path to the track data
csv_delimiter – char, delimiter to use to read the csv
- Returns
None
- set_track_path(track_path: str) None
Sets the path to the track data file
- Parameters
track_path – str, filepath to the track data
- Returns
None
- get_track_path() str
Gets the path to the track data file
- Returns
str, the path to the track data file
- get_track_data() ndarray
Returns the track csv data as a numpy array, with each row corresponding to a row in the CSV.
- Returns
np.ndarray
- get_image_at_idx(idx: int, spectrum='Infrared') DigitalTyphoonImage
Returns the idx’th DigitalTyphoonImage in the sequence. raises an exception if the idx is out of the the sequence’s range
- Parameters
idx – int, idx to access
spectrum – str, spectrum of the image
- Returns
DigitalTyphoonImage, the image object
- get_image_at_idx_as_numpy(idx: int, spectrum=None) ndarray
Gets the idx’th image in the sequence as a numpy array. Raises an exception if the idx is outside of the sequence’s range.
- Parameters
idx – int, idx to access
spectrum – str, spectrum of the image
- Returns
np.ndarray, image as a numpy array with shape of the image dimensions
- get_all_images_in_sequence() List[DigitalTyphoonImage]
Returns all of the image objects (DigitalTyphoonImage) in the sequence in order.
- Returns
List[DigitalTyphoonImage]
- return_all_images_in_sequence_as_np(spectrum=None) ndarray
Returns all the images in a sequence as a numpy array of shape (num_images, image_shape[0], image_shape[1])
- Parameters
spectrum – str, spectrum of the image
- Returns
np.ndarray of shape (num_image, image_shape[0], image_shape[1])
- num_images_match_num_expected() bool
Returns True if the number of image filepaths stored matches the number of images stated when initializing the sequence object. False otherwise.
- Returns
bool
- get_image_filepaths() List[str]
Returns a list of the filenames of the images (without the root path)
- Returns
List[str], list of the filenames
- set_images_root_path(images_root_path: str) None
Sets the root path of the images.
- Parameters
images_root_path – str, the root path
- Returns
None
- get_images_root_path() str
Gets the root path to the image directory
- Returns
str, the root path