Skip to main content
Python Software Foundation 20th Year Anniversary Fundraiser  Donate today!

A package to calculate the thermal free-free emission from stellar winds

Project description

Radio Emission from Stellar Winds


This is a Python code to calculate the radio emission produced by the winds around stars. The code calculates thermal bremsstrahlung that is emitted from the wind, which depends directly on the density and temperature of the stellar wind plasma. The program takes input data in the form of an interpolated 3d grid of points (of the stellar wind) containing position, temperature and density data. From this it calculates the thermal free-free emission expected from the wind at a range of user-defined frequencies.

This code is used in a paper accepted to Monthly Notices of the Royal Astronomical Society. Available at ArXiv:

Please cite the above work if using this code.


The code is available using pip: pip install radiowinds

Or alternatively can be cloned directly from this repository.


The calculations in this package depend on a number of different python packages, namely:

Required packages are shown in bold.


The quickest way to test that the code is working is to use the test script included in the package.

To test:

from radiowinds import test

#set up initial parameters for grid
ndim = 50
gridsize = 10
ordered = True

#Instantiate testcase class
t = test.testcase(ndim, gridsize, ordered)
#call the test
data = t.test()

The data variable should now contain an array of 3 variables: 2d array of intensity, radio flux in Jy, and the size of the radio photosphere in R.

The above test will also output an image that should look like the following:

Alt text

Quick Example Code

To use this code with your own data follow the steps below. You require that the data is in the format of an evenly interpolated 3D grid.

There are many ways to interpolate a 3d grid of points. For the purposes of this example Tecplot was used to output an interpolated grid of points.

The readData() function is used to get access to the data, it uses the pandas module. The radioEmission() function is the fastest way to make a calculation and get an output.

import radiowinds.radio_emission as re

rstar = 1.05 #radius of star in R_sun

skiprows = 12 #this is the header size in the data file, which should be changed for users needs
ndim = 200 #This is the number of gridpoints in each dimension
gridsize = 10 #size of the radius of the grid in R_star

df = re.readData(filename, skiprows, ndim)

n = df[1] #grid density
T = df[2] #grid temperature
ds = df[0] #grid spacing along integration line
freq = 9e8 #observing frequency
distance = 10 #distance in parsecs

#remove density from behind star as this will not contribute to emisison
n = re.emptyBack(n, gridsize, ndim)

#find integration constant for grid of current size
int_c = re.integrationConstant(rstar)

I, sv, rv = re.radioEmission(ds, n, T, freq, distance, ndim, gridsize, int_c)

This should output an image of the intensity (and assign this data to I) from the wind and assign the radio flux to sv and the radio photopshere size to rv.

Compute a Radio Spectrum

This repository also provides a way to automatically cycle through a range of frequencies to find the spectrum of a stellar wind.

This can be done by using the spectrumCalculate() function.

Continuing on from the quick example above:

#set a range of frequencies to iterate over``
freqs = np.logspace(8,11,50)
output_dir = '/path/to/output' #where you want any output images to go
plotting=False #set to True to save images of intensity at each frequency to output_dir

svs, rvs = re.spectrumCalculate(output_dir, freqs, ds, n, T, d, ndim, gridsize, int_c, plotting=plotting)

svs will contain the flux in Jy at each frequency defined in freqs. To plot the spectrum simply use:

plt.plot(freqs, svs)

Creating animations

Using the images plotted from the spectrum function (provided plotting == True), one can use the moviepy module to make a short animation of the output.

import radiowinds.make_animation as ma 

output_dir = '/path/to/output' #same directory as above


This will create an mp4 animation of the radio emission at different frequencies.

Numerical Issues


If very low frequencies are used in the above calculations you run into some numerical problems. Namely this is that the flux is overestimated.

This is due to the fact that the optically thick region of the wind gets larger at lower frequencies, and eventually will reach the boundary of the 3d grid. When this happens the code calculates the emission from denser regions than would be visible had the 3d box been larger.


  • readData()

    This function allows you to read in the coordinates of the grid, the density of the grid and the temperature of the grid The pandas module is used to load data.

    For the function to work properly, the datafile must be in column format with whitespace as the data seperator. The order of the data should be [X, Y, Z, density, temperature].

  • generateinterpolatedGrid()

    If Tecplot is installed on the system then this function should work to interpolated a 3d grid of data onto a regular 3d grid. It uses some function from the pytecplot module as well as some macro functions avaiable from Tecplot. As inputs it requires the .lay datafile, the number of points you want in your interpolated grid and the size of the grid in R. The final input is the variable number of density and temperature as a list. e.g. [3, 20]

    generateinterpolatedGrid('/path/to/tecplotfile.lay', 200, 10, [3, 20])

    Would create a grid of 200 x 200 x 200 points ranging from -10 to 10 R in each direction (x,y,z).

    Ensure that pytecplot is installed on your system.

    In future might adapt this to work for the VisIT output.


Written by Dúalta Ó Fionnagáin in Trinity College Dublin, 2018 MIT License

Email :

My Github

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for radiowinds, version 1.2.0
Filename, size File type Python version Upload date Hashes
Filename, size radiowinds-1.2.0.tar.gz (14.3 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page