# Measuring shade use of dairy cattle at pasture with an on-cow light sensor: a case study

Lydiane Aubé, Bruno Meunier, Romain Lardy

<figure><img src="image_1.png" /></figure>

## To cite this version:

Lydiane Aubé, Bruno Meunier, Romain Lardy. Measuring shade use of dairy cattle at pasture with an on-cow light sensor: a case study. Computers and Electronics in Agriculture, 2026, 240, pp.111152. 10.1016/j.compag.2025.111152. hal-05348017

HAL Id: hal-05348017

https://hal.inrae.fr/hal-05348017v1

Submitted on 5 Nov 2025

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_2.png" /></figure>
<figure><img src="image_3.png" /></figure>

# Measuring shade use of dairy cattle at pasture with an on-cow light sensor: a case study

Lydiane Aubé, Bruno Meunier, Romain Lardy*

Université Clermont Auvergne, INRAE, VetAgroSup, UMR Herbivores, 63122 Saint-Genès-Champanelle, France

## ARTICLE INFO

**Keywords:**

Grazing cattle

Heat stress

Sun exposure

Method validation

Behavior monitoring

## ABSTRACT

Grazing cows preferentially access shade to shield against the sun. However, the conditions that provide cows with optimal shade access and use (e.g. no competition for access to shade) are still unknown. Continuous monitoring of shade use by grazing cattle could help to understand how and when cows use shade resources. The aim of this study was to validate a method based on a light sensor (HOBO Pendant MX2202) attached to the back (on the transverse processes of the lumbar vertebrae) of 7 dairy cows at pasture to continuously record their use of natural shade for research purposes. Live behavioral observations of shade use and cow posture were recorded in summer (June to September, between 9 am and 6 pm). Based on the behavioral observation data, we determined thresholds in lux to discriminate between cows in shade and cows in sun on a randomly-generated training dataset representing 15 % of the initial dataset. This process was repeated 100 times, generating 100 thresholds and threshold performances. Data loss due to sensor loss or battery discharge was 9 %, which is acceptable. The thresholds ranged from 15,688 to 40556 lx: sensitivity ranged from 92.0 % to 99.8 % and specificity ranged from 88.7 % to 99.9 %, showing that the performances were robust to threshold variation within this range. This study demonstrates that an efficient threshold to discriminate cows in shade from cows in the sun can be determined via a relatively short (about 12 h) series of live observations. As performances seem to be slightly lower for lying cows than for standing cows (mean false-positive rate is 7.4 % for lying cows versus 1.8 % for standing cows), future studies should consider the posture (which can also be monitored continuously with other sensors such as accelerometer installed on the legs or on the neck collar of the cows).

## 1. Introduction

Heat stress is a major concern for the productivity and welfare of dairy cows. Heat stress leads to reduced reproductive performance and reduced milk yield, resulting in substantial economic losses (Becker et al., 2020), reduced comfort, and can lead to negative affective state resulting in impaired welfare. Cows at pasture are directly exposed to solar radiation, which makes it crucial to provide an environment that enables them to adapt and cope with heat load. Cows use different coping strategies to alleviate heat stress, including both behavioral and physiological adaptations. As heat load increases, cows adapt their behavior in an effort to maintain comfort. These behavioral adaptations include decreased feed intake, increased drinking, and increased time spent standing (Becker et al., 2020; Galan et al., 2018; Polsky & von Keyserlingk, 2017). When outside temperatures rise, cows also seek out resources such as sprinklers and fans, or shade (Deniz et al., 2023). For cows at pasture, natural or artificial shade is crucial as a resource

enabling cows to mitigate heat stress risk (Schütz et al., 2014; Tucker et al., 2008; Van Laer et al., 2015). For example, the increase in respiration rate (sign of heat stress) with increased ambient temperature was less pronounced for cows in shade than for cows that were not in shade (Van Laer et al., 2015). When temperatures rise, cows are highly motivated to access shade, as observed by Schütz et al. (2008) who showed that cows chose to stand in shade rather than lie down in the sun even after 12 h of lying deprivation.

Despite the importance of shade access for dairy cows at pasture, the optimal conditions for shade access are still unknown. For example, it is not known how many shade areas are needed for all cows to enjoy access to shade without competition. Schütz et al. (2014) studied cow behavior under varying amounts of natural shade area (from 0 to 15.6 m² shade/ cow) and showed that proportion of the herd using the shade increased and proportion of cows with high panting scores decreased with increasing shade space available (Schütz et al., 2014). However, the authors concluded that further research is needed to provide specific

<footnote>* Corresponding author.</footnote>

<footnote>E-mail address: romain.lardy@inrae.fr (R. Lardy).</footnote>
recommendations (Schütz et al., 2014). Even with a shade area of 10.7 m²/cow, Deniz et al. (2021) observed that low-social-rank cows spent less time in the shade than dominant and intermediate-rank cows, suggesting that the amount of shade or the arrangement of tree canopy was not optimal. The arrangement of trees and/or hedges on the pasture plot can also affect shade efficiency and use by cows. In their literature review on silvopastoral systems, De Sousa et al. (2023) did not find clear evidence of the impact of trees arrangement on cattle behavior and performances. Further studies are clearly needed to investigate the optimal tree arrangements for heat mitigation in grazing cows. Finally, the position of the shade on the pasture plot in relation to other resources (e.g. distance from water sources) may also play an important role in cow behavior patterns, but few studies have investigated this issue. Note that cows spent less time in shade when the shade area was placed 40 m away from an in-paddock water and feed trough than 5 m away (Oliveira et al., 2019).

Shade use by cattle is typically measured by live or video-based behavioral observation. However, live behavioral observations are time-consuming, and hot climate conditions can be challenging for the observer too. Furthermore, when cows use shade, they will often bunch together, making individual tracking difficult. Video-based behavioral recognition could be good solution for artificial shades due to its low cost and high feasibility (for example, one can mount a camera near the entrance to count animals entering and exiting the artificial shade). However, video-based behavioral observation is difficult to implement in the field, especially in pasture with widely dispersed natural shade. Indeed, it would be difficult to cover large pasture areas with cameras. A tool that continuously monitors shade use would be extremely useful for future research that would aim to study and understand shade use behavior on pasture and the optimal conditions for shade access.

