def get_charge(max_tdc, tdc_calibration_values, tdc_pixel_calibration):  
charge_calibration = np.zeros(shape=(<NUM_LIT>, <NUM_LIT>, max_tdc))<EOL>for column in range(<NUM_LIT>):<EOL><INDENT>for row in range(<NUM_LIT>):<EOL><INDENT>actual_pixel_calibration = tdc_pixel_calibration[column, row, :]<EOL>if np.any(actual_pixel_calibration != <NUM_LIT:0>) and np.any(np.isfinite(actual_pixel_calibration)):<EOL><INDENT>selected_measurements = np.isfinite(actual_pixel_calibration)  <EOL>selected_actual_pixel_calibration = actual_pixel_calibration[selected_measurements]<EOL>selected_tdc_calibration_values = tdc_calibration_values[selected_measurements]<EOL>interpolation = interp1d(x=selected_actual_pixel_calibration, y=selected_tdc_calibration_values, kind='<STR_LIT>', bounds_error=False, fill_value=<NUM_LIT:0>)<EOL>charge_calibration[column, row, :] = interpolation(np.arange(max_tdc))<EOL><DEDENT><DEDENT><DEDENT>return charge_calibration<EOL>
Interpolatet the TDC calibration for each pixel from 0 to max_tdc