Skip to content

Instantly share code, notes, and snippets.

@TTY6335
Last active September 27, 2020 12:20
Show Gist options
  • Save TTY6335/ac2a71d6e2ce39f6b3735e53e396326d to your computer and use it in GitHub Desktop.
Save TTY6335/ac2a71d6e2ce39f6b3735e53e396326d to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"\n",
"import astropy.units as u\n",
"from astropy import time\n",
"\n",
"from poliastro import iod\n",
"from poliastro.bodies import Earth, Mars, Sun\n",
"from poliastro.ephem import Ephem\n",
"from poliastro.twobody import Orbit\n",
"from poliastro.maneuver import Maneuver\n",
"from poliastro.util import time_range"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"from astropy.coordinates import solar_system_ephemeris"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"#打ち上げ日\n",
"date_launch = time.Time(\"2020-07-30 11:50\", scale=\"utc\").tdb\n",
"#火星到着日\n",
"date_arrival = time.Time(\"2021-02-18 20:30\", scale=\"utc\").tdb"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"遷移軌道を計算していきます"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"#地球の定義を呼び出す\n",
"earth = Ephem.from_body(Earth, time_range(date_launch, end=date_arrival))\n",
"#火星の定義を呼び出す\n",
"mars = Ephem.from_body(Mars, time_range(date_launch, end=date_arrival))"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"# Solve for departure and target orbits\n",
"ss_earth = Orbit.from_ephem(Sun, earth, date_launch)\n",
"ss_mars = Orbit.from_ephem(Sun, mars, date_arrival)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"# 遷移軌道を計算する\n",
"man_lambert = Maneuver.lambert(ss_earth, ss_mars)\n",
"ss_trans, ss_target = ss_earth.apply_maneuver(man_lambert, intermediate=True)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"#3Dプロットのモジュールを呼び出す\n",
"from poliastro.plotting import OrbitPlotter3D"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
"#ここのコメントを外してください\n",
"#plotter = OrbitPlotter3D()\n",
"#plotter.set_attractor(Sun)\n",
"\n",
"#plotter.plot_ephem(earth, date_launch, label=\"Earth at launch position\")\n",
"#plotter.plot_ephem(mars, date_arrival, label=\"Mars at arrival position\")\n",
"#plotter.plot_trajectory(\n",
"# ss_trans.sample(max_anomaly=180 * u.deg), color=\"black\", label=\"Transfer orbit\"\n",
"#)\n",
"#plotter.set_view(30 * u.deg, 260 * u.deg, distance=3 * u.km)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.0"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment