:py:mod:`gnome.spills` ====================== .. py:module:: gnome.spills Subpackages ----------- .. toctree:: :titlesonly: :maxdepth: 3 sample_oils/index.rst Submodules ---------- .. toctree:: :titlesonly: :maxdepth: 1 gnome_oil/index.rst initializers/index.rst le/index.rst release/index.rst spill/index.rst substance/index.rst Package Contents ---------------- Classes ~~~~~~~ .. autoapisummary:: gnome.spills.Spill gnome.spills.Release gnome.spills.PointLineRelease gnome.spills.PolygonRelease gnome.spills.VerticalPlumeRelease gnome.spills.InitElemsFromFile gnome.spills.NonWeatheringSubstance gnome.spills.GnomeOil gnome.spills.LEData Functions ~~~~~~~~~ .. autoapisummary:: gnome.spills.surface_point_line_spill gnome.spills.subsurface_spill gnome.spills.grid_spill gnome.spills.spatial_release_spill gnome.spills.polygon_release_spill gnome.spills.GridRelease .. py:class:: Spill(on=True, num_elements=1000, amount=0, units='kg', substance=None, release=None, water=None, amount_uncertainty_scale=0.0, **kwargs) Bases: :py:obj:`BaseSpill` Models a spill by combining Release and Substance objects Spills used by the gnome model. It contains a release object, which releases elements. It also contains a Substance which contains the type of substance spilled and it initializes data arrays to non-default values (non-zero). :param release: an object defining how elements are to be released :type release: derived from :class:`~gnome.spills.release.Release` :param substance: an object defining the substance of this spill. Defaults to :class:`~gnome.spills.substance.NonWeatheringSubstance` :type substance: derived from :class:`~gnome.spills.substance.Substance` **Optional parameters (kwargs):** :param name: Human-usable Name of this spill :type name: str :param on=True: Toggles the spill on/off. :type on: bool :param amount=None: mass or volume of oil spilled. :type amount: double (volume or mass) :param units=None: must provide units for amount spilled. :type units: str :param amount_uncertainty_scale=0.0: scale value in range 0-1 that adds uncertainty to the spill amount. Maximum uncertainty scale is (2/3) * spill_amount. :type amount_uncertainty_scale: float .. note:: Define either volume or mass in 'amount' attribute and provide appropriate 'units'. .. py:property:: all_array_types Need to add array types from Release and Substance .. py:property:: substance .. py:property:: release_time .. py:property:: end_release_time .. py:property:: release_duration .. py:property:: num_elements .. py:property:: start_position .. py:property:: end_position .. py:property:: amount .. py:property:: units Default units in which amount of oil spilled was entered by user. The 'amount' property is returned in these 'units' .. py:attribute:: _schema .. py:attribute:: valid_vol_units .. py:attribute:: valid_mass_units .. py:method:: __repr__() Return repr(self). .. py:method:: _check_units(units) Checks the user provided units are in list of valid volume or mass units .. py:method:: get_mass() Return the total mass released during the spill. .. py:method:: uncertain_copy() Returns a deepcopy of this spill for the uncertainty runs The copy has everything the same, including the spill_num, but it is a new object with a new id. Not much to this method, but it could be overridden to do something fancier in the future or a subclass. There are a number of python objects that cannot be deepcopied. - Logger objects So we copy them temporarily to local variables before we deepcopy our Spill object. .. py:method:: set_amount_uncertainty(up_or_down=None) This function shifts the spill amount based on a scale value in the range [0.0 ... 1.0]. The maximum uncertainty scale value is (2/3) * spill_amount. We determine either an upper uncertainty or a lower uncertainty multiplier. Then we shift our spill amount value based on it. Since we are irreversibly changing the spill amount value, we should probably do this only once. .. py:method:: rewind() rewinds the release to original status (before anything has been released). .. py:method:: prepare_for_model_run(timestep) array_types comes from all the other objects above in the model such as movers, weatherers, etc. The ones from the substance still need to be added .. py:method:: release_elements(sc, start_time, end_time, environment=None) Releases and partially initializes new LEs Note: this will have to be updated if we allow backwards runs for continuous spills .. py:method:: num_elements_to_release(current_time, time_step) Determines the number of elements to be released during: current_time + time_step It invokes the num_elements_to_release method for the the underlying release object: self.release.num_elements_to_release() :param current_time: current time :type current_time: datetime.datetime :param int time_step: the time step, sometimes used to decide how many should get released. :returns: the number of elements that will be released. This is taken by SpillContainer to initialize all data_arrays. .. py:method:: _attach_default_refs(ref_dict) !!!IMPORTANT!!! If this object requires default references (self._req_refs exists), this function will use the name of the references as keys into a reference dictionary to get a list of satisfactory references (objects that have obj._ref_as == self._req_refs). It will then attach the first object in the reference list to that attribute on this object. This behavior can be overridden if the object needs more specific attachment behavior than simply 'first in line' In addition, this function SHOULD BE EXTENDED if this object should provide default references to any contained child objects. When doing so, please be careful to respect already existing references. The reference attachment system should only act if the requested reference 'is None' when the function is invoked. See Model._attach_default_refs() for an example. .. py:function:: surface_point_line_spill(num_elements, start_position, release_time, end_position=None, end_release_time=None, substance=None, amount=0, units='kg', water=None, on=True, windage_range=None, windage_persist=None, name='Surface Point or Line Release') Helper function returns a Spill object :param num_elements: total number of elements to be released :type num_elements: integer :param start_position: initial location the elements are released :type start_position: 2-tuple of floats (long, lat) :param release_time: time the LEs are released (datetime object) :type release_time: datetime.datetime :param end_position=None: Optional. For moving source, the end position If None, then release is from a point source :type end_position: 2-tuple of floats (long, lat) :param end_release_time=None: optional -- for a time varying release, the end release time. If None, then release is instantaneous :type end_release_time: datetime.datetime :param substance=None: Type of oil spilled. :type substance: Substance object :param amount=None: mass or volume of oil spilled :type amount: float :param units=None: units for amount spilled :type units: str :param tuple windage_range=(.01, .04): Percentage range for windage. Active only for surface particles when a mind mover is added :type windage_range: tuple :param windage_persist=900: Persistence for windage values in seconds. Use -1 for inifinite, otherwise it is randomly reset on this time scale :type windage_persist: int :param name='Surface Point/Line Spill': a name for the spill :type name: str .. py:function:: subsurface_spill(num_elements, start_position, release_time, distribution, distribution_type='droplet_size', end_release_time=None, substance=None, amount=0, units='kg', water=None, on=True, windage_range=None, windage_persist=None, name='Subsurface plume') Helper function returns a Spill object :param num_elements: total number of elements to be released :type num_elements: integer :param start_position: initial location the elements are released :type start_position: 3-tuple of floats (long, lat, z) :param release_time: time the LEs are released (datetime object) :type release_time: datetime.datetime :param distribution=None: An object capable of generating a probability distribution. Right now, we have: * UniformDistribution * NormalDistribution * LogNormalDistribution * WeibullDistribution :type distribution: gnome.utilities.distribution :param str distribution_type=droplet_size: What is being sampled from the distribution. Options are: * droplet_size - Rise velocity is then calculated * rise_velocity - No droplet size is computed :param end_release_time=None: End release time for a time varying release. If None, then release is instantaneous :type end_release_time: datetime.datetime :param substance=None: Required unless density specified. Type of oil spilled. :type substance: GnomeOil :param float density=None: Required unless substance specified. Density of spilled material. :param str density_units='kg/m^3': :param float amount=None: mass or volume of oil spilled. :param str units=None: must provide units for amount spilled. :param tuple windage_range=(.01, .04): Percentage range for windage. Active only for surface particles when a mind mover is added :param windage_persist=900: Persistence for windage values in seconds. Use -1 for inifinite, otherwise it is randomly reset on this time scale. :param str name='Subsurface Release': a name for the spill. .. py:function:: grid_spill(bounds, resolution, release_time, substance=None, amount=1.0, units='kg', on=True, water=None, windage_range=None, windage_persist=None, name='Surface Grid Spill') Helper function returns a Grid Spill object :param bounds: bounding box of region you want the elements in: ((min_lon, min_lat), (max_lon, max_lat)) :type bounds: 2x2 numpy array or equivalent :param resolution: resolution of grid -- it will be a resoluiton X resolution grid :type resolution: integer :param substance=None: Type of oil spilled. :type substance: str or OilProps :param float amount=None: mass or volume of oil spilled :param str units=None: units for amount spilled :param release_time: time the LEs are released (datetime object) :type release_time: datetime.datetime :param tuple windage_range=(.01, .04): Percentage range for windage. Active only for surface particles when a mind mover is added :param int windage_persist=900: Persistence for windage values in seconds. Use -1 for inifinite, otherwise it is randomly reset on this time scale :param str name='Surface Point/Line Release': a name for the spill .. py:function:: spatial_release_spill(start_positions, release_time, substance=None, water=None, on=True, amount=0, units='kg', windage_range=None, windage_persist=None, name='spatial_release') Helper function returns a Spill object containing a spatial release A spatial release is a spill that releases elements at known locations. .. py:function:: polygon_release_spill(filename, release_time=None, substance=None, water=None, on=True, amount=0, units='kg', windage_range=None, windage_persist=None, name='spatial_release') Helper function returns a Spill object containing a polygon release A polygon release is a spill that releases elements randomly within polygons in a shapefile. .. py:class:: Release(release_time=None, num_elements=None, num_per_timestep=None, end_release_time=None, custom_positions=None, release_mass=0, retain_initial_positions=False, **kwargs) Bases: :py:obj:`gnome.gnomeobject.GnomeId` base class for Release classes. It contains interface for Release objects Required Arguments: :param release_time: time the LEs are released :type release_time: datetime.datetime or iso string. :param custom_positions: initial location(s) the elements are released :type custom_positions: iterable of (lon, lat, z) Optional arguments: .. note:: Either num_elements or num_per_timestep must be given. If both are None, then it defaults to num_elements=1000. If both are given a TypeError is raised because user can only specify one or the other, not both. :param num_elements: total number of elements to be released :type num_elements: integer default 1000 :param num_per_timestep: fixed number of LEs released at each timestep :type num_elements: integer :param end_release_time=None: optional -- for a time varying release, the end release time. If None, then release is instantaneous :type end_release_time: datetime.datetime :param release_mass=0: optional. This is the mass released in kilograms. :type release_mass: integer :param retain_initial_positions: Optional. If True, each LE will retain information about it's originally released position :type retain_initial_positions: boolean .. py:property:: centroid .. py:property:: release_mass .. py:property:: num_per_timestep .. py:property:: num_elements .. py:property:: release_duration duration over which particles are released in seconds .. py:property:: end_release_time .. py:attribute:: _schema .. py:method:: __repr__() Return repr(self). .. py:method:: rewind() .. py:method:: LE_timestep_ratio(ts) Returns the ratio .. py:method:: maximum_mass_error(ts) This function returns the maximum error in mass present in the model at any given time. In theory, this should be the mass of 1 LE .. py:method:: get_num_release_time_steps(ts) calculates how many time steps it takes to complete the release duration .. py:method:: generate_release_timeseries(num_ts, max_release, ts) Release timeseries describe release behavior as a function of time. _release_ts describes the number of LEs that should exist at time T PolygonRelease does not have a _pos_ts because it uses start_positions only All use TimeseriesData objects. .. py:method:: num_elements_after_time(current_time) Returns the number of elements expected to exist at current_time. Returns 0 if prepare_for_model_run has not been called. :param current_time: time of release :type current_time: datetime .. py:method:: prepare_for_model_run(ts) :param ts: timestep as integer seconds .. py:method:: initialize_LEs(to_rel, sc, start_time, end_time) set positions for new elements added by the SpillContainer .. note:: this releases all the elements at their initial positions at the end_time .. py:method:: initialize_LEs_post_substance(to_rel, sc, start_time, end_time, environment) .. py:class:: PointLineRelease(release_time=None, start_position=None, num_elements=None, num_per_timestep=None, end_release_time=None, end_position=None, release_mass=0, **kwargs) Bases: :py:obj:`Release` The primary spill source class -- a release of floating non-weathering particles, can be instantaneous or continuous, and be released at a single point, or over a line. Required Arguments: :param release_time: time the LEs are released (datetime object) :type release_time: datetime.datetime :param start_position: initial location the elements are released :type start_position: 3-tuple of floats (long, lat, z) Optional arguments: .. note:: Either num_elements or num_per_timestep must be given. If both are None, then it defaults to num_elements=1000. If both are given a TypeError is raised because user can only specify one or the other, not both. :param num_elements: total number of elements to be released :type num_elements: integer :param num_per_timestep: fixed number of LEs released at each timestep :type num_elements: integer :param end_release_time=None: optional -- for a time varying release, the end release time. If None, then release is instantaneous :type end_release_time: datetime.datetime :param end_position=None: optional. For moving source, the end position If None, then release from a point source :type end_position: 3-tuple of floats (long, lat, z) :param release_mass=0: optional. This is the mass released in kilograms. :type release_mass: integer .. py:property:: is_pointsource if end_position - start_position == 0, point source otherwise it is a line source :returns: True if point source, false otherwise .. py:property:: centroid .. py:property:: start_position .. py:property:: end_position .. py:attribute:: _schema .. py:method:: __repr__() Return repr(self). .. py:method:: generate_release_timeseries(num_ts, max_release, ts) Release timeseries describe release behavior as a function of time. _release_ts describes the number of LEs that should exist at time T _pos_ts describes the spill position at time T All use TimeseriesData objects. .. py:method:: rewind() .. py:method:: prepare_for_model_run(ts) :param ts: timestep as integer seconds .. py:method:: initialize_LEs(to_rel, sc, start_time, end_time) Initializes the mass and position for to_rel new LEs. :param data: spill container with data arrays :param to_rel: number of elements to initialize :param start_time: initial time of release :param end_time: final time of release .. py:method:: initialize_LEs_post_substance(to_rel, sc, start_time, end_time, environment) .. py:class:: PolygonRelease(filename=None, features=None, polygons=None, weights=None, thicknesses=None, **kwargs) Bases: :py:obj:`Release` A release of elements into a set of provided polygons. When X particles are determined to be released, they are into the polygons randomly. For each LE, pick a polygon, weighted by it's proportional area and place the LE randomly within it. By default the PolygonRelease uses simple area for polygon weighting. Other classes (NESDISRelease for example) may use other weighting functions. Required Arguments: :param release_time: time the LEs are released (datetime object) :type release_time: datetime.datetime :param polygons: polygons to use in this release :type polygons: list of shapely.Polygon or shapely.MultiPolygon. Optional arguments: :param filename: (optional) shapefile :type filename: string name of a zip file. Polygons loaded are concatenated after polygons from kwarg :param weights: (optional) LE placement probability weighting for each polygon. Must be the same length as the polygons kwarg, and must sum to 1. If None, weights are generated at runtime based on area proportion. :param num_elements: total number of elements to be released :type num_elements: integer default 1000 :param num_per_timestep: fixed number of LEs released at each timestep :type num_elements: integer :param end_release_time=None: optional -- for a time varying release, the end release time. If None, then release is instantaneous :type end_release_time: datetime.datetime :param release_mass=0: optional. This is the mass released in kilograms. :type release_mass: integer .. py:property:: filename .. py:property:: centroid .. py:property:: __geo_interface__ .. py:property:: features .. py:property:: polygons .. py:property:: thicknesses .. py:property:: weights .. py:property:: areas .. py:attribute:: _schema .. py:method:: gen_fc_from_kwargs(kwargs) .. py:method:: rewind() .. py:method:: get_polys_as_tris(polys, weights=None) .. py:method:: compute_distribution() .. py:method:: prepare_for_model_run(ts) :param ts: timestep as integer seconds .. py:method:: initialize_LEs(to_rel, data, start_time, end_time) set positions for new elements added by the SpillContainer .. note:: this releases all the elements at their initial positions at the end_time .. py:method:: get_polygons() Returns an array of lengths, and a list of line arrays. The first array sequentially indexes the second array. When the second array is split up using the first array and the resulting lines are drawn, you should end up with a picture of the polygons. .. py:method:: get_metadata() .. py:method:: new_from_dict(dict_) :classmethod: creates a new object from dictionary This is base implementation and can be over-ridden by classes using this mixin .. py:function:: GridRelease(release_time, bounds, resolution) Utility function that creates a release with a grid of elements. Only 2-d for now :param bounds: bounding box of region you want the elements in: ((min_lon, min_lat), (max_lon, max_lat)) :type bounds: 2x2 numpy array or equivalent :param resolution: resolution of grid -- it will be a resolution X resolution grid :type resolution: integer .. py:class:: VerticalPlumeRelease(release_time=None, start_position=None, plume_data=None, end_release_time=None, **kwargs) Bases: :py:obj:`Release` An Underwater Plume spill class -- a continuous release of particles, controlled by a contained spill generator object. - plume model generator will have an iteration method. This will provide flexible looping and list comprehension behavior. :param num_elements: total number of elements to be released :type num_elements: integer :param start_position: initial location the elements are released :type start_position: 3-tuple of floats (long, lat, z) :param release_time: time the LEs are released :type release_time: datetime.datetime :param start_positions: locations the LEs are released :type start_positions: (num_elements, 3) numpy array of float64 -- (long, lat, z) .. py:method:: _plume_elem_coords(current_time, time_step) Return a list of positions for all elements released within current_time + time_step .. py:method:: num_elements_to_release(current_time, time_step) Return number of particles released in current_time + time_step .. py:method:: set_newparticle_positions(num_new_particles, current_time, time_step, data_arrays) Set positions for new elements added by the SpillContainer .. py:class:: InitElemsFromFile(filename, release_time=None, index=None, time=None) Bases: :py:obj:`Release` release object that sets the initial state of particles from a previously output NetCDF file Take a NetCDF file, which is an output of PyGnome's outputter: NetCDFOutput, and use these dataarrays as initial condition for the release. The release sets not only 'positions' but also all other arrays it finds. Arrays found in NetCDF file but not in the SpillContainer are ignored. Optional arguments, index and time can be used to initialize the release from any other record in the NetCDF file. Default behavior is to use the last record in the NetCDF to initialize the release elements. :param str filename: NetCDF file from which to initialize released elements Optional arguments: :param int index=None: index of the record from which to initialize the release elements. Default is to use -1 if neither time nor index is specified :param datetime time: timestamp at which the data is desired. Looks in the netcdf data's 'time' array and finds the closest time to this and use this data. If both 'time' and 'index' are None, use data for index = -1 .. py:method:: _read_data_file(filename, index, time) .. py:method:: num_elements_to_release(current_time, time_step) all elements should be released in the first timestep unless start time is invalid. Start time is invalid if it is after the Spill's releasetime .. py:method:: _set_data_arrays(num_new_particles, current_time, time_step, data_arrays) Will set positions and all other data arrays if data for them was found in the NetCDF initialization file. .. py:class:: NonWeatheringSubstance(windage_range=None, windage_persist=None, standard_density=1000.0, *args, **kwargs) Bases: :py:obj:`Substance` A class for assigning a unique ID for an object :param windage_range: Range of windages for the substance (leeway). Default: (.01, .04) :type windage_range: tuple of values between 0 and 1 :param windage_persist=900: persistence of windage settings in seconds. -1 or Inf means infinite. :type windage_persist: integer seconds. :param standard_density=1000.0: The density of the substance, used to convert mass to/from volume :type standard_density: float in units of kg/m^3 .. py:property:: is_weatherable .. py:attribute:: _schema The simplest substance that can be used with the model It can not be weathered, but does have basic properties for transport: Windage, density, etc. .. py:method:: initialize_LEs(to_rel, arrs, environment=None) :param to_rel - number of new LEs to initialize :param arrs - dict-like of data arrays representing LEs .. py:class:: GnomeOil(oil_name=None, filename=None, water=None, **kwargs) Bases: :py:obj:`gnome.spills.substance.Substance` Class to create an oil for use in Gnome Initialize a GnomeOil: :param oil_name=None: Name of one of the sample oils provided by: ``gnome.spills.sample_oils`` :param filename=None: filename (Path) of JSON file in the Adios Oil Database format. :param water=None: Water object with environmental conditions -- Deprecated. Additional keyword arguments will be passed to Substance: e.g.: ``windage_range``, ``windage_persist=None``, A GnomeOil can be initialized in three ways: 1) From a sample oil name : ``GnomeOil(oil_name="sample_oil_name")`` the oils are available in gnome.spills.sample_oils 2) From a JSON file in the ADIOS Oil Database format: ``GnomeOil(filename="adios_oil.json")`` usually records from the ADIOS Oil Database (https://adios.orr.noaa.gov) 3) From the json : ``GnomeOil.new_from_dict(**json_)`` for loading save files, etc. (this is usually done under the hood) GnomeOil("sample_oil_name") ---works for test oils from sample_oils only GnomeOil(oil_name="sample_oil_name") GnomeOil(filename="oil.json") ---load from file using adios_db GnomeOil.new_from_dict(**json\_) ---webgnomeclient, savefiles, etc. GnomeOil("invalid_name") ---ValueError (not in sample oils) .. py:property:: standard_density Standard density is simply the density at 15C, which is the default temperature for density_at_temp() .. py:attribute:: _schema .. py:attribute:: _req_refs :value: ['water'] .. py:method:: from_adiosdb_file(filename, kwargs) .. py:method:: _set_up_array_types() .. py:method:: _init_from_json(*, api, pour_point, solubility, bullwinkle_fraction, original_bullwinkle_fraction=None, bullwinkle_time=None, original_bullwinkle_time=None, emulsion_water_fraction_max, densities, density_ref_temps, density_weathering, kvis, kvis_ref_temps, kvis_weathering, mass_fraction, boiling_point, molecular_weight, component_density, sara_type=None, adios_oil_id=None, k0y=None, num_components=None, **kwargs) .. py:method:: __hash__() needs to be hashable, so that it can be used in lru-cache Oils will only hash equal if they are the same object -- that's limiting, but OK. .. py:method:: __deepcopy__(memo) .. py:method:: get_GnomeOil(oil_info, max_cuts=None) :classmethod: #fixme: what is oil_info ??? Use this instead of get_oil_props .. py:method:: to_dict(json_=None) Returns a dictionary representation of this object. Uses the schema to determine which attributes are put into the dictionary. No extra processing is done to each attribute. They are presented as is. The ``json_`` parameter is ignored in this base class. 'save' is passed in when the schema is saving the object. This allows an override of this function to do any custom stuff necessary to prepare for saving. .. py:method:: initialize_LEs(to_rel, arrs, environment=None) :param to_rel - number of new LEs to initialize :param arrs - dict-like of data arrays representing LEs fixme: this shouldn't use water temp -- it should use standard density and STP temp -- and let weathering_data set it correctly .. note:: weathering data is currently broken for initial setting .. py:method:: _set_pc_values(prop, values) utility that sets a property to each pseudo component checks that it's the right size, and converts to an array .. py:method:: vapor_pressure(temp, atmos_pressure=101325.0) the vapor pressure on the PCs at a given temperature water_temp and boiling point units are Kelvin :param temp: temperature in K :returns: vapor_pressure array in SI units (Pascals) ## Fixme: shouldn't this be in the Evaporation code? .. py:method:: bounding_temperatures(obj_list, temperature) :classmethod: General Utility Function From a list of objects containing a ref_temp_k attribute, return the object(s) that are closest to the specified temperature(s) Specifically: - We want the ones that immediately bound our temperature. - If our temperature is high and out of bounds of the temperatures in our obj_list, then we return a range containing only the highest temperature. - If our temperature is low and out of bounds of the temperatures in our obj_list, then we return a range containing only the lowest temperature. We accept only a scalar temperature or a sequence of temperatures .. py:method:: get_densities() return a list of densities for the oil at a specified state of weathering. #fixme: this should not happen here! We include the API as a density if: - the specified weathering is 0 - the culled list of densities does not contain a measurement at 15C .. py:method:: density_at_temp(temperature=288.15) Get the oil density at a temperature or temperatures. .. note:: This is all kruft left over from the estimating code. At this point, a GnomeOil should already have what it needs. .. note:: There is a catch-22 which prevents us from getting the min_temp in some cases: - To estimate pour point, we need viscosities - If we need to convert dynamic viscosities to kinematic, we need density at 15C - To estimate density at temp, we need to estimate pour point - ...and then we recurse For this case we need to make an exception. .. note:: If we have a pour point that is higher than one or more of our reference temperatures, then the lowest reference temperature will become our minimum temperature. TODO: We are getting rid of the argument that specifies a weathering amount because it is currently implemented in an unusably precise manner. Robert would like us to implement a means of interpolating density using a combination of (temperature, weathering). But the algorithm for this is not defined at the moment. .. py:method:: _get_reference_densities(densities, temperature) Given a temperature, we return the best measured density, and its reference temperature, to be used in calculation. For our purposes, it is the density closest to the given temperature. .. py:method:: _vol_expansion_coeff(densities, temperature) .. py:method:: closest_to_temperature(obj_list, temperature, num=1) :classmethod: General Utility Function From a list of objects containing a ref_temp_k attribute, return the object(s) that are closest to the specified temperature(s) We accept only a scalar temperature or a sequence of temperatures .. py:method:: kvis_at_temp(temp_k=288.15, weathering=0.0) Compute the kinematic viscosity of the oil as a function of temperature :param temp_k: temperatures to compute at: can be scalar or array of values. should be in Kelvin :param weathering: fraction weathered -- currently not implemented viscosity as a function of temp is given by: v = A exp(k_v2 / T) with constants determined from measured data .. py:method:: determine_visc_constants() viscosity as a function of temp is given by: v = A exp(k_v2 / T) The constants, A and k_v2 are determined from the viscosity data: If only one data point, a default value for k_vs is used: 2100 K, based on analysis of data in the ADIOS database as of 2018 If two data points, the two constants are directly computed If three or more, the constants are computed by a least squares fit. .. py:method:: get(prop) get oil props .. py:class:: LEData(name=None, *args, **kwargs) Bases: :py:obj:`collections.abc.MutableMapping`, :py:obj:`gnome.gnomeobject.AddLogger`, :py:obj:`dict` A MutableMapping is a generic container for associating key/value pairs. This class provides concrete generic implementations of all methods except for __getitem__, __setitem__, __delitem__, __iter__, and __len__. Initialize self. See help(type(self)) for accurate signature. .. py:property:: num_released The number of elements currently in the SpillContainer If SpillContainer is initialized, all data_arrays exist as ndarrays even if no elements are released. So this will always return a valid int >= 0. .. py:attribute:: clear .. py:attribute:: __str__ .. py:method:: rewind() .. py:method:: __eq__(other) Compare equality of two LEData objects .. py:method:: __ne__(other) Return self!=value. .. py:method:: __len__() The "length" of a spill container is the number of elements in it. The first dimension of any ndarray in our data_arrays will always be the number of elements that are contained in a SpillContainer. .. py:method:: __getitem__(key) x.__getitem__(y) <==> x[y] .. py:method:: __setitem__(key, value) Set self[key] to value. .. py:method:: _set_existing_LEData(key, value) .. py:method:: __delitem__(key) Delete self[key]. .. py:method:: __iter__() Implement iter(self). .. py:method:: __repr__() Return repr(self). .. py:method:: prepare_for_model_run(array_types, substance) .. py:method:: initialize_data_arrays() initialize_data_arrays() is called without input data during rewind and prepare_for_model_run to prepare the buffers and define the data arrays. .. py:method:: extend_data_arrays(num_new_elements) Adds num_new_elements to the data arrays. Resizes the arrays as necessary. Data arrays are set to their initial_values :param int num_new_elements: number of particles released