Python Forum

Full Version: Finding values to draw a line on a curve
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am newbie in Python and was attracted for a specific purpose. The project deals with Medical Physics (in cancer treatment, physics is used quite a lot) and a program called Pylinac exists for certain QA. This is what drew me to Python.

A beam profile (dose vs distance ) is obtained via a phantom. This is drawn like this:
[Image: sdfdyw.jpg]

I have to draw a line on the steep portion of the curve, on left and right. The line should be drawn on the curve such that it intersects the curve only on the steep portion and not anywhere else. I have to note the intersection of the beginning of the line and the end of the line. And midpoint of the line.

I have the values of the profile in a CSV file and can draw it. But how to draw the line based on the conditions? I have no idea. What I have done is using Excel I have subtracted the y-values from its previous rows and found something interesting. When the difference is plotted, it gives a graph like this:

[Image: v67q7t.png]

I think the gradient region of the curve is the points of the line. But how to do this in Python? and How to extract the values of the start and end point?

I have no coding experience in python and would appreciate if anybody would assist/cooperate/guide me in achieving this. This would help a lot of people in many countries.

thanks and regards
keskumar
Your grid shows distance for X axis as mm from center
Do you know the vertical scale? or the x, y position of start of line and x,y position of end line.
If so, it should be a simple point to point line draw, look at how any straight line is drawn in the example

I don't know this program, but look at the code that draws any of Pa, IPl or Pb.
It should be the same code with the new coordinates.

There should also be a command to get x,y from any point somewhere within this doc: http://pylinac.readthedocs.io/en/latest/overview.html
Larz60+

Thanks for the reply. To reply your question,
Y is in mm/cmm and Y is % which can go upto 100%. A line should be drawn on the left and right steep portion so as to determine what is called as a 'penumbra'. Different energies will give different penumbra result and hence a contnstant line wont work. It has to be drawn manually and note the values of X axis where thy intersect the line. That is the Pa and Pb points.

How to draw a line so that it intersects the curve, that is my question.