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: https://arxiv.org/pdf/1811.05356.pdf
Please cite the above work if using this code.
Installation
The code is available using pip:
pip install radiowinds
Or alternatively can be cloned directly from this repository.
Dependencies
The calculations in this package depend on a number of different python packages, namely:
Required packages are shown in bold.
Testing
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:
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
filename='/path/to/file.dat'
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
ma.make_animation(output_dir)
This will create an mp4 animation of the radio emission at different frequencies.
Numerical Issues
Warning:
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.
Functions
-
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.
Author
Written by Dúalta Ó Fionnagáin in Trinity College Dublin, 2018 MIT License
Email : ofionnad@tcd.ie
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file radiowinds-1.2.0.tar.gz
.
File metadata
- Download URL: radiowinds-1.2.0.tar.gz
- Upload date:
- Size: 14.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d5274f05530e8c8686a329bd810480697a91836ea39bbde81cd0a09259dad739 |
|
MD5 | 1149f8ab3a08de44ddec15cbc56a7cf6 |
|
BLAKE2b-256 | 8f51fc2a0cb958eeaf6694fb701f7ba4eaac99d4a0965e2e681a74104d9c505a |