Exemplo n.º 1
0
def check_regions_fracture(params, prefix):
    """ Checks that the number of regions is each family is correct. Checks that the region index is a known index. 

    Parameters
    -------------
        params : dict
            parameter dictionary
        prefix : string
            either 'e' or 'r' for ellipse or rectangle

    Returns
    ---------
        None

    Notes
    ---------
        Exits program is inconsistencies are found.
    """

    key = prefix + "Region"
    shape = "ellipse" if prefix == 'e' else "rectangle"
    num_families = params['nFamEll']['value'] if prefix == 'e' else params[
        'nFamRect']['value']
    hf.check_none(key, params[key]['value'])
    hf.check_length(key, params[key]['value'], num_families)
    hf.check_values(key, params[key]['value'], 0,
                    params["numOfRegions"]['value'])
Exemplo n.º 2
0
def check_p32_targets(params):
    """ Check the number of polygons if stopCondition is set to 1, else check the p32 target parameters.

    Parameters
    -------------
        params : dict
            parameter dictionary
    Returns
    ---------
        None

    Notes
    ---------
        Exits program is inconsistencies are found.
    """
    # Check P32 inputs for ellipses
    if params['nFamEll']['value'] > 0:
        hf.check_none('e_p32Targets', params['e_p32Targets']['value'])
        hf.check_length('e_p32Targets', params['e_p32Targets']['value'],params['nFamEll']['value'])
        hf.check_values('e_p32Targets',params['e_p32Targets']['value'],0)

    # Check P32 inputs for rectangles
    if params['nFamRect']['value'] > 0:
        hf.check_none('r_p32Targets', params['r_p32Targets']['value'])
        hf.check_length('r_p32Targets', params['r_p32Targets']['value'],params['nFamRect']['value'])
        hf.check_values('r_p32Targets',params['r_p32Targets']['value'],0)
Exemplo n.º 3
0
def check_aspect(params, prefix):
    """ Check the aspect of the rectangle or ellipse families matches the number of families requested and is a positive value


    Parameters
    -------------
        params : dict
            parameter dictionary
        prefix : string
        	either 'e' or 'r' for ellipse or rectangle

    Returns
    ---------
        None

    Notes
    ---------
        Exits program is inconsistencies are found.
    """

    key = prefix + "aspect"
    shape = "ellipse" if prefix == 'e' else "rectangle"
    num_families = params['nFamEll']['value'] if prefix == 'e' else params[
        'nFamRect']['value']
    hf.check_none(key, params[key]['value'])
    hf.check_length(key, params[key]['value'], num_families)
    hf.check_values(key, params[key]['value'], 0)
Exemplo n.º 4
0
def check_constant_dist(params, prefix, shape, cnt):
    """
    Verifies parameters for constant distribution of fractures
    """
    # print(f"checking constant {shape}")
    for i in range(cnt):
        value = params[prefix + "const"]["value"][i]
        hf.check_values(prefix + "const", value, 0)
        hf.check_min_frac_size(params, value)
Exemplo n.º 5
0
def check_aperture(params):
    """ Checks how apertures are being defined. This feature will be removed in the future and apertures will be defined by family.. 

    Parameters
    -------------
        params : dict
            parameter dictionary
    Returns
    ---------
        None

    Notes
    ---------
        Exits program is inconsistencies are found.
    """

    if params['aperture']['value'] == 1:
        hf.check_none('meanAperture', params['meanAperture']['value'])
        hf.check_none('stdAperture', params['stdAperture']['value'])
        hf.check_values('stdAperture', params['stdAperture']['value'], 0)

    elif params['aperture']['value'] == 2:
        hf.check_none('apertureFromTransmissivity',
                      params['apertureFromTransmissivity']['value'])
        hf.check_length('apertureFromTransmissivity',
                        params['apertureFromTransmissivity']['value'], 2)
        if params['apertureFromTransmissivity']['value'][0] == 0:
            hf.print_error(
                "\"apertureFromTransmissivity\"'s first value cannot be 0.")
        if params['apertureFromTransmissivity']['value'][1] == 0:
            hf.print_warning(
                "\"apertureFromTransmissivity\"'s second value is 0, which will result in a constant aperture."
            )

    elif params['aperture']['value'] == 3:
        hf.check_none('constantAperture', params['constantAperture']['value'])
        hf.check_values('constantAperture',
                        params['constantAperture']['value'], 0)

    elif params['aperture']['value'] == 4:
        hf.check_none('lengthCorrelatedAperture',
                      params['lengthCorrelatedAperture']['value'])
        hf.check_length('lengthCorrelatedAperture',
                        params['lengthCorrelatedAperture']['value'], 2)
        if params['lengthCorrelatedAperture']['value'][0] == 0:
            hf.print_error(
                "\"lengthCorrelatedAperture\"'s first value cannot be 0.")
        if params['lengthCorrelatedAperture']['value'][1] == 0:
            hf.print_warning(
                "\"lengthCorrelatedAperture\"'s second value is 0, which will result in a constant aperture."
            )
    else:
        hf.print_error("\"aperture\" must only be option 1 (log-normal), 2 (from transmissivity), "\
              "3 (constant), or 4 (length correlated).")