To our knowledge, only one study has tested a digital tool to monitor exposure to sun in dairy cows. That study, performed in 2021, tested a collar-mounted light sensor (HOBO® Pendant® MX temperature/light data logger, Onset Computer Corporation) to measure the amount of time cows voluntarily spent directly exposed to solar radiation (Sánchez-Rodríguez & Domenech-Pérez, 2021). The authors found a lux cut-off (threshold) (4624 lx) that effectively distinguishes cows in the sun from cows in artificial shade. Their study validated the use of the light sensor to measure use of artificial shade by cows but not use of natural shade from trees and/or hedges. Here we report a study designed to validate a method using the same light sensor as used by Sánchez-Rodríguez and Domenech-Pérez (2021) to continuously measure shade use by grazing cows with access to natural shade from trees and hedges. This method is primarily for research purposes and could help to better understand behavioral adaptation of cows facing heat load at pasture.

# 2. Materials and methods

## 2.1. Animals

The trial was conducted from May to September 2023 at the 'Herbipôle' dairy cow experimental farm (coordinates: 45.71473490, 3.02218460; altitude: 850 m; https://doi.org/10.15454/1.5572318050 509348E12; UE 1414, Theix, France) run by the French National Research Institute for Agriculture, Food and Environment (INRAE). The experiment was carried out according to the French guidelines for animal care and use, and all procedures were performed by appropriately-trained personnel. Seven lactating Holstein-breed dairy cows [LBO:0000132] were used throughout the experiment. The cows were kept in their herd on pasture except during twice-a-day milking. Each pasture plot included an amount of shade provided by hedges and/or (grouped or isolated) trees directly in the pasture plot. In our experimental site, the monthly average of the daily solar radiation (sum over the day) is 5.0 kWh/m², 5.5 kWh/m², 5.8 kWh/m², 5.5 kWh/m² from May to August.

## 2.2. Fitting light sensors: feasibility trials

First, we tested the feasibility of placing the light sensors (HOBO® Pendant® MX2202 light data logger, Onset Computer Corporation, Bourne, MA; Fig. 1) directly on the cows. A previous study had attached the same sensors to a weighted collar to keep the sensor on top of the cow's neck (Sánchez-Rodríguez & Domenech-Pérez, 2021). To avoid the cow's body shading the sensor and the cow's head movements changing the sensor angle, we tested two other locations on the cow's body in an effort to find where the on-body sensor would deviate as little as possible from the horizontal plane, as the sensor manufacturer's user manual states "when measuring light intensity outdoors or underwater, make sure the MX2202 logger is mounted horizontally so that the light sensor is pointing straight up towards the sky" (HOBO® Pendant® MX2202 temp/light logger manual, p.7, https://www.onsetcomp.com/resour ces/documentation/21536-mx2201-mx2202-manual). The two loca tions tested were the transverse processes of the lumbar vertebrae behind the hip bone (both sides tested; location A) and the backline just behind the withers (location B; Fig. 2). We expected sensors placed in location A and B to experience minimal inclination variation, whereas a collar-mounted sensor would frequently change angle as the cow moves its neck, especially when grazing. The sensor was attached to a rectan gular geotextile patch (about 5 to 10 mm larger than the sensor on all sides) using to two tie wraps (in pre-existing holes, one at each of the sensor; Fig. 1). The sensor was then attached to the cows with glue (Kamar adhesive glue for heat mount detectors, Kamar Products Inc., Zionsville, IN) at location A or B (Fig. 2). After a few weeks of testing both locations, we selected location A (on the transverse processes of the lumbar vertebrae, behind the hip bone; Fig. 2) for the rest of the study as it resulted in the least sensor loss. Note that, during the experiment, we did not observe any discomfort behaviors of the cows after sensor equipment such as specific scratching on this area.

Based on these initial tests, we also chose to remove the sensor from the cows every two or three weeks and download the data every week during the following steps of the study. All sensors were set to measure a light value (in lx) every 10 s and to record one datapoint per minute (where one datapoint was the average of the 6 datapoints measured during the previous 60 s). At this setting, the memory would theoreti cally be full in about 30 days. The final full dataset consisted of 1440 lx values per day, with one datapoint per minute.

<figure><img src="image_4.png" /><figcaption>Fig. 1. Light sensor (HOBO® Pendant® MX2202 temperature/light data logger) attached to a geotextile patch before being glued to the cow.</figcaption></figure>
<figure><img src="image_5.png" /><figcaption>**Fig. 2.** (1) The two locations tested in the feasibility study (location A: on the backline just behind the withers; location B: on the transverse processes of the lumbar vertebrae behind the hip bone); (2) The final selected location of the sensor attached to the cow on the transverse processes of the lumbar vertebrae behind the hip bone.</figcaption></figure>

## 2.3. Behavioral observations

Live behavioral observations were performed over 26 different days across the period (from 28th June to 26th September) in order to provide a reference for validation of the method. Hours of observation ranged from 09:08 to 18:08. Solar altitude angle (i.e. the angle between the sun's rays and a horizontal plane) ranged from 18.7° to 67.5° (mean = 44.1°), thus covering a wide range of solar intensity. Table 1 reports the number of datapoints per shade-use behavior, per posture and per month. The ethogram consisted of two non-exclusive categories: shade-use behaviors and postures. Shade-use behaviors included five mutually-exclusive items: (1) cow under shade (at least 70 % of the cow's body surface is under shade); (2) cow under sun (at least 70 % of the cow's body surface is under sun); (3) ambiguous situations (between 30 % and 70 % of the cow's body surface under shade; adapted from Lees et al., 2022); (4) cloudy (when the observer could not clearly distinguish the outline of shade from trees or cows on the ground); (5) not visible (when the cow was not sufficiently visible to the observer). Postures included 3 mutually-exclusive items: (1) standing, defined as “any activity in which the cow's body is off the ground and the bodyweight is supported by the legs” (Hunter et al., 2021), including transition postures from standing to lying and vice versa); (2) lying in ventral recumbency; (3) lying in lateral recumbency (lying on the side, ‘the body is resting flat on one side with the legs of the supported underside extended’, Haley et al., 2001).

<caption>**Table 1**</caption>

Description of the final dataset (direct behavioral observation paired with sensor data): number of datapoints per shade-use behavior, per posture and per month (one datapoint corresponds to one minute of observations [mean of six 10-second intervals]).

<table><thead><tr><th></th><th>Number of datapoints</th></tr></thead><tbody><tr><td>Shade use</td><td></td></tr><tr><td>Shade</td><td>1410</td></tr><tr><td>Sun</td><td>3169</td></tr><tr><td>Ambiguous</td><td>137</td></tr><tr><td>Cloudy</td><td>166</td></tr><tr><td>Not visible</td><td>59</td></tr><tr><td>In transition</td><td>511</td></tr><tr><td>Posture</td><td></td></tr><tr><td>Standing</td><td>4623</td></tr><tr><td>Lying</td><td>964</td></tr><tr><td></td><td>lying in ventral recumbency (right)</td><td>332</td></tr><tr><td></td><td>lying in ventral recumbency (left)</td><td>547</td></tr><tr><td></td><td>lying in lateral recumbency (right)</td><td>0</td></tr><tr><td></td><td>lying in lateral recumbency (left)</td><td>85</td></tr><tr><td>Month</td><td></td></tr><tr><td>Not visible</td><td>21</td></tr><tr><td>June</td><td>491</td></tr><tr><td>July</td><td>1696</td></tr><tr><td>August</td><td>905</td></tr><tr><td>September</td><td>2516</td></tr></tbody></table>
Lying side was either left or right: “body resting on the ground with the left (respectively right) side in contact with the floor”.

Five trained and experienced observers performed the observations, with one observer following one cow (during the whole experiment a maximum of three cows were equipped with a light sensor simultaneously). Before starting the live observations, we first tested inter-and intra-observer reliability by observing pictures (n = 140). The set of pictures consisted of pictures of cattle either standing or lying (including 23 pictures with the cow lying on the left side and 27 with the cow lying on the right side) with 25 % of the pictures showing cows in the shade (n = 35), 25 % showing cows in the sun (n = 35), 25 % showing ambiguous situations (n = 35) and 25 % showing cloudy conditions (n = 35). Intra- and inter-observer reliability was assessed on based on categorical data using percent of agreement (PA) and Cohen's kappa (K) coefficient for shade, posture, and lying side. Cohen's kappa coefficient, which is widely used to measure intra/inter-rater reliability for categorical data, is the proportion of agreement after chance agreement is removed from consideration (Cohen, 1960). Percent of agreement is the number of observations for which the observers agreed divided by the total number of observations, multiplied by 100, where PA = 0 means no agreement and PA = 100 means perfect agreement; Parham et al., 2019). Both PA values and K coefficients were calculated using the “irr” package (Gamer et al., 2019) in R software version 4.2.2 (R Core Team, 2022). PA values were interpreted as acceptable if ≥ 75 % (Vieira et al., 2018). Kappa coefficients were interpreted as follows: 0.00–0.20 = poor, 0.21–0.40 = passable, 0.41–0.60 = moderate, 0.61–0.80 = substantial, 0.81–1.00 = almost perfect (Landis & Koch, 1977). Intra-observer reliability was acceptable for shade items (PA range 77.9 %–99.3 % and K range 0.70–0.99), postures (PA range 98.6 %–100 % and K range 0.97–1.0) and lying side (PA range 95.8 %–100 % and K range 0.91–0.96). For inter-observer reliability between pairs of observers for shade-use behaviors, PA ranged from 76.4 % to 95 % (mean = 84.8 %) and K ranged from 0.69 to 0.93 (mean = 0.80). For postures, PA was 100 % and K was 1.0 for all pairs of observers. For lying side, PA ranged from 94.0 % to 100 % (mean = 97.2 %) and K ranged from 0.88 to 1.0 (mean = 0.94) between pairs of observers. All observers were considered to demonstrate good intra- and inter-observer reliability and were therefore recruited to perform live observations for the rest of the study.

