I always buy whole spices (with the exception of turmeric) and grind only what I need for a recipe because spices begin to deteriorate the instant they’re ground. The most fragrant spices come from stores with a high rate of turnover. Many grocery stores have a good selection of spices, and if you live near an Indian or Middle Eastern market, check out its spice section, which may have more variety. You can also order online. Air, light, and heat are the enemies of spices, so keep them in airtight containers in a drawer or cupboard, but never over the stove.
Grinding releases a spice’s flavorful aromatic oils. A coarser grind adds textural interest and a mosaic of flavors to a dish. (But not all spices should be left coarse: cinnamon, clove, mace, nutmeg, and green and black cardamom are so strongly flavored that biting into a big piece is not pleasant.) Finer grinds tend to be more subtle, with the flavors more evenly blended.
A small electric coffee grinder lets you grind a few tablespoons of spice at a time. If you use a mortar and pestle, grind in a circular motion and hold a piece of plastic wrap over the bowl while you grind to keep the spices from sneaking out.