Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Use EnvironmentAnalysis to initialize the Flight class #657

Open
Gui-FernandesBR opened this issue Aug 19, 2024 · 0 comments
Open

ENH: Use EnvironmentAnalysis to initialize the Flight class #657

Gui-FernandesBR opened this issue Aug 19, 2024 · 0 comments
Labels
Enhancement New feature or request, including adjustments in current codes Environment Enviroment Class related features Good first issue Good for newcomers

Comments

@Gui-FernandesBR
Copy link
Member

Hi, I hope this email finds you well.

My name is Gregorio and I am using RocketPy to do trajectory simulation for competition rockets. I really appreciate all your work.

For a competition we have later this year (EuRoC), we need to do a preliminary simulation and we would like to make an Environmental Analysis and use that as our Environment for the simulation. We can make the EnvironmentalAnalysis and it works fine. However, we cannot use it directly as a parameter for the flight.

We would like to do something like this:

"
Ea = EnvironmentAnalysis(
start_date=date1,
end_date=date2,
start_hour=8,
end_hour=19,
latitude=lat ,
longitude=lon,
surface_data_file="./single_levels.nc",
pressure_level_data_file="./pressure_file.nc,
timezone="CET",
unit_system="metric",
)

......

flight = Flight(
environment = Ea,
rocket = myRocket,
rail_length = rail_length,
inclination = inclination,
heading = direction,
name=f"Nominal",
)
"

However, that doesn't work, and we are doing it the following (indirect) way:

"
Ea = EnvironmentAnalysis(
start_date=date1,
end_date=date2,
start_hour=8,
end_hour=19,
latitude=lat ,
longitude=lon,
surface_data_file="./single_levels.nc",
pressure_level_data_file="./pressure_file.nc,
timezone="CET",
unit_system="metric",
)

Get the mean values from the Environmenatal Analysis

altitude_list = Ea.altitude_list
temperature_profile = Ea.average_temperature_profile + 273.15 # converting from °C to °K
wind_heading_profile = Ea.average_wind_heading_profile
wind_speed_profile = Ea.average_wind_speed_profile
pressure_profile = Ea.average_pressure_profile * 100 # converting from Pa to HPa

wind_u_profile = -1 * wind_speed_profile * np.sin(np.radians(wind_heading_profile))
wind_v_profile = -1 * wind_speed_profile * np.cos(np.radians(wind_heading_profile))

Convert the data to the form accepted by set_environment_model()

alt_p = list(zip(altitude_list, pressure_profile))
alt_t = list(zip(altitude_list, temperature_profile))
alt_wind_v = list(zip(altitude_list, wind_v_profile))
alt_wind_u = list(zip(altitude_list, wind_u_profile))

Create an environment for the simulation

env = Environment(
date=flight_data,
latitude=lat ,
longitude=lon,
elevation=elevation
)

Set the profiles for the custom environment using the data we obtained from the Environmental Analysis.

env.set_atmospheric_model(
type="custom_atmosphere",
pressure=alt_p,
temperature=alt_t,
wind_u = alt_wind_u,
wind_v = alt_wind_v
)
env.max_expected_height=4000.0

......

flight = Flight(
environment = env,
rocket = myRocket,
rail_length = rail_length,
inclination = inclination,
heading = direction,
name=f"Nominal",
)
"

Is there a better way to do it?

Thanks,
Grego

@Gui-FernandesBR Gui-FernandesBR changed the title ENH: Use Environment analysis to initialize the Flight class ENH: Use EnvironmentAnalysis to initialize the Flight class Aug 20, 2024
@Gui-FernandesBR Gui-FernandesBR added Good first issue Good for newcomers Environment Enviroment Class related features Enhancement New feature or request, including adjustments in current codes labels Nov 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request, including adjustments in current codes Environment Enviroment Class related features Good first issue Good for newcomers
Projects
Status: Backlog
Development

No branches or pull requests

1 participant