From eab9be8105ac8e2241b63737f75f8df045383c62 Mon Sep 17 00:00:00 2001 From: FranzYuri <86535872+FranzYuri@users.noreply.github.com> Date: Fri, 5 Nov 2021 02:50:31 -0300 Subject: [PATCH 01/16] Update Environment.py --- rocketpy/Environment.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/rocketpy/Environment.py b/rocketpy/Environment.py index 26b8102fc..2e84fbcb6 100644 --- a/rocketpy/Environment.py +++ b/rocketpy/Environment.py @@ -9,6 +9,7 @@ import bisect import warnings import time +import pytz from datetime import datetime, timedelta from inspect import signature, getsourcelines from collections import namedtuple @@ -346,6 +347,12 @@ def __init__( self.setDate(date) else: self.date = None + + # Save local date + self.local_date = None + + # Save local time zone + self.time_zone = None # Initialize constants self.earthRadius = 6.3781 * (10 ** 6) @@ -380,12 +387,15 @@ def __init__( def setDate(self, date): """Set date and time of launch and update weather conditions if - date dependent atmospheric model is used. + date dependent atmospheric model is used. To see all time zones use + print(pytz.all_timezones). Parameters ---------- date : Date Date object specifying launch date and time. + time_zone : string, optional + Name of the time zone. Return ------ @@ -394,6 +404,11 @@ def setDate(self, date): # Store date self.date = datetime(*date) + if time_zone != None: + self.time_zone = time_zone + tz = pytz.timezone(self.time_zone) + self.local_date = self.date.replace(tzinfo=pytz.UTC).astimezone(tz) + # Update atmospheric conditions if atmosphere type is Forecast, # Reanalysis or Ensemble try: @@ -2823,6 +2838,8 @@ def info(self): print("\nLaunch Rail Length: ", self.rL, " m") if self.date != None: print("Launch Date: ", self.date, " UTC") + if self.local_date != None: + print("Launch Date: ", self.local_date, self.time_zone) if self.lat != None and self.lon != None: print("Launch Site Latitude: {:.5f}°".format(self.lat)) print("Launch Site Longitude: {:.5f}°".format(self.lon)) @@ -2950,6 +2967,8 @@ def allInfo(self): print("\nLaunch Rail Length: ", self.rL, " m") if self.date != None: print("Launch Date: ", self.date, " UTC") + if self.local_date != None: + print("Launch Date: ", self.local_date, self.time_zone) if self.lat != None and self.lon != None: print("Launch Site Latitude: {:.5f}°".format(self.lat)) print("Launch Site Longitude: {:.5f}°".format(self.lon)) From 5a0decf0fc5d15f082e7f1360f2250e07af7719a Mon Sep 17 00:00:00 2001 From: Franz Masatoshi Yuri Date: Tue, 9 Nov 2021 03:35:49 -0300 Subject: [PATCH 02/16] commit on 'enh/utc_time' --- rocketpy/Environment.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rocketpy/Environment.py b/rocketpy/Environment.py index 2e84fbcb6..65663f16c 100644 --- a/rocketpy/Environment.py +++ b/rocketpy/Environment.py @@ -347,7 +347,7 @@ def __init__( self.setDate(date) else: self.date = None - + # Save local date self.local_date = None @@ -385,7 +385,7 @@ def __init__( return None - def setDate(self, date): + def setDate(self, date, time_zone = None): """Set date and time of launch and update weather conditions if date dependent atmospheric model is used. To see all time zones use print(pytz.all_timezones). From 73962a1d4c5f8f3f02f783fd5633af091847edea Mon Sep 17 00:00:00 2001 From: Franz Masatoshi Yuri Date: Tue, 9 Nov 2021 03:39:44 -0300 Subject: [PATCH 03/16] commit on 'enh/utc_time' --- rocketpy/Environment.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rocketpy/Environment.py b/rocketpy/Environment.py index 65663f16c..49e94e9eb 100644 --- a/rocketpy/Environment.py +++ b/rocketpy/Environment.py @@ -385,7 +385,7 @@ def __init__( return None - def setDate(self, date, time_zone = None): + def setDate(self, date, time_zone=None): """Set date and time of launch and update weather conditions if date dependent atmospheric model is used. To see all time zones use print(pytz.all_timezones). From c322a4986ac3c938b1c834b47f0b1213de6ef5ba Mon Sep 17 00:00:00 2001 From: FranzYuri <86535872+FranzYuri@users.noreply.github.com> Date: Thu, 11 Nov 2021 16:50:30 -0300 Subject: [PATCH 04/16] Update requirements.txt --- requirements.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 30001b109..4a59f377b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,4 +2,5 @@ numpy>=1.0 scipy>=1.0 matplotlib>=3.0 netCDF4>=1.4 -requests \ No newline at end of file +requests +pytz From 8ad3df61e4d5abc4f57e0fb7a709cbad1883e238 Mon Sep 17 00:00:00 2001 From: Franz Masatoshi Yuri Date: Mon, 3 Jan 2022 03:56:21 -0300 Subject: [PATCH 05/16] commit on 'enh/utc_time' --- rocketpy/Environment.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/rocketpy/Environment.py b/rocketpy/Environment.py index 49e94e9eb..dceaec1a8 100644 --- a/rocketpy/Environment.py +++ b/rocketpy/Environment.py @@ -385,15 +385,15 @@ def __init__( return None - def setDate(self, date, time_zone=None): + def setDate(self, date, time_zone='UTC'): """Set date and time of launch and update weather conditions if date dependent atmospheric model is used. To see all time zones use print(pytz.all_timezones). Parameters ---------- - date : Date - Date object specifying launch date and time. + date : Datetime + Datetime object specifying launch date and time. time_zone : string, optional Name of the time zone. @@ -402,12 +402,13 @@ def setDate(self, date, time_zone=None): None """ # Store date - self.date = datetime(*date) - - if time_zone != None: - self.time_zone = time_zone - tz = pytz.timezone(self.time_zone) - self.local_date = self.date.replace(tzinfo=pytz.UTC).astimezone(tz) + self.time_zone = time_zone + tz = pytz.timezone(self.time_zone) + local_date = datetime(*date) + if local_date.tzinfo == None: + local_date = tz.localize(local_date) + self.local_date = local_date + self.date = self.local_date.replace(tzinfo=pytz.UTC) # Update atmospheric conditions if atmosphere type is Forecast, # Reanalysis or Ensemble From 4d37d86f50ccc92a6ce2c2ad0ea538fd00fb0799 Mon Sep 17 00:00:00 2001 From: giovaniceotto Date: Mon, 3 Jan 2022 11:11:23 -0300 Subject: [PATCH 06/16] FEAT: add pytz to setup.py install requirements --- setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index b971b83fa..08c84e267 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,8 @@ 'numpy>=1.0', 'scipy>=1.0', 'matplotlib>=3.0', - 'requests' + 'requests', + 'pytz', ], maintainer="RocketPy Developers", author="Giovani Hidalgo Ceotto", From ac46cf01f24b0e348db269e510141fa5cf8818d1 Mon Sep 17 00:00:00 2001 From: giovaniceotto Date: Mon, 3 Jan 2022 11:11:52 -0300 Subject: [PATCH 07/16] MAINT: minor code refactoring --- rocketpy/Environment.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/rocketpy/Environment.py b/rocketpy/Environment.py index dceaec1a8..e51e5630f 100644 --- a/rocketpy/Environment.py +++ b/rocketpy/Environment.py @@ -81,7 +81,11 @@ class Environment: Environment.elevation : float Launch site elevation. Environment.date : datetime - Date time of launch. + Date time of launch in UTC. + Environment.local_date : datetime + Date time of launch in the local time_zone, defined by Environment.time_zone. + Environment.time_zone : string + Local time zone specification. Topographic informations: Environment.elevLonArray: array @@ -387,21 +391,21 @@ def __init__( def setDate(self, date, time_zone='UTC'): """Set date and time of launch and update weather conditions if - date dependent atmospheric model is used. To see all time zones use - print(pytz.all_timezones). + date dependent atmospheric model is used. Parameters ---------- date : Datetime Datetime object specifying launch date and time. time_zone : string, optional - Name of the time zone. + Name of the time zone. To see all time zones, import pytz and run + print(pytz.all_timezones). Default time zone is "UTC". Return ------ None """ - # Store date + # Store date and configure time zone self.time_zone = time_zone tz = pytz.timezone(self.time_zone) local_date = datetime(*date) From 16c11070070c0080ce1b1bb356208fdda64ba134 Mon Sep 17 00:00:00 2001 From: giovaniceotto Date: Mon, 3 Jan 2022 11:41:31 -0300 Subject: [PATCH 08/16] FEAT: added time zone argument to Env.init --- rocketpy/Environment.py | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/rocketpy/Environment.py b/rocketpy/Environment.py index e51e5630f..34fa9d85d 100644 --- a/rocketpy/Environment.py +++ b/rocketpy/Environment.py @@ -295,6 +295,7 @@ def __init__( longitude=0, elevation=0, datum="SIRGAS2000", + time_zone="UTC", ): """Initialize Environment class, saving launch rail length, launch date, location coordinates and elevation. Note that @@ -331,7 +332,13 @@ def __init__( 'Open-Elevation' which uses the Open-Elevation API to find elevation data. For this option, latitude and longitude must also be specified. Default value is 0. - datum: + datum : string + The desired reference ellipsoide model, the following options are + available: "SAD69", "WGS84", "NAD83", and "SIRGAS2000". The default + is "SIRGAS2000", then this model will be used if the user make some + typing mistake. + time_zone : string, optional + Name of the time zone. To see all time zones, import pytz and run Returns ------- @@ -348,15 +355,11 @@ def __init__( # Save date if date != None: - self.setDate(date) + self.setDate(date, time_zone) else: self.date = None - - # Save local date - self.local_date = None - - # Save local time zone - self.time_zone = None + self.local_date = None + self.time_zone = None # Initialize constants self.earthRadius = 6.3781 * (10 ** 6) @@ -2841,10 +2844,10 @@ def info(self): # Print launch site details print("Launch Site Details") print("\nLaunch Rail Length: ", self.rL, " m") - if self.date != None: + if self.date != None and 'UTC' not in self.time_zone: + print("Launch Date: ", self.date, " UTC |", self.local_date, self.time_zone) + else: print("Launch Date: ", self.date, " UTC") - if self.local_date != None: - print("Launch Date: ", self.local_date, self.time_zone) if self.lat != None and self.lon != None: print("Launch Site Latitude: {:.5f}°".format(self.lat)) print("Launch Site Longitude: {:.5f}°".format(self.lon)) @@ -2970,10 +2973,10 @@ def allInfo(self): # Print launch site details print("\n\nLaunch Site Details") print("\nLaunch Rail Length: ", self.rL, " m") - if self.date != None: + if self.date != None and 'UTC' not in self.time_zone: + print("Launch Date: ", self.date, " UTC |", self.local_date, self.time_zone) + else: print("Launch Date: ", self.date, " UTC") - if self.local_date != None: - print("Launch Date: ", self.local_date, self.time_zone) if self.lat != None and self.lon != None: print("Launch Site Latitude: {:.5f}°".format(self.lat)) print("Launch Site Longitude: {:.5f}°".format(self.lon)) From 658f478bcbb1396efba736649c637eb00f98c0ef Mon Sep 17 00:00:00 2001 From: giovaniceotto Date: Mon, 3 Jan 2022 11:44:21 -0300 Subject: [PATCH 09/16] MAINT: rename time_zone to timeZone, following current camelCase standard --- rocketpy/Environment.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/rocketpy/Environment.py b/rocketpy/Environment.py index 34fa9d85d..f5a0df04e 100644 --- a/rocketpy/Environment.py +++ b/rocketpy/Environment.py @@ -83,9 +83,9 @@ class Environment: Environment.date : datetime Date time of launch in UTC. Environment.local_date : datetime - Date time of launch in the local time_zone, defined by Environment.time_zone. - Environment.time_zone : string - Local time zone specification. + Date time of launch in the local time zone, defined by Environment.timeZone. + Environment.timeZone : string + Local time zone specification. See pytz for time zone info. Topographic informations: Environment.elevLonArray: array @@ -295,7 +295,7 @@ def __init__( longitude=0, elevation=0, datum="SIRGAS2000", - time_zone="UTC", + timeZone="UTC", ): """Initialize Environment class, saving launch rail length, launch date, location coordinates and elevation. Note that @@ -337,7 +337,7 @@ def __init__( available: "SAD69", "WGS84", "NAD83", and "SIRGAS2000". The default is "SIRGAS2000", then this model will be used if the user make some typing mistake. - time_zone : string, optional + timeZone : string, optional Name of the time zone. To see all time zones, import pytz and run Returns @@ -355,11 +355,11 @@ def __init__( # Save date if date != None: - self.setDate(date, time_zone) + self.setDate(date, timeZone) else: self.date = None self.local_date = None - self.time_zone = None + self.timeZone = None # Initialize constants self.earthRadius = 6.3781 * (10 ** 6) @@ -392,7 +392,7 @@ def __init__( return None - def setDate(self, date, time_zone='UTC'): + def setDate(self, date, timeZone='UTC'): """Set date and time of launch and update weather conditions if date dependent atmospheric model is used. @@ -400,7 +400,7 @@ def setDate(self, date, time_zone='UTC'): ---------- date : Datetime Datetime object specifying launch date and time. - time_zone : string, optional + timeZone : string, optional Name of the time zone. To see all time zones, import pytz and run print(pytz.all_timezones). Default time zone is "UTC". @@ -409,8 +409,8 @@ def setDate(self, date, time_zone='UTC'): None """ # Store date and configure time zone - self.time_zone = time_zone - tz = pytz.timezone(self.time_zone) + self.timeZone = timeZone + tz = pytz.timezone(self.timeZone) local_date = datetime(*date) if local_date.tzinfo == None: local_date = tz.localize(local_date) @@ -2844,8 +2844,8 @@ def info(self): # Print launch site details print("Launch Site Details") print("\nLaunch Rail Length: ", self.rL, " m") - if self.date != None and 'UTC' not in self.time_zone: - print("Launch Date: ", self.date, " UTC |", self.local_date, self.time_zone) + if self.date != None and 'UTC' not in self.timeZone: + print("Launch Date: ", self.date, " UTC |", self.local_date, self.timeZone) else: print("Launch Date: ", self.date, " UTC") if self.lat != None and self.lon != None: @@ -2973,8 +2973,8 @@ def allInfo(self): # Print launch site details print("\n\nLaunch Site Details") print("\nLaunch Rail Length: ", self.rL, " m") - if self.date != None and 'UTC' not in self.time_zone: - print("Launch Date: ", self.date, " UTC |", self.local_date, self.time_zone) + if self.date != None and 'UTC' not in self.timeZone: + print("Launch Date: ", self.date, " UTC |", self.local_date, self.timeZone) else: print("Launch Date: ", self.date, " UTC") if self.lat != None and self.lon != None: From 6394b0f2cc391b72df5daeaf80a6dd8f69a030ff Mon Sep 17 00:00:00 2001 From: giovaniceotto Date: Mon, 3 Jan 2022 11:46:28 -0300 Subject: [PATCH 10/16] Maint: rename local_date to LocalDate to follow camelCase --- rocketpy/Environment.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/rocketpy/Environment.py b/rocketpy/Environment.py index f5a0df04e..01580d8dd 100644 --- a/rocketpy/Environment.py +++ b/rocketpy/Environment.py @@ -82,7 +82,7 @@ class Environment: Launch site elevation. Environment.date : datetime Date time of launch in UTC. - Environment.local_date : datetime + Environment.localDate : datetime Date time of launch in the local time zone, defined by Environment.timeZone. Environment.timeZone : string Local time zone specification. See pytz for time zone info. @@ -358,7 +358,7 @@ def __init__( self.setDate(date, timeZone) else: self.date = None - self.local_date = None + self.localDate = None self.timeZone = None # Initialize constants @@ -411,11 +411,11 @@ def setDate(self, date, timeZone='UTC'): # Store date and configure time zone self.timeZone = timeZone tz = pytz.timezone(self.timeZone) - local_date = datetime(*date) - if local_date.tzinfo == None: - local_date = tz.localize(local_date) - self.local_date = local_date - self.date = self.local_date.replace(tzinfo=pytz.UTC) + localDate = datetime(*date) + if localDate.tzinfo == None: + localDate = tz.localize(localDate) + self.localDate = localDate + self.date = self.localDate.replace(tzinfo=pytz.UTC) # Update atmospheric conditions if atmosphere type is Forecast, # Reanalysis or Ensemble @@ -2845,7 +2845,7 @@ def info(self): print("Launch Site Details") print("\nLaunch Rail Length: ", self.rL, " m") if self.date != None and 'UTC' not in self.timeZone: - print("Launch Date: ", self.date, " UTC |", self.local_date, self.timeZone) + print("Launch Date: ", self.date, " UTC |", self.localDate, self.timeZone) else: print("Launch Date: ", self.date, " UTC") if self.lat != None and self.lon != None: @@ -2974,7 +2974,7 @@ def allInfo(self): print("\n\nLaunch Site Details") print("\nLaunch Rail Length: ", self.rL, " m") if self.date != None and 'UTC' not in self.timeZone: - print("Launch Date: ", self.date, " UTC |", self.local_date, self.timeZone) + print("Launch Date: ", self.date, " UTC |", self.localDate, self.timeZone) else: print("Launch Date: ", self.date, " UTC") if self.lat != None and self.lon != None: From 756381d677d5228ada0ed8f95263c90bf2bde792 Mon Sep 17 00:00:00 2001 From: giovaniceotto Date: Mon, 3 Jan 2022 12:04:36 -0300 Subject: [PATCH 11/16] BUG: fix conversion between local and UTC time zone using astimezone --- rocketpy/Environment.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/rocketpy/Environment.py b/rocketpy/Environment.py index 01580d8dd..7f3738941 100644 --- a/rocketpy/Environment.py +++ b/rocketpy/Environment.py @@ -415,7 +415,7 @@ def setDate(self, date, timeZone='UTC'): if localDate.tzinfo == None: localDate = tz.localize(localDate) self.localDate = localDate - self.date = self.localDate.replace(tzinfo=pytz.UTC) + self.date = self.localDate.astimezone(pytz.UTC) # Update atmospheric conditions if atmosphere type is Forecast, # Reanalysis or Ensemble @@ -2844,10 +2844,11 @@ def info(self): # Print launch site details print("Launch Site Details") print("\nLaunch Rail Length: ", self.rL, " m") + time_format = "%Y-%m-%d %H:%M:%S" if self.date != None and 'UTC' not in self.timeZone: - print("Launch Date: ", self.date, " UTC |", self.localDate, self.timeZone) + print("Launch Date:", self.date.strftime(time_format), "UTC |", self.localDate.strftime(time_format), self.timeZone) else: - print("Launch Date: ", self.date, " UTC") + print("Launch Date:", self.date.strftime(time_format), "UTC") if self.lat != None and self.lon != None: print("Launch Site Latitude: {:.5f}°".format(self.lat)) print("Launch Site Longitude: {:.5f}°".format(self.lon)) From 4ed5fc05f797570b297d81767b8a09c4e7d6af58 Mon Sep 17 00:00:00 2001 From: giovaniceotto Date: Mon, 3 Jan 2022 12:06:55 -0300 Subject: [PATCH 12/16] MAINT: minor code refactoring --- rocketpy/Environment.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/rocketpy/Environment.py b/rocketpy/Environment.py index 7f3738941..17bee08a2 100644 --- a/rocketpy/Environment.py +++ b/rocketpy/Environment.py @@ -501,7 +501,7 @@ def setElevation(self, elevation="Open-Elevation"): response = requests.get(requestURL) results = response.json()["results"] self.elevation = results[0]["elevation"] - print("Elevation received: ", self.elevation) + print("Elevation received:", self.elevation) except: raise RuntimeError("Unabel to reach Open-Elevation API servers.") else: @@ -2843,7 +2843,7 @@ def info(self): """ # Print launch site details print("Launch Site Details") - print("\nLaunch Rail Length: ", self.rL, " m") + print("\nLaunch Rail Length:", self.rL, " m") time_format = "%Y-%m-%d %H:%M:%S" if self.date != None and 'UTC' not in self.timeZone: print("Launch Date:", self.date.strftime(time_format), "UTC |", self.localDate.strftime(time_format), self.timeZone) @@ -2865,7 +2865,7 @@ def info(self): # Print atmospheric model details print("\n\nAtmospheric Model Details") modelType = self.atmosphericModelType - print("\nAtmospheric Model Type: ", modelType) + print("\nAtmospheric Model Type:", modelType) print( modelType + " Maximum Height: {:.3f} km".format(self.maxExpectedHeight / 1000) @@ -2876,7 +2876,7 @@ def info(self): endDate = self.atmosphericModelEndDate interval = self.atmosphericModelInterval print(modelType + " Time Period: From ", initDate, " to ", endDate, " UTC") - print(modelType + " Hour Interval: ", interval, " hrs") + print(modelType + " Hour Interval:", interval, " hrs") # Determine latitude and longitude range initLat = self.atmosphericModelInitLat endLat = self.atmosphericModelEndLat @@ -2885,8 +2885,8 @@ def info(self): print(modelType + " Latitude Range: From ", initLat, "° To ", endLat, "°") print(modelType + " Longitude Range: From ", initLon, "° To ", endLon, "°") if modelType == "Ensemble": - print("Number of Ensemble Members: ", self.numEnsembleMembers) - print("Selected Ensemble Member: ", self.ensembleMember, " (Starts from 0)") + print("Number of Ensemble Members:", self.numEnsembleMembers) + print("Selected Ensemble Member:", self.ensembleMember, " (Starts from 0)") # Print atmospheric conditions print("\n\nSurface Atmospheric Conditions") @@ -2973,11 +2973,11 @@ def allInfo(self): # Print launch site details print("\n\nLaunch Site Details") - print("\nLaunch Rail Length: ", self.rL, " m") + print("\nLaunch Rail Length:", self.rL, " m") if self.date != None and 'UTC' not in self.timeZone: - print("Launch Date: ", self.date, " UTC |", self.localDate, self.timeZone) + print("Launch Date:", self.date, " UTC |", self.localDate, self.timeZone) else: - print("Launch Date: ", self.date, " UTC") + print("Launch Date:", self.date, " UTC") if self.lat != None and self.lon != None: print("Launch Site Latitude: {:.5f}°".format(self.lat)) print("Launch Site Longitude: {:.5f}°".format(self.lon)) @@ -2986,7 +2986,7 @@ def allInfo(self): # Print atmospheric model details print("\n\nAtmospheric Model Details") modelType = self.atmosphericModelType - print("\nAtmospheric Model Type: ", modelType) + print("\nAtmospheric Model Type:", modelType) print( modelType + " Maximum Height: {:.3f} km".format(self.maxExpectedHeight / 1000) @@ -2997,7 +2997,7 @@ def allInfo(self): endDate = self.atmosphericModelEndDate interval = self.atmosphericModelInterval print(modelType + " Time Period: From ", initDate, " to ", endDate, " UTC") - print(modelType + " Hour Interval: ", interval, " hrs") + print(modelType + " Hour Interval:", interval, " hrs") # Determine latitude and longitude range initLat = self.atmosphericModelInitLat endLat = self.atmosphericModelEndLat @@ -3006,8 +3006,8 @@ def allInfo(self): print(modelType + " Latitude Range: From ", initLat, "° To ", endLat, "°") print(modelType + " Longitude Range: From ", initLon, "° To ", endLon, "°") if modelType == "Ensemble": - print("Number of Ensemble Members: ", self.numEnsembleMembers) - print("Selected Ensemble Member: ", self.ensembleMember, " (Starts from 0)") + print("Number of Ensemble Members:", self.numEnsembleMembers) + print("Selected Ensemble Member:", self.ensembleMember, " (Starts from 0)") # Print atmospheric conditions print("\n\nSurface Atmospheric Conditions") @@ -3534,7 +3534,7 @@ def printEarthDetails(self): # print("Launch Site UTM coordinates: {:.2f} ".format(self.initialEast) # + self.initialEW + " {:.2f} ".format(self.initialNorth) + self.initialHemisphere # ) - # print("Launch Site UTM zone number: ", self.initialUtmZone) + # print("Launch Site UTM zone number:", self.initialUtmZone) # print("Launch Site Surface Elevation: {:.1f} m".format(self.elevation)) print("Earth Radius at Launch site: {:.1f} m".format(self.earthRadius)) print("Gravity acceleration at launch site: Still not implemented :(") From f14b26d53f376b69aaa0c8b578c21972b9a212e1 Mon Sep 17 00:00:00 2001 From: giovaniceotto Date: Mon, 3 Jan 2022 12:13:57 -0300 Subject: [PATCH 13/16] MAINT: fix date time format in Env.allInfo() --- rocketpy/Environment.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rocketpy/Environment.py b/rocketpy/Environment.py index 17bee08a2..95ca5368a 100644 --- a/rocketpy/Environment.py +++ b/rocketpy/Environment.py @@ -2974,10 +2974,11 @@ def allInfo(self): # Print launch site details print("\n\nLaunch Site Details") print("\nLaunch Rail Length:", self.rL, " m") + time_format = "%Y-%m-%d %H:%M:%S" if self.date != None and 'UTC' not in self.timeZone: - print("Launch Date:", self.date, " UTC |", self.localDate, self.timeZone) + print("Launch Date:", self.date.strftime(time_format), "UTC |", self.localDate.strftime(time_format), self.timeZone) else: - print("Launch Date:", self.date, " UTC") + print("Launch Date:", self.date.strftime(time_format), "UTC") if self.lat != None and self.lon != None: print("Launch Site Latitude: {:.5f}°".format(self.lat)) print("Launch Site Longitude: {:.5f}°".format(self.lon)) From f6120b18d745d3ea58197e2f97cbd8fcef8058b8 Mon Sep 17 00:00:00 2001 From: giovaniceotto Date: Mon, 3 Jan 2022 12:35:34 -0300 Subject: [PATCH 14/16] TST: fix failing tests due to minor bugs --- rocketpy/Environment.py | 4 ++-- tests/test_environment.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/rocketpy/Environment.py b/rocketpy/Environment.py index 95ca5368a..f96b68415 100644 --- a/rocketpy/Environment.py +++ b/rocketpy/Environment.py @@ -2847,7 +2847,7 @@ def info(self): time_format = "%Y-%m-%d %H:%M:%S" if self.date != None and 'UTC' not in self.timeZone: print("Launch Date:", self.date.strftime(time_format), "UTC |", self.localDate.strftime(time_format), self.timeZone) - else: + elif self.date != None: print("Launch Date:", self.date.strftime(time_format), "UTC") if self.lat != None and self.lon != None: print("Launch Site Latitude: {:.5f}°".format(self.lat)) @@ -2977,7 +2977,7 @@ def allInfo(self): time_format = "%Y-%m-%d %H:%M:%S" if self.date != None and 'UTC' not in self.timeZone: print("Launch Date:", self.date.strftime(time_format), "UTC |", self.localDate.strftime(time_format), self.timeZone) - else: + elif self.date != None: print("Launch Date:", self.date.strftime(time_format), "UTC") if self.lat != None and self.lon != None: print("Launch Site Latitude: {:.5f}°".format(self.lat)) diff --git a/tests/test_environment.py b/tests/test_environment.py index 948e55f30..86ed049cf 100644 --- a/tests/test_environment.py +++ b/tests/test_environment.py @@ -1,4 +1,5 @@ import datetime +import pytz from unittest.mock import patch import pytest @@ -32,7 +33,7 @@ def test_env_set_date(example_env): tomorrow = datetime.date.today() + datetime.timedelta(days=1) example_env.setDate((tomorrow.year, tomorrow.month, tomorrow.day, 12)) assert example_env.date == datetime.datetime( - tomorrow.year, tomorrow.month, tomorrow.day, 12 + tomorrow.year, tomorrow.month, tomorrow.day, 12, tzinfo=pytz.utc ) From c284e818173068a17811a71353c3e813058adc2d Mon Sep 17 00:00:00 2001 From: giovaniceotto Date: Mon, 3 Jan 2022 12:40:19 -0300 Subject: [PATCH 15/16] STY: apply black formatting --- rocketpy/Environment.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/rocketpy/Environment.py b/rocketpy/Environment.py index f96b68415..c772230b2 100644 --- a/rocketpy/Environment.py +++ b/rocketpy/Environment.py @@ -338,7 +338,7 @@ def __init__( is "SIRGAS2000", then this model will be used if the user make some typing mistake. timeZone : string, optional - Name of the time zone. To see all time zones, import pytz and run + Name of the time zone. To see all time zones, import pytz and run Returns ------- @@ -392,7 +392,7 @@ def __init__( return None - def setDate(self, date, timeZone='UTC'): + def setDate(self, date, timeZone="UTC"): """Set date and time of launch and update weather conditions if date dependent atmospheric model is used. @@ -2845,8 +2845,14 @@ def info(self): print("Launch Site Details") print("\nLaunch Rail Length:", self.rL, " m") time_format = "%Y-%m-%d %H:%M:%S" - if self.date != None and 'UTC' not in self.timeZone: - print("Launch Date:", self.date.strftime(time_format), "UTC |", self.localDate.strftime(time_format), self.timeZone) + if self.date != None and "UTC" not in self.timeZone: + print( + "Launch Date:", + self.date.strftime(time_format), + "UTC |", + self.localDate.strftime(time_format), + self.timeZone, + ) elif self.date != None: print("Launch Date:", self.date.strftime(time_format), "UTC") if self.lat != None and self.lon != None: @@ -2975,8 +2981,14 @@ def allInfo(self): print("\n\nLaunch Site Details") print("\nLaunch Rail Length:", self.rL, " m") time_format = "%Y-%m-%d %H:%M:%S" - if self.date != None and 'UTC' not in self.timeZone: - print("Launch Date:", self.date.strftime(time_format), "UTC |", self.localDate.strftime(time_format), self.timeZone) + if self.date != None and "UTC" not in self.timeZone: + print( + "Launch Date:", + self.date.strftime(time_format), + "UTC |", + self.localDate.strftime(time_format), + self.timeZone, + ) elif self.date != None: print("Launch Date:", self.date.strftime(time_format), "UTC") if self.lat != None and self.lon != None: From f458d30d04e885beb9056b23edb8cceb814a5abd Mon Sep 17 00:00:00 2001 From: Lint Action Date: Sat, 8 Jan 2022 23:59:59 +0000 Subject: [PATCH 16/16] Fix code style issues with Black --- setup.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index a3291ffa6..4ecc61447 100644 --- a/setup.py +++ b/setup.py @@ -6,12 +6,12 @@ setuptools.setup( name="rocketpy", version="0.9.9", - install_requires = [ - 'numpy>=1.0', - 'scipy>=1.0', - 'matplotlib>=3.0', - 'requests', - 'pytz', + install_requires=[ + "numpy>=1.0", + "scipy>=1.0", + "matplotlib>=3.0", + "requests", + "pytz", ], maintainer="RocketPy Developers", author="Giovani Hidalgo Ceotto",