:py:mod:`hypso.classification.WaterDetection.waterdetect.InputOutput`
=====================================================================

.. py:module:: hypso.classification.WaterDetection.waterdetect.InputOutput


Module Contents
---------------

Classes
~~~~~~~

.. autoapisummary::

   hypso.classification.WaterDetection.waterdetect.InputOutput.DWLoader
   hypso.classification.WaterDetection.waterdetect.InputOutput.DWSaver
   hypso.classification.WaterDetection.waterdetect.InputOutput.DWS2CORMaskProcessor
   hypso.classification.WaterDetection.waterdetect.InputOutput.DWLandsatMaskProcessor
   hypso.classification.WaterDetection.waterdetect.InputOutput.DWTheiaMaskProcessor




.. py:class:: DWLoader(input_folder, shape_file=None, product='S2_THEIA', ref_band='Red', single_mode=False)

   .. py:property:: product_dict


   .. py:property:: area_name

      Extracts the name of the area based on the shapefile name
      :return: name of the area


   .. py:property:: current_image_folder

      Returns the full path folder of current (selected) image
      :return: Posixpath of current image


   .. py:property:: current_image_name

      Returns the name of the current (selected) image
      :return: String name of the current (selected) image


   .. py:property:: bands_path

      Return the directory of the bands depending on the product
      :return: PosixPath of the directory containing the bands


   .. py:property:: granule_metadata

      Returns the full path folder of the image's granule metadata
      :return: Posixpath of current image's granule metadata


   .. py:property:: metadata

      Returns the full path folder of the image's metadata
      :return: Posixpath of current image's metadata


   .. py:property:: glint_name

      "
      Name of the glint image for the report


   .. py:property:: projection


   .. py:property:: geo_transform


   .. py:property:: x_size


   .. py:property:: y_size


   .. py:attribute:: satellite_Dict

      

   .. py:attribute:: band_ids

      

   .. py:method:: __len__()


   .. py:method:: __iter__()


   .. py:method:: __next__()


   .. py:method:: get_bands_files()

      Retrieve the full path of bands saved for the current image, according to the product
      :return: Posix_path of bands files


   .. py:method:: open_current_image(ref_band_name='Red')

      Load a bands list, given a image_list and a dictionary of Keys(BandName) and identifiers to parse the filename
      ex. {'Green':'B3', 'Red':'B4'...}
      The result, will be a dictionary with Keys(BandName) and GdalDatasets as values


   .. py:method:: open_gdal_image(bands_list, desired_band)
      :staticmethod:

      Get the image in the list corresponding to the informed Band.
      Return the image opened with GDAL as a RasterImage object
      If cant find the band return None
      If is more than 1 image, raise exception


   .. py:method:: clip_bands(bands_to_clip, ref_band, temp_dir)


   .. py:method:: get_offset(band)

      Get the offset value to be applied to the band. This offset exists in the Sen2Cor images after 25 January 2022.
      https://sentinels.copernicus.eu/documents/247904/4830984/OMPC.CS.DQR.002.07-2022%20-%20i52r0%20-%20MSI%20L2A%20DQR%20August%202022.pdf/36edbb04-0c6c-fba3-5c34-0ba3be82e91c
      @param band: Reflectance band
      @return: Value to be added to the loaded band


   .. py:method:: load_raster_bands(bands_list)


   .. py:method:: update_mask(mask)


   .. py:method:: load_masks(product_masks_list, external_mask, mask_name, mask_valid_value=None, mask_invalid_value=None)



.. py:class:: DWSaver(output_folder, product_name, area_name=None)

   .. py:property:: area_name


   .. py:property:: temp_dir


   .. py:method:: set_output_folder(image_name, geo_transform, projection)

      For each image, the saver has to prepare the specific output directory, and saving parameters.
      The output directory is based on the base_output_folder, the area name and the image name
      :param image_name: name of the image being processed
      :param geo_transform: geo transformation to save rasters
      :param projection: projection to save rasters
      :return: Nothing


   .. py:method:: update_geo_transform(geo_transform, projection)


   .. py:method:: create_base_name(product_name, image_name)
      :staticmethod:


   .. py:method:: create_output_folder(output_folder, image_name, area_name)
      :staticmethod:


   .. py:method:: save_array(array, name, opt_relative_path=None, no_data_value=0, dtype=None)


   .. py:method:: save_rgb_array(red, green, blue, name, opt_relative_path=None)


   .. py:method:: save_multiband(array, name, opt_relative_path=None, no_data_value=0, dtype=None)

      Save a multilayer array

      :param array: array with all bands wanted
      :param name: name of the output

      :return: the complete filename



.. py:class:: DWS2CORMaskProcessor(base_folder, x_size, y_size, shape_file=None, temp_dir=None)

   .. py:attribute:: Sen2CorMaskList

      

   .. py:method:: open_mask(shape_file, temp_dir)


   .. py:method:: open_gdal_masks(shape_file, temp_dir)


   .. py:method:: get_combined_masks(masks_list)



.. py:class:: DWLandsatMaskProcessor(base_folder, x_size, y_size, shape_file=None, temp_dir=None)

   .. py:attribute:: LandsatMaskDict

      

   .. py:method:: open_mask(shape_file, temp_dir)


   .. py:method:: open_gdal_masks(shape_file, temp_dir)


   .. py:method:: get_combined_masks(masks_list)



.. py:class:: DWTheiaMaskProcessor(base_folder, x_size, y_size, shape_file=None, temp_dir=None)

   .. py:attribute:: TheiaMaskDict

      

   .. py:attribute:: TheiaCLMDict

      

   .. py:attribute:: TheiaMG2Dict

      

   .. py:method:: open_masks(shape_file, temp_dir)


   .. py:method:: open_gdal_masks(shape_file, temp_dir)


   .. py:method:: get_combined_masks(masks_list)