Live observations on the cows at pasture were performed opportunistically according to weather conditions, i.e. only on sunny days (to be able to distinguish tree shade). The exact time and duration of observations were dictated by the availabilities of the observers. Behavioral observations were conducted using BORIS software version 8.19.3 (Behavioral Observation Research Interactive Software; Friard and Gamba, 2016) running on smartphone or tablet. No more than three cows were equipped with a light sensor at any one time. All sensor-equipped cows were clearly marked with colored stripes to make them easy to find in the pasture. A total of approximatively 110 h of direct observations were carried out, breaking down as: for sun/shade, 62 h with cows observed in the sun, 33 h with cows observed in shade, 5.6 h with cows observed in ambiguous situations, and 5.6 h with cows observed in cloudy conditions; for posture, 89 h with cows observed standing, 10 h with cows lying in ventral recumbency, and 9.3 h with cows lying in lateral recumbency.

## 2.4. Data processing and analysis

### 2.4.1. Quantity and quality of data collected by the light sensor

A first aim of the study was to quantify data actually obtained compared to the quantity of data theoretically expected. The first step was to calculate the percentage of data loss due to sensor loss based on the number of days the sensor was actually on the cow in practice and the number of days the sensor was supposed to be on the cow in theory. The second step was to check the number of datapoints per day to determine the percentage of missing data. The third step was to visually check for potential time drift (based on known milking schedules and

sunset and sunrise hours). The final step was to check the data obtained were all in the possible range of the data in lx (i.e. range from 0 up to the 167731 lx limit of the sensor). The final percentage of usable data actually obtained was calculated as the number of full-day-record datapoints actually collected without time drift and within the possible range divided by the number of days the sensor was theoretical supposed to be on the cow, multiplied by 100.

