Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b2ab0a4

Browse files
authored
Improving richness analysis tools (#241)
* Improving documentation and fixing typos. * Removing bootstrap after FitMC; adding Poisson noise; improving resample. * Updating stubs and tests. * Adding ncm_pln1d (Poisson-LogNormal) with tests and conditional testing. * Adding cumulative calculation support and tests. * Creating abstract Richness interface; implementing Ascaso and Extended models with tests. * New cluster richness analysis package; reorganizing tests. * Fixing exception handling and logging. * Improving diagnostics and integer R diagnostics. * Adding support for noise, obs_params (Mobs, zobs), and persistence. * Fixing tests and unsupported flags. * Code formatting (black) and cleanup. * Refining Python requirements and CI: - conditional/skipped tests (astropy, getdist, healpy) - separating sphere_map suite (no MALLOC_PERTURB_) - relaxing timing requirements - simplifying/installing reqs - macOS adjustments and matplotlib via brew - pytest debugging * Removing leftovers and debug calls. * Removing Amazon LLM files.
1 parent 5ab221e commit b2ab0a4

174 files changed

Lines changed: 12160 additions & 1601 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build_check.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
run: |
2727
sudo apt-get update
2828
sudo apt-get install gobject-introspection gir1.2-glib-2.0 gir1.2-glib-2.0-dev libgirepository-2.0-dev gcc gfortran pkg-config libglib2.0-dev libgmp3-dev libmpfr-dev libgsl0-dev libfftw3-dev libopenblas-dev libflint-dev libcfitsio-dev libfyaml-dev libnlopt-dev libhdf5-dev libopenmpi-dev libcairo2-dev uncrustify
29-
pip install meson ninja pytest pytest-tap pytest-lazy-fixtures numpy pygobject --break-system-packages
29+
pip install meson ninja pytest pytest-tap pytest-lazy-fixtures numpy scipy pygobject typer matplotlib --break-system-packages
3030
- name: Ensure clear Jupyter Notebooks
3131
uses: ResearchSoftwareActions/[email protected]
3232
- name: Configure NumCosmo
@@ -90,10 +90,10 @@ jobs:
9090
- name: Brew install pre-requisites
9191
run: |
9292
brew uninstall --ignore-dependencies --force [email protected]
93-
brew install python3 gobject-introspection pygobject3 numpy meson ninja gsl gmp mpfr fftw cfitsio libfyaml nlopt gfortran glib openblas
93+
brew install python3 gobject-introspection pygobject3 numpy scipy python-matplotlib meson ninja gsl gmp mpfr fftw cfitsio libfyaml nlopt gfortran glib openblas
9494
- name: Pip install pre-requisites
9595
run: |
96-
python3 -m pip install pytest pytest-tap pytest-lazy-fixtures --break-system-packages
96+
python3 -m pip install pytest pytest-tap pytest-lazy-fixtures typer pydantic --break-system-packages
9797
- name: Ensure clear Jupyter Notebooks
9898
uses: ResearchSoftwareActions/[email protected]
9999
- name: Fix libfyaml.pc
@@ -137,6 +137,8 @@ jobs:
137137
cd examples
138138
python3 example_simple.py
139139
python3 example_cbe.py
140+
cd ..
141+
pytest -xvs tests/python --run-sphere-map -m sphere_map
140142
- name: Check NumCosmo
141143
run: |
142144
meson test -C build --num-processes=2 || (cat build/meson-logs/testlog.txt && exit 1)

meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,7 @@ endif
830830
#######################################################################################
831831

832832
python_module = import('python')
833-
python = python_module.find_installation('python3', modules: ['pytest', 'pytest_lazy_fixtures', 'gi'])
833+
python = python_module.find_installation('python3')
834834

835835
python_pip = python_module.find_installation(
836836
'python3',

numcosmo/data/nc_data_bao.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ G_BEGIN_DECLS
6565
* @NC_DATA_BAO_DVR_DTDH_DESI_DR1_2024: Adame at el., arXiv:2404.03000, table 18
6666
* @NC_DATA_BAO_DVR_DTDH_DESI_DR2_2025: Abdul Karim et al., arXiv:2503.14738, table IV
6767
*
68-
* Available BAO datasets identifiers.
68+
* Enumeration of available BAO (Baryon Acoustic Oscillations) datasets.
69+
*
6970
* These enumerate different Baryon Acoustic Oscillation observations from various
7071
* surveys and releases. Each identifier corresponds to a specific measurement type
7172
* and publication referenced in the parameter documentation above.

numcosmo/data/nc_data_cluster_mass_rich.c

Lines changed: 207 additions & 89 deletions
Large diffs are not rendered by default.

numcosmo/data/nc_data_cluster_mass_rich.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,11 @@ void nc_data_cluster_mass_rich_free (NcDataClusterMassRich *dmr);
4444
void nc_data_cluster_mass_rich_clear (NcDataClusterMassRich **dmr);
4545
void nc_data_cluster_mass_rich_apply_cut (NcDataClusterMassRich *dmr, gdouble cut);
4646

47-
void nc_data_cluster_mass_rich_set_data (NcDataClusterMassRich *dmr, NcmVector *lnM, NcmVector *z, NcmVector *lnR);
47+
void nc_data_cluster_mass_rich_set_data (NcDataClusterMassRich *dmr, NcmVector *lnM, NcmVector *z, NcmVector *lnR, NcmVector *sigma_lnR);
4848
NcmVector *nc_data_cluster_mass_rich_peek_lnM (NcDataClusterMassRich *dmr);
4949
NcmVector *nc_data_cluster_mass_rich_peek_z (NcDataClusterMassRich *dmr);
5050
NcmVector *nc_data_cluster_mass_rich_peek_lnR (NcDataClusterMassRich *dmr);
51+
NcmVector *nc_data_cluster_mass_rich_peek_sigma_lnR (NcDataClusterMassRich *dmr);
5152

5253
G_END_DECLS
5354

numcosmo/data/nc_data_cluster_ncount.c

Lines changed: 319 additions & 44 deletions
Large diffs are not rendered by default.

numcosmo/data/nc_data_cluster_ncount.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ void nc_data_cluster_ncount_set_z_obs_params (NcDataClusterNCount *ncount, const
9797

9898
void nc_data_cluster_ncount_set_lnM_obs_bins (NcDataClusterNCount *ncount, NcmObjArray *lnM_obs_bins);
9999
void nc_data_cluster_ncount_set_z_obs_bins (NcDataClusterNCount *ncount, NcmObjArray *z_obs_bins);
100+
void nc_data_cluster_ncount_set_lnM_obs_bins_params (NcDataClusterNCount *ncount, NcmObjArray *lnM_obs_bins_params);
101+
void nc_data_cluster_ncount_set_z_obs_bins_params (NcDataClusterNCount *ncount, NcmObjArray *z_obs_bins_params);
100102
void nc_data_cluster_ncount_set_bin_count (NcDataClusterNCount *ncount, NcmVector *bin_count);
101103

102104
gboolean nc_data_cluster_ncount_has_lnM_true (NcDataClusterNCount *ncount);
@@ -121,7 +123,7 @@ void nc_data_cluster_ncount_true_data (NcDataClusterNCount *ncount, gboolean use
121123
gboolean nc_data_cluster_ncount_using_true_data (NcDataClusterNCount *ncount);
122124
void nc_data_cluster_ncount_init_from_sampling (NcDataClusterNCount *ncount, NcmMSet *mset, gdouble area_survey, NcmRNG *rng);
123125

124-
void nc_data_cluster_ncount_add_bin (NcDataClusterNCount *ncount, NcmVector *lnM_obs_lb, NcmVector *lnM_obs_ub, NcmVector *z_obs_lb, NcmVector *z_obs_ub);
126+
void nc_data_cluster_ncount_add_bin (NcDataClusterNCount *ncount, NcmVector *lnM_obs_lb, NcmVector *lnM_obs_ub, NcmVector *z_obs_lb, NcmVector *z_obs_ub, NcmVector *lnM_obs_params, NcmVector *z_obs_params);
125127
void nc_data_cluster_ncount_del_bins (NcDataClusterNCount *ncount);
126128
void nc_data_cluster_ncount_set_binned (NcDataClusterNCount *ncount, gboolean on);
127129
void nc_data_cluster_ncount_bin_data (NcDataClusterNCount *ncount);

numcosmo/data/nc_data_cluster_ncounts_gauss.c

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ typedef struct _NcDataClusterNCountsGaussIndex
9797
gdouble *z_obs_ub;
9898
gdouble *lnM_obs_lb;
9999
gdouble *lnM_obs_ub;
100+
gdouble *z_obs_params;
101+
gdouble *lnM_obs_params;
100102
} NcDataClusterNCountsGaussIndex;
101103

102104
static void
@@ -335,21 +337,25 @@ _nc_data_cluster_ncounts_gauss_begin (NcmData *data)
335337

336338
{
337339
gint i_z, i_lnM;
340+
gint bin_index = 0;
338341

339342
for (i_z = 0; i_z < nz; i_z++)
340343
{
341344
for (i_lnM = 0; i_lnM < nlnM; i_lnM++)
342345
{
343346
NcDataClusterNCountsGaussIndex k;
344347

345-
k.i_z = i_z;
346-
k.i_lnM = i_lnM;
347-
k.z_obs_lb = ncm_vector_ptr (self->z_obs, i_z + 0);
348-
k.z_obs_ub = ncm_vector_ptr (self->z_obs, i_z + 1);
349-
k.lnM_obs_lb = ncm_vector_ptr (self->lnM_obs, i_lnM + 0);
350-
k.lnM_obs_ub = ncm_vector_ptr (self->lnM_obs, i_lnM + 1);
348+
k.i_z = i_z;
349+
k.i_lnM = i_lnM;
350+
k.z_obs_lb = ncm_vector_ptr (self->z_obs, i_z + 0);
351+
k.z_obs_ub = ncm_vector_ptr (self->z_obs, i_z + 1);
352+
k.lnM_obs_lb = ncm_vector_ptr (self->lnM_obs, i_lnM + 0);
353+
k.lnM_obs_ub = ncm_vector_ptr (self->lnM_obs, i_lnM + 1);
354+
k.z_obs_params = (self->z_obs_params != NULL) ? ncm_matrix_ptr (self->z_obs_params, bin_index, 0) : NULL;
355+
k.lnM_obs_params = (self->lnM_obs_params != NULL) ? ncm_matrix_ptr (self->lnM_obs_params, bin_index, 0) : NULL;
351356

352357
g_array_append_val (self->index_map, k);
358+
bin_index++;
353359
}
354360
}
355361
}
@@ -411,14 +417,16 @@ _nc_data_cluster_ncounts_gauss_mean_func (NcmDataGaussCov *gauss_cov, NcmMSet *m
411417
for (i = 0; i < self->index_map->len; i++)
412418
{
413419
const NcDataClusterNCountsGaussIndex *k = &g_array_index (self->index_map, NcDataClusterNCountsGaussIndex, i);
420+
const gdouble *lnM_params = k->lnM_obs_params;
421+
const gdouble *z_params = k->z_obs_params;
414422

415423
const gdouble mean = nc_cluster_abundance_intp_bin_d2n (cad, cosmo, clusterz, clusterm,
416424
k->lnM_obs_lb,
417425
k->lnM_obs_ub,
418-
NULL,
426+
lnM_params,
419427
k->z_obs_lb,
420428
k->z_obs_ub,
421-
NULL);
429+
z_params);
422430

423431
ncm_vector_set (vp, i, mean);
424432
}
@@ -467,13 +475,15 @@ _nc_data_cluster_ncounts_gauss_cov_func (NcmDataGaussCov *gauss_cov, NcmMSet *ms
467475
for (i = 0; i < self->index_map->len; i++)
468476
{
469477
const NcDataClusterNCountsGaussIndex *k_i = &g_array_index (self->index_map, NcDataClusterNCountsGaussIndex, i);
478+
const gdouble *lnM_params_i = k_i->lnM_obs_params;
479+
const gdouble *z_params_i = k_i->z_obs_params;
470480
const gdouble bias_i = nc_cluster_abundance_intp_bin_d2n_bias (cad, cosmo, clusterz, clusterm,
471481
k_i->lnM_obs_lb,
472482
k_i->lnM_obs_ub,
473-
NULL,
483+
lnM_params_i,
474484
k_i->z_obs_lb,
475485
k_i->z_obs_ub,
476-
NULL);
486+
z_params_i);
477487

478488
for (j = 0; j < self->index_map->len; j++)
479489
{
@@ -486,22 +496,24 @@ _nc_data_cluster_ncounts_gauss_cov_func (NcmDataGaussCov *gauss_cov, NcmMSet *ms
486496
const gdouble poisson_i = nc_cluster_abundance_intp_bin_d2n (cad, cosmo, clusterz, clusterm,
487497
k_i->lnM_obs_lb,
488498
k_i->lnM_obs_ub,
489-
NULL,
499+
lnM_params_i,
490500
k_i->z_obs_lb,
491501
k_i->z_obs_ub,
492-
NULL);
502+
z_params_i);
493503

494504
ncm_matrix_set (cov, i, j, poisson_i + bias_i * bias_i * Sij);
495505
}
496506
else
497507
{
498-
const gdouble bias_j = nc_cluster_abundance_intp_bin_d2n_bias (cad, cosmo, clusterz, clusterm,
499-
k_j->lnM_obs_lb,
500-
k_j->lnM_obs_ub,
501-
NULL,
502-
k_j->z_obs_lb,
503-
k_j->z_obs_ub,
504-
NULL);
508+
const gdouble *lnM_params_j = k_j->lnM_obs_params;
509+
const gdouble *z_params_j = k_j->z_obs_params;
510+
const gdouble bias_j = nc_cluster_abundance_intp_bin_d2n_bias (cad, cosmo, clusterz, clusterm,
511+
k_j->lnM_obs_lb,
512+
k_j->lnM_obs_ub,
513+
lnM_params_j,
514+
k_j->z_obs_lb,
515+
k_j->z_obs_ub,
516+
z_params_j);
505517

506518
ncm_matrix_set (cov, i, j, bias_i * bias_j * Sij);
507519
}
@@ -513,13 +525,15 @@ _nc_data_cluster_ncounts_gauss_cov_func (NcmDataGaussCov *gauss_cov, NcmMSet *ms
513525
for (i = 0; i < self->index_map->len; i++)
514526
{
515527
const NcDataClusterNCountsGaussIndex *k_i = &g_array_index (self->index_map, NcDataClusterNCountsGaussIndex, i);
528+
const gdouble *lnM_params = k_i->lnM_obs_params;
529+
const gdouble *z_params = k_i->z_obs_params;
516530
const gdouble poisson_i = nc_cluster_abundance_intp_bin_d2n (cad, cosmo, clusterz, clusterm,
517531
k_i->lnM_obs_lb,
518532
k_i->lnM_obs_ub,
519-
NULL,
533+
lnM_params,
520534
k_i->z_obs_lb,
521535
k_i->z_obs_ub,
522-
NULL);
536+
z_params);
523537

524538
ncm_matrix_set (cov, i, i, poisson_i);
525539
}

numcosmo/data/nc_data_cluster_pseudo_counts.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ _nc_data_cluster_pseudo_counts_prepare (NcmData *data, NcmMSet *mset)
304304
NcClusterPseudoCounts *cpc = NC_CLUSTER_PSEUDO_COUNTS (ncm_mset_peek (mset, nc_cluster_pseudo_counts_id ()));
305305

306306
if (dcpc->cad == NULL)
307-
g_error ("_nc_data_cluster_pseudo_counts_prepare: NcClusterAbundance not set, call _l");
307+
g_error ("_nc_data_cluster_pseudo_counts_prepare: NcClusterAbundance not set, call nc_data_cluster_pseudo_counts_set_cad() first.");
308308

309309
g_assert ((cosmo != NULL) && (clusterz != NULL) && (clusterm != NULL) && (cpc != NULL));
310310

@@ -562,9 +562,10 @@ nc_data_cluster_pseudo_counts_set_true_data (NcDataClusterPseudoCounts *dcpc, co
562562
* @rng: a #NcmRNG
563563
* @np: number of clusters
564564
*
565-
* Initializes cluster pseudo-counts data from Monte Carlo sampling.
566-
* Generates @np mock cluster observations based on the model parameters in @mset
567-
* using the random number generator @rng.
565+
* Initializes the cluster pseudo counts data by sampling @np clusters. Sets the number
566+
* of clusters and generates observational uncertainties for Planck and CLASH catalogs,
567+
* then resamples the data using the provided model set @mset and random number
568+
* generator @rng.
568569
*
569570
*/
570571
void

numcosmo/data/nc_data_dist_mu.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
/**
2727
* NcDataDistMu:
2828
*
29-
* Likelihod object for distance modulus data.
29+
* Likelihood object for distance modulus data.
3030
*
3131
* This class implements the likelihood for distance modulus data.
3232
*
@@ -210,12 +210,11 @@ _nc_data_dist_mu_set_size (NcmDataGaussDiag *diag, guint np)
210210

211211
/**
212212
* nc_data_dist_mu_new_empty:
213-
* @dist: a #NcDistance object
213+
* @dist: a #NcDistance
214214
*
215-
* Creates a new empty #NcDataDistMu object for distance modulus data.
216-
* The distance object @dist is used to compute theoretical predictions.
215+
* Creates a new empty #NcDataDistMu with the given distance object.
217216
*
218-
* Returns: a newly created #NcDataDistMu
217+
* Returns: (transfer full): a new #NcDataDistMu
219218
*/
220219
NcDataDistMu *
221220
nc_data_dist_mu_new_empty (NcDistance *dist)
@@ -251,10 +250,9 @@ nc_data_dist_mu_new_from_file (const gchar *filename)
251250
* @dist: a #NcDistance
252251
* @id: a #NcDataSNIAId
253252
*
254-
* Creates a new #NcDataDistMu object from a predefined Type Ia supernova dataset.
255-
* This loads distance modulus data from the survey/compilation specified by @id.
253+
* Creates a new #NcDataDistMu from a predefined SNIa dataset identifier.
256254
*
257-
* Returns: the newly created #NcDataDistMu
255+
* Returns: (transfer full): a new #NcDataDistMu
258256
*/
259257
NcDataDistMu *
260258
nc_data_dist_mu_new_from_id (NcDistance *dist, NcDataSNIAId id)

0 commit comments

Comments
 (0)