nuctransportdb.merge_method =========================== .. py:module:: nuctransportdb.merge_method Attributes ---------- .. autoapisummary:: nuctransportdb.merge_method.dict_sorption_rock_cv nuctransportdb.merge_method.distribution_descriptions Functions --------- .. autoapisummary:: nuctransportdb.merge_method.value_empty_mask nuctransportdb.merge_method.value_invalid_mask nuctransportdb.merge_method.value_pdf_mask nuctransportdb.merge_method.value_uniform_mask nuctransportdb.merge_method.value_truncnorm_mask nuctransportdb.merge_method.value_lognorm_mask nuctransportdb.merge_method.value_PERT_mask nuctransportdb.merge_method.format_number_adaptive nuctransportdb.merge_method.generate_truncnorm nuctransportdb.merge_method.generate_PERT nuctransportdb.merge_method.generate_lognorm nuctransportdb.merge_method.generate_uniform nuctransportdb.merge_method.generate_norm nuctransportdb.merge_method.generate_samples nuctransportdb.merge_method.get_sample_statistics nuctransportdb.merge_method.generate_unit nuctransportdb.merge_method.merge_property_value Module Contents --------------- .. py:function:: value_empty_mask(input_pd_df) Filter data in the input DataFrame that is empty. :param input_pd_df: Input DataFrame. :type input_pd_df: pd.DataFrame :returns: A Boolean series indicating which data is empty. :rtype: pd.Series .. py:function:: value_invalid_mask(input_pd_df) Filter some data in the input DataFrame that contains invalid entries. :param input_pd_df: Input DataFrame. :type input_pd_df: pd.DataFrame :returns: A Boolean Series indicating which data is invalid. :rtype: pd.Series .. py:function:: value_pdf_mask(input_pd_df) Filter some data in the input DataFrame given by a probability distribution. :param input_pd_df: Input DataFrame. :type input_pd_df: pd.DataFrame :returns: A Boolean series indicating which data entries have a corresponding probability distribution. :rtype: pd.Series .. py:function:: value_uniform_mask(input_pd_df) Filter some data in the input DataFrame given by a range. :param input_pd_df: Input DataFrame. :type input_pd_df: pd.DataFrame :returns: A Boolean series indicating which data is uniform. :rtype: pd.Series .. py:function:: value_truncnorm_mask(input_pd_df) Filter some data in the input DataFrame that can be assumed with a truncated normal distribution. :param input_pd_df: Input DataFrame. :type input_pd_df: pd.DataFrame :returns: A Boolean series indicating which data is truncated normal. :rtype: pd.Series .. py:function:: value_lognorm_mask(input_pd_df) Filter some data in the input DataFrame that can be assumed with a log-normal distribution. :param input_pd_df: Input DataFrame. :type input_pd_df: pd.DataFrame :returns: A Boolean series indicating which data is log-normal. :rtype: pd.Series .. py:function:: value_PERT_mask(input_pd_df) Filter some data in the input DataFrame that can be assumed with a PERT distribution. :param input_pd_df: Input DataFrame. :type input_pd_df: pd.DataFrame :returns: A Boolean series indicating which data is PERT. :rtype: pd.Series .. py:function:: format_number_adaptive(number) Format the number adaptively: If the number is smaller than 0.0001, use scientific notation and keep two significant digits. If the number is between 0.001 and 0.1, use three significant digits. Otherwise, round to two decimal places. :param number: The number to format. :type number: float, None, np.nan :returns: The formatted number or None. :rtype: float .. py:function:: generate_truncnorm(value, value_std, value_min, value_max, as_string=False, **kwargs) Generate a truncated normal distribution based on the given parameters. :param value: The mean of the original dataset. :type value: float :param value_std: The standard deviation of the original dataset. :type value_std: float :param value_min: The minimum value of the original dataset. :type value_min: float :param value_max: The maximum value of the original dataset. :type value_max: float :param as_string: If True, return a string representation of the truncated normal distribution. If False, return a frozen distribution object. Default is False. :type as_string: bool :param \*\*kwargs: Extra keyword arguments accepted for compatibility and ignored. :returns: A truncated normal distribution object if `as_string` is False, otherwise a string representation. :rtype: scipy.stats._distn_infrastructure.rv_continuous_frozen | str .. py:function:: generate_PERT(value, value_min, value_max, as_string=False, **kwargs) Generate a PERT distribution based on the given parameters. :param value: The mean of the original dataset. :type value: float :param value_min: The minimum value of the original dataset. :type value_min: float :param value_max: The maximum value of the original dataset. :type value_max: float :param as_string: If True, return a string representation of the PERT distribution. If False, return a beta distribution object. Default is False. :type as_string: bool :param \*\*kwargs: Extra keyword arguments accepted for compatibility and ignored. :returns: A beta distribution object if `as_string` is False, otherwise a string representation. :rtype: scipy.stats._distn_infrastructure.rv_continuous_frozen | str .. py:function:: generate_lognorm(value, value_std, value_min, as_string=False, **kwargs) Generate a log-normal distribution based on the given parameters. :param value: The mean of the original dataset. :type value: float :param value_std: The standard deviation of the original dataset. :type value_std: float :param value_min: Shift the distribution to start from the minimum value. :type value_min: float :param as_string: If True, return a string representation of the log-normal distribution. If False, return a log-normal distribution object. Default is False. :type as_string: bool :param \*\*kwargs: Extra keyword arguments accepted for compatibility and ignored. :returns: A log-normal distribution object if `as_string` is False, otherwise a string representation. :rtype: scipy.stats._distn_infrastructure.rv_continuous_frozen | str .. py:function:: generate_uniform(value_min, value_max, as_string=False, **kwargs) Generate a uniform distribution based on the given parameters. :param value_min: The minimum value of the original dataset. :type value_min: float :param value_max: The maximum value of the original dataset. :type value_max: float :param as_string: If True, return a string representation of the uniform distribution. If False, return a uniform distribution object. Default is False. :type as_string: bool :param \*\*kwargs: Extra keyword arguments accepted for compatibility and ignored. :returns: A uniform distribution object if `as_string` is False, otherwise a string representation. :rtype: scipy.stats._distn_infrastructure.rv_continuous_frozen | str .. py:function:: generate_norm(value, value_std, as_string=False, **kwargs) Generate a normal distribution based on the given parameters. :param value: The mean of the original dataset. :type value: float :param value_std: The standard deviation of the original dataset. :type value_std: float :param as_string: If True, return a string representation of the normal distribution. If False, return a normal distribution object. Default is False. :type as_string: bool :param \*\*kwargs: Extra keyword arguments accepted for compatibility and ignored. :returns: A normal distribution object if `as_string` is False, otherwise a string representation. :rtype: scipy.stats._distn_infrastructure.rv_continuous_frozen | str .. py:data:: dict_sorption_rock_cv .. py:function:: generate_samples(input_df_group, df_pdf_type, random_state=21) Generate samples for a group of input data according to its specified distribution type, including uniform, truncated normal, log-normal, and PERT. :param input_df_group: The input DataFrame containing the data for one specific property and one type of pdf. :type input_df_group: pd.DataFrame :param df_pdf_type: The type of probability distribution function to use. It can be "is_pdf_df", "is_uniform_df", "is_truncnorm_df", "is_lognorm_df", or "is_PERT_df". :type df_pdf_type: str :param random_state: The random state for reproducibility. Defaults to 21. :type random_state: int, optional :raises ValueError: If the distribution type is not recognized. :returns: The generated samples falls within three standard deviations of the mean. :rtype: np.ndarray .. py:function:: get_sample_statistics(input_property_group) This function concatenates samples from different distributions for a group of input data and computes statistical properties (mean, std, min, max). :param input_property_group: DataFrame containing values for one specific property. :type input_property_group: pd.DataFrame :returns: A tuple containing the mean, standard deviation, minimum value, maximum value of the combined samples. The tuple is in the following order: (samples_mean, samples_std, samples_min, samples_max) :rtype: tuple .. py:function:: generate_unit(property_name) Generate a unit string and base for a given property name. :param property_name: The name of the property for which to generate the unit. :type property_name: str :raises TypeError: If the property name is not recognized. :returns: The unit string for the property. list: The unit base for the property. :rtype: str .. py:data:: distribution_descriptions .. py:function:: merge_property_value(input_property, sample_size=1000000, source_type='merged', sampling_functions_by_property=None) Merge property values from multiple datasets into a single DataFrame with combined statistics. The merged results include summary statistics and truncated normal distribution parameters for each property, along with metadata such as description and combined IDs. :param input_property: DataFrame containing property values. :type input_property: pd.DataFrame :param sample_size: The number of samples to generate for each merged dataset. Default is 1000000. :type sample_size: int :param source_type: "merged" or "default". Default is "merged". :type source_type: str :param sampling_functions_by_property: A dictionary mapping property names to desired sampling functions. If provided, the function will use the specified sampling functions for each property instead of the truncnorm. :type sampling_functions_by_property: dict :returns: DataFrame containing merged property values, summary statistics, distribution parameters, and metadata for each property. :rtype: pd.DataFrame