def get_area_summed_M(c,phi,r0,do,dI,phi_c,R_corner,Phi_corner,X_rim,ring_pos):
	""" given a pixel in the position middle ('M'), a ray, 
		and a circle including all its properties,
		this function determines the intersection area of the pixel and
		the area inside the radius of the circle and left to the ray;
		this function, oposed to the others, is not derived on paper. 
		I was to impatient and just wrote it down in python. """
	
	# the area will be increased during this function
	area = 0
	
	# we are going in phi direction over the pixel area and add up its contributions
	# until we reach the phi value
	idx = 0
	if phi<=Phi_corner[idx]:
		if ring_pos[idx] == "p": area += 0.5 * ( (dI["a_I"] - X_rim[(idx-1)%4])*(0.5+c[1]) )
		elif ring_pos[idx] == "c": area += 0.5 * ( phi*r0*r0 )
		elif ring_pos[idx] == "cp": area += 0.5 * ( (dI["a_I"] - X_rim[(idx-1)%4])*(0.5+c[1]) )
		elif ring_pos[idx] == "pc": 
			if phi<do["phi_a_o"]: area += 0.5 * ( (dI["a_I"] - X_rim[(idx-1)%4])*(0.5+c[1]) )
			else: area += 0.5 * ( (do["a_o"] - X_rim[(idx-1)%4])*(0.5+c[1]) + (phi-do["phi_a_o"])*r0*r0 )
		elif ring_pos[idx] == "cpc": 
			if phi<do["phi_a_o+"]: area += 0.5 * ( (dI["a_I"] - X_rim[(idx-1)%4])*(0.5+c[1]) )
			else: area += 0.5 * ( (do["a_o+"] - X_rim[(idx-1)%4])*(0.5+c[1]) + (phi-do["phi_a_o+"])*r0*r0 )
		return area
	else:
		if ring_pos[idx] == "p": area += 0.5 * ( (1. - X_rim[(idx-1)%4])*(0.5+c[1]) )
		elif ring_pos[idx] == "c": area += 0.5 * ( Phi_corner[idx]*r0*r0)
		elif ring_pos[idx] == "cp": area += 0.5 * ( (1. - X_rim[(idx-1)%4])*(0.5+c[1]) )
		elif ring_pos[idx] == "pc": area += 0.5 * ( (do["a_o"] - X_rim[(idx-1)%4])*(0.5+c[1]) + (Phi_corner[idx]-do["phi_a_o"])*r0*r0 )
		elif ring_pos[idx] == "cpc": area += 0.5 * ( (do["a_o+"] - X_rim[(idx-1)%4])*(0.5+c[1]) + (Phi_corner[idx]-do["phi_a_o+"])*r0*r0 )

	idx = 1
	if phi<=Phi_corner[idx]:
		if ring_pos[idx] == "p": area += 0.5 * ( dI["b_I"]*(0.5+c[0]) )
		elif ring_pos[idx] == "c": area += 0.5 * ( (phi-Phi_corner[idx-1])*r0*r0 )
		elif ring_pos[idx] == "cp": 
			if phi<do["phi_b_o"]: area += 0.5 * ( (phi-Phi_corner[idx-1])*r0*r0 )
			else: area += 0.5 * ( (do["phi_b_o"]-Phi_corner[idx-1])*r0*r0 + (dI["b_I"] - do["b_o"])*(0.5+c[0]) )
		elif ring_pos[idx] == "pc": 
			if phi<do["phi_b_o"]: area += 0.5 * ( dI["b_I"]*(0.5+c[0]) )
			else: area += 0.5 *  ( do["b_o"]*(0.5+c[0]) + (phi-do["phi_b_o"])*r0*r0 )
		elif ring_pos[idx] == "cpc": 
			if phi<do["phi_b_o"]: area += 0.5 * ( (phi-Phi_corner[idx-1])*r0*r0 )
			elif phi<do["phi_b_o+"]: area += 0.5 * ( (do["phi_b_o"]-Phi_corner[idx-1])*r0*r0 + (dI["b_I"] - do["b_o"])*(0.5+c[0]) )
			else: area += 0.5 * ( (do["phi_b_o"]-Phi_corner[idx-1])*r0*r0 + (do["b_o+"] - do["b_o"])*(0.5+c[0]) + (phi-do["phi_b_o+"])*r0*r0 )
		return area
	else:
		if ring_pos[idx] == "p": area += 0.5 * ( (0.5+c[0]) )
		elif ring_pos[idx] == "c": area += 0.5 * ( (Phi_corner[idx]-Phi_corner[idx-1]) * r0*r0)
		elif ring_pos[idx] == "cp": area += 0.5 * ( (do["phi_b_o"]-Phi_corner[idx-1])*r0*r0 + (1. - do["b_o"])*(0.5+c[0]) )
		elif ring_pos[idx] == "pc": area += 0.5 * ( do["b_o"]*(0.5+c[0]) + (Phi_corner[idx]-do["phi_b_o"])*r0*r0 )
		elif ring_pos[idx] == "cpc": area += 0.5 * ( (do["phi_b_o"]-Phi_corner[idx-1])*r0*r0 + (do["b_o+"] - do["b_o"])*(0.5+c[0]) + (Phi_corner[idx]-do["phi_b_o+"])*r0*r0 )

	idx = 2
	if phi<=Phi_corner[idx]:
		if ring_pos[idx] == "p": area += 0.5 * ( dI["c_I"]*(0.5-c[1]) )
		elif ring_pos[idx] == "c": area += 0.5 * ( (phi-Phi_corner[idx-1])*r0*r0 )
		elif ring_pos[idx] == "cp": 
			if phi<do["phi_c_o"]: area += 0.5 * ( (phi-Phi_corner[idx-1])*r0*r0 )
			else: area += 0.5 * ( (do["phi_c_o"]-Phi_corner[idx-1])*r0*r0 + (dI["c_I"] - do["c_o"])*(0.5-c[1]) )
		elif ring_pos[idx] == "pc": 
			if phi<do["phi_c_o"]: area += 0.5 * ( dI["c_I"]*(0.5-c[1]) )
			else: area += 0.5 *  ( do["c_o"]*(0.5-c[1]) + (phi-do["phi_c_o"])*r0*r0 )
		elif ring_pos[idx] == "cpc": 
			if phi<do["phi_c_o"]: area += 0.5 * ( (phi-Phi_corner[idx-1])*r0*r0 )
			elif phi<do["phi_c_o+"]: area += 0.5 * ( (do["phi_c_o"]-Phi_corner[idx-1])*r0*r0 + (dI["c_I"] - do["c_o"])*(0.5-c[1]) )
			else: area += 0.5 * ( (do["phi_c_o"]-Phi_corner[idx-1])*r0*r0 + (do["c_o+"] - do["c_o"])*(0.5-c[1]) + (phi-do["phi_c_o+"])*r0*r0 )
		return area
	else:
		if ring_pos[idx] == "p": area += 0.5 * ( (0.5-c[1]) )
		elif ring_pos[idx] == "c": area += 0.5 * ( (Phi_corner[idx]-Phi_corner[idx-1]) * r0*r0)
		elif ring_pos[idx] == "cp": area += 0.5 * ( (do["phi_c_o"]-Phi_corner[idx-1])*r0*r0 + (1. - do["c_o"])*(0.5-c[1]) )
		elif ring_pos[idx] == "pc": area += 0.5 * ( do["c_o"]*(0.5-c[1]) + (Phi_corner[idx]-do["phi_c_o"])*r0*r0 )
		elif ring_pos[idx] == "cpc": area += 0.5 * ( (do["phi_c_o"]-Phi_corner[idx-1])*r0*r0 + (do["c_o+"] - do["c_o"])*(0.5-c[1]) + (Phi_corner[idx]-do["phi_c_o+"])*r0*r0 )

	idx = 3
	if phi<=Phi_corner[idx]:
		if ring_pos[idx] == "p": area += 0.5 * ( dI["d_I"]*(0.5-c[0]) )
		elif ring_pos[idx] == "c": area += 0.5 * ( (phi-Phi_corner[idx-1])*r0*r0 )
		elif ring_pos[idx] == "cp": 
			if phi<do["phi_d_o"]: area += 0.5 * ( (phi-Phi_corner[idx-1])*r0*r0 )
			else: area += 0.5 * ( (do["phi_d_o"]-Phi_corner[idx-1])*r0*r0 + (dI["d_I"] - do["d_o"])*(0.5-c[0]) )
		elif ring_pos[idx] == "pc": 
			if phi<do["phi_d_o"]: area += 0.5 * ( dI["d_I"]*(0.5-c[0]) )
			else: area += 0.5 *  ( do["d_o"]*(0.5-c[0]) + (phi-do["phi_d_o"])*r0*r0 )
		elif ring_pos[idx] == "cpc": 
			if phi<do["phi_d_o"]: area += 0.5 * ( (phi-Phi_corner[idx-1])*r0*r0 )
			elif phi<do["phi_d_o+"]: area += 0.5 * ( (do["phi_d_o"]-Phi_corner[idx-1])*r0*r0 + (dI["d_I"] - do["d_o"])*(0.5-c[0]) )
			else: area += 0.5 * ( (do["phi_d_o"]-Phi_corner[idx-1])*r0*r0 + (do["d_o+"] - do["d_o"])*(0.5-c[0]) + (phi-do["phi_d_o+"])*r0*r0 )
		return area
	else:
		if ring_pos[idx] == "p": area += 0.5 * ( (0.5-c[0]) )
		elif ring_pos[idx] == "c": area += 0.5 * ( (Phi_corner[idx]-Phi_corner[idx-1]) * r0*r0)
		elif ring_pos[idx] == "cp": area += 0.5 * ( (do["phi_d_o"]-Phi_corner[idx-1])*r0*r0 + (1. - do["d_o"])*(0.5-c[0]) )
		elif ring_pos[idx] == "pc": area += 0.5 * ( do["d_o"]*(0.5-c[0]) + (Phi_corner[idx]-do["phi_d_o"])*r0*r0 )
		elif ring_pos[idx] == "cpc": area += 0.5 * ( (do["phi_d_o"]-Phi_corner[idx-1])*r0*r0 + (do["d_o+"] - do["d_o"])*(0.5-c[0]) + (Phi_corner[idx]-do["phi_d_o+"])*r0*r0 )
	
	
	idx = 0
	if ring_pos[idx] == "p": area += 0.5 * ( dI["a_I"]*(0.5+c[1]) )
	elif ring_pos[idx] == "c": area += 0.5 * ( (phi-Phi_corner[(idx-1)%4])*r0*r0 )
	elif ring_pos[idx] == "cp": 
		if phi<do["phi_a_o"]: area += 0.5 * ( (phi-Phi_corner[(idx-1)%4])*r0*r0 )
		else: area += 0.5 * ( (do["phi_a_o"]-Phi_corner[(idx-1)%4])*r0*r0 + (dI["a_I"] - do["a_o"])*(0.5+c[1]) )
	elif ring_pos[idx] == "pc": area += 0.5 * ( dI["a_I"]*(0.5+c[1]) )
	elif ring_pos[idx] == "cpc": 
		if phi<do["phi_a_o"]: area += 0.5 * ( (phi-Phi_corner[(idx-1)%4])*r0*r0 )
		else: area += 0.5 * ( (do["phi_a_o"]-Phi_corner[(idx-1)%4])*r0*r0 + (dI["a_I"] - do["a_o"])*(0.5+c[1]) )
	return area