Image Class
DigitalTyphoonImage
- class pyphoon2.DigitalTyphoonImage.DigitalTyphoonImage(image_filepath: str, track_entry: ndarray, sequence_id=None, load_imgs_into_mem=False, transform_func=None, spectrum='Infrared')
Bases:
object- __init__(image_filepath: str, track_entry: ndarray, sequence_id=None, load_imgs_into_mem=False, transform_func=None, spectrum='Infrared')
Class for one image with metadata for the DigitalTyphoonDataset
Does NOT check for file existence until accessing the image.
- Parameters
image_filepath – str, path to image file
track_entry – np.ndarray, 1d numpy array for the track csv entry corresponding to the image
load_imgs_into_mem – bool, flag indicating whether images should be loaded into memory
spectrum – str, default spectrum to read the image in
- param transform_func: this function will be called on the image array when the array is accessed (or read into memory).
It should take and return a numpy image array
- image(spectrum=None) ndarray
Returns the image as a numpy array. If load_imgs_into_mem was set to true, it will cache the image
- Parameters
spectrum – spectrum (channel) the image was taken in
- Returns
np.ndarray, the image
- sequence_id() str
Returns the sequence ID this image belongs to
- Returns
str sequence str
- track_array() ndarray
Returns the csv row for this image
- Returns
nparray containing the track data
- value_from_string(label)
Returns the image’s value given the label as a string. e.g. value_from_string(‘month’) -> the month
- Returns
the element
- year() int
Returns the year the image was taken
- Returns
int, the year
- month() int
Returns the month the image was taken
- Returns
int, the month (1-12)
- day() int
Returns the day the image was taken (number 1-31)
- Returns
int the day
- hour() int
Returns the hour the image was taken
- Returns
int, the hour
- datetime() datetime
Returns a datetime object of when the image was taken
- Returns
datetime
- grade() int
Returns the grade of the typhoon in the image
- Returns
int, the grade
- lat() float
Returns the latitude of the image
- Returns
float
- long() float
Returns the longitude of the image
- Returns
float
- pressure() float
Returns the pressure in # TODO: units? probably hg
- Returns
float
- wind() float
Returns the wind speed in # TODO: units?
- Returns
float
- dir50() float
# TODO: what is this?
- Returns
float
- long50() float
# TODO: what is this?
- Returns
float
- short50() float
# TODO: what is this?
- Returns
float
- dir30() float
# TODO: what is this?
- Returns
float
- long30() float
# TODO: what is this?
- Returns
float
- short30() float
# TODO: what is this?
- Returns
float
- landfall() float
# TODO: what is this?
- Returns
float
- interpolated() bool
Returns whether this entry is interpolated or not
- Returns
bool
- filepath() str
Returns the filepath to the image
- Returns
str
- mask_1() float
Returns number of pixels in the image that are corrupted
- Returns
float the number of pixels
- mask_1_percent() float
Returns percentage of pixels in the image that are corrupted
- Returns
float the percentage of pixels
- set_track_data(track_entry: ndarray) None
Sets the track entry
- Parameters
track_entry – numpy array representing one entry of the track csv
- Returns
None
- set_image_data(image_filepath: str, load_imgs_into_mem=False, spectrum=None) None
Sets the image file data
- Parameters
load_imgs_into_mem – bool, whether to load images into memory
spectrum – str, spectrum to open h5 images with
image_filepath – string to image
- Returns
None