-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b459044
commit d79900b
Showing
6 changed files
with
153 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
from isacalc.main_executable import calculate_at_h, get_atmosphere | ||
from isacalc.table_maker import tabulate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
import numpy as np | ||
import pandas as pd | ||
from isacalc.main_executable import get_atmosphere, calculate_at_h | ||
|
||
|
||
def __extract_desired_params(boolean_list: list, parameter_list: list): | ||
""" | ||
Function which takes 2 lists, one with booleans and one with any other data types. | ||
Returns a list with all values of the parameter list which had the same indices as | ||
the True booleans in the boolean list | ||
:param boolean_list: List of True or False | ||
:param parameter_list: List of parameters | ||
:return: List of parameters that coincide with True items in boolean list | ||
""" | ||
|
||
if len(boolean_list) != len(parameter_list): | ||
raise IndexError("Input sizes do not match") | ||
|
||
result = [] | ||
|
||
for boolean, item in zip(boolean_list, parameter_list): | ||
if boolean is True: | ||
result.append(item) | ||
|
||
return result | ||
|
||
|
||
def tabulate(height_range: tuple, atmosphere_model=get_atmosphere(), export_as: str = '', params: list = []): | ||
""" | ||
Function to tabulate all the calculated data. | ||
For large projects where the ISA data needs to be calculated and accessed a lot, this will be | ||
a beneficial tradeoff of space against time. Storing in a csv or xlsx file is optional | ||
:param height_range: Range of heights, (start, stop, step) format is required | ||
:param atmosphere_model: Model on which the computations need to be performed | ||
:param export_as: If left blank, will not be saved to file | ||
:param params: List of all desired parameters to be recorded | ||
:return: Numpy Array of all values calculated [Height, Temp, Press, Dens, SOS, Visc] | ||
""" | ||
|
||
param_names = ['Temperature [K]', | ||
'Pressure [Pa]', | ||
'Density [kg/m^3]', | ||
'Speed of Sound [m/s]', | ||
'Dynamic Viscosity [kg/(m*s)]'] | ||
|
||
start, stop, step = height_range | ||
heights = np.arange(start=start, stop=stop+step, step=step) | ||
|
||
params = [a.lower() for a in params if type(a) == str and len(params) != 0] | ||
|
||
boolean_record_list = [True]*5 | ||
|
||
if params: | ||
if 't' not in params: | ||
boolean_record_list[0] = False | ||
|
||
if 'p' not in params: | ||
boolean_record_list[1] = False | ||
|
||
if 'd' not in params: | ||
boolean_record_list[2] = False | ||
|
||
if 'a' not in params: | ||
boolean_record_list[3] = False | ||
|
||
if 'mu' not in params: | ||
boolean_record_list[4] = False | ||
|
||
table_shape = (len(heights), sum(boolean_record_list)+1) | ||
result = np.zeros(table_shape, dtype=float) | ||
|
||
for idx, height in enumerate(heights): | ||
|
||
parameters = __extract_desired_params(boolean_record_list, list(calculate_at_h(height, atmosphere_model=atmosphere_model))) | ||
result[idx,:] = [height] + parameters | ||
|
||
if export_as: | ||
|
||
param_names = __extract_desired_params(boolean_record_list, param_names) | ||
|
||
extension = export_as.split('.')[-1] | ||
|
||
df_result = pd.DataFrame(data=result, | ||
index=range(0, table_shape[0]), | ||
columns=['Height [m]']+param_names) | ||
|
||
if extension == 'csv': | ||
df_result.to_csv(export_as) | ||
|
||
else: | ||
df_result.to_excel(export_as) | ||
|
||
return result | ||
|
||
|
||
if __name__ == "__main__": | ||
|
||
table = tabulate((0, 110000, 100), export_as=r'test1.csv', params=['T', 'mu', 'p']) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,17 +9,17 @@ def readme(): | |
setup( | ||
name = 'isacalc', # How you named your package folder (MyLib) | ||
packages = ['isacalc'], # Chose the same as "name" | ||
version = 'v1.2.0', # Start with a small number and increase it with every change you make | ||
version = 'v1.2.1', # Start with a small number and increase it with every change you make | ||
license='GNU GPLv3', # Chose a license from here: https://help.github.com/articles/licensing-a-repository | ||
description = 'Standard International Atmosphere Calculator', # Give a short description about your library | ||
long_description=readme(), | ||
author = 'Luke de Waal', # Type in your name | ||
author_email = '[email protected]', # Type in your E-Mail | ||
url = 'https://github.com/LukeDeWaal/ISA_Calculator', # Provide either the link to your github or to your website | ||
download_url = 'https://github.com/LukeDeWaal/ISA_Calculator/archive/v1.2.0.tar.gz', # I explain this later on | ||
download_url = 'https://github.com/LukeDeWaal/ISA_Calculator/archive/v1.2.1.tar.gz', # I explain this later on | ||
keywords = ['ISA','Aerospace','Aeronautical','Atmosphere'], # Keywords that define your package best | ||
install_requires=[ # I get to this in a second | ||
'numpy', | ||
'numpy', 'pandas' | ||
], | ||
classifiers=[ | ||
'Development Status :: 3 - Alpha', # Chose either "3 - Alpha", "4 - Beta" or "5 - Production/Stable" as the current state of your package | ||
|