pynkowski.data.base_da

This submodule contains the base abstract class for data fields.

 1'''This submodule contains the base abstract class for data fields.'''
 2import numpy as np
 3
 4class DataField():
 5    """General class for Data fields, to be used as base for all fields.
 6
 7    Parameters
 8    ----------
 9    field : np.array
10        Data of the field in an undefined structure.
11    
12    dim : int
13        Dimension of the space where the field is defined.
14        
15    name : str, optional
16        Name of the field.
17        Defaul : `'DataField'`
18    
19    first_der : np.array or None, optional
20        First **covariant** derivatives of the field in an orthonormal basis of the space. Same structure as `field`, and shape `(dim, field.shape)`.
21    
22    second_der : np.array or None, optional
23        Second **covariant** derivatives of the field in an orthonormal basis of the space. Same structure as `field`, and shape `(dim*(dim+1)/2, field.shape)`.
24        The order of the derivatives is diagonal first, e.g. in `dim=3`: `11`, `22`, `33`, `12`, `13`, `23`.
25        
26    mask : np.array or None, optional
27        Mask where the field if considered. It is a bool array of the same shape that `field`.
28        
29    Attributes
30    ----------
31    field : np.array
32        Data of the field in an undefined structure.
33    
34    dim : int
35        Dimension of the space where the field is defined.
36        
37    name : str
38        Name of the field.
39    
40    first_der : np.array or None
41        First **covariant** derivatives of the field in an orthonormal basis of the space. Same structure as `field`, and shape `(dim, field.shape)`.
42    
43    second_der : np.array or None
44        Second **covariant** derivatives of the field in an orthonormal basis of the space. Same structure as `field`, and shape `(dim*(dim+1)/2, field.shape)`.
45        The order of the derivatives is diagonal first, e.g. in `dim=3`: `11`, `22`, `33`, `12`, `13`, `23`.
46        
47    mask : np.array
48        Mask where the field if considered. It is a bool array of the same shape that `field`.
49        
50    """   
51    
52    def __init__(self, field, dim, name="DataField", first_der=None, second_der=None, mask=None):
53        self.field = field.copy()
54        self.dim = dim
55        self.name = name
56        if mask is None:
57            self.mask = np.ones_like(self.field, dtype='bool')
58        else:
59            self.mask = mask
60        self.first_der = first_der
61        self.second_der = second_der
62        
63    def __repr__(self):
64        return(f'{self.name} DataField: {self.field}')
65       
66
67
68__all__ = ["DataField"]
69
70__docformat__ = "numpy"
class DataField:
 5class DataField():
 6    """General class for Data fields, to be used as base for all fields.
 7
 8    Parameters
 9    ----------
10    field : np.array
11        Data of the field in an undefined structure.
12    
13    dim : int
14        Dimension of the space where the field is defined.
15        
16    name : str, optional
17        Name of the field.
18        Defaul : `'DataField'`
19    
20    first_der : np.array or None, optional
21        First **covariant** derivatives of the field in an orthonormal basis of the space. Same structure as `field`, and shape `(dim, field.shape)`.
22    
23    second_der : np.array or None, optional
24        Second **covariant** derivatives of the field in an orthonormal basis of the space. Same structure as `field`, and shape `(dim*(dim+1)/2, field.shape)`.
25        The order of the derivatives is diagonal first, e.g. in `dim=3`: `11`, `22`, `33`, `12`, `13`, `23`.
26        
27    mask : np.array or None, optional
28        Mask where the field if considered. It is a bool array of the same shape that `field`.
29        
30    Attributes
31    ----------
32    field : np.array
33        Data of the field in an undefined structure.
34    
35    dim : int
36        Dimension of the space where the field is defined.
37        
38    name : str
39        Name of the field.
40    
41    first_der : np.array or None
42        First **covariant** derivatives of the field in an orthonormal basis of the space. Same structure as `field`, and shape `(dim, field.shape)`.
43    
44    second_der : np.array or None
45        Second **covariant** derivatives of the field in an orthonormal basis of the space. Same structure as `field`, and shape `(dim*(dim+1)/2, field.shape)`.
46        The order of the derivatives is diagonal first, e.g. in `dim=3`: `11`, `22`, `33`, `12`, `13`, `23`.
47        
48    mask : np.array
49        Mask where the field if considered. It is a bool array of the same shape that `field`.
50        
51    """   
52    
53    def __init__(self, field, dim, name="DataField", first_der=None, second_der=None, mask=None):
54        self.field = field.copy()
55        self.dim = dim
56        self.name = name
57        if mask is None:
58            self.mask = np.ones_like(self.field, dtype='bool')
59        else:
60            self.mask = mask
61        self.first_der = first_der
62        self.second_der = second_der
63        
64    def __repr__(self):
65        return(f'{self.name} DataField: {self.field}')

General class for Data fields, to be used as base for all fields.

Parameters
  • field (np.array): Data of the field in an undefined structure.
  • dim (int): Dimension of the space where the field is defined.
  • name (str, optional): Name of the field. Defaul : 'DataField'
  • first_der (np.array or None, optional): First covariant derivatives of the field in an orthonormal basis of the space. Same structure as field, and shape (dim, field.shape).
  • second_der (np.array or None, optional): Second covariant derivatives of the field in an orthonormal basis of the space. Same structure as field, and shape (dim*(dim+1)/2, field.shape). The order of the derivatives is diagonal first, e.g. in dim=3: 11, 22, 33, 12, 13, 23.
  • mask (np.array or None, optional): Mask where the field if considered. It is a bool array of the same shape that field.
Attributes
  • field (np.array): Data of the field in an undefined structure.
  • dim (int): Dimension of the space where the field is defined.
  • name (str): Name of the field.
  • first_der (np.array or None): First covariant derivatives of the field in an orthonormal basis of the space. Same structure as field, and shape (dim, field.shape).
  • second_der (np.array or None): Second covariant derivatives of the field in an orthonormal basis of the space. Same structure as field, and shape (dim*(dim+1)/2, field.shape). The order of the derivatives is diagonal first, e.g. in dim=3: 11, 22, 33, 12, 13, 23.
  • mask (np.array): Mask where the field if considered. It is a bool array of the same shape that field.
DataField( field, dim, name='DataField', first_der=None, second_der=None, mask=None)
53    def __init__(self, field, dim, name="DataField", first_der=None, second_der=None, mask=None):
54        self.field = field.copy()
55        self.dim = dim
56        self.name = name
57        if mask is None:
58            self.mask = np.ones_like(self.field, dtype='bool')
59        else:
60            self.mask = mask
61        self.first_der = first_der
62        self.second_der = second_der