Skip to content

Commit

Permalink
Merge pull request #315 from RocketPy-Team/enh/optional-timezonefinder
Browse files Browse the repository at this point in the history
ENH: Make timezonefinder an optional dependency
  • Loading branch information
giovaniceotto committed Jan 10, 2023
2 parents 1baa95d + 203d0f0 commit 0541011
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 10 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/test_pytest.yaml
Expand Up @@ -22,11 +22,10 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -r requirements_test.txt
- name: Build RocketPy
run: |
python setup.py install
pip install -e .
- name: Test with pytest
run: |
pytest
Expand Down
24 changes: 19 additions & 5 deletions docs/user/requirements.rst
Expand Up @@ -7,9 +7,10 @@ But read further if this is not your case!
Python Version
--------------

RocketPy was made to run on Python 3.6+.
RocketPy supports Python 3.7 and above.
Support for Python 3.11 is still limited by some dependencies.
Sorry, there are currently no plans to support earlier versions.
If you really need to run RocketPy on Python 3.5 or earlier, feel free to submit an issue and we will see what we can do!
If you really need to run RocketPy on Python 3.6 or earlier, feel free to submit an issue and we will see what we can do!

Required Packages
-----------------
Expand All @@ -20,17 +21,16 @@ The following packages are needed in order to run RocketPy:
- Numpy >= 1.0
- Scipy >= 1.0
- Matplotlib >= 3.0
- netCDF4 >= 1.4 (optional, requires Cython)
- netCDF4 >= 1.4
- windrose >= 1.6.8
- requests
- pytz
- timezonefinder
- simplekml
- ipywidgets >= 7.6.3
- jsonpickle


All of these packages, with the exception of netCDF4, should be automatically installed when RocketPy is installed using either ``pip`` or ``conda``.
All of these packages, are automatically installed when RocketPy is installed using either ``pip`` or ``conda``.
However, in case the user wants to install these packages manually, they can do so by following the instructions bellow.

Installing Required Packages Using ``pip``
Expand Down Expand Up @@ -64,6 +64,20 @@ To update Scipy and install netCDF4 using Conda, the following code is used:
conda install "scipy>=1.0"
conda install -c anaconda "netcdf4>=1.4"
Optional Packages
-----------------

Optionally, you can install timezonefinder to allow for automatic timezone detection when performing Enviornment Analysis.
This can be done by running the following line of code in your preferred terminal:

.. code-block:: shell
pip install timezonefinder
Keep in mind that this package is not required to run RocketPy, but it can be useful if you want to perform Environment Analysis.
Furthermore, timezonefinder can only be used with Python 3.8+.

Useful Packages
---------------

Expand Down
11 changes: 10 additions & 1 deletion rocketpy/EnvironmentAnalysis.py
Expand Up @@ -22,7 +22,6 @@
from matplotlib.animation import FuncAnimation
from matplotlib.animation import PillowWriter as ImageWriter
from scipy import stats
from timezonefinder import TimezoneFinder
from windrose import WindroseAxes
from rocketpy.Environment import Environment

Expand Down Expand Up @@ -421,6 +420,16 @@ def __localize_input_dates(self):

def __find_preferred_timezone(self):
if self.preferred_timezone is None:
try:
import timezonefinder as TimezoneFinder
except ImportError:
raise ImportError(
"The timezonefinder package is required to automatically "
+ "determine local timezone based on lat,lon coordinates. "
+ "Please specify the desired timezone using the `timezone` "
+ "argument when initializing the EnvironmentAnalysis class "
+ "or install timezonefinder with `pip install timezonefinder`."
)
# Use local timezone based on lat lon pair
tf = TimezoneFinder()
self.preferred_timezone = pytz.timezone(
Expand Down
6 changes: 4 additions & 2 deletions setup.py
Expand Up @@ -15,10 +15,12 @@
"ipywidgets>=7.6.3",
"requests",
"pytz",
"timezonefinder",
"simplekml",
"jsonpickle",
],
extras_require={
"timezonefinder": ["timezonefinder"],
},
maintainer="RocketPy Developers",
author="Giovani Hidalgo Ceotto",
author_email="ghceotto@gmail.com",
Expand All @@ -32,5 +34,5 @@
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
python_requires=">=3.6",
python_requires=">=3.7",
)

0 comments on commit 0541011

Please sign in to comment.