API reference
ESA product Family Logic
set of methods to confirm a product Sentinel-1 is nominal using manifest file
- s1ifr.check_SAFE_files.check_safe_sentinel3(full_path_safe)
proto checker for Sentinel-3 SRAL
- s1ifr.check_SAFE_files.delete_corrupted_safe(corrupted_list, dirout) int
- Parameters:
corrupted_list – list
dirout – str directory where to list the SAFE removed
- Returns:
- s1ifr.check_SAFE_files.check_number_of_measurement(manifestpath) bool
return true if the number of measurement is in line with manifest file
- Parameters:
manifestpath (str) – full path of the manifest.safe file
- Returns:
all_measu_present (bool): True -> valid product
- s1ifr.check_SAFE_files.check_presence_of_manifest_file(manifestpath)
return True if the manifest is present
- Parameters:
manifestpath (str) – full path of the manifest.safe
- s1ifr.check_SAFE_files.exploit_check_sum(safepath)
use the checksum value of manifest file to control that the data is not corrupted
- s1ifr.check_SAFE_files.check_sub_directories(safe_path, level, typefile)
return True if all sub dir are present
- s1ifr.check_SAFE_files.safe_checker(safe_path, logpath, enable_checksum=False, security_time=300) bool
test one given SAFE SAFE is ok by default to avoid lots of deletions (for examplt if the :param safe_path: full path of SAFE product :type safe_path: str :param file_handler: file handler to write logs :type file_handler: int :param security_time: nber of seconds to wait before checking [optional] :type security_time: int
- Returns:
True if the SAFE is OK, False if it is corrupted
- Return type:
flag_ok_safe (bool)
- s1ifr.check_SAFE_files.log_path(config_path=None)
return a file where to log products that are not nominal.
- Parameters:
config_path (str) – full path of config file .yml for s1ifr [optional]
- Returns:
path of .lst file
- Return type:
list_safe_having_problem (str)
- s1ifr.check_SAFE_files.main_loop(repdata=None, pattern=None, unique_safe=None, enable_checksum=False, list_safe_having_problem=None, limit_nb_safe=None)
browse the whole archive to find the pattern
- Parameters:
repdata (str)
pattern (str)
unique_safe (str)
enable_checksum (bool)
limit_nb_safe (int) – optional, give the max number of safe analyzed before stoping
list_safe_having_problem (str) – full path
Functions to resolve full paths for Sentinel-1 SAFE products in the Ifremer archive.
- s1ifr.get_path_from_base_safe.get_safe_basename_from_fullpath_measu(fullpathmeasu: str) str
Extracts the SAFE product’s basename from a full path to a measurement file.
For example, given ‘/path/to/S1A…SAFE/measurement/s1a-iw-grd-vv-….tiff’, it returns ‘S1A…SAFE’.
- Parameters:
fullpathmeasu – The full path to a measurement file inside a SAFE directory.
- Returns:
The basename of the parent .SAFE directory.
- s1ifr.get_path_from_base_safe.get_path_from_base_safe(safe_basename: str, archive_name: str = 'datawork', check_existence: bool = False, config_path: str = None) str | None
Constructs the full, absolute path for a given SAFE product basename.
This function resolves the path within the specified Ifremer archive structure. If the basename contains a wildcard (‘*’), it attempts to find the first matching file.
- Parameters:
safe_basename – The name of the SAFE product. (e.g., “S1A_IW_OCN__2SDV_20150731T222653_20150731T222719_007061_0099AE_B180.SAFE”)
archive_name – The target archive, either ‘datawork’ or ‘scale’.
check_existence – True -> check if the file exists, and if safe does not exist return None, False -> do not check.
config_path – str path of configuration .yml file
- Returns:
The absolute path to the SAFE product if found, otherwise None or the path with the unresolved wildcard.
Clean multiple occurrences of the same SAFE file in Sentinel-1 data.
This script identifies duplicate Sentinel-1 products based on their acquisition parameters and keeps only the version with the latest processing time. Old versions are moved to quarantine or deleted. It is designed to be called by the Sentinel-1 ‘pieuvre’ (data ventilation) system.
Example
find $PWD -maxdepth 1 -name '*SAFE' | python clean_sentinel1_duplicates_function.py --safe [SAFE_PATH]
- s1ifr.clean_sentinel1_duplicates_function.Author
Antoine Grouazel
- s1ifr.clean_sentinel1_duplicates_function.Date
April 2014
- s1ifr.clean_sentinel1_duplicates_function.get_ending_processing_time(safe_full_path)
Extract the stop processing time from the SAFE manifest file.
- Parameters:
safe_full_path (str) – Full path to the SAFE directory.
- Returns:
- The processing stop time extracted from the manifest.
Returns 2014-01-01 as a default value if the manifest is missing or empty.
- Return type:
datetime.datetime
- s1ifr.clean_sentinel1_duplicates_function.spot_dupli_core(safebasename, repdata)
Identify duplicate SAFE products and find the latest processed version.
Searches for files matching the acquisition prefix of the provided basename within the specified directory and compares their processing dates.
- Parameters:
safebasename (str) – Basename of the S1 SAFE product to check.
repdata (str) – Path to the directory where potential duplicates are stored.
- Returns:
- A tuple containing:
int: Index of the latest processed file in the occurrence list.
list: Full paths of all potential occurrences found.
numpy.ndarray: Array of processing stop times for each occurrence.
- Return type:
tuple
- s1ifr.clean_sentinel1_duplicates_function.latest_safe_processed(duplicates_list)
Compare processing times for a list of duplicate SAFE products.
- Parameters:
duplicates_list (list) – List of full paths to duplicate SAFE products.
- Returns:
- A tuple containing:
int: Index of the latest processed version in the list.
list: The input duplicates_list.
numpy.ndarray: Array of processing stop times (datetime objects).
- Return type:
tuple
- s1ifr.clean_sentinel1_duplicates_function.check_duplicate(file_to_be_checked, config_path, archive='datawork', dryrun=True)
Detect and remove duplicate SAFEs based on processing time.
Identifies SAFEs with the same acquisition dates as the input file. Keeps only the version with the latest processing time and sends others to quarantine.
- Parameters:
file_to_be_checked (str) – Full path of the .SAFE (or .tar) to be checked.
config_path (str) – Full path of the config .yml file for s1ifr.
archive (str) – Storage name (‘scale’ or ‘datawork’). Defaults to “datawork”.
dryrun (bool) – If True, logs actions without deleting/moving files. Defaults to True.
- Returns:
Number of duplicate files identified for removal.
- Return type:
int
- s1ifr.clean_sentinel1_duplicates_function.main()
Main entry point for the CLI tool to clean SAFE duplicates.
methods for sorting SAFE into IFREMER archive author: Antoine Grouazel
- s1ifr.existence_safe.product_is_present_at_ifremer(safe_basename, full_path_safe=None, config_path=None)
check that the safe downloaded do not exist in other archive dirs and delete the one in spool_dir if yes
- Parameters:
safe_basename (str)
full_path_safe (str) – [optional]
config_path (str) – full path of config file .yml for s1ifr [optional]
- Returns:
True -> continue archiving process existing_storage (str): could be ‘quarantine’ or ‘datawork’ or … archive (str): name of the Ifremer archive where the product is stored
- Return type:
flag_continue (bool)
- s1ifr.existence_safe.remove_file_already_in_archive(full_path_tar)
delete SAFE.tar files from spool when already in archive
- Parameters:
full_path_tar – str
Author: Antoine.Grouazel@ifremer.fr Purpose:separate information in SAFE name sentinel1 Creation: 2014-11-28 Arguments: basename SAFE directory note: valid also for Sentinel3 SRAL data
- s1ifr.explodesafename.check_safe_name_match_expected_s1_pattern(safename: str) bool
Check if the given SAFE name matches the expected Sentinel-1 pattern.
- Parameters:
safename – The SAFE product name to check.
- class s1ifr.explodesafename.ExplodeSAFE(basename_safe)
input basename_safe (str) SAFE name only (no parent directories before neitheir children files)
methods to find path in Ifremer archive for a given measurement base-name
- s1ifr.get_full_path_from_measurement.get_full_path_from_measu(measurement, storage='datawork', config_path=None) str
to get the full path in ifremer archive of given measurement
- Parameters:
measurement (str) – basename of a S1 measurement .raw .tiff or .nc
storage (str) – ‘scale’ or ‘datawork’
config_path (str) – full path of config file .yml for s1ifr [optional]
- Returns:
full path in archive or None if not found
- Return type:
fp (str)
- s1ifr.get_full_path_from_measurement.get_full_path_ocn_wv_from_approximate_date(datedt, sat, level='L2', storage='datawork', nb_seconds_delta=3, config_path=None)
method to find a WV path from a date and a SAR unit ok for OCN and SLC WV only
- Parameters:
datedt (datetime.datetime) – the date for which a WV acquisition is suspected to exist
sat (str) – SAR Sentinel-1 unit such as S1A S1B …
level (str) – Level of processing of the WV product sought, L2 or L1 [default=L2]
storage (str) – file system where the product is suposed to be stored ‘datawork’ or ‘scale’ [optional]
nb_seconds_delta (int) – positive maximum range of search for the number of seconds of shift with respect to datedt
config_path (str) – full path of config file .yml for s1ifr [optional]
Returns
reso (str): full path of the WV measurement.
- s1ifr.get_full_path_from_measurement.get_full_path_with_safe_and_measu(safebase, measu_base, storage='datawork', config_path=None) str
used when inputs are coming from the json of datavore xwave quicklook request
- Parameters:
safebase (str)
measu_base (str)
config_path (str) – full path of config file .yml for s1ifr [optional]
- Returns:
str full path of the measurement in archive (no exist test)
- Return type:
finalpath
- s1ifr.match_SLC_GRD.core_find(fp, max_delta_second, res_base, startdate) str
Finds the SAFE path if it exists at Ifremer.
Deprecated since version 2026.10.1:
core_find()will be removed in a future release. Usenew_replacement_function()instead.- Parameters:
fp (str) – Full path pattern of the SAFE to test.
max_delta_second (int) – Maximum allowed time difference in seconds.
res_base (str) – Radical of the SAFE pattern to replace in original SAFE.
startdate (datetime.datetime) – Start date of the input product.
- Returns:
Full path of the SAFE if found, otherwise None.
- Return type:
str or None
- s1ifr.match_SLC_GRD.match_slc_grd(safenameslc, type_input='SLC_', type_seek='GRDH', max_delta_second=3, config_path=None) str
Matches an SLC product with its corresponding GRD (or vice versa).
Deprecated since version 2026.10.1:
match_slc_grd()will be removed in a future release. Usenew_replacement_function()instead.- Parameters:
safenameslc (str) – The basename of the SAFE product.
type_input (str) – The type of the input product, e.g.,
"SLC_"or"GRDH".type_seek (str) – The type of product to search for, e.g.,
"GRDH"or"SLC_".max_delta_second (int) – Maximum time difference in seconds for a valid match. Defaults to 3. Found one case with 7 seconds diff.
config_path (str) – path of the confg .yml file [optional, default is None]
- Returns:
Full path of the matched SAFE if found in archives, otherwise None.
- Return type:
str or None
Ifremer product Family Logic
methods to get dataframe from SLC L1 to L1B and L1C and L2 in order to check the completness of a given listing Janaury 2025
- s1ifr.paths_safe_product_family._resolve_slc_path(slc_identifier)
Resolves the physical path of an SLC SAFE from various archives.
- Parameters:
slc_identifier (str) – Filename or full path of the SLC SAFE.
- Returns:
Full path if found, else None.
- Return type:
str or None
- s1ifr.paths_safe_product_family.get_output_l1b_safe(slc_iw_path_safe, outputdir, productid) str
Predicts the expected L1B/L1C XSP SAFE path based on an SLC path.
- Parameters:
slc_iw_path_safe (str) – Path to source SLC.
outputdir (str) – Base output directory.
productid (str) – Version/Product ID (e.g., ‘A14’).
- Returns:
Constructured path.
- Return type:
str
- s1ifr.paths_safe_product_family.get_output_l2wav_safe(slc_path, outputdir, productid) str
Predicts the expected L2 WAV SAFE path based on an SLC path.
- Parameters:
slc_path (str) – Path to source SLC.
outputdir (str) – Base output directory.
productid (str) – Version/Product ID.
- Returns:
Constructed path.
- Return type:
str
- s1ifr.paths_safe_product_family._find_version_path(slc_path, pid, search_dirs, path_generator_func)
Generic helper to find a versioned product across multiple directories.
- s1ifr.paths_safe_product_family.add_L1B(df, cpt=None, versions=None, disable_tqdm=False, config_path=None)
Collect Level-1B paths from Ifr archive.
- Parameters:
df (pd.DataFrame) – Input dataframe with ‘L1_SLC’ column.
cpt (defaultdict) – Counters dictionary.
versions (list) – List of versions to search.
disable_tqdm (bool) – Disable progress bar.
config_path (str) – Path to config file.
- Returns:
(updated df, updated cpt)
- Return type:
tuple
- s1ifr.paths_safe_product_family.add_L1C(df, versions=None, cpt=None, disable_tqdm=False, config_path=None)
From L1 path, find associated L1C XSP products.
- Parameters:
df (pd.DataFrame) – Input dataframe.
versions (list) – L1C versions.
cpt (defaultdict) – Counters.
disable_tqdm (bool) – Progress bar control.
config_path (str) – Config file path.
- Returns:
(updated df, updated cpt)
- Return type:
tuple
- s1ifr.paths_safe_product_family.add_L2WAV(df, versions=None, cpt=None, disable_tqdm=False, config_path=None)
From SLC path, find associated L2-WAV products.
- Parameters:
df (pd.DataFrame) – Input dataframe.
versions (list) – L2 versions.
cpt (defaultdict) – Counters.
disable_tqdm (bool) – Progress bar control.
config_path (str) – Config file path.
- Returns:
(updated df, updated cpt)
- Return type:
tuple
- s1ifr.paths_safe_product_family.add_SLC(df, cpt=None, config_path=None)
to be used if the input listing is GRD
- Parameters:
df (pd.DataFrame)
cpt (collections.defaultditc(int)) – [optional]
config_path (str) – [optional]
- Returns:
- s1ifr.paths_safe_product_family.get_products_family(df, l1bversions=None, l1cversions=None, disable_tqdm=False, config=None) DataFrame
wrapper method to add Level-1B , Level-1C and Level-2 WAV paths associated to initial SAFE
- Parameters:
df – pandas.DataFrame with ‘L1_SLC’ column filled with SAFE paths
l1bversions – list of str [‘A12’] for instance [optional]
l1cversions – list of str [‘B17’] for instance [optional]
disable_tqdm – bool
config – str path of the config [optional default=None]
- Returns:
pandas.DataFrame with new columns
- Return type:
df
- s1ifr.paths_safe_product_family.create_a_listing(newdf)
- s1ifr.paths_safe_product_family.entrypoint()