hypso.classification.WaterDetection.waterdetect.Common
Module Contents
Classes
| Base class for | |
| Configuration for | |
Functions
| 
 | 
- hypso.classification.WaterDetection.waterdetect.Common.test_ini()
- class hypso.classification.WaterDetection.waterdetect.Common.DWBaseConfig(config_file=None)
- Base class for - _defaults
 - _units
 - load_config_file(config_file)
- Load config file :param config_file: :return: 
 - return_defaults(section, key)
- Return default values :param section: :param key: :return: 
 - get_option(section, key, evaluate)
- Get option value :param section: :param key: :param evaluate: :return: - Parameters:
- evaluate (bool) – 
 
 
- class hypso.classification.WaterDetection.waterdetect.Common.DWConfig(config_file=None)
- Bases: - DWBaseConfig- Configuration for - property reference_band
- Returns the reference band :return: 
 - property create_composite
- Returns the composite :return: 
 - property pdf_reports
- Returns the pdf report :return: 
 - property calc_glint
- Returns calculated glint :return: 
 - property glint_mode
- Returns glint mode :return: 
 - property min_glint_multiplier
- Returns minimum glint multiplier :return: 
 - property pdf_resolution
- Returns pdf resolution :return: 
 - property pekel_water
 - property pekel_accuracy
 - property save_indices
 - property texture_stretching
 - property external_mask
 - property mask_name
 - property mask_valid_value
 - property mask_invalid_value
 - property maximum_invalid
 - property average_results
 - property min_positive_pixels
 - property clustering_method
 - property linkage
 - property train_size
 - property regularization
 - property min_train_size
 - property max_train_size
 - property score_index
 - property classifier
 - property detect_water_cluster
 - property min_clusters
 - property max_clusters
 - property plot_graphs
 - property graphs_bands
 - property plot_ts
 - property clustering_bands
 - property clip_band
 - property clip_inf_value
 - property clip_sup_value
 - _config_file = 'WaterDetect.ini'
 - _defaults
 - get_masks_list(product)
 
- class hypso.classification.WaterDetection.waterdetect.Common.DWutils
- indices
 - static parse_sat_name(folder, img_type='S2_THEIA')
- Function To :param folder: :param img_type: - Returns:
 
 - static parse_planetary_name(name)
- Get the string with a MS PLANETARY name and extract the useful information from it. :param name: Image name :return: Dictionary with the values. - Parameters:
- name (str) – 
 
 - static parse_maja_name(name)
- Get the string with a MAJA img name (THEIA format) and extract the useful information from it. :param name: Image name :return: Dictionary with the values. - Parameters:
- name (str) – 
 
 - static parse_s2cor_name(name)
- Get the string with a S2COR name (.SAFE format) and extract the useful information from it. :param name: Image name :return: Dictionary with the values. - Parameters:
- name (str) – 
- Return type:
- dict 
 
 - static bitwise_or(array, bit_values)
 - static bitwise_and(array, bit_values)
 - static flatten(x)
 - static listify(lst, uniques=[])
 - static check_path(path_str, is_dir=False)
- Check if the path/file exists and returns a Path variable with it :param path_str: path string to test :param is_dir: whether if it is a directory or a file :return: Path type variable 
 - static get_directories(input_folder)
- Return a list of directories in input_folder. These folders are the repository for satellite products :param input_folder: folder that stores the images :return: list of images (i.e. directories) 
 - static calc_normalized_difference(img1, img2, mask=None, compress_cte=0.02)
- Calc the normalized difference of given arrays (img1 - img2)/(img1 + img2). Updates the mask if any invalid numbers (ex. np.inf or np.nan) are encountered :param img1: first array :param img2: second array :param mask: initial mask, that will be updated :param compress_cte: amount of index compression. The greater, the more the index will be compressed towards 0 :return: nd array filled with -9999 in the mask and the mask itself 
 - static calc_mbwi(bands, factor, mask)
 - static rgb_burn_in(red, green, blue, burn_in_array, color=None, min_value=None, max_value=None, colormap='viridis', fade=1, uniform_distribution=False, no_data_value=- 9999, valid_value=1, transp=0.0)
