%load_ext autoreload
%autoreload 2
%matplotlib inline
import os
import fpfs
import galsim
import numpy as np
import matplotlib.pylab as plt
from astropy.visualization import simple_norm
from mpl_toolkits.axes_grid1 import ImageGrid
import numpy.lib.recfunctions as rfn
import matplotlib as mpl
mpl.rcParams['axes.linewidth'] = 2.0 #set the value globally
ngrid = 256
shear_value = 0.02
scale = 0.168
outDir='galaxy_basicCenter_psf60'
psfInt = galsim.Moffat(
beta=3.5, fwhm=0.6, trunc=0.6 * 4.0
).shear(e1=0.02, e2=-0.02)
psf_data = psfInt.shift(0.5 * scale, 0.5 * scale).drawImage(nx=ngrid, ny=ngrid, scale=scale).array
seed = 2
gname = "g1-1"
gal_data = fpfs.simutil.make_isolate_sim(
gal_type="mixed",
psf_obj=psfInt,
gname=gname,
seed=seed,
ny=ngrid,
nx=ngrid,
scale=scale,
do_shift=False,
nrot_per_gal=4,
shear_value=shear_value,
)[0]
plt.close()
plt.imshow(gal_data,aspect='equal',cmap='RdYlBu_r',origin='lower',interpolation='None',\
norm=simple_norm(gal_data,'asinh',asinh_a=0.1,min_cut=-0.01,max_cut=0.3))
2024/10/10 20:03:39 --- Creating Mixed galaxy profiles
2024/10/10 20:03:39 --- Processing for g1-1, and shear is 0.02.
WARNING: AstropyDeprecationWarning: "min_cut" was deprecated in version 6.1 and will be removed in a future version. Use argument "vmin" instead. [warnings]
2024/10/10 20:03:40 --- AstropyDeprecationWarning: "min_cut" was deprecated in version 6.1 and will be removed in a future version. Use argument "vmin" instead.
WARNING: AstropyDeprecationWarning: "max_cut" was deprecated in version 6.1 and will be removed in a future version. Use argument "vmax" instead. [warnings]
2024/10/10 20:03:40 --- AstropyDeprecationWarning: "max_cut" was deprecated in version 6.1 and will be removed in a future version. Use argument "vmax" instead.
<matplotlib.image.AxesImage at 0x7fa84bddf220>
rcut = 16
psf_data = psfInt.shift(0.5 * scale, 0.5 * scale).drawImage(nx=rcut*2, ny=rcut*2, scale=scale).array
p1 = ngrid //2 - rcut
p2 = ngrid //2 - rcut
psf_data2 = np.pad(psf_data, ((p1, p1), (p2, p2)))
fpTask = fpfs.image.measure_source(psf_data, sigma_arcsec=0.7, pix_scale=scale)
coords = fpTask.detect_sources(
gal_data,
psf_data2,
thres=0.01,
thres2=-0.00,
)
print(coords.shape)
mms = fpTask.measure(gal_data, coords)
mms = fpTask.get_results(mms)
ells= fpfs.catalog.fpfs_m2e(mms,const=2000)
resp=np.average(ells['fpfs_R1E'])
shear=np.average(ells['fpfs_e1'])/resp
print(shear)
(16, 2)
0.019992876518769367
2024/10/10 20:03:40 --- Unable to initialize backend 'rocm': module 'jaxlib.xla_extension' has no attribute 'GpuAllocatorConfig'
2024/10/10 20:03:40 --- Unable to initialize backend 'tpu': INTERNAL: Failed to open libtpu.so: libtpu.so: cannot open shared object file: No such file or directory
2024/10/10 20:03:40 --- Order of the shear estimator: nnord=4
2024/10/10 20:03:40 --- Shapelet kernel in configuration space: sigma= 0.7000 arcsec
2024/10/10 20:03:40 --- Detection kernel in configuration space: sigma= 0.7000 arcsec
2024/10/10 20:03:40 --- Maximum |k| is 1.767
/home/docs/checkouts/readthedocs.org/user_builds/fpfs/envs/latest/lib/python3.10/site-packages/jax/_src/core.py:700: FutureWarning: unhashable type: <class 'jax._src.interpreters.partial_eval.DynamicJaxprTracer'>. Attempting to hash a tracer will lead to an error in a future JAX release.
warnings.warn(
/home/docs/checkouts/readthedocs.org/user_builds/fpfs/envs/latest/lib/python3.10/site-packages/jax/_src/core.py:700: FutureWarning: unhashable type: <class 'jax._src.interpreters.partial_eval.DynamicJaxprTracer'>. Attempting to hash a tracer will lead to an error in a future JAX release.
warnings.warn(