DynSpe

a python tool for creating dynamic (trailed) spectra

  • its main purpose is to create a 2D image showing changes of a star's spectrum in time
  • horizontal axis can be either linear in wavelength or radial velocity from the line's centre
  • vertical axis can be either linear in time or orbital phase based on given ephemerid
  • the code is implemented as a python 3 module
  • the code can be found here

    Prerequisities

    the code requires these python modules:

  • numpy
  • scipy
  • matplotlib
  • os
  • DynSpe DynamicSpectrum class description

    class DynamicSpectrum(outname = "dynamicspectrum.png")

  • initializes the class and sets name for output file
  • function add_LST(name, pref, folder="./", col=-2, headerrows=8)

  • add a file containing names of individual files and times of observations
  • name (str) - name of the file
  • pref (str) - the file names should be in format of pref+$1
  • folder (opt, str) - name of the folder if the files are in a different folder than script, default "." (current folder)
  • col (opt, int) - column where the observation times can be found - default -2 (second to last)
  • headerrows (opt, int)- skip a number of rows from the begining
  • function set_wlmid(value)

  • central wavelength of the spectrum
  • value (opt, float) - on initialization set to 6562.81 - H alpha
  • function set_toRV(value=True)

  • data will be displayed as linear in radial velocity from central point
  • value (opt, boolean) - on initialization set to False
  • function set_xvalrange(value)

  • sets interval of values around central line (either interval of wavelength or velocity depending whether is set to WL or RV)
  • value (float)
  • function set_xvalrange(value)

  • set step in x to interpolate the spectra to
  • value (float)
  • function set_nrlevels(value)

  • set number of color steps
  • value (int)
  • function set_period(value, digits=-1)

  • display the image as linear in orbital phase
  • value (float) - orbital period, default is None (display linearly in time)
  • digits (opt, int) - if set to > 0 then the value will be displayed in the top right corner up to digits number of digits
  • function set_T0(value, digits=-1)

  • set begining of ephemeris if orbital phase is to be computed
  • value (float) - epoch begining, default is None (display linearly in time)
  • digits (opt, int) - if set to > 0 then the value will be displayed in the top right corner up to digits number of digits
  • function set_title(value)

  • set title
  • value (str) - name of the dynamic spectrum - for greek letters use raw string
  • function set_emptyColor(value)

  • set color of empty space
  • value (str)
  • function set_zeroPhaseColor(value)

  • set color of zero-phase marker
  • value (str)
  • function set_cmap(value)

  • set colormap for the dynamic spectrum
  • currently there are 3 sequential (Reds, Blues, Greys) and one diverging (RdBu) colormaps implemented with their reverse (ie. Reds_r)
  • sequential colormaps are better suited for spectra which are either fully in emission (>1) or absorption (<1)
  • diverging colormap are better suited for spectra with both emission and absorption component
  • value (str) - colormap
  • function set_midpoint(value)

  • set midpoint of diverging colormap
  • value (float) - default is 1. (continuum)
  • function add_cmap(cmap, cmclass)

  • add and set a colormap predefined in matplotlib
  • cmap (str) - name of colormap
  • cmclass (str) - colormap class, either "Sequential" or "Diverging"
  • Example


    this dynamic spectrum was created using the following script:

    import dynspe
    dynspeHa = dynspe.DynamicSpectrum("ds_ha.png")
    dynspeHa.add_LST("Phi_Per_BeSS_rv.lst", "PPC", "../BeSS")
    dynspeHa.add_LST("SPEFOGood.LST", "PPO", "../Ond", col=9)
    dynspeHa.add_LST("PPB.lst", "PPB", "../BeSS_new")
    dynspeHa.set_xvalrange(12.)
    dynspeHa.set_xvalstep(.1)
    dynspeHa.set_nrlevels(15.)
    dynspeHa.set_title(r"$\varphi$ Per H$\alpha$")
    dynspeHa.plot_ds()