I found some problems with your code.
In Solve[D[eqn2, k] == 0, k] the equation is quite difficult to solve exactly. I would suggest NSolve instead of Solve.
When you write filtered_k2, it is interpreted as a pattern. I would suggest a symbol like filteredk2.
The syntax of Pick wants the first element to be a list, but sol2 is a single number, not a list.
The syntax of Pick wants the second element to be a list of True/False, not a function.