Exemplo n.º 6
0
def check_lognormal_dist(params, prefix, shape, cnt):
    """
    Verifies all logNormal Parameters for ellipses and Rectangles.

     Parameters
    -------------
        params : dict
            parameter dictionary
        prefix : string
            either 'e' or 'r' for ellipse or rectangle

    Returns
    ---------
        None

    Notes
    ---------
        Exits program is inconsistencies are found.
    """
    #print(f"checking log normal {shape}")
    for i in range(cnt):
        min_val = params[prefix + "LogMin"]["value"][i]
        max_val = params[prefix + "LogMax"]["value"][i]
        mean_val = params[prefix + "LogMean"]["value"][i]
        std_val = params[prefix + "sd"]["value"][i]

        hf.check_values(prefix + "LogMax", min_val, 0)
        hf.check_values(prefix + "LogMin", max_val, 0)
        hf.check_min_max(min_val, max_val, i, f"{shape} log-normal")

        if std_val <= 0:
            hf.print_error(
                f"A standard deviation equal of {std_val} was provided for {shape} log-normal entry {i+1}. Value must be post"
            )

        # Get the mean and variance of the final distribution.
        # Note these are the actual values, not the input variables
        mu = np.exp(mean_val + std_val**2 / 2)
        variance = (np.exp(std_val**2) - 1) * np.exp(2 * mean_val + std_val**2)

        if mu <= min_val:
            hf.print_error(
                f"Requested mean value of final {shape} log-normal {mu} is smaller than minimum value {min_val}. Note that the mean value is determined by {prefix+'LogMean'} and {prefix+'sd'}. See documentation for more details."
            )

        if mu >= max_val:
            hf.print_error(
                f"Requested mean value of {shape} log-normal {mu} is larger than maximum value {max_val}. Note that the mean value is determined by {prefix+'LogMean'} and {prefix+'sd'}. See documentation for more details."
            )

        hf.check_min_frac_size(params, min_val)
Exemplo n.º 7
0
def check_enum_points(params):
    """ Check that the value of enumPoints for each ellipse family is an integer greater than 4

    Parameters
    -------------
        params : dict
            parameter dictionary

    Returns
    ---------
        None

    Notes
    ---------
        Exits program is inconsistencies are found.
    """
    key = 'enumPoints'
    hf.check_none(key, params[key]['value'])
    hf.check_length(key, params[key]['value'], params['nFamEll']['value'])
    hf.check_values(key, params[key]['value'], 4)
Exemplo n.º 8
0
def check_permeability(params):
    """Verify the float used for permeability, if permOption is set to 1

    Parameters
    -------------
        params : dict
            parameter dictionary
    Returns
    ---------
        None

    Notes
    ---------
        Exits program is inconsistencies are found.
    """

    if params['permOption']['value'] == 1:
        hf.check_none('constantPermeability',
                      params['constantPermeability']['value'])
        hf.check_values('constantPermeability',
                        params['constantPermeability']['value'], 0)
Exemplo n.º 9
0
def check_exponential_dist(params, prefix, shape, cnt):
    """
    Verifies parameters for exponential distribution of fractures.
    """
    #print(f"checking exp {shape}")
    for i in range(cnt):
        min_val = params[prefix + "ExpMin"]["value"][i]
        max_val = params[prefix + "ExpMax"]["value"][i]
        mean_val = params[prefix + "ExpMean"]["value"][i]
        hf.check_values(prefix + "min", min_val, 0)
        hf.check_values(prefix + "max", max_val, 0)
        hf.check_values(prefix + "ExpMean", mean_val, 0)

        hf.check_values(prefix + "ExpMean",
                        mean_val,
                        min_val=min_val,
                        max_val=max_val)

        hf.check_min_max(min_val, max_val, i, f"{shape} exponential")
        hf.check_min_frac_size(params, min_val)
Exemplo n.º 10
0
def check_tpl_dist(params, prefix, shape, cnt):
    """
    Verifies parameters for truncated power law distribution of fractures.
    """
    #print(f"checking tpl {shape}")
    for i in range(cnt):
        min_val = params[prefix + "min"]["value"][i]
        max_val = params[prefix + "max"]["value"][i]
        alpha = params[prefix + "alpha"]["value"][i]
        hf.check_values(prefix + "min", min_val, 0)
        hf.check_values(prefix + "max", max_val, 0)
        hf.check_values(prefix + "alpha", alpha, 0)
        hf.check_min_max(min_val, max_val, i, f"{shape} Truncated Power law")
        hf.check_min_frac_size(params, min_val)
