Esempio n. 1
0
x = numpy.random.uniform(x_st, x_ed, total_num)

a1, a2 = 0, -0.02
profile_params = [a1, a2]

# shear field
shear_field = a1 + a2 * x

# the galactic parameters
h5f = h5py.File(parent_path + "param_slope.hdf5", "w")

h5f["/FIELD_g"] = shear_field

h5f["/x"] = x

mag_i = tool_box.mag_generator(total_num, 20, 23.5)
flux_i = tool_box.mag_to_flux(mag_i)
h5f["/mag"] = mag_i
h5f["/flux"] = flux_i
print(flux_i.min(), flux_i.max())

# Plot
img = Image_Plot()
img.subplots(1, 3)
img.set_style()
inverse = range(nx - 1, -1, -1)

norm_g = plt.Normalize(vmin=numpy.min(shear_field_ch),
                       vmax=numpy.max(shear_field_ch))
cmap_g = plt.get_cmap('jet')
Esempio n. 2
0
shear_st = m * rank
shear_ed = m * (rank + 1)
if rank == cpus - 1:
    shear_ed += n

for shear_id in range(shear_st, shear_ed):
    h5_path = para_path + '/para_%d.hdf5' % shear_id

    f = h5py.File(h5_path, "w")

    # magnitude & flux
    flux, mag = numpy.zeros((chip_num * stamp_num, )), numpy.zeros(
        (chip_num * stamp_num, ))
    for i in range(loops):
        time.sleep(rank * 0.05)
        mag_i = tool_box.mag_generator(num_i * stamp_num, mag_s, mag_e)
        # mag_i = numpy.ones((num_i*stamp_num,))*mag_e
        flux_i = tool_box.mag_to_flux(mag_i)
        sp, ep = i * num_i * stamp_num, (i + 1) * num_i * stamp_num
        mag[sp:ep] = mag_i
        flux[sp:ep] = flux_i

        print(rank, mag_i.mean(), mag_i.max(), mag_i.min(), flux_i.mean(),
              flux_i.max(), flux_i.min())

    plt.figure(figsize=(8, 6))
    f["/flux"] = numpy.float32(flux)
    f["/mag"] = numpy.float32(mag)
    f.close()

    pic = para_path + "/pic/mag_%d.png" % shear_id
Esempio n. 3
0
numprocs = comm.Get_size()

data_path = argv[1]

rng = numpy.random.RandomState((rank + 1) * 1000)

time.sleep(rank * 0.05)

chip_num = 2000
stamp_num = 10000

t1 = time.time()

# magnitude & flux
mag_s, mag_e = 21, 25.5
mag = tool_box.mag_generator(chip_num * stamp_num, mag_s,
                             mag_e).astype(dtype=numpy.float32)
flux = tool_box.mag_to_flux(mag).astype(dtype=numpy.float32)

# galactic radius
radius_s, radius_e = 0.75, 1.87

radius = tool_box.radii_from_mags(mag, radius_s,
                                  radius_e).astype(dtype=numpy.float32) / 0.187

rand_seed = rng.randint(1, 4094967296, size=chip_num)

if rank == 0:
    if not os.path.exists(data_path):
        os.makedirs(data_path)
    if not os.path.exists(data_path + "/pic"):
        os.makedirs(data_path + "/pic")
Esempio n. 4
0
ra = gal_coord[0]
dec = gal_coord[1]
print(ra.min(), ra.max(), ra.mean())
print(dec.min(), dec.max(), dec.mean())

h5f["/ra"] = ra
h5f["/dec"] = dec
h5f["/radius"] = gal_coord[2]

g, g1, g2 = MCMC_program.shear_field(profile_params, ra, dec)
h5f["/g"] = g
h5f["/g1"] = g1
h5f["/g2"] = g2
print(g1.min(), g1.max())

mag_i = tool_box.mag_generator(num_each_expo, 20, 23.5)
flux_i = tool_box.mag_to_flux(mag_i)
h5f["/mag"] = mag_i
h5f["/flux"] = flux_i
print(flux_i.min(), flux_i.max())

img = Image_Plot()
img.subplots(1, 3)

norm_g = plt.Normalize(vmin=numpy.min(g), vmax=numpy.max(g))
cmap_g = plt.get_cmap('jet')
img.axs[0][0].scatter(ra, dec, color=cmap_g(norm_g(g)), s=1)
sm = plt.cm.ScalarMappable(cmap=cmap_g, norm=norm_g)
sm._A = []
plt.colorbar(sm, ax=img.axs[0][0])
Esempio n. 5
0
my_home = os.popen("echo $HOME").readlines()[0][:-1]
path.append('%s/work/mylib/' % my_home)
path.append("E:/Github/astrophy-research/mylib/")
from plot_tool import Image_Plot
import tool_box
import h5py
from subprocess import Popen
from Fourier_Quad import Fourier_Quad

parent_path = "/mnt/perc/hklee/multi_shear_dectect/"
shear_num = 3
source_num = 1000000
for i in range(shear_num):

    h5f = h5py.File(parent_path + "param_%d.hdf5" % i, "w")
    mag = tool_box.mag_generator(source_num, 22, 25)
    flux = tool_box.mag_to_flux(mag)
    h5f["/flux"] = flux
    h5f.close()

print("Begin simu...")
cmd = "mpirun -np 20 ./simu"
a = Popen(cmd, shell=True)
a.wait()

fq = Fourier_Quad(3, 123)

for i in range(shear_num):
    h5f = h5py.File(parent_path + "result_%d.hdf5" % i, "r")
    data = h5f["/data"].value
    mg1 = data[:, 0]