Skip to content

Repository files navigation

Galacticus Dev Tools

A collection of scripts and tools that are helpful in maintaining and developing Galacticus. They are not part of the Galacticus model itself; they are utilities used by developers and maintainers for housekeeping, data preparation, validation, and CI/CD support tasks around the main repository.

Tools

GPLerize.py

Adds (or refreshes) the standard Galacticus GPL header on every Fortran (.f, .f90, .inc) and C/C++ (.c, .cpp, .h) source file in a given directory. The copyright year range is generated dynamically from 2009 to the current year, and any pre-existing comment header at the top of the file is stripped before the new one is written. The original file is preserved as a ~-suffixed backup.

./GPLerize.py <sourceDir>

extractSDSSBPTData.py

Builds the HDF5 datasets of emission-line fluxes for star-forming galaxies and AGN that Galacticus uses as observational constraints, drawn from the SDSS DR8 MPA-JHU value-added catalogs. The script downloads galSpecExtra-dr8.fits and galSpecLine-dr8.fits if they are not already present, splits the sample by BPT class, and writes emissionLineFluxesStarFormingSDSSDR8.hdf5 and emissionLineFluxesAGNSDSSDR8.hdf5 to ${GALACTICUS_DATA_PATH}/static/observations/emissionLines/. Each output records its provenance (source URL, git revision of this script, MD5 checksums of the input FITS files, and a timestamp) as HDF5 attributes.

Requires numpy, h5py, astropy, and gitpython, and the GALACTICUS_DATA_PATH environment variable.

migrateAllParameterFiles.py

Walks the parameters, constraints, and testSuite directories of a Galacticus checkout and runs scripts/aux/parametersMigrate.py on every XML parameter file in-place, so that all bundled parameter files are migrated to the current schema in a single pass. Files that are not Galacticus parameter files (no top-level <parameters> element) and a fixed set of excluded sub-directories (e.g. testSuite/outputs) are skipped. After migration the script also resets the lastModified revision recorded in the test suite's strictOutdated.xml and unstrictOutdated.xml files, which deliberately exercise the "outdated parameter file" code paths.

Run from the root of a Galacticus checkout with GALACTICUS_EXEC_PATH set to the Galacticus executable directory.

promptCusps.py

Reference implementation used to validate Galacticus' built-in prompt-cusp model. Uses Sten Delos' cusp_halo_relation Python module to compute power-spectrum integrals σ₀ and σ₂ and the cusp properties (amplitude, mass, scale radius, scale density, virial radius, concentration, etc.) of a reference halo, and prints them so that they can be compared against the values produced by Galacticus' Fortran test tests.prompt_cusps.F90.

plotAnalyses.py

Overlays the on-the-fly analyses results stored in Galacticus HDF5 output files so that a test run can be compared against a reference run. Given a test path and a reference path -- each either a single HDF5 file or a directory of them -- it matches files by name, and for every file present in both locations plots each function1D analysis under /analyses (the test curve, the reference curve, and any target/observational overlay) into a PDF. The PDFs are written into a per-model subdirectory analyses_<model>/ under the output directory (the current directory by default). Files present in only one of the two paths are reported and skipped.

./plotAnalyses.py <testPath> <referencePath> [-o <outputDir>] [-g <glob>]

Requires the dendros package.

retrieveGHPagesArtifacts.sh

Pulls validation, benchmark, and build-profile artifacts from a Galacticus CI/CD run and merges them into a local gh-pages checkout, so that a PR's metric pages can be inspected before the PR is merged and its results are deployed for real. The set of metrics to update is read from scripts/build/ghPagesMetricsManifest.yml (the same manifest the CI regenerator uses), so adding a new metric requires no change to this script. If GALACTICUS_EXEC_PATH points at a checkout of Galacticus master, the manifest, threshold sidecar, and buildGhPagesIndex.py indexer are taken from there and the indexer is run automatically; otherwise the manifest is fetched from upstream master, the indexer step is skipped, and the script prints the command needed to regenerate the index manually. Each touched per-metric page is opened in the default browser at the end of the run.

./retrieveGHPagesArtifacts.sh <runID>

Run from a directory with the gh-pages branch of Galacticus checked out. Requires the GitHub CLI (gh).

deltaTestCaseReducer/

Wrapper around the Delta debugging tool for reducing a Galacticus source file to a minimal example that still triggers a specific error (a compiler bug, a runtime crash, etc.) by successively removing lines. See deltaTestCaseReducer/ReadMe.md for usage and testScriptExample.sh for an example test script. The delta source itself is redistributed under its original BSD license; see deltaTestCaseReducer/License.txt.

allocationProfiler/

A lightweight LD_PRELOAD allocation profiler for finding which call sites drive a program's heap-allocation churn. It interposes malloc/calloc/realloc and aggregates each allocation by call-stack, so memory use is bounded by the number of distinct allocation stacks rather than the number of allocations -- letting it profile an allocation-heavy run (a Galacticus model can make billions of allocations) to completion, where a record-every-event profiler such as heaptrack exhausts RAM. It counts cumulative allocations including freed temporaries (which a live-heap profiler cannot see), supports 1-in-N sampling for fast turnaround, and can report the inclusive share of allocations attributable to a target regex (e.g. a particular object's construct/destroy lifecycle). See allocationProfiler/ReadMe.md for usage.

./allocationProfiler/runAllocProf.sh <program> [args...]

License

The tools in this repository are released under the MIT License -- see License.txt. The bundled delta source under deltaTestCaseReducer/ retains its own BSD license, which is included alongside it.

About

A collection of scripts and tools that are helpful in maintaining and developing Galacticus

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages