Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: QOL upgrades and removal of ehtim dependency #8

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion generate_ringplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import numpy as np
from kgeo.equatorial_images import Iobs
from kgeo.equatorial_lensing import rho_of_req, critical_curve
import ehtim as eh
import matplotlib.pyplot as plt
from kgeo.bfields import Bfield
from kgeo.velocities import Velocity
Expand Down
4 changes: 2 additions & 2 deletions kgeo/equatorial_lensing.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import matplotlib.pyplot as plt
from kgeo.kerr_raytracing_utils import my_cbrt, radial_roots, mino_total, is_outside_crit, uplus_uminus, n_equatorial_crossings, n_poloidal_orbits
from kgeo.kerr_raytracing_ana import r_integrate
import ehtim.parloop as parloop
from kgeo.partools import Counter
import ehtim.observing.obs_helpers as obsh
from multiprocessing import cpu_count, Pool
import os
Expand Down Expand Up @@ -363,7 +363,7 @@ def generate_library(which='rh'):
allspins = allspins.flatten()
ntot = len(allincs)

counter = parloop.Counter(initval=0, maxval=ntot)
counter = Counter(initval=0, maxval=ntot)
print("Using Multiprocessing with %d Processes" % processes)
pool = Pool(processes=processes, initializer=init, initargs=(counter,))

Expand Down
26 changes: 26 additions & 0 deletions kgeo/partools.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# partools.py
# Wraps up some helper functions for parallel loops
# Borrowed from ehtim to avoid dependency

from builtins import str
from builtins import range
from builtins import object

from multiprocessing import Value, Lock

class Counter(object):
"""Counter object for sharing among multiprocessing jobs
"""

def __init__(self, initval=0, maxval=0):
self.val = Value('i', initval)
self.maxval = maxval
self.lock = Lock()

def increment(self):
with self.lock:
self.val.value += 1

def value(self):
with self.lock:
return self.val.value
3 changes: 0 additions & 3 deletions kgeo/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,15 @@
import numpy as np
from kgeo.equatorial_images import Iobs
from kgeo.equatorial_lensing import rho_of_req, critical_curve
import ehtim as eh
import matplotlib.pyplot as plt
from kgeo.bfields import Bfield
import kgeo.bfields as kb
from kgeo.velocities import Velocity
from kgeo.emissivities import Emissivity
from scipy.interpolate import interp1d
import numpy as np
import scipy.special as sp
import mpmath
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from tqdm import tqdm
import time
from kgeo.kerr_raytracing_utils import *
Expand Down