BUG: Handle readonly arrays in period_array
Closes #25403

~@jbrockmendel suggested changing the def from `object[:]` to `ndarray[object]`. This unfortunately had the same runtime error about readonly buffers. So as a workaround for now (until Cython has const memoryviews), how about unsetting and then `re-setting` the writability of the input array?~