Examples

The repository comes with example data and scripts in LineStacker/Example, and a notebook that runs all of them: Examples notebook.

Notebook

LineStacker/Example/LineStacker_examples.ipynb runs every example on the example data in about half a minute and writes its files to Example/notebook_outputs/. Start it from the Example folder:

cd LineStacker/Example
jupyter notebook LineStacker_examples.ipynb

It covers 1D stacking, bootstrapping and subsampling of spectra; cube stacking with the three ways of giving the stacking positions (a catalogue, Python arrays, and the coordinate files of LineStacker 1.x); line fits, rebinning and bootstrapping of cubes; and continuum stacking with stacks at random positions.

Scripts

Spectra (Example/oneD, run from that folder):

  • basic-example.py stacks 100 spectra (data/spectra_<i>, velocity and flux columns) on their central velocities (data/central_velocity_<i>).

  • extended-example.py takes 50 spectra, 10 of which have lines ten times brighter: a median stack, a bootstrap that shows the stack depends on which sources are drawn, and a subsampling that finds the bright spectra.

Cubes (Example/cube): 30 CASA cubes of simulated line emitters in data and 50 in dataExtended. Their positions are in the catalogues sources.csv and sources_extended.csv (columns ra, dec, z, image), and also in one coordinate file per cube (*_coord.txt, the 1.x format). The scripts can be run from any folder and write their results there:

python LineStacker/Example/cube/basic_example.py       # line stack: catalogue, arrays, coordinate files
python LineStacker/Example/cube/extended_example.py    # spectra, fits, rebinning, bootstrap
python LineStacker/Example/cube/continuum_example.py   # continuum stack and random positions

basic_example.py makes the same stack three ways:

# 1. a catalogue: one row per source, with the cube it lies in
coords = LineStacker.readCatalog('sources.csv')
stacked = LineStacker.image.stack(coords, fEm=FEM, stampsize=16, N_chans=16)

# 2. Python arrays, e.g. the columns of your own table
cat = Table.read('sources.csv')
coords = LineStacker.makeCoords(cat['ra'], cat['dec'], z=cat['z'], image=cubes)

# 3. coordinate files (LineStacker 1.x) and the list of cubes, in the same order
coords = LineStacker.readCoords(coordNames)
stacked = LineStacker.image.stack(coords, imagenames=imagenames, fEm=FEM, stampsize=16, N_chans=16)

See Stacking positions for the options of each.