Coverage for D:\Ralf Gerlich\git\modypy\modypy\utils\uiuc_db.py: 0%

# Coverage for D:\Ralf Gerlich\git\modypy\modypy\utils\uiuc_db.py : 0%

## 15 statements

Hot-keys on this page

r m x p toggle line displays

j k next/prev highlighted chunk

0 (zero) top of page

1 (one) first highlighted chunk

1"""

2 Utilities for loading measurement data from the UIUC aeronautical databases.

3"""

4 import urllib.parse as parse

5 import urllib.request as request

6

7 import numpy as np

8 from scipy.interpolate import interp1d

9

10 UIUC_PROP_DB = "https://m-selig.ae.illinois.edu/props/"

11

12

13 def load_static_propeller(path,

14 urlopen_options=None,

15 interp_options=None):

16 """Retrieve data about the static performance of a given propeller and

17 provide interpolation functions for the thrust and power coefficient.

18

19 Args:

20 path: The relative path of the respective input file, e.g.

21 `volume-2/data/apcff_4.2x4_static_0615rd.txt`

22 urlopen_options: Dictionary of options passed to `urllib.request.urlopen`

23 (Default value = None)

24 interp_options: Dictionary of options passed to

25 `scipy.interpolate.interp1d` (Default value = None)

26

27 Returns:

28 Functions for determining the thrust- and power-coefficient based on the

29 speed (in 1/s)

30 """

31

32 urlopen_options = urlopen_options or {}

33 interp_options = interp_options or {}

34

35 full_url = parse.urljoin(UIUC_PROP_DB, path)

36

37 with request.urlopen(full_url, **urlopen_options) as req:

38 data = np.loadtxt(req, skiprows=1)

39 speed = data[:, 0] / 60

40 thrust_coeff = data[:, 1]

41 power_coeff = data[:, 2]

42

43 return interp1d(speed, thrust_coeff, **interp_options), \

44 interp1d(speed, power_coeff, **interp_options)