Skip to content

Commit

Permalink
Added 'complex' harmonic type as alias for 'sph'.
Browse files Browse the repository at this point in the history
  • Loading branch information
phockett committed Sep 23, 2022
1 parent 65564a0 commit fe42f98
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
7 changes: 3 additions & 4 deletions epsproc/sphCalc.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ def sphCalc(Lmax = 2, Lmin = 0, res = None, angs = None, XFlag = True, fnType =
Flag for output. If true, output is Xarray. If false, np.arrays
fnType : str, optional, default = 'sph'
Currently can set to 'sph' for SciPy spherical harmonics, or 'lg' for SciPy Legendre polynomials.
23/09/22 - hacked in 'complex' and 'real' here too, but TODO: split by kind and backend.
More backends to follow.
convention : str, optional, default = 'phys'
Set to 'phys' (theta from z-axis) or 'maths' (phi from z-axis) spherical polar conventions.
Expand Down Expand Up @@ -500,7 +501,7 @@ def sphCalc(Lmax = 2, Lmin = 0, res = None, angs = None, XFlag = True, fnType =
for l in np.arange(Lmin,Lmax+1):
for m in np.arange(-l,l+1):
lm.append([l, m])
if fnType == 'sph':
if (fnType == 'sph') or (fnType == 'complex'): # 23/09/22 - hacked in 'complex' here too, but TODO: split by kind and backend
if convention == 'maths':
# Ylm.append(sph_harm(m,l,theta,phi))
Ylm.append(sph_harm(m,l,TP[0],TP[1])) # For SciPy.special.sph_harm() 'maths' convention is enforced.
Expand Down Expand Up @@ -550,7 +551,7 @@ def sphCalc(Lmax = 2, Lmin = 0, res = None, angs = None, XFlag = True, fnType =


# Metadata
if (fnType == 'sph') or (fnType == 'real'):
if (fnType == 'sph') or (fnType == 'real') or (fnType == 'complex'):
# Define meta data
fnName = 'scipy.special.sph_harm' # Should generalise to fn.__name__ - although may be less informative.

Expand Down Expand Up @@ -589,8 +590,6 @@ def sphCalc(Lmax = 2, Lmin = 0, res = None, angs = None, XFlag = True, fnType =
YlmX.attrs['harmonics'] = listFuncs.YLMtype(dtype='Legendre polynomials', normType= None)




# Set units
YlmX.attrs['units'] = 'arb'

Expand Down
5 changes: 4 additions & 1 deletion epsproc/sphPlot.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,9 @@ def sphFromBLMPlot(BLMXin, res = 50, pType = 'a', plotFlag = False, facetDim = N
if hasattr(BLMX,'normType') and (fnType is None):
fnType = BLMX.attrs['normType']
print(f'Using {fnType} betas (from BLMX array).')
elif hasattr(BLMX,'harmonics') and (fnType is None):
fnType = BLMX.attrs['harmonics']['kind']
print(f'Using {fnType} betas (from BLMX array).')
elif fnType is not None:
print(f'Using {fnType} betas (as passed).')
else:
Expand Down Expand Up @@ -361,7 +364,7 @@ def sphSumPlotX(dataIn, pType = 'a', facetDim = 'Eke', backend = 'mpl', convent
theta, phi = np.meshgrid(dataPlot.Theta, dataPlot.Phi)

if dataPlot.min() < 0:
print(f"*** WARNING: plot dataset has min value < 0, min = {dataPlot.min()}. This may be unphysical and/or result in plotting issues.")
print(f"*** WARNING: plot dataset has min value < 0, min = {dataPlot.min().values}. This may be unphysical and/or result in plotting issues.")

# Set data according to type of plot selected
dataPlot = plotTypeSelector(dataPlot, pType = pType, axisUW = axisUW)
Expand Down
11 changes: 10 additions & 1 deletion epsproc/util/listFuncs.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,23 @@ def ADMdimList(sType = 'stacked'):
return ['K','Q','S','t']


def YLMtype(dtype='Complex harmonics',kind='complex',
def YLMtype(dtype=None,kind='complex',
normType= 'ortho', csPhase= True, **kwargs):
"""
Return dict of specified YLM parameters.
"""

# return locals()

# Set long name if required - bit redundant
if dtype is None:
if kind == 'complex':
dtype = 'Complex harmonics'
elif kind == 'real':
dtype = 'Real harmonics'
else:
dtype = 'NA'

# Allow for kwargs and unpack to base dict.
out = {k:v for k,v in locals().items() if k != 'kwargs'}
out.update(kwargs)
Expand Down

0 comments on commit fe42f98

Please sign in to comment.