|
5 | 5 | import numpy as np |
6 | 6 |
|
7 | 7 | from . import rotor |
8 | | -from . import secondary |
| 8 | +from . import correction |
9 | 9 | from . import tools |
10 | 10 |
|
11 | 11 |
|
12 | 12 |
|
13 | | - |
14 | | -class Corrections(object): |
15 | | - """Class for storing corrections. |
16 | | -
|
17 | | - Consider all the corrections available in the secondary |
18 | | - models module. If not given by the user considers the base (empty) |
19 | | - correction with the default parameters. |
20 | | -
|
21 | | - Parameters |
22 | | - ---------- |
23 | | - corrections : optional |
24 | | - dictionary or list with the secondary corrections, either classes of |
25 | | - instances - in case of custom parameters. If dictionary is |
26 | | - given, the key must be the name of the correction as defined in |
27 | | - secondary.py with a lower first letter. |
28 | | - |
29 | | - """ |
30 | | - def __init__(self,corrections:dict={}): |
31 | | - for name, obj in inspect.getmembers(secondary): |
32 | | - if inspect.isclass(obj): |
33 | | - _name = name[0].lower() + name[1:] |
34 | | - if type(corrections) is dict: |
35 | | - if _name in corrections: |
36 | | - # instantiation of correction with default values |
37 | | - corr = corrections[_name] |
38 | | - corr = corr() if isinstance(corr,type) else corr |
39 | | - setattr(self,_name,corr) |
40 | | - else: |
41 | | - setattr(self,_name,obj.Dummy()) |
42 | | - else: |
43 | | - effect_name = obj.__qualname__ |
44 | | - setattr(self,_name,obj.Dummy()) |
45 | | - # loop for all effects to check if any of the input |
46 | | - # corrections are inner of the available corrections |
47 | | - for corr in corrections: |
48 | | - # instantiation of correction with default values |
49 | | - corr = corr() if isinstance(corr,type) else corr |
50 | | - correction_name = type(corr).__qualname__ |
51 | | - if effect_name in correction_name: |
52 | | - setattr(self,_name,corr) |
53 | | - break |
54 | | - |
55 | | - |
56 | | - def __iter__(self): |
57 | | - """Iterate corrections.""" |
58 | | - for value in self.__dict__.values(): |
59 | | - yield value |
60 | | - |
61 | | - |
62 | 13 | class BaseBEM: |
63 | 14 | """Base BEM class. |
64 | 15 |
|
@@ -89,7 +40,7 @@ def __init__(self,rotor:rotor.Rotor,rho:float=1.225,corrections:dict=None): |
89 | 40 | self.n = len(rotor.sections) |
90 | 41 |
|
91 | 42 | if corrections is None: corrections = {} |
92 | | - self.corrections = Corrections(corrections) |
| 43 | + self.corrections = correction.Corrections(corrections) |
93 | 44 |
|
94 | 45 |
|
95 | 46 |
|
|
0 commit comments