from pylinac.core.array_utils import normalize
from pylinac.core.image_generator import AS1000Image, FilterFreeFieldLayer, GaussianFilterLayer
from pylinac.core.profile import FWXMProfilePhysical, PenumbraLeftMetric, PenumbraRightMetric

# this is our set up to get a nice profile
as1000 = AS1000Image()
as1000.add_layer(
    FilterFreeFieldLayer(field_size_mm=(100, 100))
)
as1000.add_layer(
    GaussianFilterLayer(sigma_mm=2)
)  # add an image-wide gaussian to simulate penumbra/scatter

# pull out the profile array
array = normalize(as1000.image[:, as1000.shape[1] // 2])

# create the profile
profile = FWXMProfilePhysical(array, dpmm=1)

# compute the profile with our plugin
profile.compute(metrics=[PenumbraLeftMetric(), PenumbraRightMetric()])

# plot the profile
profile.plot()