Commit 698d5799 authored by Marco Selig's avatar Marco Selig

pundex improved.

parent c7163ebd
......@@ -1133,7 +1133,8 @@ class space(object):
about.warnings.cprint("WARNING: 'get_power_undex' is deprecated.")
if(pindex is None):
pindex = self.get_power_index(irreducible=False)
return list(np.unravel_index(np.unique(pindex,return_index=True,return_inverse=False)[1],pindex.shape,order='C'))
# return list(np.unravel_index(np.unique(pindex,return_index=True,return_inverse=False)[1],pindex.shape,order='C')) ## < version 0.4
return np.unique(pindex,return_index=True,return_inverse=False)[1]
def set_power_indices(self,**kwargs):
"""
......@@ -2567,7 +2568,7 @@ class rg_space(space):
if(np.any(rho==0)):
raise ValueError(about._errors.cstring("ERROR: empty bin(s).")) ## binning too fine
## power undex
pundex = list(np.unravel_index(np.unique(pindex,return_index=True,return_inverse=False)[1],pindex.shape,order='C'))
pundex = np.unique(pindex,return_index=True,return_inverse=False)[1]
## storage
self.power_indices = {"config":config,"kindex":kindex,"pindex":pindex,"pundex":pundex,"rho":rho} ## alphabetical
about.infos.cprint(" done.")
......@@ -3620,7 +3621,7 @@ class lm_space(space):
kindex = np.arange(self.para[0]+1,dtype=np.int)
rho = 2*kindex+1
pindex = hp.Alm.getlm(self.para[0],i=None)[0] ## l of (l,m)
pundex = list(np.unravel_index(np.unique(pindex,return_index=True,return_inverse=False)[1],pindex.shape,order='C'))
pundex = np.unique(pindex,return_index=True,return_inverse=False)[1]
## storage
self.power_indices = {"kindex":kindex,"pindex":pindex,"pundex":pundex,"rho":rho} ## alphabetical
# about.infos.cprint(" done.")
......@@ -9383,15 +9384,12 @@ class power_operator(diagonal_operator):
if(not np.all(np.array(np.shape(pindex))==self.domain.dim(split=True))):
raise ValueError(about._errors.cstring("ERROR: shape mismatch ( "+str(np.array(np.shape(pindex)))+" <> "+str(self.domain.dim(split=True))+" )."))
## quick pundex
pundex = list(np.unravel_index(np.unique(pindex,return_index=True,return_inverse=False)[1],pindex.shape,order='C'))
pundex = np.unique(pindex,return_index=True,return_inverse=False)[1]
## check explicit pundex
else:
if(not isinstance(pundex,list)):
raise TypeError(about._errors.cstring("ERROR: invalid input."))
elif(len(pundex)!=np.size(self.domain.dim(split=True))):
raise ValueError(about._errors.cstring("ERROR: dimension mismatch ( "+str(len(pundex))+" <> "+str(np.size(self.domain.dim(split=True)))+" )."))
pundex = np.array(pundex,dtype=np.int)
return diag[pundex]
return diag.flatten(order='C')[pundex]
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
......
......@@ -111,10 +111,10 @@ def weight_power(domain,spec,power=1,pindex=None,pundex=None,**kwargs):
pindex = domain.power_indices.get("pindex")
if(pundex is None):
pundex = domain.power_indices.get("pundex")
elif(not isinstance(pundex,list)):
raise TypeError(about._errors.cstring("ERROR: invalid input."))
elif(len(pundex)!=np.size(domain.dim(split=True))):
raise ValueError(about._errors.cstring("ERROR: dimension mismatch ( "+str(len(pundex))+" <> "+str(np.size(domain.dim(split=True)))+" )."))
else:
pundex = np.array(pundex,dtype=np.int)
if(np.size(pundex)!=np.max(pindex,axis=None,out=None)+1):
raise ValueError(about._errors.cstring("ERROR: size mismatch ( "+str(np.size(pundex))+" <> "+str(np.max(pindex,axis=None,out=None)+1)+" )."))
## check explicit power indices
else:
pindex = np.array(pindex,dtype=np.int)
......@@ -122,13 +122,13 @@ def weight_power(domain,spec,power=1,pindex=None,pundex=None,**kwargs):
raise ValueError(about._errors.cstring("ERROR: shape mismatch ( "+str(np.array(np.shape(pindex)))+" <> "+str(domain.dim(split=True))+" )."))
if(pundex is None):
## quick pundex
pundex = list(np.unravel_index(np.unique(pindex,return_index=True,return_inverse=False)[1],pindex.shape,order='C'))
elif(not isinstance(pundex,list)):
raise TypeError(about._errors.cstring("ERROR: invalid input."))
elif(len(pundex)!=np.size(domain.dim(split=True))):
raise ValueError(about._errors.cstring("ERROR: dimension mismatch ( "+str(len(pundex))+" <> "+str(np.size(domain.dim(split=True)))+" )."))
pundex = np.unique(pindex,return_index=True,return_inverse=False)[1]
else:
pundex = np.array(pundex,dtype=np.int)
if(np.size(pundex)!=np.max(pindex,axis=None,out=None)+1):
raise ValueError(about._errors.cstring("ERROR: size mismatch ( "+str(np.size(pundex))+" <> "+str(np.max(pindex,axis=None,out=None)+1)+" )."))
return np.real(domain.calc_weight(domain.enforce_power(spec,size=np.max(pindex,axis=None,out=None)+1)[pindex],power=power)[pundex])
return np.real(domain.calc_weight(domain.enforce_power(spec,size=np.max(pindex,axis=None,out=None)+1)[pindex],power=power).flatten(order='C')[pundex])
##-----------------------------------------------------------------------------
......@@ -441,14 +441,9 @@ def infer_power(m,domain=None,Sk=None,D=None,pindex=None,pundex=None,kindex=None
raise ValueError(about._errors.cstring("ERROR: invalid input."))
else:
pindex = domain.power_indices.get("pindex")
pundex = domain.power_indices.get("pundex")
kindex = domain.power_indices.get("kindex")
rho = domain.power_indices.get("rho")
if(pundex is None):
pundex = domain.power_indices.get("pundex")
elif(not isinstance(pundex,list)):
raise TypeError(about._errors.cstring("ERROR: invalid input."))
elif(len(pundex)!=np.size(domain.dim(split=True))):
raise ValueError(about._errors.cstring("ERROR: dimension mismatch ( "+str(len(pundex))+" <> "+str(np.size(domain.dim(split=True)))+" )."))
## check explicit power indices
else:
pindex = np.array(pindex,dtype=np.int)
......@@ -458,11 +453,9 @@ def infer_power(m,domain=None,Sk=None,D=None,pindex=None,pundex=None,kindex=None
rho = np.array(rho,dtype=np.int)
if(pundex is None):
## quick pundex
pundex = list(np.unravel_index(np.unique(pindex,return_index=True,return_inverse=False)[1],pindex.shape,order='C'))
elif(not isinstance(pundex,list)):
raise TypeError(about._errors.cstring("ERROR: invalid input."))
elif(len(pundex)!=np.size(domain.dim(split=True))):
raise ValueError(about._errors.cstring("ERROR: dimension mismatch ( "+str(len(pundex))+" <> "+str(np.size(domain.dim(split=True)))+" )."))
pundex = np.unique(pindex,return_index=True,return_inverse=False)[1]
else:
pundex = np.array(pundex,dtype=np.int)
## check projection operator
if(Sk is None):
Sk = projection_operator(domain,assign=pindex)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment