# How to know spin out of wave function?

I do not clearly understand some concepts, so maybe someone will clarify this for me.

Imagine we have a random wavefunction for an electron, it could be anything.
How can I with known wave function calculate the value of spin of electron? I mean I know that we cannot exactly know with 100% would it be spin up or spin down, but which steps should be made to calculate the probabilities?
Or maybe I am misunderstanding, and that the wavefunction of an electron must always be in the form of $$|\psi\rangle=c_1|\psi_{1_{spin up}}\rangle + c_2|\psi_{2_{spin down}}\rangle$$? If yes, I know that probabilities of spin up and down is just $${c_1}^2$$ and $${c_2}^2$$ respectively.
But what if wave function would be different (not necessarily identical to the following equation, but of a different form)? For example, the normalized wavefunction of a particle in an infinite square well.

$$\psi_n\left(z\right) = \sqrt{\frac{2}{L_z}}\sin{\frac{n\pi z}{L_z}}$$

The wavefunction you are giving is the one of a particle (with no spin) in an infinite potential well, this is described as a state living on a certain Hilbert space. To include the spin of a particle you must force it as a tensor product of the system you are considering times the two-level system from the spin (if you want to consider the potential well $$\otimes$$ spin). So you are right, to have a spin system, your wavefunction (a qubit) will only have two degrees of freedom represented in the Bloch sphere or as you put it $$|{\psi}\rangle = c_1 |{up}\rangle + c_2 |{down}\rangle$$ where $$|c_1|^2 + |c_2|^2 = 1$$.
Thus, if you are describing the state as energy levels of the potential and a spin configuration, you may have a superposition of states living in this space. If you want the information of a certain value (such as the spin or the energy of the harmonic oscillator) you can project to that space on the basis you prefer. For example, if you want to project on either up or down spin component you can act with $$\langle up|$$ or $$\langle down|$$ to your state $$|\psi\rangle$$. Whether you get 0 or 1 from one of these projections you may conclude if your spin is up or down, also, you could project the state you have to a particular space of energy levels (since each $$\psi_n$$ you mentioned are orthogonal).