ASTRO… Junkyard

Notes on Astrophysics, Scripting, Fitting and Unix environment, by Alexandros Maragkoudakis.

Installing LaTeX Packages Manually

To install a LaTeX package manually (for example the “morefleats” package) in an existing texlive installation:

1) Donwload the file from e.g.

2) Extract the file and move the morefloats folder (as a superuser) to: /usr/share/texlive/texmf-dist/tex/latex/

3) Generate the package and driver files as described in the README file.

4) Run texhash to refresh the file name database.



BoundingBox In Merged PS/EPS Files

When merging two or more ps/eps files using the psmerge command, the resulting file may not preserve the BoundingBox values.

This can be a problem when using the merged file in LaTeX.

We can get the BoundingBox values from one of the original files used for merging.

From the terminal type: grep BoundingBox figure.eps

This should give something like: %%BoundingBox: 22 16 596 784

Then in LaTeX we use these values to define the BoundingBox for the merged figure:

\includegraphics[keepaspectratio=true, angle=0, scale=0.8,bb=22 16 596 784]{Figure.eps}

IRAF – Commonly Used Commands

A few quick notes on some of the most commonly used IRAF (window) commands, in order to save some time scanning through the IRAF help pages. This post should be updated frequently, including more commands.


Inspecting and Altering the Aperture Location and Size:

– Delete existing aperture by typing d, and mark a new one by positioning the cursor and typing m.

– Define the lower and upper limits by positioning the cursor and typing l and u respectively.

Inspecting and Altering the Background Windows and Fit:

– In order to check the background regions we type b.

– To delete the current sample region we type t.

– To define new sample regions using the mouse, we move the cursor at the desired points and type s.

To define background sample range from the keybord we type: “:sample -50:-8,8:50



In order to overplot a second spectrum in SPLOT we first type o, to enable the overplot option and then we type g, to get the new image. We will be asked to type the full name of the image, and choose which of the 4 (sub-)spectra will  be plotted.

SDSS Notes

Available Spectroscopic Data

Catalogs of quantities measured from Spectra

Information for each galaxy processed by Garching group

file: galSpecInfo-dr8.fits (364 Mb)

Galaxy Properties

“After the spectra are output from the spectroscopic pipeline, we additionally compute a variety of derived quantities by applying stellar population models to derive stellar masses, emission-line fluxes and equivalent widths, and gas kinematics and stellar velocity dispersions ( Chen et al. 2012 , Maraston et al. 2012 , Thomas et al. 2013  ).


“The different stellar mass estimates for BOSS galaxies encompass calculations based on different stellar population models (Portsmouth, Maraston 2005; Wisconsin, Bruzal & Charlot 2003; Granada FSPS, Conroy et al. 2009), different assumptions regarding galaxy star formation histories and reddening, as well as multiple choices for the initial mass function and stellar-mass loss rates.

In addition, each method focuses on a different aspect of the available imaging and spectroscopic data. The Portsmouth and the Granada FSPS SED fitting focuses on broad-band colors and BOSS redshifts, the Portsmouth emission-line fitting focuses on specific regions of the spectrum that contain specific information on gas and stellar kinematics, and the Wisconsin PCA analysis uses the rest-frame 3700-5500 Å stellar continuum.

The WMAP 7 flat ΛCDM cosmology with H0 = 70, Ωm = 0.274, and ΩΛ = 0.726. (White et al. 2011) is applied universally to each of the Portsmouth-Wisconsin-Granada computations by the BOSS Pipeline.”

General Notes

“SDSS spectra are typically combined from 3 or more individual exposures of 15 minutes each. The individual flux-calibrated spectrograph exposures areavailable in spCFrame*.fits files. They contain spectra in the spectrograph’s native wavelength mapping, which is neither linear in wavelength nor log-wavelength.”

Normalized Gaussian In Sherpa

An arbitrary Gaussian function is given by the expression:

where a is the Amplitude ( a = 1/(σ√(2π) ), b is the mean value (μ), and c is the standard deviation (σ).

The Gaussian integral is:

Hence, the integral of the Gaussian function is:

In the case of Sherpa’s normalized Gaussian:

f(x) = [A/sqrt(pi/f)/F] exp[-f(x-x_o/F)^2],

the Amplitude is a = A/(F√(2π), so that the integral of this normalized Gaussian is equal to A.

The constant f  = 4log2 = 2.7725887 relates the full-width at half-maximum F to the Gaussian sigma so that F=sqrt(8log2)*sigma.

In order to obtain the maximum (peak) value of the normalized Gaussian (which is the amplitude of the standard Gaussian) we must divide the amplitude A by:




since A/sqrt(pi/f)/F = A/(σ√(2π), where σ is given by σ = F/sqrt(8log2).

The Equivalent Width of a line is calculated using the flux of the line within a given range, divided by the continuum’s flux density at the peak of the line.

So when using a normalized Gaussian in Sherpa: EW = A /c1.c0 , where c1.c0 is the flux density of the continuum at the center of the line.

Perl: Call a Perl Script From Another Perl Script

We can call a perl script from another perl script using the system function:

system(“/usr/bin/perl /path/to/”);

If we want to capture the output of the second script (e.g. the STDOUT output) we can use an array to store it inside the first script:

my @array = `/usr/bin/perl /path/to/`;

Perl: Shuffle An Array

use List::Util qw(shuffle); 

my @Array1 = (0..100); 

my @Array2 = shuffle @Array2;

The List::Util module provides a shuffle function which implements the Fisher-Yates shuffle.

PERL: Comment Out A Large Block Of Code


all code here

will be ignored


Protected: STARLIGHT: Testing AGN Continuum Subtraction

This content is password protected. To view it please enter your password below:

STARLIGHT: Normalization

STARLIGHT normalizes both the input spectrum and the model spectra to the flux/luminosity of a specific wavelength, or inside a wavelength region in the case of the observed spectrum (to avoid any complications like noise spikes or cosmic rays etc.), and stores the input spectrum flux of that wavelength to Oparameter (with a value equal to the input Oλ at that wavelength). Later on this value is used to denormalize the observed and synthetic spectrum.