Skip to content

ENH: Use EnvironmentAnalysis to initialize the Flight class #657

Description

@Gui-FernandesBR

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

Activity

  1. changed the title [-]ENH: Use Environment analysis to initialize the Flight class[/-] [+]ENH: Use `EnvironmentAnalysis` to initialize the `Flight` class[/+] on Aug 20, 2024
  2. added
    EnvironmentEnviroment Class related features
    EnhancementNew feature or request, including adjustments in current codes
    on Nov 2, 2024
  3. moved this from Backlog to HotFix in LibDev Roadmapon Jan 26, 2025
  4. self-assigned this
    on May 1, 2025
  5. moved this from HotFix to Closed in LibDev Roadmapon Jun 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

EnhancementNew feature or request, including adjustments in current codesEnvironmentEnviroment Class related featuresGood first issueGood for newcomers

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions