pytmosph3r.util.util
Module Contents
- get_attributes(obj, attr=None)[source]
Returns attributes of an object if they do not start nor end with an underscore.
- retrieve_name(var, up=0)[source]
- Retrieve the name of a variable
var
as a string. For example ifvar
is named ‘temperature’, the function will return “temperature”. Example:: - def test(hello, up=0):
return retrieve_name(hello, up)
bonjour = “bonjour” test(bonjour) # returns “hello” test(bonjour, up=1) # returns “bonjour”
- Parameters:
var – Variable
up – context to retrieve from (default is the current context, i.e., the function in which the function has been called)
- Retrieve the name of a variable
- to_SI(obj: object, unit: astropy.units.Unit | str = None)[source]
Convert astropy quantity to ‘units’ (SI by default).
- get_altitude_index(altitude: Literal[surface, middle, top], n_vertical: int)[source]
Return altitude index associated with keyword altitude (within “surface”,”top”,”middle”). If not among this keyword, return as is.
- get_latitude_index(latitude: Literal[north, equator, south], n_latitudes: int)[source]
Return latitude index associated with keyword latitude (within “north”,”pole”,”equator”).
- get_longitude_index(longitude: Literal[day, night, terminator], n_longitudes=None)[source]
Return longitude index associated with keyword longitude (within “day”,”night”, “terminator”). The keywords refer to the position of the star if the direction of the rays has been defined as (latitude, longitude) = (0,0).
- get_index(array, location, dim: Literal[altitude, latitude, longitude] = 'altitude')[source]
Return the index of location in array at the dimension dim (altitude/latitude/longitude). For example, if dim is ‘altitude’ and location is ‘surface’, it will return 0.
- get_2D(array, location, dim: Literal[altitude, latitude, longitude] = 'altitude')[source]
Return a 2D slice of array array at the dimension dim (among altitude, latitude and longitude). For example if dim is ‘altitude’, it will return the 2D array of all latitudes and longitudes at this altitude.
- get_column(array, latitude, longitude)[source]
Return a vertical column of array array at the position (latitude, longitude).
- convert_log(array, units: Literal[log, ln] | None = None)[source]
Convert
array
from log space to normal space.units
determines if the space is log or ln.
- mol_key(mol_dict, mol, mol_type='vap', data='')[source]
Returns the key corresponding to mol in mol_dict.
- aerosols_array_iterator(dictionary)[source]
Returns an iterator over arrays of an aerosols dictionary. For example, if the dictionary looks like this:
{'H2O':{'mmr':np.array([1, 2]), 'reff':1e-5}}
. The code will iterate over the mmr (array) but not reff (float).
- arrays_to_zeros(dictionary, shape)[source]
Returns a copy of dictionary of which subarrays are initialized as an array of shape shape filled with zeros. Used for aerosols, to initialize the arrays before interpolating.
- merge_attrs(obj, other)[source]
Merge attributes from other into obj if they do not exist/are None.
- get_wls(array, wls, array_wls)[source]
Get subset of
array
at wavelengthswls
when the wavelengths ofarray
arearray_wls
- query_yes_no(question, default='yes')[source]
Ask a yes/no question via raw_input() and return their answer.
“question” is a string that is presented to the user. “default” is the presumed answer if the user just hits <Enter>.
It must be “yes” (the default), “no” or None (meaning an answer is required of the user).
The “answer” return value is True for “yes” or False for “no”.