?About the author: A Matlab simulation developer who loves scientific research. He cultivates his mind and improves his technology simultaneously. For cooperation on MATLAB projects, please send a private message.
Personal homepage: Matlab Research Studio
Personal credo: Investigate things to gain knowledge.
For more complete Matlab code and simulation customization content, click
Intelligent optimization algorithm Neural network prediction Radar communication Wireless sensor Power system
Signal processing Image processing Path planning Cellular automaton Drone
Content introduction
With the continuous development of science and technology, we can now obtain the longitude and latitude of any place on the earth through a variety of methods. This provides convenience for us to understand local astronomical phenomena. Among them, it is very useful to calculate the rise and set times of the sun and moon and the twilight time. In this article, we will explore how to calculate these times based on known latitude and longitude.
First, let’s understand some basic concepts in astronomy. When observing astronomical phenomena on the earth, we usually use the horizon coordinate system to describe the position of celestial bodies. In this coordinate system, the position of a celestial body is determined by two parameters: azimuth and altitude. Azimuth is the angle measured counterclockwise from true north and ranges from 0 to 360 degrees. Altitude angle is the angle between a celestial body and the ground plane, ranging from 0 to 90 degrees.
The sun and moon rise and set times and twilight time are related to azimuth and altitude angles. When the altitude angle of the sun or moon reaches 0 degrees, they rise or set. Twilight time refers to the period of time between when the sun goes down and when it becomes completely dark. During this time, there is still some residual light in the sky, but it is enough for us to see objects around us clearly.
Now, let’s see how to calculate these times. We can use astronomical algorithms to calculate the altitude and azimuth of the Sun and Moon. These algorithms calculate based on the position and time of celestial objects. For the Sun, we can use the heliocentric ecliptic coordinate system to calculate its position. For the moon, we can use the lunar ecliptic coordinate system to calculate its position.
Once we have calculated the altitude and azimuth of the Sun and Moon, we can calculate their rise and set times using the following formulas:
cos(H) = (sin(-0.8333) – sin(φ) × sin(δ)) / (cos(φ) × cos(δ))
Among them, H is the altitude angle of the celestial body, φ is the latitude of the observation location, and δ is the declination of the celestial body. When cos(H) is greater than 1, the sun or moon never rises or sets. When cos(H) is less than -1, the sun or moon is always below the horizon. In this case, we can calculate their rise and fall times using the following formula:
t = acos(-tan(φ) × tan(δ)) / 15
Among them, t is time, and the unit is hours. When cos(H) is between -1 and 1, we can calculate the rise and fall times using the following formula:
t = (H ± L) / 15 + RA – 6.6974
Among them, L is the geographical longitude and RA is the right ascension of the celestial body. When the celestial body is the sun, we need to change 6.6974 to -12.
Calculating twilight time is also easy. We can use the following formula:
t = (cos(-6°) – sin(φ) × sin(δ)) / (cos(φ) × cos(δ))
Among them, t is time, and the unit is hours. When t is negative, the sun has not set yet. When t is a positive number, the sun has set.
In the modern world, we have various software and tools available to us to calculate the sun and moon rise and set times and twilight times. For example, astronomy enthusiasts can use free software such as Stellarium to observe celestial objects. For professional astronomers and astronomical researchers, they usually use more precise tools to perform calculations.
In conclusion, it is very useful to calculate the rise and set times of the sun and moon, as well as the twilight time. They help us understand local astronomical phenomena and plan our activities. By using astronomical algorithms and modern tools, we can easily calculate these times and enjoy a wonderful astronomical journey.
Part of the code
%% Clear environment variables</code><code>warning off % Close alarm information</code><code>close all % Close open figure window</code><code>clear % Clear variables</code><code>clc % clear command line</code><code>?</code><code>%% import data</code><code>res = xlsread('dataset.xlsx');</code><code>?</code><code>%% divide the training set and test set</code><code>temp = randperm(357);</code><code>?</code><code>P_train = res(temp(1: 240), 1: 12)';</code><code>T_train = res(temp(1: 240), 13)';</code><code>M = size(P_train , 2);</code><code>?</code><code>P_test = res(temp(241: end), 1: 12)';</code><code>T_test = res(temp(241 : end), 13)';</code><code>N = size(P_test, 2);</code><code>?</code><code>%% data normalization</code><code>[p_train, ps_input] = mapminmax(P_train, 0, 1);</code><code>p_test = mapminmax('apply', P_test, ps_input);</code><code>t_train = ind2vec(T_train) ;</code><code>t_test = ind2vec(T_test );
Operation results
References
[1] SUN Nan, Sun Nan, ZHU Kai-jia, et al. Establishment and solution of the “moon on willow branches, people meet after dusk” model [C]//China Society of Industrial and Applied Mathematics. Chinese Society of Industrial and Applied Mathematics, 2015.
[2] CHEN Chao, Chen Chao, ZHANG Tian-lin, et al. Mathematical models of astronomical phenomena in classical poetry [C]//China Society of Industrial and Applied Mathematics. Chinese Society of Industrial and Applied Mathematics, 2015.
[3] Shen Shuyun, Wang Li, Guo Sanmin, et al. Research on sun shadow positioning based on geometric methods [J]. Journal of Hebei Northern University: Natural Science Edition, 2017, 33(1):7.DOI:10.3969/j.issn .1673-1492.2017.01.005.