If you’ve spent your life in California, you’ve heard it dozens of times: A friend or family member bemoans a cloudy summer beach day or picnic, blaming “June gloom” or “May gray” for blotting out the sun.

You may have even heard “no-sky-July” or “Fogust,” because the gray skies persist into late summer in some parts of the state. And, apparently, we really love our cute names for weather phenomena.

Why do low clouds and fog hang around amid otherwise beautiful weather, making for these dreary summer days at the coast? The answer is a combination of high pressure, ocean winds and the temperature difference between the water and land, according to the National Weather Service.

Chilly water, meet warm air

Alex Tardy, a meteorologist at the weather agency’s office in San Diego, says May gray is a more dramatic expression of something we see year-round: the marine layer. The marine layer is a shallow slice of cool air just above the water, which often (but not always) helps form fog or clouds.

California’s cold water, which mostly flows south from frigid Alaska, contributes to the formation of that marine layer.

The colder the water, the colder the air that comes into contact with it at the surface, Tardy explains. Off the coast of California, the water is cold enough to create a “temperature inversion,” where the air actually gets warmer at higher altitudes, rather than cooler the higher you go.

The cool air near the surface of our chilly ocean eventually bumps into the warmer air overhead, which forms a “lid” of sorts that keeps the marine layer in place. Moisture in the cold air forms clouds or fog.

In Southern California, the marine layer becomes most noticeable in May and June (forming “gray” and “gloom”) as temperatures rise on land much more quickly than they do in the water, Tardy said. The ocean water doesn’t reach its peak temperature in the region until late summer or even early fall, even as the air overhead heats up much sooner.

That magnified temperature difference helps explain the stronger, more persistent marine layer gloom in late spring and summer. As summer goes on and lagging ocean temperatures finally catch up to the warmer air, the temperature inversion becomes less pronounced — as do the coastal fog and clouds.

(Graphic courtesy National Weather Service)

Large-scale weather patterns

That might be enough amateur meteorology for your day, but other factors influence the character of your “gloom” and “gray,” too.

Coastal winds, for example, helped drive record cold water temperatures in San Diego this May — feeding that crucial temperature inversion in turn. Strong onshore winds repeatedly pushed aside the upper layer of the ocean, replacing relatively warm surface water with chillier water that rises from the depths.

Forecasters call this swap of warm for cold “upwelling,” and it contributes to cloudy, foggy marine layers by helping keep the air immediately above the ocean so chilly.

The depth of the marine layer, and how far inland it extends, is influenced by other large-scale weather patterns that pass overhead.

Sinking air, under high pressure systems, can “squash” the marine layer and keep it confined to the immediate coast. That means it will stay warm and sunny just about anywhere but the beach.

A weakening of that downward pressure allows the “gray” and “gloom” to move further inland, making it more noticeable even if you live miles from the ocean.

It’s a lot to keep track of, but the National Weather Service has a handy chart explaining the changes, and how they influence temperatures even in inland communities.