Throughout the year, California’s Central Valley and the Bay Area play tug of war with air. As temperatures change seasonally, air flows from a high pressure system along the coast to a low pressure one beyond the coastal mountain range, and (much less frequently) back again.
In the spring, a mass of cold air, known as the Pacific High, makes its way south from the Gulf of Alaska, following the Pacific coast, gathering moisture and heating up while it goes. As the system swings southwest into open ocean, it drags surface water with it and causes deeper, colder water to upwell near the shoreline. Already-moist air passing over the upwelling water chills, condenses into countless droplets of water to form fog along the shore. This fog is pulled inland by the differential between the Pacific High and the inland low pressure system. On its way, the fog penetrates the sinuous dips and rises of the Bay Area. The variable local topography of the region causes uneven distribution of the fog’s effects, so your house may be lost in fog while, around the bend, your office basks in sunlight.
On days when San Francisco is mild and cool, but the Central Valley is searing hot, an inversion of air occurs, in which a warm layer tops a cool one. By early afternoon, the inversion can be strong and noted by the rolling of fog inland as the low pressure system sucks air through the biggest break in the Coast Range: the Golden Gate. As the in-rushing coastal air cools the valley, however, temperatures between the two regions begin to stabilize and the tug eastward diminishes. The fog recedes, temporarily, but in just a few days, the heat rebuilds and the process begins anew.