@@ -35,6 +35,7 @@ from numcosmo_py.plotting.tools import add_ellipse_from_ellipticity
35
35
36
36
Ncm.cfg_init()
37
37
38
+
38
39
Omega_b = 0.05
39
40
Omega_c = 0.25
40
41
Omega_k = 0.0
@@ -43,11 +44,11 @@ H0 = 70.0
43
44
# Create a cosmology object
44
45
cosmo = Nc.HICosmoDEXcdm.new()
45
46
cosmo.omega_x2omega_k()
46
- cosmo.param_set_by_name( "Omegab", Omega_b)
47
- cosmo.param_set_by_name( "Omegac", Omega_c)
48
- cosmo.param_set_by_name( "Omegak", Omega_k)
49
- cosmo.param_set_by_name( "H0", H0)
50
- cosmo.param_set_by_name( "w", -1.0)
47
+ cosmo[ "Omegab"] = Omega_b
48
+ cosmo[ "Omegac"] = Omega_c
49
+ cosmo[ "Omegak"] = Omega_k
50
+ cosmo[ "H0"] = H0
51
+ cosmo[ "w"] = -1.0
51
52
52
53
dist = Nc.Distance.new(100.0)
53
54
dist.prepare(cosmo)
@@ -80,7 +81,7 @@ The cluster's right ascension (RA) and declination (Dec) are set to $12.34^\circ
80
81
81
82
``` {python}
82
83
83
- # Set parametners
84
+ # Set parameters
84
85
mass_delta = 200
85
86
cluster_M = 2.0e16
86
87
cluster_c = 4.0
@@ -94,12 +95,12 @@ density_profile = Nc.HaloDensityProfileNFW.new(
94
95
surface_mass_density = Nc.WLSurfaceMassDensity.new(dist)
95
96
halo_position = Nc.HaloPosition.new(dist)
96
97
97
- density_profile.param_set_by_name( "cDelta", cluster_c)
98
- density_profile.param_set_by_name( "log10MDelta", np.log10(cluster_M) )
98
+ density_profile[ "cDelta"] = cluster_c
99
+ density_profile[ "log10MDelta"] = np.log10(cluster_M)
99
100
100
- halo_position.param_set_by_name( "ra", cluster_ra)
101
- halo_position.param_set_by_name( "dec", cluster_dec)
102
- halo_position.param_set_by_name( "z", cluster_z)
101
+ halo_position[ "ra"] = cluster_ra
102
+ halo_position[ "dec"] = cluster_dec
103
+ halo_position[ "z"] = cluster_z
103
104
104
105
surface_mass_density.prepare(cosmo)
105
106
halo_position.prepare(cosmo)
@@ -127,7 +128,7 @@ The specific values are as follows:
127
128
- Declination (Dec): $[ -55.273^\circ, -54.973^\circ] $
128
129
- ** Galaxy shape distribution** :
129
130
- ** Intrinsic ellipticity dispersion** : $1.0 \times 10^{-8}$
130
- - ** Ellipticity mesurement error** : $1.0 \times 10^{-8}$
131
+ - ** Ellipticity measurement error** : $1.0 \times 10^{-8}$
131
132
132
133
``` {python}
133
134
@@ -150,10 +151,7 @@ z_true = Nc.GalaxySDTrueRedshiftLSSTSRD.new(galaxy_true_z_min, galaxy_true_z_max
150
151
z_dist = Nc.GalaxySDObsRedshiftGauss.new(z_true)
151
152
s_dist = Nc.GalaxySDShapeGauss.new()
152
153
153
- s_dist.param_set_by_name("e-rms", galaxy_shape_e_rms)
154
- s_dist.param_set_by_name("e-sigma", galaxy_shape_e_sigma)
155
-
156
- s_dist.set_models(cosmo, halo_position)
154
+ s_dist["e-rms"] = galaxy_shape_e_rms
157
155
158
156
pass
159
157
```
@@ -167,14 +165,14 @@ We then set the minimum and maximum radii for the weak lensing analysis to focus
167
165
168
166
``` {python}
169
167
min_r, max_r = 0.3, 3.0
170
- cluster = Nc.DataClusterWL.new(s_dist, z_dist, p_dist )
168
+ cluster = Nc.DataClusterWL.new()
171
169
cluster.set_cut(min_r, max_r)
172
170
```
173
171
### Model-Set
174
172
175
173
We create an ` Nc.MSet ` object to encapsulate the models defined above.
176
174
The ` MSet ` object serves as the main container for all models in a given analysis.
177
- We add the cosmological model, the cluster profile and positon models, the galaxy distribution models, and the weak lensing model to the model set.
175
+ We add the cosmological model, the cluster profile and position models, the galaxy distribution models, and the weak lensing model to the model set.
178
176
179
177
This comprehensive model set allows us to manage and run simulations, ensuring that all components interact correctly to produce the desired weak lensing data.
180
178
@@ -186,8 +184,8 @@ mset = Ncm.MSet.new_array(
186
184
surface_mass_density,
187
185
halo_position,
188
186
s_dist,
189
- z_true,
190
187
z_dist,
188
+ p_dist,
191
189
]
192
190
)
193
191
@@ -207,18 +205,32 @@ The mock data, consisting of $200$ galaxies around the cluster, is then generate
207
205
``` {python}
208
206
seed = 1235
209
207
n_galaxies = 200
208
+ sigma_z = 0.03
210
209
211
210
rng = Ncm.RNG.seeded_new("mt19937", seed)
212
211
213
- cluster.gen_obs(
214
- cosmo,
215
- density_profile,
216
- surface_mass_density,
217
- halo_position,
218
- n_galaxies,
219
- rng,
220
- Nc.GalaxyWLObsCoord.EUCLIDEAN,
212
+ z_data = Nc.GalaxySDObsRedshiftData.new(z_dist)
213
+ p_data = Nc.GalaxySDPositionData.new(p_dist, z_data)
214
+ s_data = Nc.GalaxySDShapeData.new(s_dist, p_data)
215
+
216
+ obs = Nc.GalaxyWLObs.new(
217
+ Nc.GalaxyWLObsCoord.EUCLIDEAN, n_galaxies, list(s_data.required_columns())
221
218
)
219
+
220
+ for i in range(n_galaxies):
221
+ z_dist.gen(mset, z_data, sigma_z, rng)
222
+ p_dist.gen(mset, p_data, rng)
223
+ s_dist.gen(
224
+ mset,
225
+ s_data,
226
+ galaxy_shape_e_sigma,
227
+ galaxy_shape_e_sigma,
228
+ Nc.GalaxyWLObsCoord.EUCLIDEAN,
229
+ rng,
230
+ )
231
+ s_data.write_row(obs, i)
232
+
233
+ cluster.set_obs(obs)
222
234
```
223
235
224
236
The mock data can be retrieved from the ` cluster ` object and used for further analysis.
@@ -277,8 +289,8 @@ add_ellipse_from_ellipticity(
277
289
ax,
278
290
obs_df["ra"],
279
291
obs_df["dec"],
280
- obs_df["e1_int "],
281
- obs_df["e2_int "],
292
+ obs_df["epsilon_int_1 "],
293
+ obs_df["epsilon_int_2 "],
282
294
ellipse_scale=0.005,
283
295
edgecolor="red",
284
296
)
@@ -287,8 +299,8 @@ add_ellipse_from_ellipticity(
287
299
ax,
288
300
obs_df["ra"],
289
301
obs_df["dec"],
290
- obs_df["e1 "],
291
- obs_df["e2 "],
302
+ obs_df["epsilon_obs_1 "],
303
+ obs_df["epsilon_obs_2 "],
292
304
ellipse_scale=0.005,
293
305
edgecolor="blue",
294
306
)
@@ -321,25 +333,31 @@ This allows us to explore how changes in these properties affect the weak lensin
321
333
322
334
323
335
def gen_galaxies(halo_ra: float, halo_dec: float, halo_mass: float) -> pd.DataFrame:
324
- halo_position.param_set_by_name("ra", halo_ra)
325
- halo_position.param_set_by_name("dec", halo_dec)
326
- density_profile.param_set_by_name("log10MDelta", np.log10(halo_mass))
336
+ rng = Ncm.RNG.seeded_new("mt19937", 1235)
337
+ halo_position["ra"] = halo_ra
338
+ halo_position["dec"] = halo_dec
339
+ density_profile["log10MDelta"] = np.log10(halo_mass)
327
340
328
341
surface_mass_density.prepare(cosmo)
329
342
halo_position.prepare(cosmo)
330
343
331
- rng = Ncm.RNG.seeded_new("mt19937", 1235)
332
- cluster.gen_obs(
333
- cosmo,
334
- density_profile,
335
- surface_mass_density,
336
- halo_position,
337
- n_galaxies,
338
- rng,
339
- Nc.GalaxyWLObsCoord.EUCLIDEAN,
344
+ obs = Nc.GalaxyWLObs.new(
345
+ Nc.GalaxyWLObsCoord.EUCLIDEAN, n_galaxies, list(s_data.required_columns())
340
346
)
341
347
342
- obs = cluster.peek_obs()
348
+ for i in range(n_galaxies):
349
+ z_dist.gen(mset, z_data, sigma_z, rng)
350
+ p_dist.gen(mset, p_data, rng)
351
+ s_dist.gen(
352
+ mset,
353
+ s_data,
354
+ galaxy_shape_e_sigma,
355
+ galaxy_shape_e_sigma,
356
+ Nc.GalaxyWLObsCoord.EUCLIDEAN,
357
+ rng,
358
+ )
359
+ s_data.write_row(obs, i)
360
+
343
361
columns = obs.peek_columns()
344
362
345
363
obs_dict = {}
@@ -393,8 +411,8 @@ for i, ra_shift in enumerate(ra_shifts):
393
411
ax,
394
412
obs_df["ra"],
395
413
obs_df["dec"],
396
- obs_df["e1 "],
397
- obs_df["e2 "],
414
+ obs_df["epsilon_obs_1 "],
415
+ obs_df["epsilon_obs_2 "],
398
416
ellipse_scale=0.005,
399
417
edgecolor="blue",
400
418
)
@@ -452,8 +470,8 @@ for i, mass_shift in enumerate(mass_shifts):
452
470
ax,
453
471
obs_df["ra"],
454
472
obs_df["dec"],
455
- obs_df["e1 "],
456
- obs_df["e2 "],
473
+ obs_df["epsilon_obs_1 "],
474
+ obs_df["epsilon_obs_2 "],
457
475
ellipse_scale=0.005,
458
476
edgecolor="blue",
459
477
)
0 commit comments