smos.smos_l2 namespace

Submodules

smos.smos_l2.cli module

smos.smos_l2.download module

Module to synchronize SMOS L2 data from FTP to local disk

class smos.smos_l2.download.SmosDissEoFtp(local_root, username=None, password=None, dotrc=None, skip_lftp_verify=False)[source]

Bases: object

exec(cmd)[source]
last_available_day()[source]

Get the latest available day on the server (incomplete directory). We want to exclude this day from downloading.

Return type:

last_date

list(subpath='', filter='all')[source]

Create a list of all files and subdirectories under the passed path on the server. Directories end with /, files should have a file extension.

Parameters:
  • subpath (str, optional (default: '')) – Subdirectory on the server to look into. e.g. ‘/2020/01/01’

  • filter (str, optional (default: 'all')) –

    • all: returns fils and folders

    • file: returns only files

    • dir: returns only directories

Returns:

elements – List of all files and/or folders under the subpath on the server

Return type:

list

list_all_available_days(date_from=datetime.datetime(2010, 6, 1, 0, 0), date_to=datetime.datetime(2025, 9, 4, 16, 19, 5, 247441), progressbar=True)[source]

Shortcut to get a list of all available days (i.e. folders) on the server within the selected time frame.

Parameters:
  • date_from (str or datetime, optional) – First date of the time frame to check available days for on server. By default, we use the first date of SMOS L2 (2010-06-01)

  • date_to (str or datetime, optional) – Last date of the time frame to check available days for on server. By default, we use the current date.

  • progressbar (bool, optional (default: True)) – This operation will send some request to the server and may take some time. (De)activate a visual progress representation.

Returns:

dates – List of dates for which a folder exists on the server

Return type:

list

sync(year, month, day=None, opts='', dry_run=False)[source]

Download data from remote to local folder for a certain day.

Parameters:
  • year (int) – Year part of the date to download

  • month (int) – Month part of the date to download

  • day (int, optional) – Day part of the date to download. If not set, then the whole month is synced.

  • opts (str, optional, default: '') – Additional options that are added to the command mirror OPTS root_dir target_dir For all options see https://lftp.yar.ru/lftp-man.html

  • dry_run (bool, optional, default=False) – Dry run does not actually download anything. Instead of the return value, the full command is returned

Returns:

ret – Return value or command (if dry_run)

Return type:

str

sync_period(startdate, enddate, dry_run=False)[source]

Synchronize SMOS L2 data between local root and FTP folder for days in the passed time frame. The last day on the server is usually not yet complete (i.e. swath files are missing). This will NOT be synchronized.

Parameters:
  • startdate (str or datetime) – First day to download data for (if available)

  • enddate (str or datetime) – Last day to download data for (if available)

  • Returns

  • -------

  • ret (list) – List of return values or commands (if dry_run was chosen)

verify_lftp_installed()[source]

Call lftp command to check if program is available. Otherwise it has to be installed e.g. via apt-get install.

smos.smos_l2.download.load_dotrc(path=None) dict[source]

Read FTP login credentials from .smosrc file.

Parameters:

path (str, optional (default: None)) – Path to the dotrc file. None will look in the default branch with is the home folder.

Returns:

config – Elements from the dotrc file

Return type:

dict

smos.smos_l2.reshuffle module

smos.smos_l2.reshuffle.extend_ts(img_path, ts_path, memory=4, only_land=False)[source]

Append new image data to an existing time series record. This will use the last_day from summary.yml in the time series directory to decide which date the update should start from and the available image directories to decide how many images can be appended.

Parameters:
  • img_path (str) – Path where the annual folders containing downloaded SMOS L2 images are stored

  • ts_path (str) – Path where the converted time series (initially created using the reshuffle / swath2ts command) are stored.

  • memory (int, optional (default: 4)) – Available memory in GB

smos.smos_l2.reshuffle.swath2ts(img_path, ts_path, variables=('Soil_Moisture', 'Science_Flags', 'Confidence_Flags', 'Chi_2_P', 'RFI_Prob', 'N_RFI_X', 'N_RFI_Y', 'M_AVA0'), startdate=None, enddate=None, memory=4, only_land=False)[source]

Convert SMOS L2 swath data to time series in IndexedRaggedTs format.

Parameters:
  • img_path (str) – Local (root) directory where the annual folder containing SMOS L2 SM swath data are found.

  • ts_path (str) – Local directory where the converted time series data will be stored.

  • variables (tuple or str, optional (default: None)) – List of variables to include, None will use the default variables “Soil_Moisture”, “Soil_Moisture_DQX”, “Science_Flags”, “Confidence_Flags”, “Processing_Flags”, “Chi_2_P”, “RFI_Prob”, “N_RFI_X”, “N_RFI_Y”, “M_AVA0”, “acquisition_time”

  • startdate (str or datetime, optional (default: None)) – First day of the available swath data that should be included in the time series. If None is passed, then the first available day is used.

  • enddate (str or datetime, optional (default: None)) – Last day of the available swath data that should be included in the time series. If None is passed, then the last available day is used.

  • memory (float, optional (default: 4)) – Size of available memory in GB. More memory will lead to a faster conversion.