The drought that recently ravaged California for six years crushed salmon runs, torched hundreds of houses, and sent lawn-care professionals into a deep depression. It was the worst droughts in hundreds of years, and by the time it was finished in 2017, it had killed some 150 million trees in the Sierra Nevada Mountains. Many groves lost nearly all of their mature pine trees, turning green forests brown across swathes of the state.

But they didn’t die everywhere. Scientists studied one spot where nearly 80 percent of trees died, and another where just 2 percent did. A new study, just published in Nature Geoscience, reveals an elegant formula to explain why some trees died and others didn’t — and it suggests more suffering is in store for forests as the climate heats up.

This matters because California’s ambitious plan to slash its greenhouse gas emissions relies on trees soaking up a lot of carbon. But many scientists now think that all the dead and burning trees have turned California’s forests from a carbon sink to a carbon source.

There were a lot of problems ganging up on the forests in the last decade. But this study by Michael Goulden at the University of California at Irvine, and Roger Bales at the University of California at Merced, one thing driving it all: How much water came into the forest and how much water evaporated out.

Grist thanks its sponsors. Become one.

“Where there was less precipitation than the trees’ demand for water, that’s where trees died,” Bales said.

Because trees need more water when it’s hot, the scientists estimate that tree deaths will increase 15 to 20 percent in the Sierra Nevada Mountains for every increase of 1 degree Celsius.

So why didn’t California didn’t have a similar die-off of trees during the last major drought, which started in 1987?

“The difference with this drought is that it was hotter,” Bales said. “The drought in the late ‘80s was longer, but it wasn’t so hot.”

Grist thanks its sponsors. Become one.

The number and density of trees also stoked the competition for water. Each tree wound up fighting with the others for the last drops.

“There’s just too many stems in the ground sucking up water because of the fire suppression of the last century,” Bales said.

And in places where trees had exhausted their water supply, they were particularly vulnerable to bark beetles.

California’s climate and forest officials are now trying to figure out what to do with all the dead trees — tinder for wildfires. This research suggests that we could prevent future forest massacres by allowing fires or humans to thin vulnerable areas. We could also, you know, try to stop heating up the place.