How to Plot the Light Path in a Space-Time Diagram Using Python?

In summary, to replicate the space-time plot, you need to plot the Hubble radius, particle horizon, and galaxy trajectory. To plot the light path, you can use the same method as the galaxy trajectory, but with a different redshift value. An example code for plotting the light path at a specific time is provided.
  • #1
AdrianD
8
2
TL;DR Summary
Space-time diagram with python
I am trying to replicate the space time plot (the 2nd plot with Proper distance vs Time) as in this thread: space-time
I wrote everything in python using the astropy cosmology package.
Everything went smooth, but I am stuck at plotting the light path on the 'purple path', as per the above example. I don't know how to plot the light path for the light emitted by the galaxy at t0 = 0 (now), with the proper distance of aprox 13.8 Glyr, that will reach us a t=49 Gyr.
Here is the code in python:

SpaceTime:
from astropy.cosmology import Planck18, z_at_value
from astropy import units as u
import numpy as np
from matplotlib import pyplot as plt
from scipy import interpolate as inter
import astropy.constants as cc# Hubble radius

def Hradius(zed):
    c = cc.c
    return (c/cosmo.H(zed)).to(u.Glyr)

#define cosmology

cosmo = Planck18
# Z and time

redshift = np.arange(-0.9,1089,0.1)

redshift_R = redshift[::-1]

time=cosmo.age(redshift)
# trajectory of a galaxy G1 with z=1.48

TrajectoryG1 = [cosmo.scale_factor(i) * cosmo.comoving_distance(1.48737).to(u.Glyr).value for i in redshift]
### Can't make it work

#lightPathG1 = [cosmo.scale_factor(0) * cosmo.comoving_distance(i).to(u.Glyr).value for i in redshiftG1]
# horizons

hubbleRadius = [Hradius(i).value for i in redshift]

hubbleRadiusMirrored = [-Hradius(i).value for i in redshift]

lightPath = [cosmo.scale_factor(i) * cosmo.comoving_distance(i).to(u.Glyr).value for i in redshift]

lightPathMirrored = [cosmo.scale_factor(i) * -cosmo.comoving_distance(i).to(u.Glyr).value for i in redshift]term1 = [cosmo.scale_factor(i) for i in redshift]

term2 = [cosmo.comoving_distance(i).to(u.Glyr).value for i in redshift_R]

term3 = [-cosmo.comoving_distance(i).to(u.Glyr).value for i in redshift_R]

particleHorizon = [term1*term2 for i in range(len(redshift))]

particleHorizonMirrored = [term1*term3 for i in range(len(redshift))]
#plot

fig, ax1 = plt.subplots()

ax1.plot(time,hubbleRadius, 'g-', label = 'Hubble radius')

ax1.plot(time,hubbleRadiusMirrored, 'g-')

ax1.plot(time,lightPath, 'y-', label = 'Light path')

ax1.plot(time,lightPathMirrored, 'y-')

ax1.plot(time,particleHorizon, 'b-', label = 'Particle horizon')

ax1.plot(time,particleHorizonMirrored, 'b-')
ax1.plot(time,TrajectoryG1, 'k',linestyle='-.', label = 'G1 trajectory')

#ax1.plot(timeG1,lightPathG1, color = 'orange')
ax1.set_ylim(ymin=-50, ymax=50)

ax1.axvline(x=13.7,color='grey',linestyle='--',alpha=0.5)

ax1.axhline(y=0,color='grey',linestyle='--',alpha=0.5)
ax1.fill_between(np.append(time.value, time[::-1].value), np.append(hubbleRadius, hubbleRadiusMirrored[::-1]), color = 'green', alpha = 0.1)
ax1.invert_xaxis()

ax1.legend()

ax1.set_xlabel('Time (Gyr)')

ax1.set_ylabel('Proper distance (Glyr)')
And my plot :
cosmo.png
 
Space news on Phys.org
  • #2


I see that you have successfully plotted the Hubble radius, particle horizon, and galaxy trajectory. To plot the light path, you can use the same method you used for the galaxy trajectory, but with a different redshift value. Since the light from the galaxy is reaching us at t=49 Gyr, you can use the redshift value at that time to calculate the proper distance.

Here is an example code for plotting the light path at t=49 Gyr:

# redshift at t=49 Gyr
redshift_49Gyr = z_at_value(cosmo.age, 49 * u.Gyr)

# calculate proper distance at t=49 Gyr
proper_distance_49Gyr = cosmo.comoving_distance(redshift_49Gyr).to(u.Glyr).value

# plot light path at t=49 Gyr
ax1.plot(49, proper_distance_49Gyr, 'o', color='orange', label='Light path at t=49 Gyr')

# add legend to the plot
ax1.legend()

# show the plot
plt.show()

This should plot the light path at t=49 Gyr as a point on your plot. You can also adjust the code to plot the light path at different time intervals if needed. I hope this helps and good luck with your replication!
 

1. What is a space-time diagram?

A space-time diagram is a graphical representation of the relationship between space and time. It shows how objects move through space and time, and how different events are related to each other.

2. How do I read a space-time diagram?

The horizontal axis represents space, while the vertical axis represents time. The diagonal line at a 45-degree angle represents the speed of light. Objects moving at the speed of light will follow this line, while objects moving slower will have a steeper slope. Events that occur at the same time are shown on the same horizontal line, and events that occur at the same location are shown on the same vertical line.

3. What is the purpose of a space-time diagram?

A space-time diagram helps us visualize and understand the relationship between space and time in different scenarios, such as the movement of objects, the effects of gravity, and the behavior of light. It is a useful tool in studying and explaining concepts in physics and astronomy.

4. How does time dilation affect a space-time diagram?

Time dilation is the phenomenon where time appears to pass slower for objects moving at high speeds. This is represented in a space-time diagram by a flatter slope for the object's path. This means that time appears to pass slower for the moving object compared to a stationary observer.

5. Can a space-time diagram be used to represent events in the future?

Yes, a space-time diagram can be used to represent events in the future. The horizontal axis can be extended to show future events, and the slope of an object's path can indicate its speed and direction of movement in the future. However, it is important to note that the future is not predetermined and can change based on various factors.

Similar threads

  • Programming and Computer Science
Replies
3
Views
2K
Replies
5
Views
362
  • Special and General Relativity
3
Replies
75
Views
3K
  • Programming and Computer Science
Replies
21
Views
4K
  • Programming and Computer Science
Replies
4
Views
4K
  • Programming and Computer Science
Replies
1
Views
1K
Replies
9
Views
4K
Replies
2
Views
4K
  • Introductory Physics Homework Help
Replies
2
Views
3K
  • Programming and Computer Science
Replies
1
Views
2K
Back
Top