Skip to content

Commit

Permalink
Merge branch 'master' into network-update
Browse files Browse the repository at this point in the history
  • Loading branch information
jooste committed Sep 2, 2024
2 parents ea91e90 + c9c797e commit 2f5c75c
Show file tree
Hide file tree
Showing 14 changed files with 60 additions and 42 deletions.
2 changes: 2 additions & 0 deletions bluesky/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ def init(mode='sim', configfile=None, scenfile=None, discoverable=False,
from bluesky import settings
settings.init(configfile)

from bluesky import stack, tools

# Initialise tools
from bluesky import tools
tools.init()
Expand Down
2 changes: 2 additions & 0 deletions bluesky/stack/simstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ def readscn(fname):

# Try reading timestamp and command
try:
line = line.split("#")[0].strip()

icmdline = line.index(">")
tstamp = line[:icmdline]
ttxt = tstamp.strip().split(":")
Expand Down
17 changes: 2 additions & 15 deletions bluesky/tools/__init__.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,7 @@
from bluesky import settings
# Register settings defaults
settings.set_variable_defaults(prefer_compiled=False)
if settings.prefer_compiled:
try:
from . import cgeo as geo
print('Using compiled geo functions')
except ImportError:
from . import geo
print('Using Python-based geo functions')
else:
from . import geo
print('Using Python-based geo functions')

from . import cachefile
''' BlueSky tools. '''


def init():
import bluesky.tools.geo as geo
print("Reading magnetic variation data")
geo.initdecl_data()
36 changes: 36 additions & 0 deletions bluesky/tools/geo/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
''' BlueSky functions for geographical calculations. '''
from bluesky import settings
from bluesky.tools.geo._geo import nm, magdec, initdecl_data, magdeccmd, kwikpos


# Register settings defaults
settings.set_variable_defaults(prefer_compiled=False)
if getattr(settings, 'prefer_compiled'):
try:
from bluesky.tools.geo._cgeo import (
rwgs84,
rwgs84_matrix,
qdrdist,
qdrdist_matrix,
latlondist,
latlondist_matrix,
wgsg,
qdrpos,
kwikdist,
kwikdist_matrix,
kwikqdrdist,
kwikqdrdist_matrix
)
print('Using compiled geo functions')
except ImportError:
from bluesky.tools.geo._geo import (rwgs84, rwgs84_matrix, qdrdist,
qdrdist_matrix, latlondist, latlondist_matrix,
wgsg, qdrpos, kwikdist, kwikdist_matrix,
kwikqdrdist, kwikqdrdist_matrix)
print('Could not load compiled geo functions, Using Python-based geo functions instead')
else:
from bluesky.tools.geo._geo import (rwgs84, rwgs84_matrix, qdrdist,
qdrdist_matrix, latlondist, latlondist_matrix,
wgsg, qdrpos, kwikdist, kwikdist_matrix,
kwikqdrdist, kwikqdrdist_matrix)
print('Using Python-based geo functions')
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -674,25 +674,17 @@ static struct PyMethodDef methods[] = {
#define PyMODINIT_FUNC void
#endif

#if PY_MAJOR_VERSION >= 3
static struct PyModuleDef cgeodef =
{
PyModuleDef_HEAD_INIT,
"cgeo", /* name of module */
"_cgeo", /* name of module */
"", /* module documentation, may be NULL */
-1, /* size of per-interpreter state of the module, or -1 if the module keeps state in global variables. */
methods
};

PyMODINIT_FUNC PyInit_cgeo(void)
PyMODINIT_FUNC PyInit__cgeo(void)
{
import_array();
return PyModule_Create(&cgeodef);
};
#else
PyMODINIT_FUNC initcgeo()
{
Py_InitModule("cgeo", methods);
import_array();
};
#endif
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from distutils.core import setup, Extension
import numpy as np

ext_modules = [Extension('cgeo', sources=['cgeo.cpp'])]
ext_modules = [Extension('_cgeo', sources=['_cgeo.cpp'])]

setup(name='cgeo', version='1.0', include_dirs=[np.get_include()],
setup(name='_cgeo', version='1.0', include_dirs=[np.get_include()],
ext_modules=ext_modules)
7 changes: 3 additions & 4 deletions bluesky/ui/qtgl/glnavdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ def defwpt(self, data):
lon=np.array(data.custwplon, dtype=np.float32))
lbl = [n[:10].ljust(10) for n in data.custwplbl]
self.custwplblbuf.update(
np.array(lbl, dtype=np.string_))

np.array(lbl, dtype=np.bytes_))

def create(self):
apt_size = settings.apt_size
Expand Down Expand Up @@ -164,7 +163,7 @@ def create(self):
if len(wptid) <= 3:
self.nnavaids += 1
wptids += wptid[:5].ljust(5)
npwpids = np.array(wptids, dtype=np.string_)
npwpids = np.array(wptids, dtype=np.bytes_)
self.wptlabels.create(npwpids, self.waypoints.lat,
self.waypoints.lon, palette.wptlabel,
(wpt_size, 0.5 * wpt_size), instanced=True)
Expand Down Expand Up @@ -199,7 +198,7 @@ def create(self):
aptids = ''
for aptid in apnames:
aptids += aptid.ljust(4)
self.aptlabels.create(np.array(aptids, dtype=np.string_),
self.aptlabels.create(np.array(aptids, dtype=np.bytes_),
self.airports.lat, self.airports.lon,
palette.aptlabel, (apt_size, 0.5 * apt_size),
instanced=True)
Expand Down
2 changes: 1 addition & 1 deletion bluesky/ui/qtgl/gltraffic.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ def update_aircraft_data(self, data):
self.ssd.update(selssd=selssd)
self.cpalines.update(vertex=cpalines)
self.color.update(color)
self.lbl.update(np.array(rawlabel.encode('utf8'), dtype=np.string_))
self.lbl.update(np.array(rawlabel.encode('utf8'), dtype=np.bytes_))

# If there is a visible route, update the start position
if self.route_acid in data.id:
Expand Down
10 changes: 5 additions & 5 deletions requirements-gui.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ PyQt6
PyQt6-WebEngine
pygame
pyopengl
numpy
scipy
pandas
matplotlib
msgpack
numpy >= 2.0.0
scipy >= 1.13.0
matplotlib >= 3.9.0
pandas >= 2.2.0
msgpack >= 1.0.0
zmq
textual
bluesky-simdata
Expand Down
8 changes: 4 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
numpy
scipy
matplotlib
numpy >= 2.0.0
scipy >= 1.13.0
matplotlib >= 3.9.0
msgpack >= 1.0.0
zmq
pandas
pandas >= 2.2.0
bluesky-simdata
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,6 @@ def get_numpy_include():
'Source': 'https://github.com/TUDelft-CNS-ATM/bluesky',
},
include_dirs=[get_numpy_include()],
ext_modules=[Extension('bluesky.tools.cgeo', ['bluesky/tools/src_cpp/cgeo.cpp']),
ext_modules=[Extension('bluesky.tools.geo._cgeo', ['bluesky/tools/geo/src_cpp/_cgeo.cpp']),
Extension('bluesky.traffic.asas.cstatebased', ['bluesky/traffic/asas/src_cpp/cstatebased.cpp'], include_dirs=['bluesky/tools/src_cpp'])]
)

0 comments on commit 2f5c75c

Please sign in to comment.