It turns out it's not just gratitude that makes rain smell so appealing after a long period of dry weather.

There's actually some chemistry involved too.

Bacteria, plants and even lightning can all play a role in the pleasant smell we experience after a thunderstorm; that of clean air and wet earth.

Known as petrichor, the scent has long been chased by scientists and even perfumers for its enduring appeal.

Wet earth
First named by two Australian researchers in the 1960s, the warm, earthy fragrance we experience when rain hits dry ground is produced by bacteria.

"These critters are abundant in soil," explained Prof Mark Buttner, head of molecular microbiology at the John Innes Centre.

"So when you're saying you smell damp soil, actually what you're smelling is a molecule being made by a certain type of bacteria," he told the BBC.

That molecule, geosmin, is produced by Streptomyces. Present in most healthy soils, these bacteria are also used to create commercial antibiotics.

Drops of water hitting the ground cause geosmin to be released into the air, making it much more abundant after a rain shower.

"Lots of animals are sensitive but human beings are extremely sensitive to it," added Prof Buttner.

Isabel Bear and RG Thomas, the researchers who first named the scent petrichor, found that as early as the 1960s it was being captured to sell as a scent called "matti ka attar" in Uttar Pradesh, India.

Now, geosmin is becoming more common as a perfume ingredient.

"It's a really potent material and it smells just like the concrete when the rain hits it," said perfumer Marina Barcenilla. "There's something very primitive and very primal about the smell."

"Even when you dilute it down to the parts per billion range, [humans] can still detect it," she added.

Yet we also have an odd relationship with geosmin - while we are drawn to its scent, many of us dislike its taste.

Even though it is not toxic to humans, the tiniest amount can put people off mineral water or wine when it is present.

"We do not know why we dislike geosmin," commented Prof Jeppe Lund Nielsen from Aalborg University in Denmark.

"It is not toxic to humans in typical found ranges, but somehow we associate it with something negative," he added.

Plants
According to Prof Nielsen, research also indicates that geosmin could be related to terpenes - the source of scent in many plants.

Rain could bring these fragrances out, says Prof Philip Stevenson, a research leader at Royal Botanic Gardens, Kew.

"Often the plant chemicals that smell pleasant are produced in leaf hairs... and the rain may damage these, releasing the compounds.

"Rain may also break dry plant material releasing chemicals in a similar way to when you crush dried herbs - the smell becomes stronger," he told the BBC.

Very dry periods may also slow down plant metabolism, with renewed rainfall giving it a kick start and causing plants to release a pleasant scent.

Lightning bolts
Thunderstorms have their role to play too, creating the clean, sharp scent of ozone - caused by lightning and other electrical discharges in the atmosphere.

Prof Maribeth Stolzenburg of the University of Mississippi explains: "Besides the lightning, the thunderstorm and especially the rain will improve the air quality. Much of the dust, aerosols, and other particulates are rained out and the air clears."