@@ -73,7 +73,7 @@ class Environment:
73
73
Launch site E/W hemisphere
74
74
Environment.elevation : float
75
75
Launch site elevation.
76
- Environment.date : datetime
76
+ Environment.datetime_date : datetime
77
77
Date time of launch in UTC.
78
78
Environment.local_date : datetime
79
79
Date time of launch in the local time zone, defined by
@@ -281,7 +281,7 @@ def __init__(
281
281
for the Flight simulation, such as atmospheric air pressure, density,
282
282
and gravitational acceleration.
283
283
284
- Note that the default atmospheric model is the International Standard
284
+ Note that the default atmospheric model is the International Standard
285
285
Atmosphere as defined by ISO 2533 unless specified otherwise in
286
286
:meth:`Environment.set_atmospheric_model`.
287
287
@@ -292,22 +292,33 @@ def __init__(
292
292
acceleration down. If None, the Somigliana formula is used.
293
293
See :meth:`Environment.set_gravity_model` for more information.
294
294
date : array, optional
295
- Array of length 4, stating (year, month, day, hour (UTC))
296
- of rocket launch. Must be given if a Forecast, Reanalysis
295
+ Array of length 4, stating (year, month, day, hour) in the
296
+ time zone of the parameter ``timezone``.
297
+ Alternatively, can be a ``Datetime`` object specifying launch
298
+ date and time. The dates are stored as follows:
299
+
300
+ - :attr:`Environment.local_date`: Local time of launch in
301
+ the time zone specified by the parameter ``timezone``.
302
+
303
+ - :attr:`Environment.datetime_date`: UTC time of launch.
304
+
305
+ Must be given if a Forecast, Reanalysis
297
306
or Ensemble, will be set as an atmospheric model.
307
+ Default is None.
308
+ See :meth:`Environment.set_date` for more information.
298
309
latitude : float, optional
299
310
Latitude in degrees (ranging from -90 to 90) of rocket
300
311
launch location. Must be given if a Forecast, Reanalysis
301
312
or Ensemble will be used as an atmospheric model or if
302
313
Open-Elevation will be used to compute elevation. Positive
303
- values correspond to the North. Default value is 0, which
314
+ values correspond to the North. Default value is 0, which
304
315
corresponds to the equator.
305
316
longitude : float, optional
306
317
Longitude in degrees (ranging from -180 to 360) of rocket
307
318
launch location. Must be given if a Forecast, Reanalysis
308
319
or Ensemble will be used as an atmospheric model or if
309
320
Open-Elevation will be used to compute elevation. Positive
310
- values correspond to the East. Default value is 0, which
321
+ values correspond to the East. Default value is 0, which
311
322
corresponds to the Greenwich Meridian.
312
323
elevation : float, optional
313
324
Elevation of launch site measured as height above sea
@@ -321,7 +332,7 @@ def __init__(
321
332
is "SIRGAS2000".
322
333
timezone : string, optional
323
334
Name of the time zone. To see all time zones, import pytz and run
324
- print(pytz.all_timezones). Default time zone is "UTC".
335
+ `` print(pytz.all_timezones)`` . Default time zone is "UTC".
325
336
max_expected_height : float, optional
326
337
Maximum altitude in meters to keep weather data. The altitude must
327
338
be above sea level (ASL). Especially useful for visualization.
@@ -405,15 +416,57 @@ def set_date(self, date, timezone="UTC"):
405
416
406
417
Parameters
407
418
----------
408
- date : Datetime
409
- Datetime object specifying launch date and time.
419
+ date : array, Datetime
420
+ Array of length 4, stating (year, month, day, hour) in the
421
+ time zone of the parameter ``timezone``. See Notes for more
422
+ information.
423
+ Alternatively, can be a Datetime object specifying launch
424
+ date and time.
410
425
timezone : string, optional
411
426
Name of the time zone. To see all time zones, import pytz and run
412
- print(pytz.all_timezones). Default time zone is "UTC".
427
+ `` print(pytz.all_timezones)`` . Default time zone is "UTC".
413
428
414
429
Returns
415
430
-------
416
431
None
432
+
433
+ Notes
434
+ -----
435
+ - If the ``date`` is given as an array, it should be in the same
436
+ time zone as specified by the ``timezone`` parameter. This local
437
+ time will be available in the attribute :attr:`Environment.local_date`
438
+ while the UTC time will be available in the attribute
439
+ :attr:`Environment.datetime_date`.
440
+
441
+ - If the ``date`` is given as a ``Datetime`` object without a time zone,
442
+ it will be assumed to be in the same time zone as specified by the
443
+ ``timezone`` parameter. However, if the ``Datetime`` object has a time
444
+ zone specified in its ``tzinfo`` attribute, the ``timezone``
445
+ parameter will be ignored.
446
+
447
+ Examples
448
+ --------
449
+
450
+ Let's set the launch date as an array:
451
+
452
+ >>> date = [2000, 1, 1, 13] # January 1st, 2000 at 13:00 UTC+1
453
+ >>> env = Environment()
454
+ >>> env.set_date(date, timezone="Europe/Rome")
455
+ >>> print(env.datetime_date) # Get UTC time
456
+ 2000-01-01 12:00:00+00:00
457
+ >>> print(env.local_date)
458
+ 2000-01-01 13:00:00+01:00
459
+
460
+ Now let's set the launch date as a ``Datetime`` object:
461
+
462
+ >>> from datetime import datetime
463
+ >>> date = datetime(2000, 1, 1, 13, 0, 0)
464
+ >>> env = Environment()
465
+ >>> env.set_date(date, timezone="Europe/Rome")
466
+ >>> print(env.datetime_date) # Get UTC time
467
+ 2000-01-01 12:00:00+00:00
468
+ >>> print(env.local_date)
469
+ 2000-01-01 13:00:00+01:00
417
470
"""
418
471
# Store date and configure time zone
419
472
self .timezone = timezone
@@ -479,23 +532,23 @@ def set_gravity_model(self, gravity=None):
479
532
simulation, this value is positive when pointing downwards.
480
533
The input type can be one of the following:
481
534
482
- - ``int`` or ``float``: The gravity acceleration is set as a
483
- constant function with respect to height;
535
+ - ``int`` or ``float``: The gravity acceleration is set as a\
536
+ constant function with respect to height;
484
537
485
- - ``callable``: This callable should receive the height above
486
- sea level in meters and return the gravity acceleration;
538
+ - ``callable``: This callable should receive the height above\
539
+ sea level in meters and return the gravity acceleration;
487
540
488
- - ``array``: The datapoints should be structured as
489
- ``[(h_i,g_i), ...]`` where ``h_i`` is the height above sea
490
- level in meters and ``g_i`` is the gravity acceleration in m/s²;
541
+ - ``array``: The datapoints should be structured as\
542
+ ``[(h_i,g_i), ...]`` where ``h_i`` is the height above sea\
543
+ level in meters and ``g_i`` is the gravity acceleration in m/s²;
491
544
492
- - ``string``: The string should correspond to a path to a CSV file
493
- containing the gravity acceleration data;
545
+ - ``string``: The string should correspond to a path to a CSV file\
546
+ containing the gravity acceleration data;
494
547
495
- - ``None``: The Somigliana formula is used to compute the gravity
496
- acceleration.
548
+ - ``None``: The Somigliana formula is used to compute the gravity\
549
+ acceleration.
497
550
498
- This parameter is used as a :class:`Function` object source, check
551
+ This parameter is used as a :class:`Function` object source, check\
499
552
out the available input types for a more detailed explanation.
500
553
501
554
Returns
@@ -552,7 +605,7 @@ def max_expected_height(self, value):
552
605
553
606
@funcify_method ("height (m)" , "gravity (m/s²)" )
554
607
def somigliana_gravity (self , height ):
555
- """Computes the gravity acceleration with the Somigliana formula.
608
+ """Computes the gravity acceleration with the Somigliana formula [1]_ .
556
609
An height correction is applied to the normal gravity that is
557
610
accurate for heights used in aviation. The formula is based on the
558
611
WGS84 ellipsoid, but is accurate for other reference ellipsoids.
0 commit comments