### 2.4.2. Matching sensor data to behavior data

Continuous behavior data was matched to each light sensor datapoint. Shade items were only matched to a sensor datapoint if the behavior lasted for the full last minute, as the sensor datapoint is the average of 6 light measures over the previous 60 s. For example, as illustrated in Fig. 3, for the sensor datapoint at 17:20 (which is the average of the 6 measurements taken every 10 sec between 17:19 and 17:20), in the preceding minute the cow the spent 8 s in the shade (from 17:19:00 to 17:19:08) and 52 s in the sun (from 17:19:08 to 17:20:00), and so no shade item was assigned to this sensor datapoint which was considered as a transition between two shade-use behaviors (called “transition” datapoint). For the next steps of the study, we used only sensor datapoints associated with either cow in shade or cow in sun.

### 2.4.3. Performance of the shade–sun discrimination method

We used a threshold (in lx) to discriminate cows in shade from cows in sun. We divided the dataset into a training dataset, which was used to calibrate the threshold, and a test dataset, which was used to evaluate the performances of our shade–sun discrimination method (in terms of specificity and sensitivity). Sensitivity (Se) was calculated as the number of datapoints where cows were sensor-detected in shade (i.e. below the threshold) and observed in shade (based on live observations), i.e. true positives (TP) divided by the number of datapoints with cows observed in shade. Specificity (Sp) was calculated as the number of datapoints where cows were sensor-detected in sun (i.e. above the threshold) and observed in sun, i.e. true negatives (TN), divided by the number of datapoints with cows observed in sun. The whole process (from the random selection of the training dataset to the evaluation of performances) was repeated 100 times, resulting in 100 thresholds with their corresponding performances (both Se and Sp). To illustrate the robustness of our approach (in particular, the relatively short series of live observations needed for calibration), only a small part of our dataset (15 %) was used to build the training dataset: days were randomly selected until 15 % of the initial dataset was reached (maintaining the initial proportion of datapoints in shade and in sun, i.e. with 31 % of data points with cows observed in shade) to form the training dataset. The test dataset consisted of days that were not present in the training dataset, and so the test dataset had a different size. Using the ROCR package for R software (R Core Team, 2022) on the training dataset (Sing et al., 2005), we calculated the threshold that maximizes Youden's index (i.e. sensitivity + specificity – 1). As we did not want to favor detection of shade use over detection of sun exposure (or vice versa), we chose to use Youden's index because it equally maximizes both specificity (i.e. the ability to detect cows in sun) and sensitivity (i.e. the ability to detect cows in shade). We then determined the performances (Se and Sp) of the threshold by testing it on the test dataset. In order to investigate the possible effect of cow posture and solar altitude angle on performances, we calculated the false-negative rate (FNR) and false-positive rate (FPR) according to cow posture (either lying or standing) and 4 classes of solar altitude angle. The boundaries of the 4 solar altitude angle classes were determined based on the first, second and third quartiles of the solar altitude angle of the whole dataset. False-negative rate was calculated as 1 – Se and false-positive rate was calculated as 1 – Sp. All calculations were performed with R software version 4.2.2 (R Core Team, 2022).
<figure><img src="image_6.png" /><figcaption>**Fig. 3.** Illustration of sensor data (in lx) match-up to behavior data for an individual cow between 17:15 and 17:30. Background bands represent live observations: dark grey = cow observed in shade, white = cow observed in sun; light grey = no visibility on shade behavior. Letter points along the dots curve represent the shade-related cow behavior assigned to each 1-minute sensor datapoint, where N = non-visible shade behavior; S = in Shade; U = Under direct sun, T = in Transition.</figcaption></figure>

# 3. Results and discussion

## 3.1. Quantity and quality of data collected by the light sensor

The percentage of data loss due to sensor loss (in total, three sensors were lost over the course of the trial) was 8.8 % (Table 2). Among the total 217 cow-days theoretically obtained after removing sensor losses, there were 12 incomplete cow-days (days with less than 1440 datapoints or no datapoints at all). Visual inspection on graphics (curves of light intensity over the day) for potential time drifts (based on known milking schedules and sunset and sunrise times) revealed that of the 205-remaining cow-days, 5 clearly showed a time drift (5 consecutive days for the same cow) and were thus considered unusable. All the

datapoints in the remaining 200 cow-days ranged from 0 to 136000 lx which is within the possible range of the data in lx (i.e. range from 0 up to the 167731 lx limit of the sensor). The final percentage of usable data actually obtained was 84 %, which is satisfactory.

The main causes of data loss were sensor loss and sensor battery problems (all incomplete cow-days resulted from the sensor turn-off due to battery discharge preventing the sensor from recording any data). Sensor loss may occur due to the fact the sensor is glued onto the cow and so can easily come off, especially if the cow scratches the area where it is glued. If the sensor is glued to the transverse processes of the lumbar vertebrae, we recommend removing the sensor from the cow every two or three weeks, as done here, to minimize sensor losses.

<table><caption>**Table 2**

