Commit 774f7002 authored by Jakob Knollmueller's avatar Jakob Knollmueller

plotting powerspectra as well

parent a7371557
from sugar import build_problem, problem_iteration
from sugar import build_starblade, starblade_iteration
import nifty4 as ift
import numpy as np
from matplotlib import rc
......@@ -30,14 +30,14 @@ if __name__ == '__main__':
d = ift.exp(s) + ift.exp(u)
data = d.val
energy1 = build_problem(data,1.25)
energy2 = build_problem(data,1.5)
energy3 = build_problem(data,1.75)
energy1 = build_starblade(data,1.25)
energy2 = build_starblade(data,1.5)
energy3 = build_starblade(data,1.75)
for i in range(20):
energy1 = problem_iteration(energy1)
energy2 = problem_iteration(energy2)
energy3 = problem_iteration(energy3)
energy1 = starblade_iteration(energy1)
energy2 = starblade_iteration(energy2)
energy3 = starblade_iteration(energy3)
size = 15
plt.figure()
......@@ -107,3 +107,29 @@ if __name__ == '__main__':
# plt.ylim(1e-0)
plt.savefig('1d_data.pdf')
plt.figure()
binbounds = ift.PowerSpace.useful_binbounds(energy2.FFT.domain[0],logarithmic=False, nbin=100)
power1 = ift.power_analyze(energy2.FFT.inverse((energy1.s)),binbounds=binbounds)
power2 = ift.power_analyze(energy2.FFT.inverse((energy2.s)),binbounds=binbounds)
power3 = ift.power_analyze(energy2.FFT.inverse((energy3.s)),binbounds=binbounds)
real_power = ift.power_analyze(sh)
power_d = ift.power_analyze(energy2.FFT.inverse(ift.log(energy2.d)),binbounds=binbounds)
# power_u = ift.power_analyze(energy2.FFT.inverse(ift.exp(energy2.u)),binbounds=binbounds)
k_lengths = power1.domain[0].k_lengths
plt.plot(k_lengths, p_spec(k_lengths*1024.)*1024**2, 'k-', label='theoretical')
plt.plot(k_lengths, power_d.val, 'k:', label='data')
plt.plot(k_lengths, power1.val, 'k-', label=(r'$\alpha = 1.25$'), alpha=0.6)
plt.plot(k_lengths, power2.val, 'k-', label=(r'$\alpha = 1.5$'),alpha=0.3)
plt.plot(k_lengths, power3.val, 'k-', label=(r'$\alpha = 1.75$'), alpha=0.15)
# plt.plot(k_lengths, power_u.val, 'k:',label='point-like')
plt.legend()
plt.yscale('log')
plt.xscale('log')
plt.title('power spectra',size=15)
plt.ylabel('power',size=15)
plt.xlabel('harmonic mode',size=15)
plt.savefig('1d_power.pdf')
from sugar import build_problem, problem_iteration, load_data
from sugar import build_starblade, starblade_iteration#
from nifty4 import *
import nifty4 as ift
import numpy as np
from matplotlib import rc
rc('font',**{'family':'serif','serif':['Palatino']})
......@@ -15,19 +16,19 @@ from astropy.io import fits
np.random.seed(42)
if __name__ == '__main__':
path = 'hst_05195_01_wfpc2_f702w_pc_sci.fits'
path = 'demos/data/hst_05195_01_wfpc2_f702w_pc_sci.fits'
data = fits.open(path)[1].data
data = data.clip(min=0.001)
data = np.ndarray.astype(data, float)
alpha = 1.25
alpha = 1.28
myEnergy = build_problem(data, alpha=alpha)
myEnergy = build_starblade(data, alpha=alpha)
for i in range(10):
myEnergy = problem_iteration(myEnergy)
myEnergy = starblade_iteration(myEnergy)
A = FFTSmoothingOperator(myEnergy.s.domain, sigma=2.)
plt.magma()
size = 15
......@@ -131,9 +132,19 @@ if __name__ == '__main__':
plt.close()
plt.figure()
power = power_analyze(exp(myEnergy.s))
k_lengths = power.domain.k_lenghts
plt.plot(power.val, k_lengths, 'k-')
binbounds = ift.PowerSpace.useful_binbounds(myEnergy.FFT.domain[0],logarithmic=False)
power = ift.power_analyze(myEnergy.FFT.inverse(exp(myEnergy.s)),binbounds=binbounds)
power_d = ift.power_analyze(myEnergy.FFT.inverse(myEnergy.d),binbounds=binbounds)
power_u = ift.power_analyze(myEnergy.FFT.inverse(exp(myEnergy.u)),binbounds=binbounds)
k_lengths = power.domain[0].k_lengths
plt.plot(k_lengths, power.val, 'k-', label='diffuse')
plt.plot(k_lengths, power_d.val, 'k--', label='data')
plt.plot(k_lengths, power_u.val, 'k:',label='point-like')
plt.legend()
plt.yscale('log')
plt.xscale('log')
plt.title('diffuse power')
plt.title('power spectra',size=15)
plt.ylabel('power',size=15)
plt.xlabel('harmonic mode',size=15)
plt.savefig('hubble_power.pdf')
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