pysiral.surface =============== .. py:module:: pysiral.surface .. autoapi-nested-parse:: Created on Mon Jul 27 11:25:04 2015 Classes ------- .. autoapisummary:: pysiral.surface.ClassifierContainer pysiral.surface.SurfaceTypeClassifier pysiral.surface.SICCI2SurfaceType pysiral.surface.ClassifierThresholdSurfaceType pysiral.surface.ClassifierAuxiliarySurfaceType Module Contents --------------- .. py:class:: ClassifierContainer Bases: :py:obj:`object` .. py:attribute:: _parameters .. py:method:: add_parameter(parameter: numpy.ndarray, parameter_name: str) -> None .. py:method:: get(parameter_name: str, raise_on_error: bool = False) -> Union[numpy.ndarray, None] .. py:method:: __getattr__(item) Modify the attribute getter to provide a shortcut to the data content :param item: Name of the parameter :return: .. py:property:: n_parameters :type: int .. py:property:: parameter_list :type: List[str] .. py:property:: shape :type: Union[int, Tuple] .. py:class:: SurfaceTypeClassifier(*args, **kwargs) Bases: :py:obj:`object` This is a parent class that allows to quickly generate surface type classication schemes for the Level-2 processpr .. py:attribute:: surface_type .. py:attribute:: classifier .. py:attribute:: radar_modes .. py:attribute:: _classes :value: [] .. py:method:: set_initial_classification(surface_type: pysiral.core.flags.SurfaceType) -> None This method sets an initial surface type classification :param surface_type: :return: .. py:method:: transfer_l1b_classifier(l1: pysiral.l1data.L1bdataNCFile) -> None A standard functionality to transfer all l1b classifier :param l1: :return: .. py:method:: add_classifier_parameter(l2: pysiral.l2data.Level2Data, parameter_list: List[str]) -> None Retrieve a list of parameters from the l2 and add to the classifier parameter container :param l2: :param parameter_list: :return: .. py:method:: set_unknown_default(n_records: int) -> None This method can be used to initialize the surface type with unknown values :return: .. py:method:: set_l1b_land_mask(l1: pysiral.l1data.L1bdataNCFile) -> None Use this method to transfer the l1 land mask to the l2 surface type classification. NOTE: Highly recommended to do this at the end of the surface type classication in order to overwrite potential mis-classifications. :param l1: :return: .. py:method:: has_class(name: str) -> bool .. py:class:: SICCI2SurfaceType(*args, **kwargs) Bases: :py:obj:`pysiral.l2proc.procsteps.Level2ProcessorStep`, :py:obj:`SurfaceTypeClassifier` new and unified surface type classifier for cryosat2 and envisat based on similar (pulse peakiness, backscatter, leading edge width) #TODO: This could be generalized to automatically compare parameters from config file .. py:attribute:: _classes :value: ['unknown', 'ocean', 'lead', 'sea_ice', 'land'] .. py:method:: execute_procstep(l1b, l2) The mandatory class for a Level2ProcessorStep. :param l1b: :param l2: :return: .. py:method:: classify_ocean(opt, is_radar_mode) Classify ocean waveforms. :param opt: :param is_radar_mode: :return: .. py:method:: classify_leads(opt, month_num, is_radar_mode) Classify leads in sea ice :param opt: :param month_num: :param is_radar_mode: :return: .. py:method:: classify_sea_ice(opt, month_num, is_radar_mode) Classify waveforms as sea ice :param opt: The option attribute dictionary :param month_num: :param is_radar_mode: :return: .. py:method:: get_threshold_value(options, name, month_num) :staticmethod: A unified method to retrieve threshold values from lists (one per month) or a scalar :param options: configuration object :param name: (str) parameter name (must be attribute of) options :param month_num: (int) number of the month (1 - 12) :return: threshold value to use for specific month .. py:property:: l2_input_vars .. py:property:: l2_output_vars .. py:property:: error_bit .. py:class:: ClassifierThresholdSurfaceType(*args, **kwargs) Bases: :py:obj:`pysiral.l2proc.procsteps.Level2ProcessorStep`, :py:obj:`SurfaceTypeClassifier` Simplified surface type classification based on the positive classification of leads and lazy sea ice classifcation (everything that is not a lead, has a decent leading edge and is within the ice mask) .. py:attribute:: reference_date :value: None .. py:method:: execute_procstep(l1: pysiral.l1data.L1bdataNCFile, l2: pysiral.l2data.Level2Data) -> numpy.ndarray The mandatory class for a Level2ProcessorStep. :param l1: :param l2: :return: .. py:method:: _classifiy_surface_types() -> None Classifiy surface types using the options in the l2 configuration file. :return: .. py:method:: _classify_surface_type(opt_dict: dict) -> pysiral.core.flags.ANDCondition Compute the surface type flag from the conditions in the config file for a specific radar mode. The expected structure of `opt_dict` is: [exclude: surface_type_name] (Optional) radar_mode: conditions: - logical expression with parameter name in brackets {} The expression will be evaluated with `eval()` at run time and merged via AND: flag = condition1 AND condition2 AND condition3 .... If the `exclude` option is set, a condition will be added that the the current surface type cannot be any waveform that was previously (see order in `cfg.options.surface_types`) attributed to another surface type. :param opt_dict: :return: .. py:method:: _get_parameter_list() -> List[str] Construct a list of required parameters from the configuration file. This method checks all conditions for parameter name in curly brackets. :return: list of parameters that can be retrieved with `l2.get_parameter_by_name()` .. py:method:: _get_expr_param(expression: str) -> Union[str, None] :staticmethod: Get the parameter from an expression in the config file. E.g. for the expression: `{sea_ice_concentration} >= 15.0` the return value will be `sea_ice_concentration` :param expression: The expression from the config file :return: .. py:property:: l2_input_vars :type: List[str] .. py:property:: l2_output_vars :type: List[str] .. py:property:: error_bit :type: numpy.ndarray .. py:class:: ClassifierAuxiliarySurfaceType(*args, **kwargs) Bases: :py:obj:`pysiral.l2proc.procsteps.Level2ProcessorStep`, :py:obj:`SurfaceTypeClassifier` Surface type classification using a parameter already present in l1p that was read in from auxiliary files during preprocessing .. py:attribute:: reference_date :value: None .. py:attribute:: _classes :value: ['unknown', 'ocean', 'lead', 'sea_ice'] .. py:method:: execute_procstep(l1, l2) -> numpy.ndarray The mandatory class for a Level2ProcessorStep. :param l1: :param l2: :return: .. py:method:: classify_ocean() Classify ocean waveforms. :return: .. py:method:: classify_leads() Classify leads in sea ice :return: .. py:method:: classify_sea_ice() Classify waveforms as sea ice :return: .. py:property:: l2_input_vars :type: List[str] .. py:property:: l2_output_vars :type: List[str] .. py:property:: error_bit :type: numpy.ndarray