<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Define and parameterise insert
Step1:  Load model data
Step2:  Only use the data for the specified energy, applicator, and ssd
Step3:  Calculate the factor
Step4:  Display the model
<ASSISTANT_TASK:>
Python Code:
energy = 6
applicator = 10
ssd = 100
x = [0.99, -0.14, -1.0, -1.73, -2.56, -3.17, -3.49, -3.57, -3.17, -2.52, -1.76,
    -1.04, -0.17, 0.77, 1.63, 2.36, 2.79, 2.91, 3.04, 3.22, 3.34, 3.37, 3.08, 2.54,
    1.88, 1.02, 0.99]
y = [5.05, 4.98, 4.42, 3.24, 1.68, 0.6, -0.64, -1.48, -2.38, -3.77, -4.81,
    -5.26, -5.51, -5.58, -5.23, -4.64, -3.77, -2.77, -1.68, -0.29, 1.23, 2.68, 3.8,
    4.6, 5.01, 5.08, 5.05]
width, length, poi = parameterise_single_insert(x, y)
print("Width = {0:0.2f} cm\nLength = {1:0.2f} cm".format(width, length))
display_parameterisation(x, y, width, length, poi)
Explanation: Define and parameterise insert
End of explanation
data_filelist = glob('*_data.csv')
assert len(data_filelist) <= 1, "There appears to be more than 1 data.csv file, please delete the old version(s)"
assert len(data_filelist) == 1, "I need at least one data file"
data_filename = data_filelist[0]
data = pd.read_csv(data_filename)
Explanation: Load model data
End of explanation
reference = (
    (data['Energy (MeV)'] == energy) &
    (data['Applicator (cm)'] == applicator) &
    (data['SSD (cm)'] == ssd)
)
input_dataframe = data[reference]
label = np.array(input_dataframe['Label']).astype(str)
width_data = np.array(
    input_dataframe['Width (cm @ 100SSD)']).astype(float)
length_data = np.array(
    input_dataframe['Length (cm @ 100SSD)']).astype(float)
factor_data = np.array(
    input_dataframe['Insert factor (dose insert / dose open)']).astype(float)
input_dataframe
Explanation: Only use the data for the specified energy, applicator, and ssd
End of explanation
number_of_data = len(input_dataframe)    
if number_of_data >= 8:
    ratio_perim_area_data = convert2_ratio_perim_area(width_data, length_data)
    ratio_perim_area = convert2_ratio_perim_area(width, length)
    factor = float(spline_model_with_deformability(width, ratio_perim_area,
        width_data, ratio_perim_area_data, factor_data))
else: 
    factor = np.nan
print("Width = {0:0.2f} cm\nLength = {1:0.2f} cm\nFactor = {2:0.4f}".format(
        width, length, factor))
Explanation: Calculate the factor
End of explanation
if number_of_data >= 8:
    ratio_perim_area_data = convert2_ratio_perim_area(width_data, length_data)
    figure = interactive(
        width_data, length_data, ratio_perim_area_data, factor_data, label)
else:
    figure = fallback_scatter(width_data, length_data, factor_data, label) 
    
show(figure)
Explanation: Display the model
End of explanation
<END_TASK>