pynkowski.theory.base_th
This submodule contains the base abstract class for theoretical fields, TheoryField
.
1"""This submodule contains the base abstract class for theoretical fields, `TheoryField`.""" 2import numpy as np 3 4def _prepare_lkc(dim=None, lkc_ambient=None): 5 """Define the Lipschitz–Killing Curvatures of the ambient manifold as the default ones (unit volume and the rest are 0), or verify their consistency. 6 If no argument is given, it defaults to a 2D space. 7 8 Parameters 9 ---------- 10 dim : int, optional 11 The dimension of the ambient manifold. 12 13 lkc_ambient : list, optional 14 A list of the Lipschitz–Killing Curvatures of the ambient manifold. Its lenght must be `dim+1` if both arguments are given. 15 16 Returns 17 ---------- 18 dim : int 19 The dimension of the ambient manifold. 20 21 lkc_ambient : np.array or None, optional 22 An array of the Lipschitz–Killing Curvatures of the ambient manifold. 23 """ 24 if lkc_ambient is None: 25 if dim is None: 26 dim = 2 27 lkc_ambient = np.zeros(dim+1) 28 lkc_ambient[-1] = 1. 29 else: 30 if dim is None: 31 dim = len(lkc_ambient) -1 32 else: 33 assert len(lkc_ambient) == dim +1, 'If both dim and lkc_ambient are given, len(lkc_ambient) == dim +1' 34 return dim, lkc_ambient 35 36class TheoryField(): 37 """General class for Theoretical fields, to be used as base for all fields. 38 39 Parameters 40 ---------- 41 dim : int 42 Dimension of the space where the field is defined. 43 44 name : str, optional 45 Name of the field. 46 Defaul : `'TheoryField'` 47 48 sigma : float, optional 49 The standard deviation of the field. 50 Default : 1. 51 52 mu : float, optional 53 The derivative of the covariance function at the origin, times $-2$. 54 Default : 1. 55 56 nu : float, optional 57 The second derivative of the covariance function at the origin. 58 Default : 1. 59 60 lkc_ambient : np.array or None, optional 61 The values for the Lipschitz–Killing Curvatures of the ambient space. If `None`, it is assumed that the volume is 1 and the rest is 0. This (times the volume) is exact for many spaces like Euclidean spaces or the sphere, and exact to leading order in μ for the rest. 62 Default : None 63 64 Attributes 65 ---------- 66 dim : int 67 Dimension of the space where the field is defined. 68 69 name : str 70 Name of the field. 71 72 sigma : float 73 The standard deviation of the field. 74 75 mu : float 76 The derivative of the covariance function at the origin, times $-2$. Equal to the variance of the first derivatives of the field. 77 78 nu : float 79 The second derivative of the covariance function at the origin. 80 81 lkc_ambient : np.array or None 82 The values for the Lipschitz–Killing Curvatures of the ambient space. 83 84 """ 85 def __init__(self, dim, name='TheoryField', sigma=1., mu=1., nu=1., lkc_ambient=None): 86 self.name = name 87 self.sigma = sigma 88 self.mu = mu 89 self.nu = nu 90 self.dim, self.lkc_ambient = _prepare_lkc(dim, lkc_ambient) 91 92 def __repr__(self): 93 return(f'"{self.name}" TheoryField, {self.dim}D, σ = {self.sigma:.1f}, μ = {self.mu:.1f}') 94 95 96__all__ = ["TheoryField"] 97 98__docformat__ = "numpy" 99 100
class
TheoryField:
37class TheoryField(): 38 """General class for Theoretical fields, to be used as base for all fields. 39 40 Parameters 41 ---------- 42 dim : int 43 Dimension of the space where the field is defined. 44 45 name : str, optional 46 Name of the field. 47 Defaul : `'TheoryField'` 48 49 sigma : float, optional 50 The standard deviation of the field. 51 Default : 1. 52 53 mu : float, optional 54 The derivative of the covariance function at the origin, times $-2$. 55 Default : 1. 56 57 nu : float, optional 58 The second derivative of the covariance function at the origin. 59 Default : 1. 60 61 lkc_ambient : np.array or None, optional 62 The values for the Lipschitz–Killing Curvatures of the ambient space. If `None`, it is assumed that the volume is 1 and the rest is 0. This (times the volume) is exact for many spaces like Euclidean spaces or the sphere, and exact to leading order in μ for the rest. 63 Default : None 64 65 Attributes 66 ---------- 67 dim : int 68 Dimension of the space where the field is defined. 69 70 name : str 71 Name of the field. 72 73 sigma : float 74 The standard deviation of the field. 75 76 mu : float 77 The derivative of the covariance function at the origin, times $-2$. Equal to the variance of the first derivatives of the field. 78 79 nu : float 80 The second derivative of the covariance function at the origin. 81 82 lkc_ambient : np.array or None 83 The values for the Lipschitz–Killing Curvatures of the ambient space. 84 85 """ 86 def __init__(self, dim, name='TheoryField', sigma=1., mu=1., nu=1., lkc_ambient=None): 87 self.name = name 88 self.sigma = sigma 89 self.mu = mu 90 self.nu = nu 91 self.dim, self.lkc_ambient = _prepare_lkc(dim, lkc_ambient) 92 93 def __repr__(self): 94 return(f'"{self.name}" TheoryField, {self.dim}D, σ = {self.sigma:.1f}, μ = {self.mu:.1f}')
General class for Theoretical fields, to be used as base for all fields.
Parameters
- dim (int): Dimension of the space where the field is defined.
- name (str, optional):
Name of the field.
Defaul :
'TheoryField'
- sigma (float, optional): The standard deviation of the field. Default : 1.
- mu (float, optional): The derivative of the covariance function at the origin, times $-2$. Default : 1.
- nu (float, optional): The second derivative of the covariance function at the origin. Default : 1.
- lkc_ambient (np.array or None, optional):
The values for the Lipschitz–Killing Curvatures of the ambient space. If
None
, it is assumed that the volume is 1 and the rest is 0. This (times the volume) is exact for many spaces like Euclidean spaces or the sphere, and exact to leading order in μ for the rest. Default : None
Attributes
- dim (int): Dimension of the space where the field is defined.
- name (str): Name of the field.
- sigma (float): The standard deviation of the field.
- mu (float): The derivative of the covariance function at the origin, times $-2$. Equal to the variance of the first derivatives of the field.
- nu (float): The second derivative of the covariance function at the origin.
- lkc_ambient (np.array or None): The values for the Lipschitz–Killing Curvatures of the ambient space.