pysiral.l3proc

Created on Fri Jul 24 14:04:27 2015

@author: Stefan

Submodules

Classes

Level3Processor

Template for default pysiral class with logging/error handling capabilities

L2iDataStack

Template for default pysiral class with logging/error handling capabilities

L3DataGrid

Container for computing gridded data sets based on a l2i data stack

L3MetaData

Container for L3S Metadata information

Level3GridDefinition

This is a variation of GridDefinition with a mandatory link to

Level3ProductDefinition

Template for default pysiral class with logging/error handling capabilities

Level3ProcessorItem

A parent class for processing items to be selected in the Level-3 processor settings

Package Contents

class pysiral.l3proc.Level3Processor(product_def)

Bases: pysiral.core.legacy_classes.DefaultLoggingClass

Template for default pysiral class with logging/error handling capabilities

error
_job
_l3_progress_percent = 0.0
_l2i_files = None
_period = None
process_l2i_files(l2i_files, period)

The main call for the Level-3 processor TODO: Needs organization :param l2i_files: :param period: :return:

_log_progress(i)

Concise logging on the progress of l2i stack creation

static apply_orbit_filter(l2i, orbit_filter)

Apply a :param l2i: :param orbit_filter: :return:

static apply_miz_filter(l2i, miz_filter)

Flag values based on the miz filter value :param l2i: :param miz_filter: :return:

_apply_processing_items(l3grid)

Sequentially apply the processing items defined in the Level-3 processor definition files (listed under root.processing_items) :param l3grid: :return:

class pysiral.l3proc.L2iDataStack(griddef, l2_parameter)

Bases: pysiral.core.legacy_classes.DefaultLoggingClass

Template for default pysiral class with logging/error handling capabilities

griddef
l2_parameter
_n_records = 0
_l2i_count = 0
start_time = []
stop_time = []
mission = []
timeliness = []
_l2i_info = None
_initialize_stacks()

Create all data stacks, content will be added sequentially with add method

add(l2i)

Add a l2i data object to the stack

Args:

l2i (obj): l2i object (currently: pysiral.l2data.L2iNCFileImport)

Returns:

None

property n_total_records
property l2i_count
property parameter_stack
property l2i_info
class pysiral.l3proc.L3DataGrid(job, stack, period, doi='')

Bases: pysiral.core.legacy_classes.DefaultLoggingClass

Container for computing gridded data sets based on a l2i data stack (averaged l2i parameter, grid cell statistics)

error
_doi = ''
_data_record_type = 'none'
_griddef
_l3def
_period
_external_masks
_time_dim_is_unlimited
_creation_time
_l2_parameter = None
l2
_non_empty_grid_indices = None
vars
_metadata = None
set_doi(doi)
set_data_record_type(data_record_type)
get_attribute(attribute_name, *args)

Return a string for a given attribute name. This method is required for the output data handler

add_grid_variable(parameter_name, fill_value, dtype, allow_overwrite: bool = False)

Add a grid variable and fill with empty values

Parameters:
  • parameter_name – The name of the parameter

  • fill_value – the “empty” value assigned to all cell

  • dtype – numpy compatible dtype

  • allow_overwrite – If True, an existing variable will be overwritten

Returns:

calculate_longitude_latitude_fields()

Geographic coordinates from GridDefinition

grid_l2_parameter()

Compute averages of all l2i parameter for each grid cell. The list of l2i parameter is from the output format definition No averages are computed for grid cells that are tagged with a land flag.

get_parameter_by_name(name, raise_on_error=True)
set_parameter_by_name(name, var)
_init_grid_indices_mask() None

Compute a mask of non-empty grid indices :return:

_init_metadata_from_l2()

Gets metadata from Level-2 instance :return:

_init_parameter_fields(pardefs)

Initialize output parameter fields

_get_attr_source_mission_id(*args)
_get_attr_source_mission_name(*_)
_get_attr_source_timeliness(*args)
_get_attr_grid_id(*args)
_get_attr_grid_spacing_tag(*args)
_get_attr_source_mission_sensor(*args)
_get_attr_source_mission_sensor_fn(*args)

Same as source mission sensor, only a sanitized version for filenames

