I have two sets of points whose coordinates are stored in the arrays X1 Y1 and X2 Y2 respectively. We do **not** have the same number of points in the sets 1 and 2.

What I'm trying to do is mask the longest Y array (it will always be known) to get the Y value of the points that are available in both sets. For context, this is because I want to calculate a correlation factor between raw experimental data and sliding-averaged data. The sliding average crops a few points (as many as the selected averaging window width) so the raw data array is always larger.

I tried this but it only works when X1 and X2 have the same size:

```
# Base data
X1 = np.array([1,2,3,4,5])
Y1 = np.array([10,20,30,40,50])
X2 = np.array([2,3,4])
Y2 = np.array([200,300,400])

# Y data that share an X
Y1_with_common_X = Y1[X1 == X2] # expected result: y2 == np.array([20,30,40])

# analyze the cropped data (this function is already written and works fine)
R2 = correlation(Y2, Y1_with_common_X)

```

How to do for different sized arrays? Thanks in advance. 

Edit: here is a picture, it's clearer.
[![enter image description here](https://i.stack.imgur.com/e5dNt.png)](https://i.stack.imgur.com/e5dNt.png)