pysiral.retracker.samosa ======================== .. py:module:: pysiral.retracker.samosa Attributes ---------- .. autoapisummary:: pysiral.retracker.samosa.SAMOSA_OK pysiral.retracker.samosa.SAMOSA_DEBUG_MODE Classes ------- .. autoapisummary:: pysiral.retracker.samosa.SAMOSAConstants pysiral.retracker.samosa.SAMOSAFittingOptions pysiral.retracker.samosa.SAMOSALookUpTables pysiral.retracker.samosa.SAMOSARadarSpecs pysiral.retracker.samosa.SAMOSAFitResult pysiral.retracker.samosa.SAMOSAGeoVariables pysiral.retracker.samosa.SAMOSAConfiguration pysiral.retracker.samosa.SAMOSAPlus Functions --------- .. autoapisummary:: pysiral.retracker.samosa.fit_samosa_waveform_model pysiral.retracker.samosa.get_look_angles Module Contents --------------- .. py:data:: SAMOSA_OK :value: True .. py:data:: SAMOSA_DEBUG_MODE :value: False .. py:class:: SAMOSAConstants Physical constants used for the SAMOSA+ Waveform model .. py:attribute:: c0 :type: float :value: 299792458.0 .. py:attribute:: R_e :type: float :value: 6378137.0 .. py:attribute:: f_e :type: float :value: 0.0033528106647474805 .. py:attribute:: gamma_3_4 :type: float :value: 1.2254167024651779 .. py:class:: SAMOSAFittingOptions Settings for the waveform model fitting (scipy.optimize) .. py:attribute:: method :type: str :value: 'trf' .. py:attribute:: ftol :type: float :value: 0.01 .. py:attribute:: gtol :type: float :value: 0.01 .. py:attribute:: xtol :type: float :value: 0.002 .. py:attribute:: diff_step :type: Any :value: None .. py:attribute:: max_nfev :type: Any :value: None .. py:attribute:: loss :type: str :value: 'linear' .. py:class:: SAMOSALookUpTables Links to the lookup-table filenames in the samosa package .. py:attribute:: F0 :type: str :value: 'LUT_F0.txt' .. py:attribute:: F1 :type: str :value: 'LUT_F1.txt' .. py:attribute:: alphap_noweight :type: str :value: 'alphap_table_DX3000_ZP20_SWH20_10_Sept_2019(CS2_NOHAMMING).txt' .. py:attribute:: alphap_weight :type: str :value: 'alphap_table_DX3000_ZP20_SWH20_10_Sept_2019(CS2_HAMMING).txt' .. py:attribute:: alphapower_noweight :type: str :value: 'alphaPower_table_CONSTANT_SWH20_10_Feb_2020(CS2_NOHAMMING).txt' .. py:attribute:: alphapower_weight :type: str :value: 'alphaPower_table_CONSTANT_SWH20_10_Feb_2020(CS2_NOHAMMING).txt' .. py:class:: SAMOSARadarSpecs(Np_burst: int = None, Npulse: int = None, PRF_SAR: float = None, BRI: float = None, f_0: float = None, Bs: float = None, theta_3x: float = None, theta_3y: float = None, G_0: float = None, bias_sigma0: float = None) Radar altimeter specifications needed for the SAMOSA(+) Retracker .. py:attribute:: Np_burst :value: None .. py:attribute:: Npulse :value: None .. py:attribute:: PRF_SAR :value: None .. py:attribute:: BRI :value: None .. py:attribute:: f_0 :value: None .. py:attribute:: Bs :value: None .. py:attribute:: theta_3x :value: None .. py:attribute:: theta_3y :value: None .. py:attribute:: G_0 :value: None .. py:attribute:: bias_sigma0 :value: None .. py:method:: from_preset(preset: str) -> SAMOSARadarSpecs :classmethod: Sets the radar altimeter specifications for the given presets :param preset: The name of the preset of type {platform}_{sensor}_{mode} :raise ValueError: Invalid preset :return: Initialized SAMOSARadarSpecs instance .. py:class:: SAMOSAFitResult Container for output of the SAMOSA+ retracker .. py:attribute:: tau :type: numpy.ndarray .. py:attribute:: wf :type: numpy.ndarray .. py:attribute:: wf_model :type: numpy.ndarray .. py:attribute:: epoch_sec :type: float .. py:attribute:: rng :type: float .. py:attribute:: nu :type: float .. py:attribute:: swh :type: float .. py:attribute:: Pu :type: float .. py:attribute:: misfit :type: float .. py:attribute:: oceanlike_flag :type: bool .. py:attribute:: sigma0 :type: float .. py:attribute:: pval :type: float .. py:attribute:: cval :type: float .. py:attribute:: rval :type: float .. py:attribute:: kval :type: float .. py:method:: debug_plot() .. py:class:: SAMOSAGeoVariables(lat: float, lon: float, height: float, vs: float, hrate: float, pitch: float, roll: float, nu: float, track_sign: int, thn: float) Bases: :py:obj:`object` .. py:attribute:: LAT .. py:attribute:: LON .. py:attribute:: Height .. py:attribute:: Vs .. py:attribute:: Hrate .. py:attribute:: Pitch .. py:attribute:: Roll .. py:attribute:: nu .. py:attribute:: track_sign .. py:attribute:: ThN .. py:method:: from_l1(l1b, vel, hrate, ThNEcho, index) -> SAMOSAGeoVariables :classmethod: :param l1b: :param vel: :param ThNEcho: :param index: :return: .. py:class:: SAMOSAConfiguration(cst: SAMOSAConstants, rdb: SAMOSARadarSpecs, flag_slope: bool = False, beamsamp_factor: int = 1, wf_weighted: bool = True, N_Look_min: int = -90, N_Look_max: int = 90, guess_swh: float = 2.0, guess_pu: float = 1.0, guess_nu: float = 2.0, lb_epoch: float = None, lb_swh: float = -0.5, lb_pu: float = 0.2, lb_nu: float = 0.0, ub_epoch: float = None, ub_swh: float = 30.0, ub_pu: float = 1.5, ub_nu: float = 1000000000.0, rtk_type: str = 'samosa+', wght_factor: float = 1.4705) Bases: :py:obj:`object` Configuration settings for the SAMOSA+ retracker .. py:attribute:: flag_slope :value: False .. py:attribute:: beamsamp_factor :value: 1 .. py:attribute:: wf_weighted :value: True .. py:attribute:: N_Look_min :value: -90 .. py:attribute:: N_Look_max :value: 90 .. py:attribute:: guess_swh :value: 2.0 .. py:attribute:: guess_pu :value: 1.0 .. py:attribute:: guess_nu :value: 2.0 .. py:attribute:: lb_epoch :value: None .. py:attribute:: lb_swh :value: -0.5 .. py:attribute:: lb_pu :value: 0.2 .. py:attribute:: lb_nu :value: 0.0 .. py:attribute:: ub_epoch :value: None .. py:attribute:: ub_swh :value: 30.0 .. py:attribute:: ub_pu :value: 1.5 .. py:attribute:: ub_nu :value: 1000000000.0 .. py:attribute:: rtk_type :value: 'samosa+' .. py:attribute:: wght_factor :value: 1.4705 .. py:attribute:: Lz .. py:class:: SAMOSAPlus Bases: :py:obj:`pysiral.retracker.BaseRetracker` Interface to the SAMOSA+ retracker by CLS. Retracker must be installed as a package into the environment for this class to be used. .. py:attribute:: _retracker_params .. py:method:: create_retracker_properties(n_records: int) -> None Initialize retracker properties with correct arrays shapes (shape = (n_records, )). The list of parameters depends on whether the SAMOSA_DEBUG_MODE flag is set. NOTE: The properties are set to an array, but can be accessed as `self.{property_name}` via the __getattr__ method. :param n_records: .. py:method:: l2_retrack(rng, wfm, indices, radar_mode, is_valid) -> None API method for the retracker interface in the Level-2 processor. :param rng: The range per waveform samples for all waveforms in the Level-1 data object :param wfm: All waveforms in the Level-1 data object :param indices: List of waveforms for the retracker :param radar_mode: Flag indicating the radar mode for all waveforms :param is_valid: Error flag for all waveforms :return: None (Output is added to the instance) .. py:method:: _store_retracker_properties(fit_results, indices) -> None Store the output of the SAMOSA+ retracker in the class. :param fit_results: :param indices: :return: .. py:method:: _set_range_bias(radar_mode) -> None Set range bias bases on radar mode (from config file) :param radar_mode: :return: .. py:method:: _set_range_uncertainty() -> None Estimate the uncertainty of the SAMOSA+ retracker result. At the moment there is no other implementation than using a fixed uncertainty value from the Level-2 processor definition file. .. py:method:: _register_auxiliary_variables() -> None Add auxiliary variables to the L2 data object. The specific variables depend on surface type. .. py:method:: _samosa_plus_retracker(rng, wfm, indices, radar_mode) -> List[SAMOSAFitResult] Run the SAMOSA+ retracker for a set of waveforms. NOTE: The entire data structure will likely change. :param rng: :param wfm: :param indices: :param radar_mode: :return: .. py:method:: _get_samosa_dataclasses() -> Tuple[SAMOSAConstants, SAMOSAFittingOptions, SAMOSARadarSpecs, SAMOSAConfiguration, SAMOSALookUpTables] Get the data classes requires for the SAMOSA retracker :return: .. py:method:: _compute_thermal_noise(wfm: numpy.typing.NDArray, wf_zp: int, n_start_noise: int = 2, n_end_noise: int = 6) -> float :staticmethod: Compute thermal noise for all waveforms with samosa/sampy package from the early range gated in the range window. :param wfm: waveform power :param wf_zp: zero padding waveform oversampling factor :param n_start_noise: noise range gate counting from 1, no oversampling :param n_end_noise: noise range gate counting from 1, no oversampling :return: Thermal noise as computed by the `sampy` package .. py:method:: _get_normalized_waveform(wfm: numpy.typing.NDArray) -> numpy.typing.NDArray :staticmethod: The samosa/SAMPy package expecte waveforms with 16bit scaling. Scale any waveform to this range. :param wfm: :return: .. py:method:: _get_range_array(wfm, rdb: SAMOSARadarSpecs, cst: SAMOSAConstants) -> Tuple[numpy.typing.NDArray, numpy.typing.NDArray, numpy.typing.NDArray, float] .. py:method:: _get_altitude_velocity_from_l1() -> Tuple[numpy.typing.NDArray, numpy.typing.NDArray] Get altitude (height) rate and satellite velocity from l1 data :return: .. py:method:: _samosa_debug_output() -> None Write a netCDF file with debugging parameters :return: .. py:method:: _filter_results() -> None Nothing here yet. :return: .. py:method:: __getattr__(item: str) -> Any Direct attribute access to the retracker properties dictionary :param item: parameter name :raise AttributeError: item not in self._retracker_params (see self.create_retracker_properties) :return: .. py:function:: fit_samosa_waveform_model(index, samlib, l1b, wfm, tau, window_del_20_hr_ku_deuso, vel, hrate, ThNEcho, CONF, epoch0, MaskRanges, raw_range, CST, RDB) Fitting procedure for one waveform as function :param index: :param samlib: :param wfm: :param tau: :param window_del_20_hr_ku_deuso: :param vel: :param hrate: :param ThNEcho: :param CONF: :param epoch0: :param MaskRanges: :param raw_range: :param CST: :param RDB: :return: .. py:function:: get_look_angles(l1b: pysiral.l1data.L1bdataNCFile, index: int) -> numpy.typing.NDArray Compute the lookangles based on l1b stack information # TODO: This functions raises a ValueError for NaN values in the classifiers (LRM?) :param l1b: The level 1 data object :param index: Waveform index :return: