66
77For developers, see also :mod:`~swiftsimio._array_functions` containing
88helpers, wrappers and implementations that enable most :mod:`numpy` and
9- :mod:`unyt` functions to work with our cosmology-aware arrays.
9+ :mod:`unyt` functions to work with our cosmology-aware arrays.
1010"""
1111
1212from unyt import unyt_array , unyt_quantity
@@ -161,7 +161,7 @@ def __init__(
161161 ) -> None :
162162 """
163163 Constructor for warning of invalid conversion.
164-
164+
165165 Parameters
166166 ----------
167167 message : str, optional
@@ -239,61 +239,85 @@ class cosmo_factor:
239239 comoving and physical coordinates.
240240
241241 This takes the expected exponent of the array that can be parsed
242- by sympy, and the current value of the cosmological scale factor ``a``.
242+ by :mod:` sympy` , and the current value of the cosmological scale factor ``a``.
243243
244244 This should be given as the conversion from comoving to physical, i.e.
245+ :math:`r = a^f \t imes r` where :math:`a` is the scale factor,
246+ :math:`r` is a physical quantity and :math`r'` a comoving quantity.
245247
246- r = cosmo_factor * r' with r in physical and r' comoving
248+ Parameters
249+ ----------
250+ expr : sympy.expr
251+ Expression used to convert between comoving and physical coordinates.
252+ scale_factor : float
253+ The scale factor (a).
247254
255+ Attributes
256+ ----------
257+ expr : sympy.expr
258+ Expression used to convert between comoving and physical coordinates.
259+ scale_factor : float
260+ The scale factor (a).
261+
248262 Examples
249263 --------
250- Typically this would make cosmo_factor = a for the conversion between
251- comoving positions r' and physical co-ordinates r.
264+ Mass density transforms as :math:`a^3`. To set up a ``cosmo_factor``, supposing
265+ a current ``scale_factor=0.97``, we import the scale factor ``a`` and initialize
266+ as:
252267
253- To do this, use the a imported from objects multiplied as you'd like :
268+ : :
254269
255- ``density_cosmo_factor = cosmo_factor(a**3, scale_factor=0.97)``
270+ from swiftsimio.objects import a # the scale factor (a sympy symbol object)
271+ density_cosmo_factor = cosmo_factor(a**3, scale_factor=0.97)
256272
273+ :class:`~swiftsimio.objects.cosmo_factor` support arithmetic, for example:
274+
275+ ::
276+
277+ >>> cosmo_factor(a**2, scale_factor=0.5) * cosmo_factor(a**-1, scale_factor=0.5)
278+ cosmo_factor(expr=a, scale_factor=0.5)
257279 """
258280
281+ expr : sympy .expr
282+ scale_factor : float
283+
259284 def __init__ (self , expr , scale_factor ):
260285 """
261286 Constructor for cosmology factor class.
262287
263288 Parameters
264289 ----------
265290 expr : sympy.expr
266- expression used to convert between comoving and physical coordinates
291+ Expression used to convert between comoving and physical coordinates.
267292 scale_factor : float
268- the scale factor of the simulation data
293+ The scale factor (a).
269294 """
270295 self .expr = expr
271296 self .scale_factor = scale_factor
272297 pass
273298
274299 def __str__ (self ):
275300 """
276- Print exponent and current scale factor
301+ Print exponent and current scale factor.
277302
278303 Returns
279304 -------
280- str
281- string to print exponent and current scale factor
305+ out : str
306+ String with exponent and current scale factor.
282307 """
283308 return str (self .expr ) + f" at a={ self .scale_factor } "
284309
285310 @property
286311 def a_factor (self ):
287312 """
288- The a- factor for the unit .
313+ The multiplicative factor for conversion from comoving to physical .
289314
290- e.g. for density this is 1 / a**3 .
315+ For example, for density this is :math:`a^{-3}` .
291316
292317 Returns
293318 -------
294-
295- float
296- the a-factor for given unit
319+ out : float
320+ The multiplicative factor for conversion from comoving to physical.
297321 """
298322 if (self .expr is None ) or (self .scale_factor is None ):
299323 return None
@@ -302,20 +326,15 @@ def a_factor(self):
302326 @property
303327 def redshift (self ):
304328 """
305- Compute the redshift from the scale factor.
329+ The redshift computed from the scale factor.
330+
331+ Returns the redshift :math:`z = \f rac{1}{a} - 1`, where :math:`a` is the scale
332+ factor.
306333
307334 Returns
308335 -------
309-
310- float
311- redshift from the given scale factor
312-
313- Notes
314- -----
315-
316- Returns the redshift
317- ..math:: z = \\ frac{1}{a} - 1,
318- where :math: `a` is the scale factor
336+ out : float
337+ The redshift.
319338 """
320339 if self .scale_factor is None :
321340 return None
0 commit comments