Skip to content

Commit

Permalink
Merge pull request #224 from aitov/track-stack-improvements
Browse files Browse the repository at this point in the history
TrackStack - multi cores support
  • Loading branch information
dvida authored Nov 1, 2023
2 parents f8e9739 + fe29438 commit c5ed641
Show file tree
Hide file tree
Showing 3 changed files with 162 additions and 131 deletions.
7 changes: 5 additions & 2 deletions RMS/QueuedPool.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def __init__(self, inputs, outputs):
class QueuedPool(object):
def __init__(self, func, cores=None, log=None, delay_start=0, worker_timeout=2000, backup_dir='.', \
input_queue_maxsize=None, low_priority=False, func_extra_args=None, func_kwargs=None,
worker_wait_inbetween_jobs=0.1):
worker_wait_inbetween_jobs=0.1, print_state=True):
""" Provides capability of creating a pool of workers which will process jobs in a given queue, and
the input queue can be updated in another thread.
Expand Down Expand Up @@ -117,6 +117,7 @@ def __init__(self, func, cores=None, log=None, delay_start=0, worker_timeout=200
default.
worker_wait_inbetween_jobs: [float] Wait this number of seconds after finished a job and putting
the result in the output queue. 0.1 s by default.
print_state: [bool] Print state of workers during execution, True by default.
"""


Expand Down Expand Up @@ -190,6 +191,8 @@ def __init__(self, func, cores=None, log=None, delay_start=0, worker_timeout=200

### ###

self.print_state = print_state


def printAndLog(self, *args):
""" Print and log the given message. """
Expand Down Expand Up @@ -410,7 +413,7 @@ def closePool(self):

c += 1

if c%500 == 0:
if c%500 == 0 and self.print_state:
self.printAndLog('-----')
self.printAndLog('Cores in use:', self.cores.value())
self.printAndLog('Active worker threads:', self.active_workers.value())
Expand Down
2 changes: 1 addition & 1 deletion Utils/DrawConstellations.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def drawConstellations(platepar, ff_file, separation_deg=90, color_bgra=None):
to_x, to_y = raDecToXYPP(np.array(to_ra), to_dec, fftime_jd, platepar)
for i in range(len(to_x)):
if ang_sep[i] < separation_deg:
cv2.line(img, (round(from_x[i]), round(from_y[i])), (round(to_x[i]), round(to_y[i])), color_bgr, 1)
cv2.line(img, (int(round(from_x[i])), int(round(from_y[i]))), (int(round(to_x[i])), int(round(to_y[i]))), color_bgr, 1)

return img

Expand Down
Loading

0 comments on commit c5ed641

Please sign in to comment.