This is a collection of python tools used in my work on HI filament stacking simulation, including utilities for data processing, plotting, and calculations.
The code is organized into several modules, each with its own specific functionality. The main modules are:
data.py: to manipulate the hdf5 files (save, read...),plot.py: to plot multiple figures(heatmap, histogram, line, arcs...),constant.py: defined some constants for 21cm astronomy (rest_frequency...),calculation.py: to calculate some quantities (beamsize, sensitivity...),stack.py: to aid the stacking procedure,halo.py: to finish halo component fiting and subtraction (original code used in paper),halo_new.py: optimised version of halo-contriubiton subtraction (recommanded, but it's still numerical, refer to crafts_stack for analytical verison),utils.py: utilities for fiting (get coodinates, mask...),estimate.py: to estimate the signal level (original used in paper),estimate_fixwidth.py: to estimate the signal level base on given width,bins.py: helper functions for bins.
There are also useful scripts in the scripts folder:
convolve.py: to finish beam convolution (FAST main beam),pair_stack.py: to run the galaxy pairwise stacking.find_fuzzy_par.py: to find the indices of inner fuzzy particles for filament only map construction.
You can simply git clone this repository and and install it with pip install .
Or directly use:
pip install git+https://github.com/dyliu0312/mytools.gitIt was tested on Python>=3.8, and requires the following packages:
Optional:
- tqdm (for pair_stack.py script)
- illustris_python (for find_fuzzy_par.py script)
After installing, you can use the functions in the modules, for example:
from mytools.calculation import freq2z, u
freq2z(1.3*u.GHz)-
The example Jupyter notebook for filament signal estimation is in the example folder.
-
Other example Jupyter notebooks for functionality usage are in the test folder.
-
To run the
pair_stack.pyscript, please see and modify the example parameters set in the pair_stack.sh file.
Have fun!

