def plume(distribution_type='droplet_size', distribution='weibull', windage_range=(.01, .04), windage_persist=900, substance_name=None, density=None, density_units='kg/m^3', **kwargs): """ Helper function returns an ElementType object containing 'rise_vel' and 'windages' initializer with user specified parameters for distribution. See below docs for details on the parameters. NOTE: substance_name or density must be provided :param str distribution_type: default 'droplet_size' available options: 1. 'droplet_size': Droplet size is samples from the specified distribution. Rise velocity is calculated. 2.'rise_velocity': rise velocity is directly sampled from the specified distribution. No droplet size is computed. :param distribution='weibull': :param windage_range=(.01, .04): :param windage_persist=900: :param substance_name='oil_conservative': :param float density = None: :param str density_units='kg/m^3': """ if density is not None: # Assume density is at 15 K - convert density to api api = uc.convert('density', density_units, 'API', density) if substance_name is not None: substance = build_oil_props({'name':substance_name, 'api': api}, 2) else: substance = build_oil_props({'api': api}, 2) elif substance_name is not None: # model 2 cuts if fake oil substance = get_oil_props(substance_name, 2) else: ex = ValueError() ex.message = ("plume substance density and/or name must be provided") raise ex if distribution_type == 'droplet_size': return ElementType([InitRiseVelFromDropletSizeFromDist( distribution=distribution, **kwargs), InitWindages(windage_range, windage_persist)], substance) elif distribution_type == 'rise_velocity': return ElementType([InitRiseVelFromDist(distribution=distribution, **kwargs), InitWindages(windage_range, windage_persist)], substance)
def plume(distribution_type='droplet_size', distribution=None, windage_range=(.01, .04), windage_persist=900, substance_name=None, density=None, density_units='kg/m^3', **kwargs): """ Helper function returns an ElementType object containing 'rise_vel' and 'windages' initialized with user specified parameters for distribution. :param str distribution_type: default is 'droplet_size' available options: * 'droplet_size': Droplet size is samples from the specified distribution. Rise velocity is calculated. * 'rise_velocity': rise velocity is directly sampled from the specified distribution. No droplet size is computed. :param distribution=None: An object capable of generating a probability distribution. :type gnome.utilities.distributions: Right now, we have: * UniformDistribution * NormalDistribution * LogNormalDistribution * WeibullDistribution New distribution classes could be made. The only requirement is they need to have a set_values() method which accepts a NumPy array. (presumably, this function will also modify the array in some way) :param windage_range=(.01, .04): :param windage_persist=900: # :param substance_name='oil_conservative': :param substance_name=None: :param float density = None: :param str density_units='kg/m^3': .. note:: substance_name or density must be provided """ # Add docstring from called classes # Note: following gives sphinx warnings on build, ignore for now. plume.__doc__ += ("\nDocumentation of InitRiseVelFromDropletSizeFromDist:\n" + InitRiseVelFromDropletSizeFromDist.__init__.__doc__ + "\nDocumentation of InitRiseVelFromDist:\n" + InitRiseVelFromDist.__init__.__doc__ + "\nDocumentation of InitWindages:\n" + InitWindages.__init__.__doc__ ) if density is not None: # Assume density is at 15 K - convert density to api api = uc.convert('density', density_units, 'API', density) if substance_name is not None: substance = build_oil_props({'name':substance_name, 'api': api}, 2) else: substance = build_oil_props({'api': api}, 2) elif substance_name is not None: # model 2 cuts if fake oil substance = get_oil_props(substance_name, 2) else: raise ValueError("plume substance density and/or name must be provided") if distribution_type == 'droplet_size': return ElementType([InitRiseVelFromDropletSizeFromDist( distribution=distribution, **kwargs), InitWindages(windage_range, windage_persist)], substance) elif distribution_type == 'rise_velocity': return ElementType([InitRiseVelFromDist(distribution=distribution, **kwargs), InitWindages(windage_range, windage_persist)], substance) else: raise TypeError('distribution_type must be either droplet_size or rise_velocity')
def plume(distribution_type='droplet_size', distribution='weibull', windage_range=(.01, .04), windage_persist=900, substance_name=None, density=None, density_units='kg/m^3', **kwargs): """ Helper function returns an ElementType object containing 'rise_vel' and 'windages' initializer with user specified parameters for distribution. See below docs for details on the parameters. NOTE: substance_name or density must be provided :param str distribution_type: default 'droplet_size' available options: 1. 'droplet_size': Droplet size is samples from the specified distribution. Rise velocity is calculated. 2.'rise_velocity': rise velocity is directly sampled from the specified distribution. No droplet size is computed. :param distribution='weibull': :param windage_range=(.01, .04): :param windage_persist=900: :param substance_name='oil_conservative': :param float density = None: :param str density_units='kg/m^3': """ if density is not None: # Assume density is at 15 K - convert density to api api = uc.convert('density', density_units, 'API', density) if substance_name is not None: substance = build_oil_props({ 'name': substance_name, 'api': api }, 2) else: substance = build_oil_props({'api': api}, 2) elif substance_name is not None: # model 2 cuts if fake oil substance = get_oil_props(substance_name, 2) else: ex = ValueError() ex.message = ("plume substance density and/or name must be provided") raise ex if distribution_type == 'droplet_size': return ElementType([ InitRiseVelFromDropletSizeFromDist(distribution=distribution, **kwargs), InitWindages(windage_range, windage_persist) ], substance) elif distribution_type == 'rise_velocity': return ElementType([ InitRiseVelFromDist(distribution=distribution, **kwargs), InitWindages(windage_range, windage_persist) ], substance)