remotior_sensus.core.session module

Session manager.

Core class that manages the Remotior Sensus’ session. It defines fundamental parameters such as available RAM and number of parallel processes. Creates a temporary directory to store temporary files. Exposes core functions and tools. It includes a method to close the session removing temporary files and stopping parallel processes.

Typical usage example:

>>> # start the session
>>> rs = Session()
>>> # optionally set session parameters
>>> rs.set(n_processes=2)
>>> # close the session when processing is done
>>> rs.close()
class remotior_sensus.core.session.Session(n_processes: int | None = 2, available_ram: int = 2048, temporary_directory: str | None = None, directory_prefix: str | None = None, log_level: int = 20, log_time: bool = True, progress_callback=None, multiprocess_module=None, messages_callback=None, smtp_server=None, smtp_user=None, smtp_password=None, smtp_recipients=None, smtp_notification=None, sound_notification=None)

Bases: object

Manages system parameters.

This module allows for managing Remotior Sensus’ session, setting fundamental processing parameters and exposing core functions and tools.

configurations

module containing shared variables and functions

bandset

access BandSet() class

bandset_catalog

access BandSetCatalog() class

spectral_signatures_catalog

access SpectralSignaturesCatalog() class

spectral_signatures_plot_catalog

access SpectralSignaturePlotCatalog() class

spectral_signatures_plot

access SpectralSignaturePlot() class

output_manager

access OutputManager() class

table_manager

access functions of table_manager() module

dates_times

access dates and times utilities

download_tools

access download utilities

shared_tools

access shared tools

files_directories

access files directories utilities

band_calc

tool band_calc()

band_classification

tool band_classification()

classifier

tool Classifier()

band_combination

tool band_combination()

band_dilation

tool band_dilation()

band_erosion

tool band_erosion()

band_mask

tool band_mask()

band_neighbor_pixels

tool band_neighbor_pixels()

band_pca

tool band_pca()

band_resample

tool band_resample()

band_sieve

tool band_sieve()

band_stack

tool band_stack()

cross_classification

tool cross_classification()

download_products

tool download_products()

mosaic

tool mosaic()

preprocess_products

tool preprocess_products()

raster_reclassification

tool preprocess_products()

raster_report

tool raster_report()

raster_split

tool raster_split()

raster_to_vector

tool raster_to_vector()

vector_to_raster

tool vector_to_raster()

jupyter

starts a Jupyter interface

Examples

Start a session
>>> import remotior_sensus
>>> rs = remotior_sensus.Session()
Start a session defining number of parallel processes. and available RAM
>>> import remotior_sensus
>>> rs = remotior_sensus.Session(n_processes=4,available_ram=4096)
Create a BandSetCatalog()
>>> catalog = rs.bandset_catalog()
Run the tool for raster report
>>> output = rs.raster_report(raster_path='file.tif', output_path='output.txt')
Start an interactive Jupyter interface
>>> rs.jupyter().download_interface()
Stop a session at the end to clear temporary directory
>>> rs.close()
__init__(n_processes: int | None = 2, available_ram: int = 2048, temporary_directory: str | None = None, directory_prefix: str | None = None, log_level: int = 20, log_time: bool = True, progress_callback=None, multiprocess_module=None, messages_callback=None, smtp_server=None, smtp_user=None, smtp_password=None, smtp_recipients=None, smtp_notification=None, sound_notification=None)

Starts a session.

Starts a new session setting fundamental parameters for processing. It sets the number of parallel processes (default 2) and available RAM (default 2048MB) to be used in calculations. It starts the class Temporary to manage temporary files by creating a temporary directory with an optional name prefix. It starts the class Log for logging (with a default level INFO) and creates a logging formatter with the option to hide time. It starts the class Progress for displaying progress with a default callback function. A custom progress callback function can be passed optionally.

The sessions also allows for accessing to the core functions and tools.

In the end, the close() function should be called to clear the temporary directory and stop the parallel processes.

Parameters:
  • n_processes – number of parallel processes.

  • available_ram – number of megabytes of RAM available to processes.

  • temporary_directory – path to a temporary directory.

  • directory_prefix – prefix of the name of the temporary directory.

  • log_level – level of logging (10 for DEBUG, 20 for INFO).

  • log_time – if True, logging includes the time.

  • progress_callback – function for progress callback.

  • multiprocess_module – multiprocess module, useful if Remotior Sensus’ session is started from another Python module.

  • messages_callback – message module, useful if Remotior Sensus’ session is started from another Python module.

  • smtp_server – optional server for SMTP notification.

  • smtp_user – user for SMTP authentication.

  • smtp_password – password for SMTP authentication.

  • smtp_recipients – string of one or more email addresses separated by comma for SMTP notification.

  • smtp_notification – optional, if True send SMTP notification.

  • sound_notification – optional, if True play sound notification.

Examples

Start a session
>>> import remotior_sensus
>>> rs = remotior_sensus.Session()
close(log_path: str | None = None)

Closes a Session.

This function closes current session by deleting the temporary files and stopping parallel processes.

Parameters:

log_path – path where the log file is saved

Examples

Given that a session was previously started
>>> import remotior_sensus
>>> rs = remotior_sensus.Session()
Set the number of parallel processes and available RAM
>>> rs.set(n_processes=8, available_ram=20480)
Set the logging level to DEBUG
>>> rs.set(log_level=10)
set(n_processes: int | None = None, available_ram: int | None = None, temporary_directory: str | None = None, directory_prefix: str | None = None, log_level: int | None = None, log_time: bool | None = None, progress_callback: function | None = None, smtp_server=None, smtp_user=None, smtp_password=None, smtp_recipients=None, sound_notification=None, smtp_notification=None)

Sets or changes the parameters of an existing Session.

Sets the parameters of an existing Session such as number of processes or temporary directory.

Parameters:
  • n_processes – number of parallel processes.

  • available_ram – number of megabytes of RAM available to processes.

  • temporary_directory – path to a temporary directory.

  • directory_prefix – prefix of the name of the temporary directory.

  • log_level – level of logging (10 for DEBUG, 20 for INFO).

  • log_time – if True, logging includes the time.

  • progress_callback – function for progress callback.

  • smtp_server – optional server for SMTP notification.

  • smtp_user – user for SMTP authentication.

  • smtp_password – password for SMTP authentication.

  • smtp_recipients – string of one or more email addresses separated by comma for SMTP notification.

  • smtp_notification – optional, if True send SMTP notification.

  • sound_notification – optional, if True play sound notification.

Examples

Given that a session was previously started
>>> import remotior_sensus
>>> rs = remotior_sensus.Session()
Stop a session
>>> rs.close()
Stop a session saving also the log to a file
>>> rs.close(log_path='file.txt')