Quantity and quality of data obtained for each cow (data losses in grey).</caption><thead><tr><th></th><th colspan="8">Cow</th></tr><tr><th>Cow ID</th><th>9231</th><th>8001</th><th>8032</th><th>7600</th><th>8015</th><th>0203</th><th>0202</th><th>Total</th></tr></thead><tbody><tr><td>Number of cow-days theoretically expected</td><td>25</td><td>32</td><td>29</td><td>44</td><td>50</td><td>50</td><td>8</td><td>238</td></tr><tr><td>Number of cow-days after removing sensor loss</td><td>25</td><td>32</td><td>29</td><td>31</td><td>50</td><td>50</td><td>0</td><td>217</td></tr><tr><td>Percentage of data after removing sensor loss</td><td>100%</td><td>100%</td><td>100%</td><td>70.5%</td><td>100%</td><td>100%</td><td>0%</td><td>91.2%</td></tr><tr><td>Number of complete cow-days</td><td>24</td><td>32</td><td>29</td><td>31</td><td>50</td><td>39</td><td>0</td><td>205</td></tr><tr><td>Percentage of cow-days remaining after removing incomplete cow-days</td><td>96%</td><td>100%</td><td>100%</td><td>70.5%</td><td>100%</td><td>78%</td><td>0%</td><td>86.1%</td></tr><tr><td>Number of cow-days obtained without time drift</td><td>19</td><td>32</td><td>29</td><td>31</td><td>50</td><td>39</td><td>0</td><td>200</td></tr><tr><td>Percentage of cow-days obtained after removing days with time drift</td><td>76%</td><td>100%</td><td>100%</td><td>70.5%</td><td>100%</td><td>78%</td><td>0%</td><td>84.0%</td></tr></tbody></table>
## 3.2. Performance of the method

The 100 thresholds determined from the training datasets (15 % of the initial dataset) ranged from 15688 lx to 40556 lx, averaging 26416 lx (Table 3). On the testing set, within this threshold range, sensitivity varied from 92.0 % to 99.8 % and specificity varied from 88.7 % to 99.9 % (Table 3 and Fig. 4). Mean sensitivity was 98 % and mean specificity was 96 %. These performances are consistent with previous performances of the threshold found by Sánchez-Rodríguez and Domenech-Pérez (2021) to distinguish cows in sun from cows in artificial shade. Indeed, sensitivity for the solar radiation and shade exposure categories created with the threshold were 100 % and 99.4 % respectively (Sánchez-Rodríguez and Domenech-Pérez 2021). Our results showed that performances (both sensitivity and specificity) were robust to threshold variation from 15,688 to 40556. The best performances were achieved with thresholds between approximately 20,000 and 28000 lx, as both sensitivity and specificity remained above 95 % from 19476 lx to 27936 lx. Our results show that thresholds from 19476 lx to 27936 lx distinguish very well between cows in shade and cows in sun.

Table 4 presents the false-positive rate (FPR) and false-negative rate (FNR) stratified by posture (either lying or standing) and 4 classes of solar altitude angle (determined based on the first, second and third quartile of solar altitude angle in the whole dataset, i.e. class 1: ≥18.75° and < 37.10°; class 2: ≥ 37.10° and < 42.57°; class 3: ≥ 42.57° and < 49.19°, and class 4: ≥ 49.19°). Mean FPR was 13.3 % for cows lying down but 2.5 % for cows standing (Table 4). Mean FNR remained below 3 % regardless of cow posture. This result is easily explained by the fact that when cows are lying down the sensor may no longer be horizontal and pointing straight at the sky, resulting in a lower light intensity value. The orientation of cows lying in the sun may also put the sensor in the shade when it on the side facing away from the sun. The class-3 solar altitude angle had a higher FPR (11 %) than the other classes (<3 % for other classes; Table 4). The class-3 solar altitude angle also contained a larger proportion of datapoints with cows lying in the initial dataset (45 %) than the other classes (class 1 = 3 %; class 2 = 20 %, class 4 = 8 %). Therefore, the higher FPR in class 3 may be due to the higher FPR observed when cows were lying down. Interestingly, class 1, which encompassed observations at a low solar altitude angle (between 18.75° and 37.10°), had a low mean FPR and FNR (2.4 % and 1.2 %, respectively; Table 4). These results suggest that our method effectively detects shade use by cows at pasture even when the sun is relatively low, although it performs slightly less well when cows are lying down.

This study also showed that it is possible to determine an efficient threshold from relatively few datapoints. Here we used only 212 of the shade points and 476 sun points in the training datasets, corresponding to roughly 11.5 h of observation. For future studies, we recommend that the observation period should be carried out in the same conditions as the study planned to optimize the threshold (preferably using days with

<caption>**Table 3**</caption>

Description of the 100 training datasets and testing datasets, thresholds obtained and associated performances on the testing sets. The size of the training set is constant, but the testing dataset consisted of days that were not present in the training dataset, and so the testing dataset had different sizes.

<table><thead><tr><th></th><th>Mean</th><th>SD</th><th>Min</th><th>Max</th></tr></thead><tbody><tr><td>Number of cows in training datasets</td><td>5.2</td><td>0.91</td><td>3</td><td>6</td></tr><tr><td>Number of days in training datasets</td><td>5.2</td><td>1.24</td><td>3</td><td>9</td></tr><tr><td>Threshold (lx)</td><td>26,416</td><td>6123.3</td><td>15,688</td><td>40,556</td></tr><tr><td>Sensitivity (%)</td><td>98.0</td><td>0.02</td><td>92.0</td><td>99.8</td></tr><tr><td>Specificity (%)</td><td>96.0</td><td>0.03</td><td>88.7</td><td>99.9</td></tr><tr><td>Percentage of data in testing datasets</td><td>77.3</td><td>5.10</td><td>54.6</td><td>84.2</td></tr><tr><td>Number of shade points in training datasets</td><td>212</td><td></td><td></td><td></td></tr><tr><td>Number of sun points in training datasets</td><td>476</td><td></td><td></td><td></td></tr><tr><td>Number of shade points in testing datasets</td><td>1066</td><td>126.6</td><td>661</td><td>1198</td></tr><tr><td>Number of sun points in testing datasets</td><td>2475</td><td>217.5</td><td>1304</td><td>2689</td></tr></tbody></table>

variable weather, such as days with full sun and days with hazy sun). Indeed, the threshold can vary greatly depending on source of the shade (e.g. artificial shade vs. trees) and how efficiently it reduces light intensity. For example, Kotzen (2003) showed that over 8 tree species that, at its maximal intensity hour, the minimum lux intensity under the tree shade could range from 8000 lx to 25000 lx. In our study, the range of the threshold that gives a good split between shade vs. sun is quite wide (from about 15,700 to 40600 lx). This wide range is linked to the fact that the light intensity for shade vs. sun are naturally quite well split and so whatever threshold within the range will gives good results. Indeed, the mean (±SD) was 63,362 (±17893) lx for sun data points and 6702 (±5256) lx for shade data points. Moreover, the 5th and 95th percentile were 29013 lx and 91879 lx respectively for sun data points and, 2310 lx and 16444 lx respectively for shade data points (Fig. 5).

