warsa.precipitation.satellite package

Subpackages

Submodules

warsa.precipitation.satellite.download module

class SatelliteBasedPrecipitationDownload(local_dir, prefix, suffix, dir_lens, product_subfolder)

Bases: object

static clean_path(path)
contains_prefix_and_suffix(name)
download(update=False, verbose=False, begin=None, end=None)
endswith_prefix(s)
static get_datetime_from_file_name(filename)
get_full_dir_name_4(dt)
get_full_dir_name_42(dt)
get_full_dir_name_422(dt)
get_full_dir_name_43(dt)
get_full_dir_name_46(dt)
get_full_dir_name_6(dt)
get_full_dir_name_none(_)
get_local_files()
startswith_prefix(s)
class SatelliteBasedPrecipitationDownloadFTP(local_dir, prefix, suffix, dir_lens, ftp_host, ftp_dir, ftp_user=None, ftp_password=None, ftp_timeout=600, product_subfolder='')

Bases: warsa.precipitation.satellite.download.SatelliteBasedPrecipitationDownload

describe()
download(update=False, verbose=True, begin=None, end=None)
Parameters:
  • update – if TRUE, checks for any missing file on the local folder, otherwise starts download at the last saved file
  • verbose – if TRUE, outputs the current file being downloaded as well the time in seconds took to download each file
  • begin
  • end
download_ftp_files(local_files)
ftp_files()

Guarantees that the full path has no double slashes ‘//’ :param begin: :return: file name with full path lead by ‘/’

ftp_folders(ftp_dir, folder_lengths, dir_beg=None)
get_ftp_file_names(lines)
make_dir(d)
parse_ftp_dirs(folder_length, lines)
print_verbose(msg, same_line=False)

warsa.precipitation.satellite.products module

class SatellitePrecipitationGroup(product_groups, product_group_name, usr=None, pwd=None)

Bases: object

A group of products are satellite precipitation products from the same server

add_product(product, frequency, time_label, depth_intensity, download_class, download_folder, rasterize_class, **kwargs)
get_download_dir()
get_name()
get_product(product)
has_product(product)
class SatellitePrecipitationGroups(download_dir=None)

Bases: object

add_product(product_group, product, frequency, time_label, depth_intensity, download_class, download_folder, rasterize_class, **kwargs)
Parameters:
  • product_group
  • product
  • download_class
  • download_folder
  • rasterize_class
  • kwargs
Returns:

get_download_class(product_group, product)
get_download_dir()
get_group_product_names()
get_product(product_group, product)
get_product_group(product_group)
get_rasterize_class(product_group, product)
group_product()
group_product_names()
has_product(product_group, product)
has_product_group(product_group)
class SatellitePrecipitationProduct(group, product, frequency, time_label, depth_intensity, download_class, product_dir, rasterize_class, **kwargs)

Bases: object

get_begin()
get_download_class()

Return the class used to download this product

Returns:class
Return type:
get_download_dir()

Return the full path of the directory where this product was downloaded.

Returns:download dir full path
Return type:str
get_name()

Return the product name

Returns:product name
Return type:str
get_product_dir()

Return the relative path of this product’s directory.

The returned path is the same as on the data provider’s server

Returns:
Return type:str
get_rasterize_class()
create_time_series(output_dir, raster_root_dir, sarp_list, layers, **kwargs)

Create from a precipitation raster product a time series as precipitation DEPTH in (mm) with timestamp right labeled . Default is no time zone shifting, i.e. as given in the product (generally UTC)

Parameters:
  • output_dir
  • raster_root_dir
  • sarp_list
  • layers
  • kwargs
    key prefix:default is ‘precipitation’
    key utc:time zone in hours (negative for West)

    further keys for time_series.create_time_series

Returns:

download(sarp_list=None, update=False, verbose=True)

Download satellite precipitation products

Parameters:
  • sarp_list (list) – list with tuple (section, option) from config file. section is the product group and option the product. If empty or None (default), all products from all groups in the config file will be downloaded
  • update
  • verbose
Returns:

get_groups(**kwargs)
Parameters:kwargs
key root_dir:

:key sarp_list

Returns:
rasterize(output_dir, sarp_list, **kwargs)
Parameters:
  • output_dir
  • sarp_list
  • kwargs – see Rasterizer()
Returns:

warsa.precipitation.satellite.rasterize module

class Rasterizer(product_dir, output_raster_dir, suffix, **kwargs)

Bases: object

static create_dataset(raster_parameters, arr, output_filename=None)
get_local_files()
get_rasters(product_filename)

A product file contains one or more rasters. For instance, a 30-minute product delivered once per hour contains two half-hour rasters per file

This is the default method, which should be overloaded if the product_filename is not a tif file. It creates just a dataset copy of the product_filename.

Parameters:product_filename – full path name of th product file
Returns:list tuples [output_filename, RasterRead] objects output_filename is obtained from the product_filename by substituting product_dir by output_raster_dir output_dataset in in the memory (driver=’MEM’)
static open_raster(input_raster)
rasterize_file(input_filename)
rasterize_folder(verbose=False, overwrite=False)
static read_compressed_file(filename)
static save_as(input_raster, output_filename, zip=False)
default_get_raster_file_names(sarp_filename, raster_filename, suffix, overwrite)

warsa.precipitation.satellite.server module

class FTPServer(satellite_precipitation_product, host, directory, user=None, password=None, timeout=600)

Bases: warsa.precipitation.satellite.server.Server

describe()
download(update=True)
download_ftp_files(local_files, dt)
ftp_files(dt=None)
ftp_folders(ftp_dir, folder_lengths, dir_beg=None)
class Server(satellite_precipitation_product)

Bases: object

dir_lens()
get_datetime_from_file_name(filename)
get_local_files()
local_dir()
replace_server_by_local_dir()
parse_ftp_dirs(folder_length, lines)
print_verbose(msg, same_line=False)

warsa.precipitation.satellite.time_series module

create_time_series(time_series_filename, raster_dir, layers, get_datetime_from_raster_file, **kwargs)
Parameters:
  • time_series_filename
  • raster_dir
  • layers
  • get_datetime_from_raster_file
  • kwargs
    key layer_fieldname:
     
    key layer_number:
     
    key raster_suffix:
     
    key float_format:
     
Returns:

create_time_series_from_rasters_to_points(df_geo, df_ts, datetime_dict)
Parameters:
  • df_geo – station names as index and geometry-wkb as column ‘_GEOM_’
  • df_ts – datetime as index and station names as columns
  • datetime_dict – datetime as index and raster-filename as column
Returns:

create_time_series_from_rasters_to_polygons(lrs, layer_fieldname, columns, df, datetime_dict)
get_rasterized_files(rasters_dir, suffix='.tif')
print_verbose(msg, verbose=True, same_line=False)

Module contents