|
44 | 44 | class transitleastsquares(object): |
45 | 45 | """Compute the transit least squares of limb-darkened transit models""" |
46 | 46 |
|
47 | | - def __init__(self, t, y, dy=None): |
| 47 | + def __init__(self, t, y, dy=None, verbose=True): |
48 | 48 | self.t, self.y, self.dy = validate_inputs(t, y, dy) |
| 49 | + self.verbose = verbose |
49 | 50 |
|
50 | 51 | def power(self, **kwargs): |
51 | 52 | """Compute the periodogram for a set of user-defined parameters""" |
52 | 53 |
|
53 | | - print(tls_constants.TLS_VERSION) |
| 54 | + if self.verbose: |
| 55 | + print(tls_constants.TLS_VERSION) |
54 | 56 | self, kwargs = validate_args(self, kwargs) |
55 | 57 |
|
56 | 58 | periods = period_grid( |
@@ -81,36 +83,39 @@ def power(self, **kwargs): |
81 | 83 | w=self.w, |
82 | 84 | u=self.u, |
83 | 85 | limb_dark=self.limb_dark, |
| 86 | + verbose=self.verbose |
84 | 87 | ) |
85 | 88 |
|
86 | | - print( |
87 | | - "Searching " |
88 | | - + str(len(self.y)) |
89 | | - + " data points, " |
90 | | - + str(len(periods)) |
91 | | - + " periods from " |
92 | | - + str(round(min(periods), 3)) |
93 | | - + " to " |
94 | | - + str(round(max(periods), 3)) |
95 | | - + " days" |
96 | | - ) |
| 89 | + if self.verbose: |
| 90 | + print( |
| 91 | + "Searching " |
| 92 | + + str(len(self.y)) |
| 93 | + + " data points, " |
| 94 | + + str(len(periods)) |
| 95 | + + " periods from " |
| 96 | + + str(round(min(periods), 3)) |
| 97 | + + " to " |
| 98 | + + str(round(max(periods), 3)) |
| 99 | + + " days" |
| 100 | + ) |
97 | 101 |
|
98 | 102 | # Python 2 multiprocessing with "partial" doesn't work |
99 | 103 | # For now, only single-threading in Python 2 is supported |
100 | 104 | if sys.version_info[0] < 3: |
101 | 105 | self.use_threads = 1 |
102 | 106 | warnings.warn("This TLS version supports no multithreading on Python 2") |
103 | 107 |
|
104 | | - if self.use_threads == multiprocessing.cpu_count(): |
105 | | - print("Using all " + str(self.use_threads) + " CPU threads") |
106 | | - else: |
107 | | - print( |
108 | | - "Using " |
109 | | - + str(self.use_threads) |
110 | | - + " of " |
111 | | - + str(multiprocessing.cpu_count()) |
112 | | - + " CPU threads" |
113 | | - ) |
| 108 | + if self.verbose: |
| 109 | + if self.use_threads == multiprocessing.cpu_count(): |
| 110 | + print("Using all " + str(self.use_threads) + " CPU threads") |
| 111 | + else: |
| 112 | + print( |
| 113 | + "Using " |
| 114 | + + str(self.use_threads) |
| 115 | + + " of " |
| 116 | + + str(multiprocessing.cpu_count()) |
| 117 | + + " CPU threads" |
| 118 | + ) |
114 | 119 |
|
115 | 120 | if self.show_progress_bar: |
116 | 121 | bar_format = "{desc}{percentage:3.0f}%|{bar}| {n_fmt}/{total_fmt} periods | {elapsed}<{remaining}" |
|
0 commit comments