Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Zheng Gaoshan
co-devTest
Commits
f61de360
Commit
f61de360
authored
Jul 25, 2025
by
qiongying
Browse files
tst
parent
1d681ec8
Changes
4
Show whitespace changes
Inline
Side-by-side
__pycache__/codesp.cpython-311.pyc
View file @
f61de360
No preview for this file type
codesp.py
View file @
f61de360
import
jinja2
#
import jinja2
#this is test message 0523
#this is test message 0523
def
test
():
import
numpy
as
np
try
:
import
matplotlib.pyplot
as
plt
import
ephem
template
=
jinja2
.
Template
(
"Hello {{ name }}!"
)
assert
template
.
render
(
name
=
"World"
)
==
"Hello World!"
# def test():
print
(
"✅ Jinja2 模板渲染测试通过"
)
# try:
except
Exception
as
e
:
print
(
"❌ Jinja2 测试失败:"
,
e
)
# template = jinja2.Template("Hello {{ name }}!")
# assert template.render(name="World") == "Hello World!"
# print("✅ Jinja2 模板渲染测试通过")
# except Exception as e:
# print("❌ Jinja2 测试失败:", e)
def
simulate_star_trajectory
(
semi_major_axis
,
eccentricity
,
period
,
start_date
,
end_date
,
step_days
):
# Initialize observer location (e.g., Earth location)
observer
=
ephem
.
Observer
()
observer
.
lat
,
observer
.
lon
=
'0'
,
'0'
# Create a body using orbital elements
star
=
ephem
.
EllipticalBody
()
star
.
_a
=
semi_major_axis
# Semi-major axis in AU
star
.
_e
=
eccentricity
# Eccentricity of the orbit
star
.
_Om
=
0.0
# Longitude of ascending node
star
.
_om
=
0.0
# Argument of perihelion
star
.
_inc
=
0.0
# Inclination to the ecliptic
star
.
_M
=
0.0
# Mean anomaly
star
.
_epoch
=
ephem
.
Date
(
start_date
)
# Epoch of perihelion
# Date range
date_range
=
np
.
arange
(
ephem
.
Date
(
start_date
),
ephem
.
Date
(
end_date
),
step_days
)
# Store positions
positions
=
[]
for
date
in
date_range
:
observer
.
date
=
date
star
.
compute
(
observer
)
#将天体坐标转换为黄道坐标
ecliptic_coords
=
ephem
.
Ecliptic
(
star
)
# 获取黄道坐标
x
,
y
=
ecliptic_coords
.
lon
,
ecliptic_coords
.
lat
# lon 对应黄道经度,lat 对应黄道纬度
# x, y = ephem.Ecliptic(star).suun()
positions
.
append
((
x
,
y
))
# Extract x and y coordinates
x_coords
,
y_coords
=
zip
(
*
positions
)
# Visualization
plt
.
plot
(
x_coords
,
y_coords
,
label
=
'Star trajectory'
)
plt
.
scatter
(
x_coords
[
0
],
y_coords
[
0
],
color
=
'red'
,
label
=
'Start'
)
plt
.
scatter
(
x_coords
[
-
1
],
y_coords
[
-
1
],
color
=
'green'
,
label
=
'End'
)
plt
.
xlabel
(
'X (AU)'
)
plt
.
ylabel
(
'Y (AU)'
)
plt
.
title
(
'Simulated Star Trajectory'
)
plt
.
legend
()
plt
.
grid
()
plt
.
show
()
plt
.
savefig
(
"star_trajectory.png"
)
print
(
"图像已保存为 star_trajectory.png"
)
# try:
# try:
# import jsonschema
# import jsonschema
...
...
run.py
View file @
f61de360
import
os
import
os
import
shutil
import
shutil
#
from codesp import test
from
codesp
import
simula
te
_
st
ar_trajectory
...
@@ -8,28 +8,30 @@ import shutil
...
@@ -8,28 +8,30 @@ import shutil
def
main
():
def
main
():
# test()
# test()
# 定义初始路径和目标路径
simulate_star_trajectory
(
semi_major_axis
=
1.0
,
eccentricity
=
0.1
,
period
=
365.25
,
start_date
=
'2023/1/1'
,
end_date
=
'2024/1/1'
,
step_days
=
10
)
source_dir
=
'/workspace/input/'
target_dir
=
'/workspace/output/'
# # 定义初始路径和目标路径
# source_dir = '/workspace/input/'
# 确保源路径存在
# target_dir = '/workspace/output/'
if
not
os
.
path
.
exists
(
source_dir
):
print
(
f
"错误:源路径
{
source_dir
}
不存在。"
)
# # 确保源路径存在
else
:
# if not os.path.exists(source_dir):
# 创建目标路径(如果不存在)
# print(f"错误:源路径 {source_dir} 不存在。")
os
.
makedirs
(
target_dir
,
exist_ok
=
True
)
# else:
# # 创建目标路径(如果不存在)
# 获取源路径下的所有文件(不递归子目录)
# os.makedirs(target_dir, exist_ok=True)
for
file_name
in
os
.
listdir
(
source_dir
):
source_file
=
os
.
path
.
join
(
source_dir
,
file_name
)
# # 获取源路径下的所有文件(不递归子目录)
target_file
=
os
.
path
.
join
(
target_dir
,
file_name
)
# for file_name in os.listdir(source_dir):
# source_file = os.path.join(source_dir, file_name)
# 只拷贝文件,忽略子目录
# target_file = os.path.join(target_dir, file_name)
if
os
.
path
.
isfile
(
source_file
):
shutil
.
copy2
(
source_file
,
target_file
)
# copy2 保留元数据(如修改时间)
# # 只拷贝文件,忽略子目录
print
(
f
"已拷贝:
{
source_file
}
->
{
target_file
}
"
)
# if os.path.isfile(source_file):
# shutil.copy2(source_file, target_file) # copy2 保留元数据(如修改时间)
print
(
"拷贝完成。"
)
# print(f"已拷贝: {source_file} -> {target_file}")
# print("拷贝完成。")
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
main
()
main
()
star_trajectory.png
0 → 100644
View file @
f61de360
31.1 KB
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment