:py:mod:`gnome.utilities` ========================= .. py:module:: gnome.utilities .. autoapi-nested-parse:: __init__.py for the utilities package a few small things here, 'cause why not? Subpackages ----------- .. toctree:: :titlesonly: :maxdepth: 3 file_tools/index.rst geometry/index.rst graphs/index.rst weathering/index.rst Submodules ---------- .. toctree:: :titlesonly: :maxdepth: 1 appearance/index.rst cache/index.rst colormaps/index.rst compute_fraction/index.rst convert/index.rst distributions/index.rst hull/index.rst images2gif/index.rst inf_datetime/index.rst map_canvas/index.rst orderedcollection/index.rst plume/index.rst profiledeco/index.rst projections/index.rst rand/index.rst remote_data/index.rst save_updater/index.rst schema_decorator/index.rst serializable_demo_objects/index.rst shapefile_builder/index.rst surface_concentration/index.rst time_utils/index.rst timeseries/index.rst transforms/index.rst Package Contents ---------------- Functions ~~~~~~~~~ .. autoapisummary:: gnome.utilities.convert_longitude gnome.utilities._round_sf_float gnome.utilities.round_sf_scalar gnome.utilities.round_sf_array gnome.utilities.convert_mass_to_mass_or_volume Attributes ~~~~~~~~~~ .. autoapisummary:: gnome.utilities.div gnome.utilities.GetCurrentProcess .. py:data:: div .. py:function:: convert_longitude(lon, coord_system='-180--180') Convert longitude values to a given coordinate system. Options are: "-180--180": Negative 180 degrees to 180 degrees "0--360": Zero to 360 degrees :param lon: numpy array-like of longitude values of float type :param coord_system='-180--180': options are: {"-180--180", "0--360"} NOTE: this function also normalizes so that: 360 converts to 0 -180 converts to 180 It should be safe to call this on any coords -- if they are already in the expected format, they will not be changes, except for the normalization above. .. py:data:: GetCurrentProcess .. py:function:: _round_sf_float(x, sigfigs) round a float to significant figures -- no error checking This uses the "g" format specifier -- maybe slow, but robust for the purpose of getting the display what we want. .. py:function:: round_sf_scalar(x, sigfigs) .. py:function:: round_sf_array(x, sigfigs) round to a certain number of significant figures should work on floats and numpy arrays NOTE: This should be vectorizable, but np.round takes only a scalar value for number of decimals -- you could vectorize the rest of the computation, and then loop for the round, but would that buy anything? (or use np.vectorize) .. py:function:: convert_mass_to_mass_or_volume(in_unit, out_unit, density, value) convert a mass unit to either a mass or volume unit :param in_unit: units of input, should be a valid mass unit. :param out_unit: units you want the result in -- can be a volume or mass unit :param density: density to use to convert from mass to volume. has to be kg/m^3 :param value: value (in in_units) you want converted. ex: convert_mass_to_mass_or_volume('kg', 'bbl', 950, 2000) convert_mass_to_mass_or_volume('lbs', 'kg', 950, 4000)