How to use the pymedphys.labs.paulking.profile.Profile function in pymedphys

To help you get started, we’ve selected a few pymedphys examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pymedphys / pymedphys / tests / labs / paulking / test_profile.py View on Github external
def test_get_flatness():
    profiler = Profile().from_tuples(PROFILER)
    profiler = profiler.resample_x(0.1)
    assert np.isclose(profiler.get_flatness(), 0.03042644213284108)
github pymedphys / pymedphys / tests / labs / paulking / test_profile.py View on Github external
def test_make_centered():
    profiler = Profile().from_tuples(PROFILER)
    assert np.isclose(np.sum(profiler.make_centered().get_edges()), 0.0)
github pymedphys / pymedphys / tests / labs / paulking / test_profile.py View on Github external
def test_slice_penumbra():
    profiler = Profile().from_tuples(PROFILER).resample_x(0.1)
    lt_penum, rt_penum = profiler.slice_penumbra()
    assert np.all(lt_penum.x < 0)
    assert np.all(rt_penum.x > 0)
    assert np.all(lt_penum.y < profiler.get_y(0))
    assert np.all(rt_penum.y < profiler.get_y(0))
github pymedphys / pymedphys / tests / labs / paulking / test_profile.py View on Github external
def test_from_tuples():
    empty = Profile()
    profiler = empty.from_tuples(PROFILER)
    assert len(profiler.x) == len(PROFILER)
    assert profiler.x[0] == PROFILER[0][0]
github pymedphys / pymedphys / tests / labs / paulking / test_profile.py View on Github external
def test_slice_tails():
    profiler = Profile().from_tuples(PROFILER).resample_x(0.1)
    lt_tail, rt_tail = profiler.slice_tails()
    assert np.all(lt_tail.x < min(rt_tail.x))
    assert np.all(rt_tail.x > max(lt_tail.x))
github pymedphys / pymedphys / tests / labs / paulking / test_profile.py View on Github external
def test_from_pulse():
    pulse = 4 * Profile().from_pulse(0.0, 1, (-5, 5), 0.1)
    assert np.isclose(sum(pulse.y), 40)
github pymedphys / pymedphys / pymedphys / labs / paulking / profile.py View on Github external
for row in profiler_file.readlines():
                if row[:11] == "Calibration" and "File" not in row:
                    calibs = np.array(row.split())[1:].astype(float)
                elif row[:5] == "Data:":
                    counts = np.array(row.split()[5:145]).astype(float)
                elif row[:15] == "Dose Per Count:":
                    dose_per_count = float(row.split()[-1])
        dose = counts * dose_per_count * calibs

        x_vals = [-11.2 + 0.4 * i for i in range(57)]
        x_prof = list(zip(x_vals, dose[:57]))
        y_vals = [-16.4 + 0.4 * i for i in range(83)]
        y_prof = list(zip(y_vals, dose[57:]))

        if axis == "tvs":
            return Profile().from_tuples(x_prof, meta=meta)
        elif axis == "rad":
            return Profile().from_tuples(y_prof, meta=meta)
        else:
            raise TypeError("axis must be 'tvs' or 'rad'")
github pymedphys / pymedphys / pymedphys / labs / paulking / profile.py View on Github external
meta : dict, optional

        Returns
        -------
        Profile

        Examples
        --------
        ``profile = Profile().fron_lists(x_list,data_list)``

        """

        self.x = np.array(x)
        self.y = np.array(y)
        self.__init__(x=x, y=y, meta=meta)
        return Profile(x=x, y=y, meta=meta)

github pymedphys / pymedphys / pymedphys / labs / paulking / profile.py View on Github external
def make_flipped(self):
        """ flip L -> R

        Created by reversing the sequence of y values.

        Returns
        -------
        Profile

        """

        return Profile(x=self.x, y=self.y[::-1], meta=self.meta)
github pymedphys / pymedphys / pymedphys / labs / paulking / profile.py View on Github external
Returns
        -------
        Profile

        """

        reflected = Profile(x=-self.x[::-1], y=self.y[::-1])

        step = self.get_increment()
        new_x = np.arange(min(self.x), max(self.x), step)
        new_y = [self.y[0]]
        for n in new_x[1:-1]:  # AVOID EXTRAPOLATION
            new_y.append(0.5 * self.interp(n) + 0.5 * reflected.interp(n))
        new_y.append(reflected.y[0])

        return Profile(x=new_x, y=new_y, meta=self.meta)