Loading observational data: galaxy

This section will introduce you to loading observational data. This is stored in the galaxy object. Check out the second iPython notebook example for a quick-start guide to loading data.

API documentation: galaxy

class bagpipes.galaxy(ID, load_data, spec_units='ergscma', phot_units='mujy', spectrum_exists=True, photometry_exists=True, filt_list=None, out_units='ergscma', load_indices=None, index_list=None, index_redshift=None, input_spec_cov_matrix=False)

A container for observational data loaded into Bagpipes.

Parameters:
  • ID (str) – string denoting the ID of the object to be loaded. This will be passed to load_data.
  • load_data (function) – User-defined function which should take ID as an argument and return spectroscopic and/or photometric data. Spectroscopy should come first and be an array containing a column of wavelengths in Angstroms, then a column of fluxes and finally a column of flux errors. Photometry should come second and be an array containing a column of fluxes and a column of flux errors.
  • filt_list (list - optional) – A list of paths to filter curve files, which should contain a column of wavelengths in angstroms followed by a column of transmitted fraction values. Only needed for photometric data.
  • spectrum_exists (bool - optional) – If you do not have a spectrum for this object, set this to False. In this case, load_data should only return photometry.
  • photometry_exists (bool - optional) – If you do not have photometry for this object, set this to False. In this case, load_data should only return a spectrum.
  • spec_units (str - optional) – Units of the input spectrum, defaults to ergs s^-1 cm^-2 A^-1, “ergscma”. Other units (microjanskys; mujy) will be converted to ergscma by default within the class (see out_units).
  • phot_units (str - optional) – Units of the input photometry, defaults to microjanskys, “mujy” The photometry will be converted to ergscma by default within the class (see out_units).
  • out_units (str - optional) – Units to convert the inputs to within the class. Defaults to ergs s^-1 cm^-2 A^-1, “ergscma”.
  • index_list (list - optional) – list of dicts containining definitions for spectral indices.
  • load_indices (function or str - optional) – Load spectral index information for the galaxy. This can either be a function which takes the galaxy ID and returns index values in the same order as they are defined in index_list, or the str “from_spectrum”, in which case the code will measure the indices from the observed spectrum for the galaxy.
  • index_redshift (float - optional) – Observed redshift for this galaxy. This is only ever used if the user requests the code to calculate spectral indices from the observed spectrum.

The load_data function

The most important argument passed to galaxy is the load_data function, which you will need to write to access your data files and return your data. load_data should take an ID string and return observed spectroscopic and/or photometric data in the correct format and units (see below).

For example:

import bagpipes as pipes

eg_filt_list = ["list", "of", "filters"]

def load_data(ID):
    # Do some stuff to load up data for the object with the correct ID number

    return spectrum, photometry


ID_number = "0001"

galaxy = pipes.galaxy(ID_number, load_data, filt_list=eg_filt_list)

galaxy.plot()

This will plot the data returned by the load_data function.

By default, Bagpipes expects spectroscopic and photometric data to be returned by load_data in that order. If you do not have both, you must pass a keyword argument to galaxy, either spectrum_exists=False or photometry_exists=False.

The format of the spectrum returned by load_data should be a 2D array with three columns: wavelengths in Angstroms, fluxes in erg/s/cm^2/A and flux errors in the same units (can be changed to microJansksys with the spec_units keyword argument). These will be stored in galaxy.spectrum.

The format of the photometry returned by load_data should be a 2D array with a column of fluxes in microJanskys and a column of flux errors in the same units (can be changed to erg/s/cm^2/A with the phot_units keyword argument). The fluxes should be in the same order as the filters in your filt_list. Bagpipes will calculate effective wavelengths for each filter and store these along with the input data in galaxy.photometry.