Skip to content

Commit

Permalink
Merge pull request #226 from RocketPy-Team/enh/env_analysis_euroc
Browse files Browse the repository at this point in the history
WIP: ENH: Env Analysis Euroc 2022
  • Loading branch information
PatrickSampaioUSP authored Oct 8, 2022
2 parents f75c7da + 88e2bc2 commit 34744af
Show file tree
Hide file tree
Showing 9 changed files with 52,206 additions and 92 deletions.
Binary file not shown.
Binary file not shown.
51,355 changes: 51,355 additions & 0 deletions docs/notebooks/environment_analysis_EuroC_example.ipynb

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/user/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Welcome to RocketPy's user documentation!
../notebooks/getting_started.ipynb
../notebooks/environment_class_usage.ipynb
../notebooks/environment_analysis_class_usage.ipynb
../notebooks/environment_analysis_EuroC_example.ipynb
../notebooks/dispersion_analysis/dispersion_analysis.ipynb
../notebooks/utilities_usage.ipynb
../matlab/matlab.rst
Expand Down
2 changes: 2 additions & 0 deletions docs/user/requirements.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ The following packages are needed in order to run RocketPy:
- 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``.
Expand All @@ -49,6 +50,7 @@ The packages needed can be installed via ``pip`` by running the following lines
pip install pytz
pip install timezonefinder
pip install simplekml
pip install jsonpickle
Installing Required Packages Using ``conda``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ requests
pytz
timezonefinder
simplekml
jsonpickle
61 changes: 61 additions & 0 deletions rocketpy/Environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
__license__ = "MIT"

import bisect
import json
import re
import warnings
from datetime import datetime, timedelta

import matplotlib.pyplot as plt
import numpy as np
import numpy.ma as ma
import pytz
import requests

Expand Down Expand Up @@ -3325,6 +3327,65 @@ def allInfoReturned(self):
info["selectedEnsembleMember"] = self.ensembleMember
return info

def exportEnvironment(self, filename="environment"):
"""Export important attributes of Environment class so it can be used
again in further siulations by using the customAtmosphere atmospheric
model.
Parameters
----------
filename
Return
------
None
"""

# TODO: in the future, allow the user to select which format will be used (json, csv, etc.). Default must be JSON.
# TODO: add self.exportEnvDictionary to the documentation
# TODO: find a way to documennt the workaround I've used on ma.getdata(self...
self.exportEnvDictionary = {
"railLength": self.rL,
"gravity": self.g,
"date": [self.date.year, self.date.month, self.date.day, self.date.hour],
"latitude": self.lat,
"longitude": self.lon,
"elevation": self.elevation,
"datum": self.datum,
"timeZone": self.timeZone,
"maxExpectedHeight": float(self.maxExpectedHeight),
"atmosphericModelType": self.atmosphericModelType,
"atmosphericModelFile": self.atmosphericModelFile,
"atmosphericModelDict": self.atmosphericModelDict,
"atmosphericModelPressureProfile": ma.getdata(
self.pressure.getSource()
).tolist(),
"atmosphericModelTemperatureProfile": ma.getdata(
self.temperature.getSource()
).tolist(),
"atmosphericModelWindVelocityXProfile": ma.getdata(
self.windVelocityX.getSource()
).tolist(),
"atmosphericModelWindVelocityYProfile": ma.getdata(
self.windVelocityY.getSource()
).tolist(),
}

f = open(filename + ".json", "w")

# write json object to file
f.write(
json.dumps(self.exportEnvDictionary, sort_keys=False, indent=4, default=str)
)

# close file
f.close()
print("Your Environment file was saved, check it out: " + filename + ".json")
print(
"You can use it in the future by using the customAtmosphere atmospheric model."
)

return None

# Auxiliary functions - Geodesic Coordinates
def geodesicToUtm(self, lat, lon, datum):
"""Function which converts geodetic coordinates, i.e. lat/lon, to UTM
Expand Down
Loading

0 comments on commit 34744af

Please sign in to comment.