AirTrafficSim
AirTrafficSim copied to clipboard
Using a negative longitude in DemoEnv.py throws an error.
If I modify DemoEnv.py as follows:
self.aircraft_head = Aircraft(self.traffic, call_sign="GHOST", aircraft_type="C25C", flight_phase=FlightPhase.CRUISE, configuration=Config.CLEAN, lat=43.223267, long=71.631273, alt=5000.0, heading=175.0, cas=250.0, fuel_weight=10000.0, payload_weight=12000.0)
Then the simulation runs as expected.
If I try to place the aircraft at Concord, NH, USA using the following code:
self.aircraft_head = Aircraft(self.traffic, call_sign="GHOST", aircraft_type="C25C", flight_phase=FlightPhase.CRUISE, configuration=Config.CLEAN, lat=43.223267, long=-71.631273, alt=5000.0, heading=175.0, cas=250.0, fuel_weight=10000.0, payload_weight=12000.0)
Then the simulation fails with the following:
emitting event "loadingMsg" to all [/] ERA5 data exists. Traffic.py - add_aircraft() GHOST Type: C25C Traffic.py - add_aircraft() FOLLOW Type: A20N emitting event "simulationEnvironment" to all [/] Exception in thread Thread-7 (_handle_event_internal): Traceback (most recent call last): File "/opt/homebrew/Caskroom/miniforge/base/envs/airtrafficsim/lib/python3.11/threading.py", line 1038, in _bootstrap_inner self.run() File "/opt/homebrew/Caskroom/miniforge/base/envs/airtrafficsim/lib/python3.11/threading.py", line 975, in run self._target(*self._args, **self._kwargs) File "/opt/homebrew/Caskroom/miniforge/base/envs/airtrafficsim/lib/python3.11/site-packages/socketio/server.py", line 733, in _handle_event_internal r = server._trigger_event(data[0], namespace, sid, *data[1:]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Caskroom/miniforge/base/envs/airtrafficsim/lib/python3.11/site-packages/socketio/server.py", line 758, in _trigger_event return self.handlers[namespace][event](*args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Caskroom/miniforge/base/envs/airtrafficsim/lib/python3.11/site-packages/flask_socketio/__init__.py", line 282, in _handler return self._handle_event(handler, message, namespace, sid, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Caskroom/miniforge/base/envs/airtrafficsim/lib/python3.11/site-packages/flask_socketio/__init__.py", line 828, in _handle_event ret = handler(*args) ^^^^^^^^^^^^^^ File "/opt/homebrew/Caskroom/miniforge/base/envs/airtrafficsim/lib/python3.11/site-packages/airtrafficsim/server/server.py", line 153, in run_simulation env.run(socketio) File "/opt/homebrew/Caskroom/miniforge/base/envs/airtrafficsim/lib/python3.11/site-packages/airtrafficsim/core/environment.py", line 134, in run self.step(socketio) File "/opt/homebrew/Caskroom/miniforge/base/envs/airtrafficsim/lib/python3.11/site-packages/airtrafficsim/core/environment.py", line 81, in step self.traffic.update(self.global_time) File "/opt/homebrew/Caskroom/miniforge/base/envs/airtrafficsim/lib/python3.11/site-packages/airtrafficsim/core/traffic.py", line 262, in update self.weather.update(self.lat, self.long, self.alt, File "/opt/homebrew/Caskroom/miniforge/base/envs/airtrafficsim/lib/python3.11/site-packages/airtrafficsim/core/weather/weather.py", line 124, in update ds = self.weather_data.sel(longitude=xr.DataArray(long, dims="points"), latitude=xr.DataArray(lat, dims="points"), time=np.datetime64( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Caskroom/miniforge/base/envs/airtrafficsim/lib/python3.11/site-packages/xarray/core/dataset.py", line 2642, in sel query_results = map_index_queries( ^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Caskroom/miniforge/base/envs/airtrafficsim/lib/python3.11/site-packages/xarray/core/indexing.py", line 190, in map_index_queries results.append(index.sel(labels, **options)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Caskroom/miniforge/base/envs/airtrafficsim/lib/python3.11/site-packages/xarray/core/indexes.py", line 498, in sel raise KeyError(f"not all values found in index {coord_name!r}") KeyError: "not all values found in index 'longitude'"
The only difference between the two is the negative sign on the longitude.