11import unittest
2- import sys , os
2+ import sys , os , json
3+ from datetime import date ,timedelta ,datetime
34
45sys .path .append (
56 "/" .join (
89)
910import campyros as pyro
1011from campyros import statistical as stats
11- from campyros import new_wind as wind
12+ from campyros import wind
1213import csv
1314import time
1415import numpy as np
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
121120parachute = pyro .Parachute (
138137 alt_poll_interval = 1 ,
139138 parachute = parachute ,
140139)
141- """
140+
142141run = martlet4 .run (debug = False )
143142
144143test_output = pyro .from_json ("campyros/tests/test.json" )
168167 parachute_ind_run = ind
169168 if "Cleared rail" in ev :
170169 rail_ind_run = ind
171- """
170+
172171
173172class 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