SphericalHarmonicAnalysis#
- class ktch.harmonic.SphericalHarmonicAnalysis(n_harmonics=10, n_jobs=None, verbose=0)[source]#
Spherical Harmonic (SPHARM) Analysis
Notes
[Ritche_Kemp_1999], [Shen_etal_2009]
\[\begin{align} \mathbf{p}(\theta, \phi) = \sum_{l=0}^{L} \sum_{m=-l}^l \left( c_l^m Y_l^m(\theta, \phi) \right) \end{align}\], where \(Y_l^m(\theta, \phi)\) are spherical harmonics:
\[\begin{align} Y_l^m(\theta, \phi) = \sqrt{\frac{2l+1}{4\pi}\frac{(l-m)!}{(l+m)!}} P_l^m(\cos(\theta)) e^{im\phi} \end{align}\], where \(P_n^m(x)\) are associated Legendre polynomials:
\[\begin{align} P_n^m(x) = (-1)^m (1-x^2)^{\frac{m}{2}} \frac{d^m}{dx^m} P_n(x) \end{align}\], where \(P_n(x)\) are Legendre polynomials, which are solutions of Legendre’s differential equation;
\[(1-x^2)\frac{d^2 y}{dx^2} -2x \frac{dy}{dx} + n(n+1)y = 0.\]References
[Ritche_Kemp_1999]Ritchie, D.W., Kemp, G.J.L. (1999) Fast computation, rotation, and comparison of low resolution spherical harmonic molecular surfaces. J. Comput. Chem. 20: 383–395.
[Shen_etal_2009]Shen, L., Farid, H., McPeek, M.A. (2009) Modeling three-dimensional morphological structures using spherical harmonics. Evolution (N. Y). 63: 1003–1016.
- get_metadata_routing()#
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
- routingMetadataRequest
A
MetadataRequestencapsulating routing information.
- get_params(deep=True)#
Get parameters for this estimator.
- Parameters:
- deepbool, default=True
If True, will return the parameters for this estimator and contained subobjects that are estimators.
- Returns:
- paramsdict
Parameter names mapped to their values.
- inverse_transform(X_transformed, theta_range=array([0., 0.03529879, 0.07059759, 0.10589638, 0.14119518, 0.17649397, 0.21179276, 0.24709156, 0.28239035, 0.31768914, 0.35298794, 0.38828673, 0.42358553, 0.45888432, 0.49418311, 0.52948191, 0.5647807, 0.6000795, 0.63537829, 0.67067708, 0.70597588, 0.74127467, 0.77657346, 0.81187226, 0.84717105, 0.88246985, 0.91776864, 0.95306743, 0.98836623, 1.02366502, 1.05896382, 1.09426261, 1.1295614, 1.1648602, 1.20015899, 1.23545779, 1.27075658, 1.30605537, 1.34135417, 1.37665296, 1.41195175, 1.44725055, 1.48254934, 1.51784814, 1.55314693, 1.58844572, 1.62374452, 1.65904331, 1.69434211, 1.7296409, 1.76493969, 1.80023849, 1.83553728, 1.87083607, 1.90613487, 1.94143366, 1.97673246, 2.01203125, 2.04733004, 2.08262884, 2.11792763, 2.15322643, 2.18852522, 2.22382401, 2.25912281, 2.2944216, 2.32972039, 2.36501919, 2.40031798, 2.43561678, 2.47091557, 2.50621436, 2.54151316, 2.57681195, 2.61211075, 2.64740954, 2.68270833, 2.71800713, 2.75330592, 2.78860471, 2.82390351, 2.8592023, 2.8945011, 2.92979989, 2.96509868, 3.00039748, 3.03569627, 3.07099507, 3.10629386, 3.14159265]), phi_range=array([0., 0.03510159, 0.07020319, 0.10530478, 0.14040638, 0.17550797, 0.21060956, 0.24571116, 0.28081275, 0.31591435, 0.35101594, 0.38611753, 0.42121913, 0.45632072, 0.49142231, 0.52652391, 0.5616255, 0.5967271, 0.63182869, 0.66693028, 0.70203188, 0.73713347, 0.77223507, 0.80733666, 0.84243825, 0.87753985, 0.91264144, 0.94774304, 0.98284463, 1.01794622, 1.05304782, 1.08814941, 1.123251, 1.1583526, 1.19345419, 1.22855579, 1.26365738, 1.29875897, 1.33386057, 1.36896216, 1.40406376, 1.43916535, 1.47426694, 1.50936854, 1.54447013, 1.57957173, 1.61467332, 1.64977491, 1.68487651, 1.7199781, 1.75507969, 1.79018129, 1.82528288, 1.86038448, 1.89548607, 1.93058766, 1.96568926, 2.00079085, 2.03589245, 2.07099404, 2.10609563, 2.14119723, 2.17629882, 2.21140042, 2.24650201, 2.2816036, 2.3167052, 2.35180679, 2.38690838, 2.42200998, 2.45711157, 2.49221317, 2.52731476, 2.56241635, 2.59751795, 2.63261954, 2.66772114, 2.70282273, 2.73792432, 2.77302592, 2.80812751, 2.84322911, 2.8783307, 2.91343229, 2.94853389, 2.98363548, 3.01873707, 3.05383867, 3.08894026, 3.12404186, 3.15914345, 3.19424504, 3.22934664, 3.26444823, 3.29954983, 3.33465142, 3.36975301, 3.40485461, 3.4399562, 3.4750578, 3.51015939, 3.54526098, 3.58036258, 3.61546417, 3.65056577, 3.68566736, 3.72076895, 3.75587055, 3.79097214, 3.82607373, 3.86117533, 3.89627692, 3.93137852, 3.96648011, 4.0015817, 4.0366833, 4.07178489, 4.10688649, 4.14198808, 4.17708967, 4.21219127, 4.24729286, 4.28239446, 4.31749605, 4.35259764, 4.38769924, 4.42280083, 4.45790242, 4.49300402, 4.52810561, 4.56320721, 4.5983088, 4.63341039, 4.66851199, 4.70361358, 4.73871518, 4.77381677, 4.80891836, 4.84401996, 4.87912155, 4.91422315, 4.94932474, 4.98442633, 5.01952793, 5.05462952, 5.08973111, 5.12483271, 5.1599343, 5.1950359, 5.23013749, 5.26523908, 5.30034068, 5.33544227, 5.37054387, 5.40564546, 5.44074705, 5.47584865, 5.51095024, 5.54605184, 5.58115343, 5.61625502, 5.65135662, 5.68645821, 5.7215598, 5.7566614, 5.79176299, 5.82686459, 5.86196618, 5.89706777, 5.93216937, 5.96727096, 6.00237256, 6.03747415, 6.07257574, 6.10767734, 6.14277893, 6.17788053, 6.21298212, 6.24808371, 6.28318531]), l_max=None)[source]#
Inverse SPHARM transform Parameters ———————— X_transformed: array-like of shape (n_samples, n_coefficients)
SPHARM coefficients.
theta_range: array_like phi_range: array_like lmax: int
Degree of SPHARM to use how far
- Returns:
- X_coords: array-like of shape (n_samples, n_theta, n_phi, 3)
Coordinate values of reconstructed surfaces.
- set_inverse_transform_request(*, X_transformed: bool | None | str = '$UNCHANGED$', l_max: bool | None | str = '$UNCHANGED$', phi_range: bool | None | str = '$UNCHANGED$', theta_range: bool | None | str = '$UNCHANGED$') SphericalHarmonicAnalysis#
Configure whether metadata should be requested to be passed to the
inverse_transformmethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed toinverse_transformif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it toinverse_transform.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- Parameters:
- X_transformedstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
X_transformedparameter ininverse_transform.- l_maxstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
l_maxparameter ininverse_transform.- phi_rangestr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
phi_rangeparameter ininverse_transform.- theta_rangestr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
theta_rangeparameter ininverse_transform.
- Returns:
- selfobject
The updated object.
- set_output(*, transform=None)#
Set output container.
See Introducing the set_output API for an example on how to use the API.
- Parameters:
- transform{“default”, “pandas”, “polars”}, default=None
Configure output of transform and fit_transform.
“default”: Default output format of a transformer
“pandas”: DataFrame output
“polars”: Polars output
None: Transform configuration is unchanged
Added in version 1.4: “polars” option was added.
- Returns:
- selfestimator instance
Estimator instance.
- set_params(**params)#
Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as
Pipeline). The latter have parameters of the form<component>__<parameter>so that it’s possible to update each component of a nested object.- Parameters:
- **paramsdict
Estimator parameters.
- Returns:
- selfestimator instance
Estimator instance.
- set_transform_request(*, theta_phi: bool | None | str = '$UNCHANGED$') SphericalHarmonicAnalysis#
Configure whether metadata should be requested to be passed to the
transformmethod.Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with
enable_metadata_routing=True(seesklearn.set_config()). Please check the User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed totransformif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it totransform.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
- Parameters:
- theta_phistr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
theta_phiparameter intransform.
- Returns:
- selfobject
The updated object.
- transform(X, theta_phi)[source]#
Transform X to a SPHARM coefficients.
- Parameters:
- X: list of array-like
Coordinate values of n_samples. The i-th array-like whose shape (n_coords_i, 3) represents 3D coordinate values of the i-th sample .
- theta_phi: list of array-like of shape (n_coords, 2)
Surface parameter of n_samples. The i-th array-like of theta and phi values whose shape is (n_coords_i, 2).
- Returns:
- X_transformed: array-like of shape (n_samples, n_coefficients)
Returns the array-like of SPHARM coefficients.