_get_attr_source_hemisphere(*args)
static _get_attr_uuid(*args)
_get_attr_startdt(dtfmt)
_get_attr_stopdt(dtfmt)
_get_attr_geospatial_lat_min(*_)
_get_attr_geospatial_lat_max(*_)
_get_attr_geospatial_lon_min(*_)
_get_attr_geospatial_lon_max(*_)
static _get_attr_geospatial_str(value)
_get_attr_source_auxdata_sic(*_)
_get_attr_source_auxdata_snow(*_)
_get_attr_source_auxdata_sitype(*_)
_get_attr_utcnow(*args)
_get_attr_l2_time_coverage_start(*args)
_get_attr_l2_time_coverage_end(*args)
_get_attr_time_coverage_start(*args)
_get_attr_time_coverage_end(*args)
_get_attr_time_coverage_duration(*args)
_get_attr_doi(*_)
_get_attr_data_record_type(*args)
static _get_attr_pysiral_version(*args)
flipud()
property metadata
property grid_xi_range
property grid_yj_range
property all_grid_indices
property grid_indices
property dimdict
property grid_shape
property griddef
property l3def
property hemisphere
property time_bounds
class pysiral.l3proc.L3MetaData

Bases: object

Container for L3S Metadata information (see property attribute_list for a list of attributes)

_attribute_list = ['mission_ids', 'start_time', 'stop_time', 'grid_name', 'period_label', 'time_coverage_start',...
get_missions_from_stack(stack)

Get a list of missions that went into the stack (must be a list, since multi-mission grids are supported)

get_data_period_from_stack(stack)

Get the first and last timestamp

get_time_coverage_from_period(period)

Get the start and end of requested data period

get_auxdata_infos(l2i_info)

Get information on auxiliary data sources from l2i global attributes TODO: This part is deprecated :param l2i_info: :return:

get_projection_parameter(griddef)
__repr__()
property attribute_list
property attdict

Return attributes as dictionary (e.g. for netCDF export)

property mission
set_attribute(tag, value)
class pysiral.l3proc.Level3GridDefinition(l3_settings_file)

Bases: pysiral.grid.GridDefinition

This is a variation of GridDefinition with a mandatory link to a griddef yaml file

classmethod from_grid_id(l3_grid_id: str) Level3GridDefinition

Create a Level3GridDefinition from a grid id

class pysiral.l3proc.Level3ProductDefinition(l3_settings_file, grid, output, period)

Bases: pysiral.core.legacy_classes.DefaultLoggingClass

Template for default pysiral class with logging/error handling capabilities

error
_l3_settings_file
_output
_grid
_period
_parse_l3_settings()
validate()
property grid
property outputs
property n_outputs
property l3def
property period
property l3_masks

Return a sorted list of the masks applied to level 3 data

property l3_external_masks
property l3_post_processors
property l2_parameter

Extract a list of paramter names to be extracted from l2i product files

property l3_parameter

Extract a list of paramter names to be computed by the Level-3 processor

class pysiral.l3proc.Level3ProcessorItem(l3grid, **cfg)

Bases: pysiral.core.legacy_classes.DefaultLoggingClass

A parent class for processing items to be selected in the Level-3 processor settings and applied in the Level3Processor

error
l3grid
cfg
_process_dynamic_dependencies()

This method processes dynamic dependencies. Dynamic dependencies are variables that are not always required, but only if certain options are set in a certain way. All processor item classes that are inheriting this class require the property dynamic_variable_dependencies for this method to work. The property should return a list of tuples with (option_name, option_value, variable_name). If the option option_name is set to option_value, the variable variable_name is required in the Level-3 data grid. :return:

_check_variable_dependencies()

Tests if the Level-3 data grid has all required input variables (both in the Level-2 stack as well as in the Level 3 parameters). All processor item classes that are inheriting this class require the properties l3_variable_dependencies & l2_variable_dependencies for this method to work. Both parameter should return a list of variable names. Empty lists should be returned in case of no dependency. :return:

_check_options()

Tests if the all options are given in the Level-3 processor definition files. All processor item classes require the property required_options (list of option names) for this method to work. NOTE: It is in the spirit of pysiral of having all numerical values in one place only that ideally

is not the code itself.

Returns:

_add_l3_variables()

This method initializes the output variables for a given processing item to the l3grid. All processor item classes require the property l3_output_variables for this method to work. The property should return a dict with variable names as keys and the value a dict with fill_value and data type. :return:

property allow_overwrite: bool

If True, existing variables in the l3grid will be overwritten when adding new variables