# This is a shell archive. Save it in a file, remove anything before # this line, and then unpack it by entering "sh file". Note, it may # create directories; files and directories will be owned by you and # have default permissions. # # This archive contains: # # math/py-nifty7 # math/py-nifty7/pkg-descr # math/py-nifty7/Makefile # math/py-nifty7/distinfo # math/py-nifty7/example.py # echo c - math/py-nifty7 mkdir -p math/py-nifty7 > /dev/null 2>&1 echo x - math/py-nifty7/pkg-descr sed 's/^X//' >math/py-nifty7/pkg-descr << '711c023102c7c58fd8bab0489c9949cd' XNIFTy, "Numerical Information Field Theory", is a versatile library designed to Xenable the development of signal inference algorithms that operate regardless of Xthe underlying grids (spatial, spectral, temporal, ...) and their resolutions. XIts object-oriented framework is written in Python, although it accesses Xlibraries written in C++ and C for efficiency. X XWWW: https://ift.pages.mpcdf.de/nifty 711c023102c7c58fd8bab0489c9949cd echo x - math/py-nifty7/Makefile sed 's/^X//' >math/py-nifty7/Makefile << '5ec986f84aa65ebee4dab0ed8250ddb3' XPORTNAME= nifty7 XDISTVERSION= 7.2 XCATEGORIES= math python XMASTER_SITES= CHEESESHOP XPKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX} X XMAINTAINER= yuri@FreeBSD.org XCOMMENT= Numerical Information Field Theory X XLICENSE= GPLv3 XLICENSE_FILE= ${WRKSRC}/COPYING X XPY_DEPENDS= ${PYNUMPY} \ X ${PYTHON_PKGNAMEPREFIX}scipy>0:science/py-scipy@${PY_FLAVOR} XBUILD_DEPENDS= ${PY_DEPENDS} XRUN_DEPENDS= ${PY_DEPENDS} X XUSES= python:3.6+ XUSE_PYTHON= distutils autoplist X XNO_ARCH= yes X X.include 5ec986f84aa65ebee4dab0ed8250ddb3 echo x - math/py-nifty7/distinfo sed 's/^X//' >math/py-nifty7/distinfo << '5646c4dc451b6000fdcc42f00fe8c1e1' XTIMESTAMP = 1627500537 XSHA256 (nifty7-7.2.tar.gz) = c40ed1d64f2160b323af559f4aef5904138bdc1bb6d01c1362464691c1954127 XSIZE (nifty7-7.2.tar.gz) = 183825 5646c4dc451b6000fdcc42f00fe8c1e1 echo x - math/py-nifty7/example.py sed 's/^X//' >math/py-nifty7/example.py << 'f009dafa1dad638a2ff0e074eb0c1492' X#%matplotlib inline Ximport numpy as np Ximport nifty7 as ift Ximport matplotlib.pyplot as plt Xplt.rcParams['figure.dpi'] = 100 Xplt.style.use("seaborn-notebook") X Xdef Curvature(R, N, Sh): X IC = ift.GradientNormController(iteration_limit=50000, X tol_abs_gradnorm=0.1) X # WienerFilterCurvature is (R.adjoint*N.inverse*R + Sh.inverse) plus some handy X # helper methods. X return ift.WienerFilterCurvature(R,N,Sh,iteration_controller=IC,iteration_controller_sampling=IC) X X Xs_space = ift.RGSpace(N_pixels) Xh_space = s_space.get_default_codomain() XHT = ift.HarmonicTransformOperator(h_space, target=s_space) X X# Operators XSh = ift.create_power_operator(h_space, power_spectrum=pow_spec) XR = HT # @ ift.create_harmonic_smoothing_operator((h_space,), 0, 0.02) X X# Fields and data Xsh = Sh.draw_sample_with_dtype(dtype=np.float64) Xnoiseless_data=R(sh) Xnoise_amplitude = np.sqrt(0.2) XN = ift.ScalingOperator(s_space, noise_amplitude**2) X Xn = ift.Field.from_random(domain=s_space, random_type='normal', X std=noise_amplitude, mean=0) Xd = noiseless_data + n Xj = R.adjoint_times(N.inverse_times(d)) Xcurv = Curvature(R=R, N=N, Sh=Sh) XD = curv.inverse X X# Get signal data and reconstruction data Xs_data = HT(sh).val Xm_data = HT(m).val Xd_data = d.val X Xplt.plot(s_data, 'r', label="Signal", linewidth=2) Xplt.plot(d_data, 'k.', label="Data") Xplt.plot(m_data, 'k', label="Reconstruction",linewidth=2) Xplt.title("Reconstruction") Xplt.legend() Xplt.show() X Xplt.plot(s_data - s_data, 'r', label="Signal", linewidth=2) Xplt.plot(d_data - s_data, 'k.', label="Data") Xplt.plot(m_data - s_data, 'k', label="Reconstruction",linewidth=2) Xplt.axhspan(-noise_amplitude,noise_amplitude, facecolor='0.9', alpha=.5) Xplt.title("Residuals") Xplt.legend() Xplt.show() X Xs_power_data = ift.power_analyze(sh).val Xm_power_data = ift.power_analyze(m).val Xplt.loglog() Xplt.xlim(1, int(N_pixels/2)) Xymin = min(m_power_data) Xplt.ylim(ymin, 1) Xxs = np.arange(1,int(N_pixels/2),.1) Xplt.plot(xs, pow_spec(xs), label="True Power Spectrum", color='k',alpha=0.5) Xplt.plot(s_power_data, 'r', label="Signal") Xplt.plot(m_power_data, 'k', label="Reconstruction") Xplt.axhline(noise_amplitude**2 / N_pixels, color="k", linestyle='--', label="Noise level", alpha=.5) Xplt.axhspan(noise_amplitude**2 / N_pixels, ymin, facecolor='0.9', alpha=.5) Xplt.title("Power Spectrum") Xplt.legend() Xplt.show() f009dafa1dad638a2ff0e074eb0c1492 exit