Commit 0e58088a authored by Marco Selig's avatar Marco Selig

interpolate_power implemented; several minor adjustments.

parent 7cf3fd1c
......@@ -2393,10 +2393,10 @@ class rg_space(space):
if(not np.all(np.isfinite(spec))):
about.warnings.cprint("WARNING: infinite value(s).")
## check positivity (excluding null)
if(np.any(spec==0)):
about.warnings.cprint("WARNING: nonpositive value(s).")
if(np.any(spec<0)):
raise ValueError(about._errors.cstring("ERROR: nonpositive value(s)."))
elif(np.any(spec==0)):
about.warnings.cprint("WARNING: nonpositive value(s).")
if(size is None):
## explicit kindex
......@@ -3488,10 +3488,10 @@ class lm_space(space):
if(not np.all(np.isfinite(spec))):
about.warnings.cprint("WARNING: infinite value(s).")
## check positivity (excluding null)
if(np.any(spec==0)):
about.warnings.cprint("WARNING: nonpositive value(s).")
if(np.any(spec<0)):
raise ValueError(about._errors.cstring("ERROR: nonpositive value(s)."))
elif(np.any(spec==0)):
about.warnings.cprint("WARNING: nonpositive value(s).")
size = self.para[0]+1 ## lmax+1
## drop imaginary part
......@@ -3689,7 +3689,7 @@ class lm_space(space):
if(self.datatype==np.complex64):
x = gl.synalm_f(arg[1],lmax=lmax,mmax=lmax)
else:
#x = gl.synalm(spec,lmax=lmax,mmax=lmax)
#x = gl.synalm(arg[1],lmax=lmax,mmax=lmax)
x = hp.synalm(arg[1],lmax=lmax,mmax=lmax)
return x
......@@ -4307,10 +4307,10 @@ class gl_space(space):
if(not np.all(np.isfinite(spec))):
about.warnings.cprint("WARNING: infinite value(s).")
## check positivity (excluding null)
if(np.any(spec==0)):
about.warnings.cprint("WARNING: nonpositive value(s).")
if(np.any(spec<0)):
raise ValueError(about._errors.cstring("ERROR: nonpositive value(s)."))
elif(np.any(spec==0)):
about.warnings.cprint("WARNING: nonpositive value(s).")
size = self.para[0] ## nlat
......@@ -4932,10 +4932,10 @@ class hp_space(space):
if(not np.all(np.isfinite(spec))):
about.warnings.cprint("WARNING: infinite value(s).")
## check positivity (excluding null)
if(np.any(spec==0)):
about.warnings.cprint("WARNING: nonpositive value(s).")
if(np.any(spec<0)):
raise ValueError(about._errors.cstring("ERROR: nonpositive value(s)."))
elif(np.any(spec==0)):
about.warnings.cprint("WARNING: nonpositive value(s).")
size = 3*self.para[0] ## 3*nside
......
This diff is collapsed.
......@@ -64,8 +64,8 @@ def smooth_power(power, k, exclude=1, smooth_length=None):
pbinned = pbinned / counter
nmirror = int(5 * smooth_length / dk) + 2
zpbinned = np.r_[(2 * pbinned[0] - pbinned[1:nmirror][::-1]), pbinned,
(2 * pbinned[-1] - pbinned[-nmirror:-1][::-1])]
zpbinned = np.r_[np.exp(2 * np.log(pbinned[0]) - np.log(pbinned[1:nmirror][::-1])), pbinned,
np.exp(2 * np.log(pbinned[-1])- np.log(pbinned[-nmirror:-1][::-1]))]
zpbinned = np.maximum(0, zpbinned)
tpbinned = np.fft.fftshift(np.fft.fft(zpbinned))
......@@ -101,7 +101,7 @@ def smooth_power_bf(power, k, exclude=1, smooth_length=None):
smooth_length = k[1]-k[0]
nmirror = int(5*smooth_length/(k[1]-k[0]))+2
mpower = np.r_[(2*power[0]-power[1:nmirror][::-1]),power,(2*power[-1]-power[-nmirror:-1][::-1])]
mpower = np.r_[np.exp(2*np.log(power[0])-np.log(power[1:nmirror][::-1])),power,np.exp(2*np.log(power[-1])-np.log(power[-nmirror:-1][::-1]))]
mk = np.r_[(2*k[0]-k[1:nmirror][::-1]),k,(2*k[-1]-k[-nmirror:-1][::-1])]
mdk = np.r_[0.5*(mk[1]-mk[0]),0.5*(mk[2:]-mk[:-2]),0.5*(mk[-1]-mk[-2])]
......@@ -143,7 +143,7 @@ def smooth_power_2s(power, k, exclude=1, smooth_length=None):
smooth_length = k[1]-k[0]
nmirror = int(5*smooth_length/(k[1]-k[0]))+2
mpower = np.r_[(2*power[0]-power[1:nmirror][::-1]),power,(2*power[-1]-power[-nmirror:-1][::-1])]
mpower = np.r_[np.exp(2*np.log(power[0])-np.log(power[1:nmirror][::-1])),power,np.exp(2*np.log(power[-1])-np.log(power[-nmirror:-1][::-1]))]
mk = np.r_[(2*k[0]-k[1:nmirror][::-1]),k,(2*k[-1]-k[-nmirror:-1][::-1])]
mdk = np.r_[0.5*(mk[1]-mk[0]),0.5*(mk[2:]-mk[:-2]),0.5*(mk[-1]-mk[-2])]
......
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