Coverage for webgeodyn/data/__init__.py: 0%
2 statements
« prev ^ index » next coverage.py v7.2.7, created at 2023-12-18 09:33 +0000
« prev ^ index » next coverage.py v7.2.7, created at 2023-12-18 09:33 +0000
1"""
3The module implements `GHData`_ or `TSData`_ classes that are used to store measure data.
5 - `GHData`_ contains data described by :math:`g_l^m` and :math:`h_l^m` spherical harmonics coefficients. This includes magnetic field ('MF') or secular variation ('SV').
6 - `TSData`_ contains data described by a poloidal/toroidal decomposition of spherical harmonics coefficients (:math:`tc_l^m`, :math:`ts_l^m`, :math:`sc_l^m`, :math:`ss_l^m`). This includes the core flow ('U') or its horizontal divergence ('DIVHU').
8`MeasureData`_ is the parent class containing common features of `GHData`_ and `TSData`_
10Data creation
11#############
13Creation of a new measure is done by instancing `GHData`_ or `TSData`_:
15.. code-block:: python
17 from webgeodyn.data import GHData, TSData
18 from webgeodyn.data.normPnm import semiNormalisedSchmidt
20 PnmNorm = semiNormalisedSchmidt
21 myData = GHData(data, lmax, units, measureType, PnmNorm, gridth=tharray, gridph=pharray):
22 # data :
23 # 2D array [times, harmonics coefficients]
24 # or 3D array [times, harmonics coefficients, realisations]
25 # lmax : int
26 # units : string
27 # measureType : "MF", "SV" or "U"
28 # PnmNorm : normalisation function
29 # gridth (optional) : array containing list of theta points
30 # gridph (optional) : array containing list of phi points
33`normPnm`_ contains normalisation functions for Legendre functions :
35 - `semiNormalisedSchmidt`_ returns Schmidt semi-normalised coefficients (default).
36 - `noNorm`_ should be used instead when no normalisation is desired.
38Operation on data
39#################
41Setting data
42------------
44To set a new data array for `GHData`_ or `TSData`_, use the ``setData`` function (overwriting directly data arrays may cause errors when computing data):
46.. code-block:: python
48 myData.setData(newdata)
49 # newdata :
50 # 2D array [times, harmonics coefficients]
51 # or 3D array [times, harmonics coefficients, realisations]
53Evaluating values into real space
54---------------------------------
56To compute values on the globe (on given :math:`r`, :math:`\\theta`, :math:`\phi`), use the ``computeRThetaPhiData`` function:
58.. code-block :: python
60 globeData = myData.computeRThetaPhiData(r, thlist, phlist, components=["th","ph","norm"], usegridPnm=False, computeallrealisation=False, irealisation=-1)
62 # Returns a dictionary containing for each component (r, theta, phi, norm), a 3D array [times, theta, phi]
63 # (if computeallrealisation=True, the returned array is 4D [times, theta, phi, realisations])
64 #
65 # r : (float) radius
66 # thlist : (array or list) list of theta points where the values are to be calculated
67 # phlist : (array or list) list of phi points where the values are to be calculated
68 # phlist or thetalist must contain unique values [theta] or [phi]
69 # components : list of components to be calculated. Can contain "r", "th", "ph", "norm" for GHData and "th", "ph", "norm", "divh" for TSData.
70 # usegridPnm : Whether to use precalculated Pnm for listed th and ph values (warning, use only if thlist and phlist are equal to myData.th and myData.ph)
71 # computeallrealisation: (boolean)
72 # if True, returns a 4D array [times, theta, phi, realisations]
73 # if False, returns a 3D array [times, theta, phi]
74 # irealisation: (int)
75 # if irealisation<0, returns a 3D array [times, theta, phi] corresponding to the mean of realisations
76 # if irealisation>0, returns a 3D array [times, theta, phi] corresponding to the ith realisation
79Conversion from array index (:math:`k`) to degree, order (:math:`l`, :math:`m`)
80-------------------------------------------------------------------------------
82To convert :math:`g_l^m` to/from :math:`k`, the index in the data array, use ``lm2k`` or ``k2lm``:
84.. code-block :: python
86 k = myData.lm2k(l, m, coef)
87 # l (equivalent to n in other notations) : integer
88 # m : integer
89 # coef :
90 # "g" or "h" for GHData
91 # "tc", "ts", "sc", or "ss" for TSData
92 #
93 # returns :
94 # k : integer index
96 l, m, coef = myData.k2lm(k)
97 # k : integer index
98 #
99 # returns :
100 # l (equivalent to n in other notations) : integer
101 # m : integer
102 # coef :
103 # "g" or "h" for GHData
104 # "tc", "ts", "sc", or "ss" for TSData
107.. _GHData: https://geodynamo.gricad-pages.univ-grenoble-alpes.fr/webgeodyn/webgeodyn.data.GHData.html
108.. _TSData: https://geodynamo.gricad-pages.univ-grenoble-alpes.fr/webgeodyn/webgeodyn.data.TSData.html
109.. _MeasureData: https://geodynamo.gricad-pages.univ-grenoble-alpes.fr/webgeodyn/webgeodyn.data.measuredata.html
110.. _normPnm: https://geodynamo.gricad-pages.univ-grenoble-alpes.fr/webgeodyn/webgeodyn.data.normPnm.html
111.. _semiNormalisedSchmidt: https://geodynamo.gricad-pages.univ-grenoble-alpes.fr/webgeodyn/webgeodyn.data.normPnm.html#webgeodyn.data.normPnm.semiNormalisedSchmidt
112.. _noNorm: https://geodynamo.gricad-pages.univ-grenoble-alpes.fr/webgeodyn/webgeodyn.data.normPnm.html#webgeodyn.data.normPnm.noNorm
114"""
116from .TSData import TSData
117from .GHData import GHData