Nevertheless, our results showed that best performances were achieved within a narrowest range, with both sensitivity and specificity being over 95 % with a threshold ranging from 19476 lx to 27936 lx. We, thus, would advise to use a threshold within this range (in particular around 25000 lx which maximize both sensitivity and specificity), but of course this threshold should be used carefully as the optimal threshold could vary according to environmental conditions (e.g. source of shade). Using the same light sensor attached to cow collars and exposing the cows to artificial shade, Sánchez-Rodríguez and Domenech-Pérez (2021) found a threshold of 4624 lx to distinguish cows in shade from cows in the sun. This threshold is clearly lower than the 100 thresholds found here (which ranged from 15,688 to 40556 lx), and applying the threshold of 4624 lx to our data would have led to a significant number of misclassifications (many cows observed as in shade would have been classified as in sun, leading to low sensitivity). Similar to the calibration of every scientific sensor, it therefore appears necessary to optimize the threshold for each experimental condition. However, based on the fact that the possible range is wide, if one used a fixed threshold instead of calibrating one, we can assume that detection performances will still be good. One could make a list of thresholds depending on the type of shade source, the threshold would be different: from 4600 lx for a complete artificial shade (Sánchez-Rodríguez and Domenech-Pérez, 2021) to 25000 lx for shade provided by hedges and/or (grouped or isolated) trees directly in the pasture plot.

Here we chose to process the data in order to classify cows as either in the sun or in shade, whereas previous studies in cows have used this data in a different way to estimate the voluntary exposure to solar radiation. Contreras-Correa et al. (2024) calculated hourly averages of light intensity to compare voluntary solar radiation exposure between different breeds of cows in a paddock with natural shade. For example, the average light intensity at 10 am was 15467 lx for the Holstein cattle carrying a prolactin receptor gene mutation (SLICK) and 10057 lx for wild-type-haired Holsteins. The authors concluded that SLICK cows showed higher voluntary exposure to solar radiation that their wild-type counterparts. However, there are concerns around their analysis and interpretation of the data. The 5000 lx difference between the two groups of cows could also be attributed to a difference in solar permeability of the trees rather than exclusively to more time spent in the sun, making it hard to firmly conclude on greater voluntary solar radiation exposure based on comparative average hourly light intensity. We advise using a threshold to convert light intensity into behavioral data where the cow is either in shade or in sun depending on the lx value, as the time spent in shade can then be compared regardless of the solar permeability of the shade source.

## 3.3. Perspectives

This classification of a cow's behavior as either in the sun or in the shade only holds under sunny skies, so we first have to classify the period of interest as either sunny or cloudy. Weather-station data can make it easy to get this cloudiness information, but in most cases it will unfortunately not be available (no nearby weather station or no data
<figure><img src="image_7.png" /><figcaption>Fig. 4. Sensitivity (black dots) and specificity (grey dots) of the 100 thresholds plotted against threshold value in lx.</figcaption></figure>

**Table 4**

False-positive rate and false-negative rate stratified by posture (either lying or standing) and 4 classes of solar altitude angle (determined based on the first, second and third quartile of solar altitude angle in the total dataset, i.e. class 1: < 37.10°; class 2: ≥ 37.10° and < 42.57°; class 3: ≥ 42.57° and < 49.19°; class 4: ≥ 49.19°) for the 100 thresholds tested.

<table><thead><tr><th rowspan="2"></th><th colspan="4">False-positive rate</th><th colspan="4">False-negative rate</th></tr><tr><th>Mean</th><th>SD</th><th>Min</th><th>Max</th><th>Mean</th><th>SD</th><th>Min</th><th>Max</th></tr></thead><tbody><tr><td>Posture</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Lying</td><td>13.3</td><td>13.5</td><td>0.0</td><td>52.3</td><td>0.3</td><td>0.4</td><td>0.0</td><td>1.4</td></tr><tr><td>Standing</td><td>2.5</td><td>1.9</td><td>0.0</td><td>8.5</td><td>2.5</td><td>2.3</td><td>0.2</td><td>10.5</td></tr><tr><td>Class of solar altitude angle</td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr><tr><td>Class 1</td><td>2.4</td><td>3.7</td><td>0.0</td><td>17.2</td><td>1.2</td><td>1.5</td><td>0.0</td><td>6.2</td></tr><tr><td>Class 2</td><td>2.2</td><td>1.7</td><td>0.0</td><td>6.6</td><td>2.2</td><td>1.9</td><td>0.0</td><td>8.1</td></tr><tr><td>Class 3</td><td>11.0</td><td>7.7</td><td>0.3</td><td>30.2</td><td>3.7</td><td>2.8</td><td>0.0</td><td>13.4</td></tr><tr><td>Class 4</td><td>0.5</td><td>0.3</td><td>0.0</td><td>1.5</td><td>1.1</td><td>1.5</td><td>0.0</td><td>6.8</td></tr></tbody></table>

<figure><img src="image_8.png" /><figcaption>Fig. 5. Number of data points according to light intensity in Lux recorded by light sensor on cows (under shade in dark grey and under sun in light grey).</figcaption></figure>

available). Another solution is to add a light sensor in (or near) the pasture and place it in the sun (away from shade), thus making it possible to i) convert the light sensor data into solar radiation (e.g. Reis & Ribeiro, 2020) and then ii) estimate the diffuse fraction (Varlet-Grancher et al., 1989, 1993) which iii) can then be linked to the sky clearness index (Wong & Chow, 2001) that iv) can be used to form sunny/cloudy classes (e.g. Escobedo et al., 2009).

