Package: radiowinds
Radio Emission from Stellar WindsThis 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.pdfPlease cite the above work if using this code.InstallationThe code is available using pip:pip install radiowindsOr alternatively can be cloned directly from this repository.DependenciesThe calculations in this package depend on a number of different python packages, namely:numpymatplotlibpandasscipypytecplotmoviepynatsortRequired packages are shown in bold.TestingThe quickest way to test that the code is working is to use the test script included in the package.To test:fromradiowindsimporttest#set up initial parameters for gridndim=50gridsize=10ordered=True#Instantiate testcase classt=test.testcase(ndim,gridsize,ordered)#call the testdata=t.test()Thedatavariable 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 CodeTo 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.importradiowinds.radio_emissionasrerstar=1.05#radius of star in R_sunfilename='/path/to/file.dat'skiprows=12#this is the header size in the data file, which should be changed for users needsndim=200#This is the number of gridpoints in each dimensiongridsize=10#size of the radius of the grid in R_stardf=re.readData(filename,skiprows,ndim)n=df[1]#grid densityT=df[2]#grid temperatureds=df[0]#grid spacing along integration linefreq=9e8#observing frequencydistance=10#distance in parsecs#remove density from behind star as this will not contribute to emisisonn=re.emptyBack(n,gridsize,ndim)#find integration constant for grid of current sizeint_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 toI) from the wind and assign the radio flux tosvand the radio photopshere size torv.Compute a Radio SpectrumThis 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 thespectrumCalculate()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 goplotting=False#set to True to save images of intensity at each frequency to output_dirsvs,rvs=re.spectrumCalculate(output_dir,freqs,ds,n,T,d,ndim,gridsize,int_c,plotting=plotting)svswill contain the flux in Jy at each frequency defined in freqs. To plot the spectrum simply use:plt.plot(freqs,svs)Creating animationsUsing the images plotted from the spectrum function (providedplotting == True), one can use themoviepy moduleto make a short animation of the output.importradiowinds.make_animationasmaoutput_dir='/path/to/output'#same directory as abovema.make_animation(output_dir)This will create an mp4 animation of the radio emission at different frequencies.Numerical IssuesWarning: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.FunctionsreadData()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.AuthorWritten by Dúalta Ó Fionnagáin in Trinity College Dublin, 2018
MIT LicenseEmail :ofionnad@tcd.ieMy Github