The record of the weather is written in the leaves.

While you may not remember the details of the weather over the past few months, the trees do, and the color they are splashing in forests across the Northeast and Midwest is proof.

The more spectacular a display of fall foliage colors, the more likely the preceding few weeks were made up of warm sunny days and cool crisp nights, according to the website of the Northeastern area Forest Service, a division of the U.S. Department of Agriculture. Rainfall also plays a role.

“It’s really what happens in late July to late September that sets the stage,” said Michael Schlacter, a meteorologist at Weather 2000 Inc. in New York. “This is one of the most ideal two-month seasons you could have had; it has pretty much clinched the season.”

There are three compounds that go into the recipe for determining leaf color, according to the Forest Service, based in Newtown Square, Pennsylvania.

Chlorophyll, necessary for photosynthesis — the process plants use to turn sunlight into sugar — provides the green. Carotenoids also give carrots and buttercups their yellow and orange colors, and anthocyanins bring out the reds in apples and purples in plums.

While carotenoids are always present, they just don’t get their chance to shine until the nights grow longer and the plants stop producing chlorophyll, thus giving some leaves their orange glow.

It’s the red leaves, though, that are really telling the story about the weather. That’s because anthocyanins need the bright days to spur the plant to produce a lot of sugar, and the cold nights to keep sugar from getting out of the leaf.

Schlacter said a good spread between daily high and low temperatures can almost ensure the reds will pop.

“It just so happens that those ideal conditions are kind of traced right along where people go — a nice broad strip from lower Ohio into West Virginia and Virginia and then all the way up the Appalachians,” Schlacter said by telephone.

For instance, Burlington, Vermont, and Watertown, New York, had a spread of at least 20 degrees Fahrenheit (11 Celsius) between high and low temperatures for more than half the days in September, according to the National Weather Service.

Storms also affect foliage season, although not the color of the leaves, said Tom Kines, a meteorologist at AccuWeather in State College, Pennsylvania.

“The wind and heavy rain are the No. 1 culprit for destroying the leaf-viewing season,” Kines said. “And so far, we have avoided them.”

The economies of states like Vermont depend heavily on visits from leaf-peepers, as foliage tourists are known. An estimated 48 percent of the $1.9 billion spent in Vermont on “forest-based recreational activities” came from foliage viewing, according to a 2013 report by the North East State Foresters Association, based in Concord, New Hampshire.

The organization, which also represents Maine, New Hampshire and New York, said looking at leaves accounted for 47 percent of the $1.4 billion spent in New Hampshire.

So the next time you see a mountain decked out in brilliant red leaves, you’ll know the weather conditions that helped create it. If you look close enough, you may also see a little green in there, too — it may be the pine trees, which don’t change color, or it may be all the money those leaves are generating.