Skip to content

Commit 5e97b59

Browse files
committed
seems to be working
1 parent 17d192d commit 5e97b59

7 files changed

Lines changed: 87 additions & 669 deletions

File tree

campyros/main.py

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
from scipy.spatial.transform import Rotation
4343
import numexpr as ne
4444

45-
from datetime import date
45+
from datetime import date, timedelta
4646
from ambiance import Atmosphere
4747

4848
from .constants import r_earth, ang_vel_earth, f
@@ -222,11 +222,8 @@ def __init__(
222222
lat,
223223
variable_wind=True,
224224
default_wind=[0, 0, 0],
225-
wind_data_loc="data/wind/gfs",
226-
run_date=date.today().strftime("%Y%m%d"),
227-
forcast_time="00",
228-
forcast_plus_time="000",
229-
fast_wind=False,
225+
launch_datetime=(date.today()-timedelta(days=2)).strftime("%Y%m%d %H:%M"),
226+
cache_Wind=False
230227
):
231228
self.rail_length = rail_length
232229
self.rail_yaw = rail_yaw
@@ -235,15 +232,10 @@ def __init__(
235232
self.longi = longi
236233
self.lat = lat
237234
self.wind = Wind(
238-
longi,
239-
lat,
240235
variable=variable_wind,
241236
default=default_wind,
242-
data_loc=wind_data_loc,
243-
run_date=run_date,
244-
forcast_time=forcast_time,
245-
forcast_plus_time=forcast_plus_time,
246-
fast=fast_wind,
237+
datetime=launch_datetime,
238+
cache=cache_Wind
247239
)
248240

249241

campyros/new_wind.py

Lines changed: 0 additions & 96 deletions
This file was deleted.

campyros/statistical.py

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -122,18 +122,6 @@ def __init__(self, run_file):
122122
self.enviromental = data["enviromental"]
123123
self.thrust_error = data["thrust_error"]
124124
self.mass_vars = data["mass"]
125-
126-
self.wind_base = Wind(
127-
self.launch_site_vars["long"][0],
128-
self.launch_site_vars["lat"][0],
129-
variable=bool(self.launch_site_vars["variable_wind"]),
130-
run_date=self.launch_site_vars["run_date"],
131-
forcast_time=self.launch_site_vars["run_time"],
132-
forcast_plus_time=self.launch_site_vars["run_plus_time"],
133-
fast=self.launch_site_vars["fast_wind"],
134-
)
135-
136-
print(data["motor_file"])
137125
self.motor_data = load_motor(data["motor_file"])
138126
self.motor_base = Motor.from_novus(data["motor_file"], pos=data["motor_pos"])
139127

@@ -156,8 +144,6 @@ def run_itteration(self, id, save_loc, debug=False):
156144
thrust_e = np.random.normal(1, self.thrust_error["magnitude"])
157145
motor.thrust_array = [t * thrust_e for t in motor.thrust_array]
158146

159-
wind = copy.copy(self.wind_base) # Wind variability coming soon
160-
161147
dry_mass = self.mass_vars["dry_mass"][0] * np.random.normal(
162148
1, self.mass_vars["dry_mass"][1]
163149
)
@@ -263,10 +249,8 @@ def run_itteration(self, id, save_loc, debug=False):
263249
lat=self.launch_site_vars["lat"][0]
264250
* np.random.normal(1, self.launch_site_vars["lat"][1]),
265251
variable_wind=bool(self.launch_site_vars["variable_wind"]),
266-
run_date=self.launch_site_vars["run_date"],
267-
forcast_plus_time=self.launch_site_vars["run_plus_time"],
268-
forcast_time=self.launch_site_vars["run_time"],
269-
fast_wind=bool(self.launch_site_vars["fast_wind"]),
252+
launch_datetime=self.launch_site_vars["launch_datetime"],
253+
cache_Wind=True
270254
)
271255

272256
###Parachute

campyros/tests/test.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import unittest
2-
import sys, os
2+
import sys, os, json
3+
from datetime import date,timedelta,datetime
34

45
sys.path.append(
56
"/".join(
@@ -8,7 +9,7 @@
89
)
910
import campyros as pyro
1011
from campyros import statistical as stats
11-
from campyros import new_wind as wind
12+
from campyros import wind
1213
import csv
1314
import time
1415
import numpy as np
@@ -114,8 +115,6 @@
114115
longi=0.1,
115116
lat=52.1,
116117
variable_wind=False,
117-
fast_wind=True,
118-
run_date="20210216",
119118
) # Use this version if you don't want to use the real wind (e.g. to test something else)
120119

121120
parachute = pyro.Parachute(
@@ -138,7 +137,7 @@
138137
alt_poll_interval=1,
139138
parachute=parachute,
140139
)
141-
"""
140+
142141
run = martlet4.run(debug=False)
143142

144143
test_output = pyro.from_json("campyros/tests/test.json")
@@ -168,10 +167,10 @@
168167
parachute_ind_run = ind
169168
if "Cleared rail" in ev:
170169
rail_ind_run = ind
171-
"""
170+
172171

173172
class ExampleTest(unittest.TestCase):
174-
"""def test_time(self):
173+
def test_time(self):
175174
self.assertAlmostEqual(run_time // 5, run.time.max() // 5, places=0)
176175

177176
def test_apogee(self):
@@ -205,6 +204,11 @@ def test_parachute(self):
205204
)
206205

207206
def test_stats(self):
207+
with open("campyros/tests/test_stats.json",'r') as f:
208+
stat_dat=json.load(f)
209+
stat_dat["launch_site"]["launch_datetime"]=(date.today()-timedelta(days=2)).strftime("%Y%m%d %H:%M")
210+
with open("campyros/tests/test_stats.json",'w') as f:
211+
json.dump(stat_dat,f)
208212
stats_model = stats.StatisticalModel("campyros/tests/test_stats.json")
209213
ran = stats_model.run_model(test_mode=True, num_cpus=1)
210214
print(ran)
@@ -216,16 +220,16 @@ def test_stats(self):
216220
True,
217221
ran,
218222
msg="Statistical model run failed, no further information automatically available",
219-
)"""
223+
)
220224

221225
def test_wind(self):
222226
wind1=wind.Wind((date.today()-timedelta(days=1)).strftime("%Y%m%d %H:%M"))
223-
wind1_val=wind1.get(239,923,292728238)
224-
self.assertIsInstance(wind1_val,type((0.0,0.0)))
225-
self.assertEqual(2,len(wind1_val))
227+
wind1_val=wind1.get_wind(239,923,292728238)
228+
self.assertIsInstance(wind1_val,type(np.array([0.0,0.0])))
229+
self.assertEqual(3,len(wind1_val))
226230

227231
wind2=wind.Wind(variable=False)
228-
wind2_val=wind2.get(-239,-923,-292728238)
232+
wind2_val=wind2.get_wind(-239,-923,-292728238)
229233
self.assertEqual(0,wind2_val[0])
230234
self.assertEqual(0,wind2_val[1])
231235

0 commit comments

Comments
 (0)