Skip to content

Commit 34744af

Browse files
Merge pull request #226 from RocketPy-Team/enh/env_analysis_euroc
WIP: ENH: Env Analysis Euroc 2022
2 parents f75c7da + 88e2bc2 commit 34744af

9 files changed

Lines changed: 52206 additions & 92 deletions
26.3 MB
Binary file not shown.
4.16 MB
Binary file not shown.

docs/notebooks/environment_analysis_EuroC_example.ipynb

Lines changed: 51355 additions & 0 deletions
Large diffs are not rendered by default.

docs/user/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Welcome to RocketPy's user documentation!
1010
../notebooks/getting_started.ipynb
1111
../notebooks/environment_class_usage.ipynb
1212
../notebooks/environment_analysis_class_usage.ipynb
13+
../notebooks/environment_analysis_EuroC_example.ipynb
1314
../notebooks/dispersion_analysis/dispersion_analysis.ipynb
1415
../notebooks/utilities_usage.ipynb
1516
../matlab/matlab.rst

docs/user/requirements.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ The following packages are needed in order to run RocketPy:
2727
- timezonefinder
2828
- simplekml
2929
- ipywidgets >= 7.6.3
30+
- jsonpickle
3031

3132

3233
All of these packages, with the exception of netCDF4, should be automatically installed when RocketPy is installed using either ``pip`` or ``conda``.
@@ -49,6 +50,7 @@ The packages needed can be installed via ``pip`` by running the following lines
4950
pip install pytz
5051
pip install timezonefinder
5152
pip install simplekml
53+
pip install jsonpickle
5254
5355
Installing Required Packages Using ``conda``
5456
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ requests
88
pytz
99
timezonefinder
1010
simplekml
11+
jsonpickle

rocketpy/Environment.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@
77
__license__ = "MIT"
88

99
import bisect
10+
import json
1011
import re
1112
import warnings
1213
from datetime import datetime, timedelta
1314

1415
import matplotlib.pyplot as plt
1516
import numpy as np
17+
import numpy.ma as ma
1618
import pytz
1719
import requests
1820

@@ -3325,6 +3327,65 @@ def allInfoReturned(self):
33253327
info["selectedEnsembleMember"] = self.ensembleMember
33263328
return info
33273329

3330+
def exportEnvironment(self, filename="environment"):
3331+
"""Export important attributes of Environment class so it can be used
3332+
again in further siulations by using the customAtmosphere atmospheric
3333+
model.
3334+
Parameters
3335+
----------
3336+
filename
3337+
3338+
Return
3339+
------
3340+
None
3341+
"""
3342+
3343+
# TODO: in the future, allow the user to select which format will be used (json, csv, etc.). Default must be JSON.
3344+
# TODO: add self.exportEnvDictionary to the documentation
3345+
# TODO: find a way to documennt the workaround I've used on ma.getdata(self...
3346+
self.exportEnvDictionary = {
3347+
"railLength": self.rL,
3348+
"gravity": self.g,
3349+
"date": [self.date.year, self.date.month, self.date.day, self.date.hour],
3350+
"latitude": self.lat,
3351+
"longitude": self.lon,
3352+
"elevation": self.elevation,
3353+
"datum": self.datum,
3354+
"timeZone": self.timeZone,
3355+
"maxExpectedHeight": float(self.maxExpectedHeight),
3356+
"atmosphericModelType": self.atmosphericModelType,
3357+
"atmosphericModelFile": self.atmosphericModelFile,
3358+
"atmosphericModelDict": self.atmosphericModelDict,
3359+
"atmosphericModelPressureProfile": ma.getdata(
3360+
self.pressure.getSource()
3361+
).tolist(),
3362+
"atmosphericModelTemperatureProfile": ma.getdata(
3363+
self.temperature.getSource()
3364+
).tolist(),
3365+
"atmosphericModelWindVelocityXProfile": ma.getdata(
3366+
self.windVelocityX.getSource()
3367+
).tolist(),
3368+
"atmosphericModelWindVelocityYProfile": ma.getdata(
3369+
self.windVelocityY.getSource()
3370+
).tolist(),
3371+
}
3372+
3373+
f = open(filename + ".json", "w")
3374+
3375+
# write json object to file
3376+
f.write(
3377+
json.dumps(self.exportEnvDictionary, sort_keys=False, indent=4, default=str)
3378+
)
3379+
3380+
# close file
3381+
f.close()
3382+
print("Your Environment file was saved, check it out: " + filename + ".json")
3383+
print(
3384+
"You can use it in the future by using the customAtmosphere atmospheric model."
3385+
)
3386+
3387+
return None
3388+
33283389
# Auxiliary functions - Geodesic Coordinates
33293390
def geodesicToUtm(self, lat, lon, datum):
33303391
"""Function which converts geodetic coordinates, i.e. lat/lon, to UTM

0 commit comments

Comments
 (0)