We anticipate our results as a promising starting point for automatic monitoring of natural shade use by cows at pasture. This method has a high scalability potential, with a short time required to install the sensor on the animal (a few minutes per cow), a relatively low cost (90 Euros per sensor) for research purposes, and the possibility to apply this method to as many cows as required simultaneously. For example, after the validation experiment described in this paper, we successfully applied this method to 40 grazing cows within a herd simultaneously for two periods of 15 days and on an experimental farm in northern France more than 500 km away. We have no doubt that this method could be used for even hundreds of cows. As an alternative to using a direct sensor to measure shade use, one could use existing location sensors (e.g. GPS) and combine the information with the LiDAR data used to predict shade location to predict shade use. This type of approach may be limited by the small number of farms using this type of technologies (at least in Europe), and the complexity of ground shade modelling for each tree present on the pasture plot (considering tree high, density, etc. and weather conditions, time of the day, sun position, etc.) to predict presence/absence of shade on pasture. Moreover, most GPS sensors won't be precise enough (in particular under trees). In addition, our approach is inherently adapted to most type of shading and grazing system, whereas GPS would have low accuracy on plots with high tree density.

As heat stress at pasture is also a major challenge for animal welfare and productivity in other species, the automatic recording of shade use by other species at pasture may also be of interest for research purposes. We also expect this method to be easy to apply to other species, such as sheep, goats, or swine, although it would appear necessary to first perform a feasibility study to find the best sensor location and attachment method to minimize sensor loss and measurement bias. The method presented here could also work with other light sensor models
and for automatic monitoring of animal use of artificial shade.

## 4. Conclusions

This study demonstrated that the use of natural shade by cows at pasture can be accurately monitored using a cow-mounted light sensor. A threshold for effectively discriminating cows in shade from cows in the sun can be determined via a relatively short (about 12 h) series of live observations. The 100 thresholds tested here ranged from 15688 lx to 40556 lx and showed very good performance (both sensitivity and specificity). We anticipate that this method can easily be applied to other species, such as sheep, goats, and even pigs and poultry.

## CRediT authorship contribution statement

**Lydiane Aubé:** Writing – review & editing, Writing – original draft, Visualization, Validation, Supervision, Project administration, Methodology, Investigation, Formal analysis, Data curation, Conceptualization.
**Bruno Meunier:** Writing – review & editing, Project administration, Investigation, Data curation, Conceptualization.
**Romain Lardy:** Writing – review & editing, Supervision, Resources, Project administration, Funding acquisition, Formal analysis, Conceptualization.

## Declaration of competing interest

The authors declare the following financial interests/personal relationships which may be considered as potential competing interests: AUBE Lydiane reports financial support was provided by French National Research Agency. LARDY Romain reports financial support was provided by French National Research Agency. MEUNIER Bruno reports financial support was provided by French National Research Agency. If there are other authors, they declare that they have no known competing financial interests or personal relationships that could have appeared to influence the work reported in this paper.

## Acknowledgements

The authors thank Dr. Véronique Deiss and Cécile Ginane for their valuable advice on using the sensors; Blanche Deloupy-Dobin, Quentin Delahaye, Christophe Mallet for their participation in the experiment and the live observations; the staff at the ‘Herbipôle’ experimental farm (doi: 10.15454/1.5572318050509348E12; UE 1414, Theix, France) for their help with animal care and handling; and Marc Saudreau (UMR PIAF) for his contribution to the idea of classifying days into as sunny/ cloudy classes using a light sensor.

We also thank Metaform Langues for proof-editing the manuscript. This study received financial support via the Agence Nationale de Recherche (ANR) under the France 2030 program under grant ANR-22-PEAE-0008 and French government IDEX-ISITE initiative 16-IDEX-0001 (CAP 20–25).

## Data availability

Data will be made available on request.

## References

* Becker, C.A., Collier, R.J., Stone, A.E., 2020. Invited review: Physiological and behavioral effects of heat stress in dairy cows. J. Dairy Sci. 103 (8), 6751–6770. https://doi.org/10.3168/jds.2019.17929.

* Cohen, J., 1960. A coefficient of agreement for nominal scales. Educ. Psychol. Meas. 20 (1), 37–46.

* Contreras-Correa, Z.E., Sánchez-Rodríguez, H.L., Arick, M.A., Muñiz-Colón, G., Lemley, C.O., 2024. Thermotolerance capabilities, blood metabolomics and mammary gland hemodynamics and transcriptomic profiles of slick-haired Holstein cattle during mid-lactation in Puerto Rico. J. Dairy Sci. https://doi.org/10.3168/jds.2023-23878.

* Deniz, M., de Sousa, K.T., Moro, M.F., Vale, M.M. do, Dittrich, J.R., Machado Filho, L.C. P., Hötzel, M.J., 2021. Social hierarchy influences dairy cows’ use of shade in a silvopastoral system under intensive rotational grazing. Appl. Anim. Behav. Sci. 244, 105467. https://doi.org/10.1016/j.applanim.2021.105467.

* Deniz, M., De-Sousa, K.T., Vieira, F.M.C., Vale, M.M. do, Dittrich, J.R., Daros, R.R., Hötzel, M.J., 2023. A systematic review of the effects of silvopastoral system on thermal environment and dairy cows’ behavioral and physiological responses. Int. J. Biometeorol. 67 (3), 409–422. https://doi.org/10.1007/s00484-023-02431-5.

* De-Sousa, K.T., Deniz, M., Dittrich, J.R., Hötzel, M.J., 2023. Effects of tree arrangements of silvopasture system on behaviour and performance of cattle – a systematic review. Ann. Anim. Sci. 23 (3), 629–639.

* Escobedo, J.F., Gomes, E.N., Oliveira, A.P., Soares, J., 2009. Modeling hourly and daily fractions of UV, PAR and NIR to global solar radiation under various sky conditions at Botucatu, Brazil. Appl. Energy 86 (3), 299–309. https://doi.org/10.1016/j.apenergy.2008.04.013.