- Burn in a mask or a specific parameter into an RGB image for visualization purposes. The burn_in_array will be copied where values are different from no_data_value. :param uniform_distribution: convert the input values in a uniform histogram :param colormap: matplotlib colormap (string) to create the RGB ramp :param max_value: maximum value :param min_value: minimum value :param red: Original red band :param green: Original green band :param blue: Original blue band :param burn_in_array: Values to be burnt in :param no_data_value: Value to ne unconsidered :param color: Tuple of color (R, G, B) to be used in the burn in :param fade: Fade the RGB bands to emphasize the copied values :param transp: Transparency to use in the mask (0=opaque 1=completely transparent) :return: RGB image bands 
 - static apply_mask(array, mask, no_data_value=- 9999, clear_nan=True)
 - static gray2color_ramp(grey_array, color1=(0.0, 0.0, 0.6), color2=(0.0, 0.8, 0.0), color3=(1.0, 0.0, 0.0), min_value=0, max_value=20, colormap='viridis', limits=(0, 1))
- Convert a greyscale n-dimensional matrix into a rgb matrix, adding 3 dimensions to it for R, G, and B The colors will be mixed :param max_value: Maximum value for the color ramp, if None, we consider max(grey) :param min_value: Minimum value for the color ramp, if None, we consider min(grey) :param grey_array: greyscale vector/matrix :param color1: Color for the minimum value :param color2: Color for the mid value :param color3: Color for the maximum value :param limits: Final boundary limits for the RGB values :return: Colored vector/matrix 
 - static array2raster(filename, array, geo_transform, projection, nodatavalue=0, dtype=None)
 - static array2rgb_raster(filename, red, green, blue, geo_transform, projection, nodatavalue=- 9999)
 - static tif_2_pdf(tif_file, resolution=600, scale=2000)
- Convert a TIF image into a PDF given a resolution :param tif_file: :param resolution: :param scale: :return: 
 - static array2multiband(filename, array, geo_transform, projection, nodatavalue=0, dtype=None)
 - static get_train_test_data(data, train_size, min_train_size, max_train_size)
- Split the provided data in train-test bunches :param min_train_size: minimum data quantity for train set :param max_train_size: maximum data quantity for train set :param train_size: percentage of the data to be used as train dataset :param data: data to be split :return: train and test datasets 
 - static plot_clustered_data(data, cluster_names, file_name, graph_options, pdf_merger)
 - static plot_graphs(bands, graphs_bands, labels_array, file_name, graph_title, invalid_mask=False, max_points=1000, pdf_merger=None)
 - static create_composite(bands, folder_name, pdf=True, resolution=600, offset=0)
 - static create_bands_dict(bands_array, bands_order)
 - static create_colorbar_pdf(product_name, title, label, colormap, min_value, max_value, log_scale=False)
 - static find_file_glob(file_string, folder)
 - static read_gdal_ds(file, shape_file, temp_dir)
- Read a GDAL dataset clipping it with a given shapefile, if necessary :param file: Filepath of the GDAL file (.tif, etc.) as Pathlib :param shape_file: file path of the shapefile :param temp_dir: file path of the temporary directory :return: GDAL dataset 
 - static extract_angles_from_xml(xml)
- xmlTYPE xml file
- DESCRIPTION Filepath of the metadata file from L2A Sentinel 2 data: example “SENTINEL2A_20200328-104846-345_L2A_T31TFJ_C_V2-2_MTD_ALL.xml” 
 - Return g:
- list of glint values 
 - SZATYPE float
- DESCRIPTION. Sun zenith angle 
- SazATYPE float
- DESCRIPTION. Sun azimuth angle 
- zenith_angleTYPE list of strings
- DESCRIPTION. Mean_Viewing_Incidence_Angle_List for all the bands 
- azimuth_angleTYPE list of strings
- DESCRIPTION. Mean_Viewing_Incidence_Angle_List for all the bands 
 
 - static write_pdf(filename, text, size=(300, 50), position=(5, 5), font_color=(0, 0, 0))
 - static create_glint_pdf(xml, name_img, output_folder, g, pdf_merger)
- Function to create an image to add in the pdf report that indicates if there is glint on an image - xmlTYPE xml file
- DESCRIPTION Filepath of the metadata file from L2A Sentinel 2 data: example “SENTINEL2A_20200328-104846-345_L2A_T31TFJ_C_V2-2_MTD_ALL.xml” 
 - name_img : getting current image name - output_folder: filepath of the output folder - g: TYPE list
- DESCRIPTION list with glint values for each band of the Sentinel 2 product 
 - pdf_merger: function to add an element to a pdf 
 - static remove_negatives(bands, mask=None, negative_values='mask')
- Remove negatives values of given arrays b1 and b2, except masked values. - Parameters:
- bands – list of bands to be adjusted 
- mask – initial mask 
- negative_values – mask - mask the negative values; # fixed - replace all negative values for 0.001; shift - shift each band by its minimum value, so every band has only positive values; shift_all - shift each band by the minimum value of all bands. All bands will be shifted up by the same amount 
 
- Returns:
- nd arrays without negatives values