Wednesday 30 November 2016

1D Solar Atmosphere Models in IDL: Penumbra by Ding & Fang (1989)

Plane-parallel atmosphere in hydrostatic equilibrium published by Ding & Fang (1989, "A semi-empirical model of sunspots penumbra", 1989A&A...225..204D). Statistical equilibrium for hydrogen model-atom with 12 levels plus continuum. The model is produced by fitting observations of penumbra in  2 lines of H and 5 lines of Ca. The observations were carried out on McMath telescope at Kitt Peak National Observatory. The observed sunspot was small, rounded and close to the disk center. The field strength in the umbra was around 1.25 kG and 560 G in the penumbra.

It is interesting to note their Fig.2 (see it below). In the deep photosphere, the temperature in this model is similar to the temperature in the model of Yun et al. (1981). However, between the optical depths -3 and -4 it becomes close to the VALC model (Vernazza et al, 1981).


Friday 21 October 2016

Installing IDL v7.1 on Kubuntu 16.04 (on MacBook pro)


The IDL installation went smooth as usual, but when I tried to run IDL, there was an error:

error while loading shared libraries: libXp.so.6: cannot open shared object file: No such file or directory 

In the IDL help pages ( IDL fails to install on Linux: What to do, scroll down to the Ubuntu section) there is a comment on that that turned only half useful. Two libraries I got installed with no problem:

sudo apt-get install libxmu-dev
sudo apt-get install libxmu6


but the other three were not found in repositories. Instead of manual installation (two of them are available from http://packages.ubuntu.com/xenial/, but the last one is a bit mysterious. Google finds it only in three pages related to IDL, one of them being the previously mentioned page from the IDL docs). Instead, I got if from Git. As I have just installed Kubuntu there was still some important packages missing, so some of the following steps may be redundant for you.

sudo apt-get install autoconf autogen intltool
sudo apt-get install git
sudo apt-get install xutils-dev libtool libx11-dev 
                          x11proto-xext-dev x11proto-print-dev
git clone https://cgit.freedesktop.org/xorg/lib/libXp/

Then cd to libXp directory and execute

sudo ./autogen.sh

In my case if was complaining about the line 18214 related to XPRINT. I commented out that line from the script and executed it again. After that everything is straight forward:

sudo ./configure
sudo make install

And finally I add the path to the library to .bashrc (all in one line):

echo 'export LD_LIBRARY_PATH="/usr/local/lib/:$LD_LIBRARY_PATH"' >> ~/.bashrc

After that IDL worked normally. 

Friday 23 September 2016

How to find if point is in or out of polygon? (in IDL)

It's a common problem in visualization and many other applications. There are many ways to solve it, but not all the ways are equally efficient. Baard Krane wrote a very elegant solution in IDL that was later vectorized by William Connelly and popularized in the community - of course - by David Fanning (see his article here and get the source of the inside.pro).

Example:
IDL> px = [0.3, 0.3, 0.7, 0.7]
IDL> py = [0.3, 0.7, 0.7, 0.3]
IDL> x = RANDOMU(seed1, 5000) 
IDL> y = RANDOMU(seed2, 5000) 
IDL> id = INSIDE(x, y, px, py, /ind)          
IDL> PLOT, x, y, psym = 3                     
IDL> OPLOT, [px, 0.3], [py, 0.3]              
IDL> OPLOT, x[id], y[id], psym = 3, col = 255


Saturday 16 July 2016

Equation of state: Vardya - Mihalas - Wittmann

These are my notes on equation of state derived initially by Vardya (1965), described by Mihalas (1967) and popularized by Wittmann (1974). It is widely used (or at least present as an option) in spectral synthesis codes like SIR or NICOLE. It is also prepared for the MANCHA code with several modifications and additionally computed quantities. However, the equation is derived in this particular form to be solvable on computing resources half a century ago. From today's perspective, this formulation is rather obsolete. While the results of the VMW EOS are still largely reliable, various tricks introduced to control numerical stability limit its usability to rather restricted range of the pressure and temperature.

Here I derive a simple equation of state for the solar atmosphere following the classical work of Vardya (1965), Mihalas (1967) and Wittmann (1974). The EOS is based on the Saha ionisation equilibrium and the instanteneous chemical equilibrium for the molecules. The main ingredient is hydrogen. It's included as atomic hydrogen (H), negative hydrogen ion (H-), positive hydrogen ion (H+), and as H2 and H2+ molecules. For all other atoms the neutral and the first two ionisation stages are included.

The equations were first published by Vardya (1967). Mihalas (1967) gave a simple numerical algorithm for an efficient solution of the system. Wittmann (1974) copied the equations and add a corrective factor that provides numerical stability at high temperature.



The derivation here follows Mihalas. However, in the original derivation there is a couple of inconsistencies that obscure the procedure. Here I write the equations in a correct and consistent way.

Definitions

Let's first define the pressures:
$p_{\mathrm{H}}$ - partial pressure of the neutral H atoms;
$p_{\mathrm{H^+}}$ - partial pressure of the positive H ions (protons);

Tuesday 3 May 2016

Effective Lande g-factor (in IDL)

The effective Lande g-factor (Shenstone and Blaire, 1929) is defined for a spectral line. It shows how much the $\sigma$ components of the normal Zeeman triplet are separated from the line center.  The higher the Lande factor is, the line is more sensitive to the magnetic field. It is computed as a combination of g-factors for each of the involved atomic levels. Derivation of the equation can be found, for example, in Landi Degl'Innocenti (1982SoPh...77..285L, see it for more details and for an alternative expression useful in the polarized radiative transfer).

For each of the levels (u for upper, l for lower) in LS coupling holds:
$$g_\mathrm{LS} =\frac{3}{2}+\frac{S (S+1) - L (L+1)}{2J(J+1)}, $$ 
where $L$, $S$ and $J$ are the orbitatl, spin and total angular momentum quantum numbers of the atomic level (note that it is undefined for $J=0$). The effective Lande g-factor is then defined as:
$$\bar{g} = \frac{1}{2}(g_\mathrm{l} +g_\mathrm{u}) + \frac{1}{4}(g_\mathrm{l} - g_\mathrm{u})(J_\mathrm{l}(J_\mathrm{l}+1) - J_\mathrm{u}(J_\mathrm{u}+1)).$$

Here is my IDL code for computing the effective Lande g-factor of a spectral line in LS coupling. At the input the code takes the quantum number of the lower and the upper level of a transition. The numbers may be specified either as an array [L, S, J] or in spectroscopic notation.

Example:
IDL> PRINT, LANDE_FACTOR(lower  = [3., 1, 2.], upper = '3p1.0')
  Upper term: 3p1.0 => l = 1.00000s = 1.00000j = 1.00000
          0.250000

IDL> PRINT, LANDE_FACTOR(lower  = '5F1.0', upper = '5d0.0')
  Lower term: 5f1.0 => l = 3.00000s = 2.00000j = 1.00000
  Upper term: 5d0.0 => l = 2.00000s = 2.00000j = 0.00000
          0.00000


Download: lande_factor.pro

Friday 15 January 2016

Kurucz' Atlas in GNU Linux

I have just found about great effort made by Sbordone, Bonifacio & Castelli to make the Atlas code of Bob Kurucz available at GNU Linux.

There is a webpage: http://atmos.obspm.fr/ providing the code and the documentation.