docs: def main():
      """
      Update the ossuary Postgres db with images observed for OSSOS.
      iq: Go through and check all ossuary's images for new existence of IQs/zeropoints.
      comment: Go through all ossuary and
      Then updates ossuary with new images that are at any stage of processing.
      Constructs full image entries, including header and info in the vtags, and inserts to ossuary.
  
      TODO: a CLUSTER after data is inserted - maybe once a week, depending how much there is
      CLUSTER images;   need to sqlalchemy this one
      """
      parser = argparse.ArgumentParser()
  
      parser.add_argument("-iq", "--iq", action="store_true",
                          help="Check existing images in ossuary that do not yet have "
                               "IQ/zeropoint information; update where possible.")
      parser.add_argument("-comment", action="store_true",
                          help="Add comments on images provided by S. Gwyn to database.")
      parser.add_argument("-snr", action="store_true",
                          help="Update existing images in ossuary for SNR info where that exists in a vtag.")
      args = parser.parse_args()
  
      images = web.field_obs.queries.ImagesQuery()
      processed_images, iqs = retrieve_processed_images(images)  # straight list of primary keys
      commdict = parse_sgwn_comments()
  
      if args.iq:
          unmeasured_iqs = iq_unmeasured_images(images)
          sys.stdout.write('%d images in ossuary; updating %d with new IQ/zeropoint information.\n' %
                           (len(processed_images), len(unmeasured_iqs)))
          for n, image in enumerate(unmeasured_iqs):  # it's in the db, so has already passed the other checks
              update_values(images, image)
              sys.stdout.write('%s %d/%d...ossuary updated.\n' % (image, n + 1, len(unmeasured_iqs)))
  
      if args.snr:
          unmeasured = snr_unmeasured_images(images)
          sys.stdout.write('%d images in ossuary; updating %d with new SNR information.\n' %
                           (len(processed_images), len(unmeasured)))
          for n, image in enumerate(unmeasured):  # it's in the db, so has already passed the other checks
              update_values(images, image, iq_zeropt=False, snr=True)
              sys.stdout.write('%s %d/%d...ossuary updated.\n' % (image, n + 1, len(unmeasured)))
  
      if args.comment:
          sys.stdout.write('%d images in ossuary; updating with new comment information.\n' %
                           len(processed_images))
          for image in commdict.keys():
              if int(image) in processed_images:
                  update_values(images, image, iq_zeropt=False, comment=True, commdict=commdict)
                  sys.stdout.write('%s has comment...\n' % image)
  
      unprocessed_images = parse_unprocessed_images(storage.list_dbimages(), processed_images)
      sys.stdout.write('%d images in ossuary; updating with %d new in VOspace.\n' %
                       (len(processed_images), len(unprocessed_images)))
  
      for n, image in enumerate(unprocessed_images):
          sys.stdout.write('%s %d/%d ' % (image, n + 1, len(unprocessed_images)))
          try:
              subheader, fullheader = get_header(image)
              if subheader is not None:
                  sys.stdout.write('Header obtained. ')
                  verify_ossos_image(fullheader)
                  header = get_iq_and_zeropoint(image, subheader)
                  header = get_snr(image, header)
                  if image in commdict.keys():
                      header['comment'] = commdict[image]
                  put_image_in_database(header, images)
                  sys.stdout.write('...added to ossuary...\n')
                  # generate_MegaCam_previews(image)
                  # sys.stdout.write(' .gif preview saved.\n')
              else:
                  sys.stdout.write('Header is not available: skipping.\n')
          except Exception, e:
              sys.stdout.write('... %s\n' % e)