@@ -51,7 +51,10 @@ class FlightController:
51
51
"""
52
52
53
53
def __init__ (
54
- self , flight : Flight , rocket_option : RocketOptions , motor_kind : MotorKinds
54
+ self ,
55
+ flight : Flight ,
56
+ rocket_option : RocketOptions ,
57
+ motor_kind : MotorKinds ,
55
58
):
56
59
rocketpy_rocket = RocketController (
57
60
flight .rocket , rocket_option = rocket_option , motor_kind = motor_kind
@@ -110,7 +113,8 @@ async def get_flight(flight_id: int) -> "Union[Flight, HTTPException]":
110
113
).get_flight ()
111
114
if not successfully_read_flight :
112
115
raise HTTPException (
113
- status_code = status .HTTP_404_NOT_FOUND , detail = "Flight not found."
116
+ status_code = status .HTTP_404_NOT_FOUND ,
117
+ detail = "Flight not found." ,
114
118
)
115
119
116
120
return successfully_read_flight
@@ -136,13 +140,18 @@ async def get_rocketpy_flight(
136
140
).get_flight ()
137
141
if not successfully_read_flight :
138
142
raise HTTPException (
139
- status_code = status .HTTP_404_NOT_FOUND , detail = "Flight not found."
143
+ status_code = status .HTTP_404_NOT_FOUND ,
144
+ detail = "Flight not found." ,
140
145
)
141
146
142
147
successfully_read_rocketpy_flight = FlightController (
143
148
flight = successfully_read_flight ,
144
- rocket_option = RocketOptions (successfully_read_flight .rocket ._rocket_option ),
145
- motor_kind = MotorKinds (successfully_read_flight .rocket .motor ._motor_kind ),
149
+ rocket_option = RocketOptions (
150
+ successfully_read_flight .rocket ._rocket_option
151
+ ),
152
+ motor_kind = MotorKinds (
153
+ successfully_read_flight .rocket .motor ._motor_kind
154
+ ),
146
155
).rocketpy_flight
147
156
148
157
return FlightPickle (
@@ -171,12 +180,15 @@ async def update_flight(
171
180
).get_flight ()
172
181
if not successfully_read_flight :
173
182
raise HTTPException (
174
- status_code = status .HTTP_404_NOT_FOUND , detail = "Flight not found."
183
+ status_code = status .HTTP_404_NOT_FOUND ,
184
+ detail = "Flight not found." ,
175
185
)
176
186
177
187
successfully_updated_flight = await FlightRepository (
178
188
flight = self .flight , flight_id = flight_id
179
- ).update_flight (rocket_option = self .rocket_option , motor_kind = self .motor_kind )
189
+ ).update_flight (
190
+ rocket_option = self .rocket_option , motor_kind = self .motor_kind
191
+ )
180
192
if not successfully_updated_flight :
181
193
raise HTTPException (
182
194
status_code = status .HTTP_500_INTERNAL_SERVER_ERROR ,
@@ -207,7 +219,8 @@ async def update_env(
207
219
).get_flight ()
208
220
if not successfully_read_flight :
209
221
raise HTTPException (
210
- status_code = status .HTTP_404_NOT_FOUND , detail = "Flight not found."
222
+ status_code = status .HTTP_404_NOT_FOUND ,
223
+ detail = "Flight not found." ,
211
224
)
212
225
213
226
flight = successfully_read_flight .dict ()
@@ -246,7 +259,8 @@ async def update_rocket(
246
259
).get_flight ()
247
260
if not successfully_read_flight :
248
261
raise HTTPException (
249
- status_code = status .HTTP_404_NOT_FOUND , detail = "Flight not found."
262
+ status_code = status .HTTP_404_NOT_FOUND ,
263
+ detail = "Flight not found." ,
250
264
)
251
265
252
266
flight = successfully_read_flight .dict ()
@@ -267,7 +281,9 @@ async def update_rocket(
267
281
return FlightUpdated (new_flight_id = str (successfully_updated_flight ))
268
282
269
283
@staticmethod
270
- async def delete_flight (flight_id : int ) -> "Union[FlightDeleted, HTTPException]" :
284
+ async def delete_flight (
285
+ flight_id : int ,
286
+ ) -> "Union[FlightDeleted, HTTPException]" :
271
287
"""
272
288
Delete a flight from the database.
273
289
@@ -285,7 +301,8 @@ async def delete_flight(flight_id: int) -> "Union[FlightDeleted, HTTPException]"
285
301
).get_flight ()
286
302
if not successfully_read_flight :
287
303
raise HTTPException (
288
- status_code = status .HTTP_404_NOT_FOUND , detail = "Flight not found."
304
+ status_code = status .HTTP_404_NOT_FOUND ,
305
+ detail = "Flight not found." ,
289
306
)
290
307
291
308
successfully_deleted_flight = await FlightRepository (
@@ -300,7 +317,9 @@ async def delete_flight(flight_id: int) -> "Union[FlightDeleted, HTTPException]"
300
317
return FlightDeleted (deleted_flight_id = str (flight_id ))
301
318
302
319
@staticmethod
303
- async def simulate (flight_id : int ) -> "Union[FlightSummary, HTTPException]" :
320
+ async def simulate (
321
+ flight_id : int ,
322
+ ) -> "Union[FlightSummary, HTTPException]" :
304
323
"""
305
324
Simulate a rocket flight.
306
325
@@ -318,7 +337,8 @@ async def simulate(flight_id: int) -> "Union[FlightSummary, HTTPException]":
318
337
).get_flight ()
319
338
if not successfully_read_flight :
320
339
raise HTTPException (
321
- status_code = status .HTTP_404_NOT_FOUND , detail = "Flight not found."
340
+ status_code = status .HTTP_404_NOT_FOUND ,
341
+ detail = "Flight not found." ,
322
342
)
323
343
324
344
try :
@@ -351,7 +371,9 @@ async def simulate(flight_id: int) -> "Union[FlightSummary, HTTPException]":
351
371
)
352
372
353
373
_numerical_integration_settings = NumericalIntegrationSettings (
354
- max_time = "Maximum Allowed Flight Time: {:f} s" .format (flight .max_time ),
374
+ max_time = "Maximum Allowed Flight Time: {:f} s" .format (
375
+ flight .max_time
376
+ ),
355
377
max_time_step = "Maximum Allowed Time Step: {:f} s" .format (
356
378
flight .max_time_step
357
379
),
@@ -371,11 +393,15 @@ async def simulate(flight_id: int) -> "Union[FlightSummary, HTTPException]":
371
393
)
372
394
373
395
_launch_rail_conditions = LaunchRailConditions (
374
- rail_length = "Launch Rail Length: {:.2f} m" .format (flight .rail_length ),
396
+ rail_length = "Launch Rail Length: {:.2f} m" .format (
397
+ flight .rail_length
398
+ ),
375
399
flight_inclination = "Launch Rail Inclination: {:.2f}°" .format (
376
400
flight .inclination
377
401
),
378
- flight_heading = "Launch Rail Heading: {:.2f}°" .format (flight .heading ),
402
+ flight_heading = "Launch Rail Heading: {:.2f}°" .format (
403
+ flight .heading
404
+ ),
379
405
)
380
406
381
407
_surface_wind_conditions = SurfaceWindConditions (
@@ -413,17 +439,25 @@ async def simulate(flight_id: int) -> "Union[FlightSummary, HTTPException]":
413
439
flight .rocket .motor .burn_out_time
414
440
),
415
441
burnout_altitude = "Altitude at burn out: {:.3f} m (AGL)" .format (
416
- flight .z (flight .rocket .motor .burn_out_time ) - flight .env .elevation
442
+ flight .z (flight .rocket .motor .burn_out_time )
443
+ - flight .env .elevation
417
444
),
418
445
burnout_rocket_velocity = "Rocket velocity at burn out: {:.3f} m/s" .format (
419
446
flight .speed (flight .rocket .motor .burn_out_time )
420
447
),
421
448
burnout_freestream_velocity = "Freestream velocity at burn out: {:.3f} m/s" .format (
422
449
(
423
- flight .stream_velocity_x (flight .rocket .motor .burn_out_time ) ** 2
424
- + flight .stream_velocity_y (flight .rocket .motor .burn_out_time )
450
+ flight .stream_velocity_x (
451
+ flight .rocket .motor .burn_out_time
452
+ )
453
+ ** 2
454
+ + flight .stream_velocity_y (
455
+ flight .rocket .motor .burn_out_time
456
+ )
425
457
** 2
426
- + flight .stream_velocity_z (flight .rocket .motor .burn_out_time )
458
+ + flight .stream_velocity_z (
459
+ flight .rocket .motor .burn_out_time
460
+ )
427
461
** 2
428
462
)
429
463
** 0.5
@@ -457,14 +491,17 @@ async def simulate(flight_id: int) -> "Union[FlightSummary, HTTPException]":
457
491
flight .max_reynolds_number , flight .max_reynolds_number_time
458
492
),
459
493
maximum_dynamic_pressure = "Maximum Dynamic Pressure: {:.3e} Pa at {:.2f} s" .format (
460
- flight .max_dynamic_pressure , flight .max_dynamic_pressure_time
494
+ flight .max_dynamic_pressure ,
495
+ flight .max_dynamic_pressure_time ,
461
496
),
462
497
maximum_acceleration_during_motor_burn = "Maximum Acceleration During Motor Burn: {:.3f} m/s² at {:.2f} s" .format (
463
498
flight .max_acceleration , flight .max_acceleration_time
464
499
),
465
500
maximum_gs_during_motor_burn = "Maximum Gs During Motor Burn: {:.3f} g at {:.2f} s" .format (
466
501
flight .max_acceleration
467
- / flight .env .gravity (flight .z (flight .max_acceleration_time )),
502
+ / flight .env .gravity (
503
+ flight .z (flight .max_acceleration_time )
504
+ ),
468
505
flight .max_acceleration_time ,
469
506
),
470
507
maximum_acceleration_after_motor_burn = "Maximum Acceleration After Motor Burn: {:.3f} m/s² at {:.2f} s" .format (
@@ -491,17 +528,25 @@ async def simulate(flight_id: int) -> "Union[FlightSummary, HTTPException]":
491
528
492
529
if len (flight .impact_state ) != 0 :
493
530
_impact_conditions = ImpactConditions (
494
- x_impact_position = "X Impact: {:.3f} m" .format (flight .x_impact ),
495
- y_impact_position = "Y Impact: {:.3f} m" .format (flight .y_impact ),
496
- time_of_impact = "Time of Impact: {:.3f} s" .format (flight .t_final ),
531
+ x_impact_position = "X Impact: {:.3f} m" .format (
532
+ flight .x_impact
533
+ ),
534
+ y_impact_position = "Y Impact: {:.3f} m" .format (
535
+ flight .y_impact
536
+ ),
537
+ time_of_impact = "Time of Impact: {:.3f} s" .format (
538
+ flight .t_final
539
+ ),
497
540
impact_velocity = "Velocity at Impact: {:.3f} m/s" .format (
498
541
flight .impact_velocity
499
542
),
500
543
)
501
544
elif flight .terminate_on_apogee is False :
502
545
_impact_conditions = ImpactConditions (
503
546
time = "Time: {:.3f} s" .format (flight .solution [- 1 ][0 ]),
504
- altitude = "Altitude: {:.3f} m" .format (flight .solution [- 1 ][3 ]),
547
+ altitude = "Altitude: {:.3f} m" .format (
548
+ flight .solution [- 1 ][3 ]
549
+ ),
505
550
)
506
551
507
552
if len (flight .parachute_events ) == 0 :
@@ -519,10 +564,14 @@ async def simulate(flight_id: int) -> "Union[FlightSummary, HTTPException]":
519
564
name = parachute .name .title ()
520
565
events [name ] = []
521
566
events [name ].append (
522
- name + " Ejection Triggered at: {:.3f} s" .format (trigger_time )
567
+ name
568
+ + " Ejection Triggered at: {:.3f} s" .format (
569
+ trigger_time
570
+ )
523
571
)
524
572
events [name ].append (
525
- name + " Parachute Inflated at: {:.3f} s" .format (open_time )
573
+ name
574
+ + " Parachute Inflated at: {:.3f} s" .format (open_time )
526
575
)
527
576
events [name ].append (
528
577
name
0 commit comments