Exemplo n.º 11
0
def check_distributions(params, prefix):
    """ 
    Verifies "edistr" and "rdistr" making sure one distribution is defined per family and each distribution is either 1 (log-normal), 2 (Truncated Power Law), 3 (Exponential), or 4 (constant).

     Parameters
    -------------
        params : dict
            parameter dictionary
        prefix : string
            either 'e' or 'r' for ellipse or rectangle

    Returns
    ---------
        None

    Notes
    ---------
        Exits program is inconsistencies are found.
    """

    key = prefix + "distr"
    shape = "ellipse" if prefix == 'e' else "rectangle"
    num_families = params['nFamEll']['value'] if prefix == 'e' else params[
        'nFamRect']['value']
    hf.check_none(key, params[key]['value'])
    hf.check_length(key, params[key]['value'], num_families)
    hf.check_values(key, params[key]['value'], 1, 4)

    #check lengths
    for i in params[key]['value']:
        cnt = params[key]['value'].count(i)
        if i == 1:
            ## logNormal
            dist_keys = [
                prefix + name
                for name in ["LogMean", "sd", "LogMin", "LogMax"]
            ]
            for dist_key in dist_keys:
                hf.check_none(dist_key, params[dist_key]['value'])
                hf.check_length(dist_key, params[dist_key]['value'], cnt)
            check_lognormal_dist(params, prefix, shape, cnt)
        elif i == 2:
            # TPL
            dist_keys = [prefix + name for name in ["min", "max", "alpha"]]
            for dist_key in dist_keys:
                hf.check_none(dist_key, params[dist_key]['value'])
                hf.check_length(dist_key, params[dist_key]['value'], cnt)
            check_tpl_dist(params, prefix, shape, cnt)
        elif i == 3:
            # Exp
            dist_keys = [
                prefix + name for name in ["ExpMean", "ExpMin", "ExpMax"]
            ]
            for dist_key in dist_keys:
                hf.check_none(dist_key, params[dist_key]['value'])
                hf.check_length(dist_key, params[dist_key]['value'], cnt)
            check_exponential_dist(params, prefix, shape, cnt)
        elif i == 4:
            # constant
            dist_keys = [prefix + name for name in ["const"]]
            for dist_key in dist_keys:
                hf.check_none(dist_key, params[dist_key]['value'])
                hf.check_length(dist_key, params[dist_key]['value'], cnt)
            check_constant_dist(params, prefix, shape, cnt)
Exemplo n.º 12
0
def check_orientations(params, prefix):
    """ Checks orientation options. If using trend/plunge, degrees must be used. If using spherical, radians are okay as well. Checks that values are within acceptable ranges. 

    Parameters
    -------------
        params : dict
            parameter dictionary
        prefix : string
            either 'e' or 'r' for ellipse or rectangle

    Returns
    ---------
        None

    Notes
    ---------
        Exits program is inconsistencies are found.
    """
    shape = "ellipse" if prefix == 'e' else "rectangle"
    num_families = params['nFamEll']['value'] if prefix == 'e' else params[
        'nFamRect']['value']
    angle_option_key = prefix + 'AngleOption'

    if params["orientationOption"]["value"] == 0:
        #print("--> Using Spherical Coordinates")
        keys = [prefix + name for name in ["theta", "phi"]]

    elif params["orientationOption"]["value"] == 1:
        #print("--> Using Trend and Plunge")
        # 0 is radians, 1 is degrees
        if params[angle_option_key]['value'] == 0:
            hf.print_error(
                f"Using Trend and Plunge but {prefix + 'AngleOption'} is set to use radians. Trend and plunge must use degrees. Set {prefix + 'AngleOption'} = 1. "
            )
        keys = [prefix + name for name in ["trend", "plunge"]]

    elif params["orientationOption"]["value"] == 2:
        # using dip / strike
        if params[angle_option_key]['value'] == 0:
            hf.print_error(
                f"Using Dip and Strike but {prefix + 'AngleOption'} is set to use radians. Trend and plunge must use degrees. Set {prefix + 'AngleOption'} = 1. "
            )
        keys = [prefix + name for name in ["dip", "strike"]]
    else:
        hf.print_error(f"Unknown orientation option. Value must be 0,1, or 2.")

    for key in keys:
        hf.check_none(key, params[key]['value'])
        hf.check_length(key, params[key]['value'], num_families)
        for i, val in enumerate(params[key]['value']):
            # check radians
            if params[angle_option_key]['value'] == 0:
                if val < 0 or val > 2 * pi:
                    hf.print_error(
                        f"\"{key}\" entry {i+1} has value {val} which is outside of acceptable parameter range [0,2*pi). If you want to use degrees, please use {angle_option_key} = 1. "
                    )
            # check degrees
            else:
                if val < 0 or val > 365:
                    hf.print_error(
                        f"\"{key}\" entry {i+1} has value {val} which is outside of acceptable parameter range [0,365). "
                    )
    #check kappa
    key = prefix + 'kappa'
    hf.check_none(key, params[key]['value'])
    hf.check_length(key, params[key]['value'], num_families)
    hf.check_values(key, params[key]['value'], 0, 100)