* Friard, O., Gamba, M., 2016. BORIS: a free, versatile open-source event-logging software for video/audio coding and live observations. Methods Ecol. Evol. 7 (11), 1325–1330. https://doi.org/10.1111/2041-210X.12584.

* Galan, E., Llonch, P., Villagra, A., Levit, H., Pinto, S., del Prado, A., 2018. A systematic review of non-productivity-related animal-based indicators of heat stress resilience in dairy cattle. PLoS One 13 (11).

* Gamer, M., Lemon, J., & Singh, I. F. P. (2019). *irr: Various Coefficients of Interrater Reliability and Agreement*. R package version 0.84.1. (Version 0.84.1) [Logiciel]. https://CRAN.R-project.org/package=irr.

* Haley, D.B., de Passillé, A.M., Rushen, J., 2001. Assessing cow comfort: effects of two floor types and two tie stall designs on the behaviour of lactating dairy cows. Appl. Anim. Behav. Sci. 71 (2), 105–117. https://doi.org/10.1016/S0168-1591(00)00175-1.

* Hunter, L.B., O'Connor, C., Haskell, M.J., Langford, F.M., Webster, J.R., Stafford, K.J., 2021. Lying posture does not accurately indicate sleep stage in dairy cows. Appl. Anim. Behav. Sci. 242, 105427. https://doi.org/10.1016/j.applanim.2021.105427.

* Kotzen, B., 2003. An investigation of shade under six different tree species of the Negev desert towards their potential use for enhancing micro-climatic conditions in landscape architectural development. J. Arid Environ. 55 (2), 231–274. https://doi.org/10.1016/S0140-1963(03)00030-2.

* Lees, J.C., Lees, A.M., Gaughan, J.B., 2022. The influence of shade availability on the effectiveness of the dairy heat load index (DHLI) to predict lactating cow behavior, physiology, and production traits. Int. J. Biometeorol. 66 (2), 289–299. https://doi.org/10.1007/s00484-021-02186-x.

* Oliveira, S.E.O., de Melo Costa, C.C., Chiquetelli Neto, M., Dalla Costa, F.A., Maia, A.S.C., 2019. Effects of shade location and protection from direct solar radiation on the behavior of Holstein cows. Int. J. Biometeorol. https://doi.org/10.1007/s00484-019-01747-5.

* Parham, J.T., Tanner, A.E., Wahlberg, M.L., Grandin, T., Lewis, R.M., 2019. Subjective methods to quantify temperament in beef cattle are insensitive to the number and biases of observers. Appl. Anim. Behav. Sci. 212, 30–35. https://doi.org/10.1016/j.applanim.2019.01.005.

* Polsky, L., von Keyserlingk, M.A.G., 2017. Invited review: effects of heat stress on dairy cattle welfare. J. Dairy Sci. 100 (11), 8645–8657. https://doi.org/10.3168/jds.2017-12651.

* R Core Team, 2022. *R: A language and environment for statistical computing* (Version R Foundation for Statistical Computing, Vienna, Austria. URL https://www.R-project.org/) [Logiciel]. https://cir.nii.ac.jp/crid/1370294721063650048.

* dos Reis, M.G., Ribeiro, A., 2020. Conversion factors and general equations applied in agricultural and forest meteorology. Article 2 Agrometeoros 27 (2). https://doi.org/10.31062/agrom.v27i2.26527.

* Sánchez-Rodríguez, H.L., Domenech-Pérez, K., 2021. Light sensors assess solar radiation vs. Shade exposure of slick-and wild-type Puerto Rican Holstein cows. J Agric Univ PR 105 (1), 39–48.

* Schütz, K.E., Cox, N.R., Matthews, L.R., 2008. How important is shade to dairy cattle? Choice between shade or lying following different levels of lying deprivation. Appl. Anim. Behav. Sci. 114 (3–4), 307–318.

* Schütz, K.E., Cox, N.R., Tucker, C.B., 2014. A field study of the behavioral and physiological effects of varying amounts of shade for lactating cows at pasture. J. Dairy Sci. 97 (6), 3599–3605. https://doi.org/10.3168/jds.2013-7649.

* Sing, T., Sander, O., Beerenwinkel, N., Lengauer, T., 2005. ROCR: visualizing classifier performance in R. Bioinformatics 21 (20), 3940–3941. https://ipa-tys.github.io/ROCR/.

* Tucker, C.B., Rogers, A.R., Schütz, K.E., 2008. Effect of solar radiation on dairy cattle behaviour, use of shade and body temperature in a pasture-based system. Appl. Anim. Behav. Sci. 109 (2), 141–154. https://doi.org/10.1016/j.applanim.2007.03.015.

* Van Laer, E., Tuyttens, F.A.M., Ampe, B., Sonck, B., Moons, C.P.H., Vandaele, L., 2015. Effect of summer conditions and shade on the production and metabolism of Holstein dairy cows on pasture in temperate climate. Animal: an Int. J. Animal Biosci. 9 (9), 1547–1558. https://doi.org/10.1017/S1751731115000816.

* Varlet-Grancher, C., Bonhomme, R., Sinoquet, H., 1993. Crop structure and light microclimate: Characterization and applications. https://www.cabidigitallibrary.org/doi/full/10.5555/19930765692.
Varlet-Grancher, C., Gosse, G., Chartier, M., Sinoquet, H., Bonhomme, R., Allirand, J.M., 1989. Mise au point : Rayonnement solaire absorbé ou intercepté par un couvert végétal. Agronomie 9 (5), 419-439. https://doi.org/10.1051/agro:19890501.

Vieira, A., Battini, M., Can, E., Mattiello, S., Stilwell, G., 2018. Inter-observer reliability of animal-based welfare indicators included in the Animal Welfare Indicators welfare

assessment protocol for dairy goats. Animal 12 (9), 1942–1949. https://doi.org/
10.1017/S1751731117003597.

Wong, L.T., Chow, W.K., 2001. Solar radiation model. Appl. Energy 69 (3), 191–224.
https://doi.org/10.1016/S0306-2619(01)00012-5.