This code obtains the tetrahedral local order parameter q as given by Chau&Hardwick and later rescaled by Debenedetti et. al:
Chau, P. L., & Hardwick, A. J. (1998). A new order parameter for tetrahedral configurations. Molecular Physics, 93(3), 511-518.
Errington, J. R., & Debenedetti, P. G. (2001). Relationship between structural order and the anomalies of liquid water. Nature, 409(6818), 318-321.
I use the program ANGULA in order to obtain the first four neighbours of every water molecule:
https://gcm.upc.edu/en/members/luis-carlos/angula/ANGULA
You can take a look at our paper:
Pardo, L. C., Henao, A., Busch, S., Guàrdia, E., & Tamarit, J. L. (2014). A continuous mixture of two different dimers in liquid water. Physical Chemistry Chemical Physics, 16(44), 24479-24483.