<p>As far as I know, interstellar scintillation has only been observed in the radio. However, Habibi et al. present a model in
<a href="https://www.aanda.org/articles/aa/pdf/2013/04/aa20172-12.pdf" rel="nofollow noreferrer">A&amp;A 552, A93 (2013)</a> that suggests it should be detectable in the optical.</p>

CC BY-SA 4.0
2024-06-19T07:22:33.530Z
I upvoted your answer. It turns out that ideally, when modeling, we need to take into account both diffraction and twinkling, because, as I understand it, these are different optical effects. Diffraction gives an image where the star looks like a cross or a plus sign, and twinkling enhances/weaken this effect. https://i.giphy.com/FlodpfQUBSp20.webp
ayr
CC BY-SA 4.0
2024-06-18T21:30:37.663Z
2024-06-18T21:30:37.663Z
John Doty
<p>I found some simple codes for gravitational lensing in Python and reworked one of them for Matlab. Despite the complexity of the theory of relativity, the codes themselves do not look complicated... I will attach my version in Matlab below. Who needs it - use it!  And <a href="https://wwwstaff.ari.uni-heidelberg.de/rschmidt/papers/Jena_Proceedings_Schmidt.html" rel="nofollow noreferrer">here</a> is a link to the source (<em>case #2</em>) in the public domain so that everyone knows the real author. Everything is fair. While working with the code, I wanted to learn the basics of working with wavefront distortion caused by gravitational lensing. One of the factors can be considered closed; what remains is cosmic dust, plasma, etc.</p>
<pre><code>b=0.85;      % deflection angle
gamma=0.15;  % external shear
step=0.005;
window=1.3;
source_size=0.05;
rays = [-window:step:window];
id = rays==0;
rays(id) = (-step) + ((step)-(-step)).*rand(1,nnz(id));
%rays(length(rays)) = [];
[xx, yy] = meshgrid(rays, rays);
nray=length(rays);

% arrangement for spiral source: phi/radius=const
phi=atan2(yy+0.025,xx-0.09);
rr=sqrt((xx-0.09).^2+(yy+0.025).^2);
spiral_1=phi./(2.*rr);
spiral_2=(phi+2.*pi)./(2.*rr);

%source plane with four sources
source_plane=zeros([nray,nray]);
source_plane(xx.^2+(yy+0.025).^2&lt;source_size.^2)=1;
source_plane(((spiral_1&lt;100) &amp; (spiral_1&gt;60)))=2;
source_plane(((spiral_2&lt;100) &amp; (spiral_2&gt;60)))=2;
source_plane((xx-0.22).^2+(yy+0.025).^2&lt;source_size.^2)=3;
source_plane((xx+0.22).^2+(yy+0.22).^2&lt;source_size.^2)=4;

figure
surf(xx,yy,source_plane,'edgecolor','none')
view ([0 0 90])

% construct image plane from rays to source plane
image_plane=zeros([nray,nray]);
for nx = 1:nray
    for ny = 1:nray
        [u,v]=deflect_ray(xx(ny,nx),yy(ny,nx), gamma, b);
        image_plane(ny,nx)=source_plane(fix((v+window)./step),fix((u+window)./step));
    end
end

%plotting sources and caustics/critical lines
beta_plus=2.*b.*gamma./(1+gamma);
beta_minus=2.*b.*gamma./(1-gamma);
phi=linspace(0,2.*pi,100);
tangential_caustic_x=-beta_plus.*cos(phi).^3;
tangential_caustic_y=beta_minus.*sin(phi).^3;
radial_caustic_x=b.*cos(phi)./(1-gamma);
radial_caustic_y=b*sin(phi)/(1+gamma);
critical_curve=b.*(1-gamma.*cos(2.*phi))./(1-gamma.^2);
    
subplot(1,2,1)
surf(xx,yy,source_plane,'edgecolor','none')
view ([0 0 90])
hold on
plot(tangential_caustic_x,tangential_caustic_y,'r','LineWidth',2)
plot(radial_caustic_x,radial_caustic_y,'r','LineWidth',2)
colorbar
axis square

subplot(1,2,2)
surf(xx,yy,image_plane,'edgecolor','none')
view ([0 0 90])
hold on
plot(critical_curve.*cos(phi),critical_curve.*sin(phi),'r','LineWidth',2)
colorbar
axis square
</code></pre>
<p>And function:</p>
<pre><code>function [out1,out2] = deflect_ray(theta_1,theta_2,gamma,b)
% Lens equation
theta = sqrt(theta_1.^2+theta_2.^2);
%[out1,out2] = [theta_1.*(1-gamma)-b.*theta_1./theta, theta_2.*(1+gamma)-b.*theta_2./theta];

out1 = theta_1.*(1-gamma)-b.*theta_1./theta;
out2 = theta_2.*(1+gamma)-b.*theta_2./theta;
end
</code></pre>
<p><a href="https://i.sstatic.net/Oloneww1.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Oloneww1.png" alt="enter image description here" /></a></p>

CC BY-SA 4.0
2024-06-22T15:05:13.463Z
2024-06-22T15:05:13.463Z
ayr
<p>Associated with: <a href="https://astronomy.stackexchange.com/questions/57929/flowchart-of-the-pipeline-of-key-processes-for-modeling-wavefront-distortion-of">Flowchart of the pipeline of key processes for modeling wavefront distortion of astronomical objects: ground-based observation case</a></p>
<p>Let's imagine for a moment that we are outside the Earth and decided to observe one of the astronomical objects (exoplanet, star, star cluster, galaxy, etc.). We have all the necessary tools at our disposal. Introduced?</p>
<p>Now let's go back to Earth and imagine that we need to simulate what the wavefront of our chosen object would look like if we were observing it from outside the Earth. For some time I have been haunted by the following question: in space there are many factors that can also distort the wavefront of the selected object of observation, in addition to turbulence in the atmosphere.</p>
<p>These factors include cosmic dust, plasma, rays from other particles with which an electromagnetic wave can interact, gravitational fields, stellar wind and other components of the interstellar medium.
Are there mathematical models that simulate the influence of these factors on the wavefront of the observed astronomical object in the case of observation outside the Earth.
I couldn't find any information myself, unfortunately.</p>
<p><strong>EDIT:</strong> Together with <a href="https://astronomy.stackexchange.com/a/57932/48182">John Doty's answer</a> and <a href="https://astronomy.stackexchange.com/a/57956/48182">mine</a>, this provides background for two effects: interstellar scintillation and gravitational lensing. Can someone add other effects and give a quick summary?</p>

CC BY-SA 4.0
2024-06-19T09:37:50.623Z
Can you mention a wavelength range, or would you like answers to cover say a few MHz to gamma rays?
uhoh
CC BY-SA 4.0
2024-06-20T04:13:56.170Z
@uhoh I would like any wavelength and frequency that exists in nature to be available as a model parameter. When modeling, it is better to proceed from the object that is selected for this (for example, class G stars, spiral galaxies, gas exoplanets, etc.). I would start with the star models.
ayr
<observational-astronomy><astrophysics><dust><modeling><gas>
Mathematical modeling of the influence of components of the interstellar medium on the distortion of the wavefront of the observed object
ayr
# Mathematical modeling of the influence of components of the interstellar medium on the distortion of the wavefront of the observed object

(Asked by: username_0 on 2024-06-18)

Associated with: [Flowchart of the pipeline of key processes for modeling wavefront distortion of astronomical objects: ground-based observation case](https://astronomy.stackexchange.com/questions/57929/flowchart-of-the-pipeline-of-key-processes-for-modeling-wavefront-distortion-of)

Let's imagine for a moment that we are outside the Earth and decided to observe one of the astronomical objects (exoplanet, star, star cluster, galaxy, etc.). We have all the necessary tools at our disposal. Introduced?

Now let's go back to Earth and imagine that we need to simulate what the wavefront of our chosen object would look like if we were observing it from outside the Earth. For some time I have been haunted by the following question: in space there are many factors that can also distort the wavefront of the selected object of observation, in addition to turbulence in the atmosphere.

These factors include cosmic dust, plasma, rays from other particles with which an electromagnetic wave can interact, gravitational fields, stellar wind and other components of the interstellar medium.
Are there mathematical models that simulate the influence of these factors on the wavefront of the observed astronomical object in the case of observation outside the Earth.
I couldn't find any information myself, unfortunately.

**EDIT:** Together with [John Doty's answer](https://astronomy.stackexchange.com/a/57932/48182) and [mine](https://astronomy.stackexchange.com/a/57956/48182), this provides background for two effects: interstellar scintillation and gravitational lensing. Can someone add other effects and give a quick summary?

**Tags:** observational-astronomy, astrophysics, dust, modeling, gas
> **Comments:**
> **username_1**: Can you mention a wavelength range, or would you like answers to cover say a few MHz to gamma rays?  
> **username_0**: @uhoh I would like any wavelength and frequency that exists in nature to be available as a model parameter. When modeling, it is better to proceed from the object that is selected for this (for example, class G stars, spiral galaxies, gas exoplanets, etc.). I would start with the star models.  

---

## 2 answers

### Answer by username_2 on 2024-06-18. Score: 4

As far as I know, interstellar scintillation has only been observed in the radio. However, Habibi et al. present a model in
[A&A 552, A93 (2013)](https://www.aanda.org/articles/aa/pdf/2013/04/aa20172-12.pdf) that suggests it should be detectable in the optical.

> **Comments:**
> **username_0**: I upvoted your answer. It turns out that ideally, when modeling, we need to take into account both diffraction and twinkling, because, as I understand it, these are different optical effects. Diffraction gives an image where the star looks like a cross or a plus sign, and twinkling enhances/weaken this effect. https://i.giphy.com/FlodpfQUBSp20.webp  

---

### Answer by username_0 on 2024-06-22. Score: 1

I found some simple codes for gravitational lensing in Python and reworked one of them for Matlab. Despite the complexity of the theory of relativity, the codes themselves do not look complicated... I will attach my version in Matlab below. Who needs it - use it!  And here is a link to the source (case #2) in the public domain so that everyone knows the real author. Everything is fair. While working with the code, I wanted to learn the basics of working with wavefront distortion caused by gravitational lensing. One of the factors can be considered closed; what remains is cosmic dust, plasma, etc.
b=0.85;      % deflection angle
gamma=0.15;  % external shear
step=0.005;
window=1.3;
source_size=0.05;
rays = [-window:step:window];
id = rays==0;
rays(id) = (-step) + ((step)-(-step)).*rand(1,nnz(id));
%rays(length(rays)) = [];
[xx, yy] = meshgrid(rays, rays);
nray=length(rays);

% arrangement for spiral source: phi/radius=const
phi=atan2(yy+0.025,xx-0.09);
rr=sqrt((xx-0.09).^2+(yy+0.025).^2);
spiral_1=phi./(2.*rr);
spiral_2=(phi+2.*pi)./(2.*rr);

%source plane with four sources
source_plane=zeros([nray,nray]);
source_plane(xx.^2+(yy+0.025).^260)))=2;
source_plane(((spiral_2<100) & (spiral_2>60)))=2;
source_plane((xx-0.22).^2+(yy+0.025).^2
And function:
function [out1,out2] = deflect_ray(theta_1,theta_2,gamma,b)
% Lens equation
theta = sqrt(theta_1.^2+theta_2.^2);
%[out1,out2] = [theta_1.*(1-gamma)-b.*theta_1./theta, theta_2.*(1+gamma)-b.*theta_2./theta];

out1 = theta_1.*(1-gamma)-b.*theta_1./theta;
out2 = theta_2.*(1+gamma)-b.*theta_2./theta;
end


---

