docs: def recompute_mag(mpc_in, skip_centroids=False):
      """
      Get the mag of the object given the mp_ephem.ephem.Observation
      """
      # TODO this really shouldn't need to build a 'reading' to get the cutout...
  
      from ossos.downloads.cutouts import downloader
      dlm = downloader.ImageCutoutDownloader()
  
      mpc_obs = deepcopy(mpc_in)
      assert isinstance(mpc_obs, mp_ephem.ephem.Observation)
      assert isinstance(mpc_obs.comment, mp_ephem.ephem.OSSOSComment)
  
      if mpc_obs.null_observation:
          return mpc_obs
  
      parts = re.search('(?P<expnum>\d{7})(?P<type>\S)(?P<ccd>\d\d)', mpc_obs.comment.frame)
      if parts is None:
          return mpc_obs
      expnum = parts.group('expnum')
      ccd = parts.group('ccd')
      file_type = parts.group('type')
  
      observation = astrom.Observation(expnum, file_type, ccd)
      assert isinstance(observation, astrom.Observation)
  
      ast_header = _connection_error_wrapper(storage._get_sghead, int(expnum))[int(ccd)+1]
  
      filter_value = None
      for keyword in ['FILTER', 'FILT1 NAME']:
         filter_value = ast_header.get(keyword, None)
         if filter_value is not None:
           if filter_value.startswith('gri'):
               filter_value = 'w'
           else:
               filter_value = filter_value[0]
           break
      # The ZP for the current astrometric lines is the pipeline one.  The new ZP is in the astheader file.
      new_zp = ast_header.get('PHOTZP')
  
      # The .zeropoint.used value is likely the one used for the original photometry.
      old_zp = _connection_error_wrapper(storage.get_zeropoint, int(expnum), int(ccd))
  
      reading = astrom.SourceReading(float(mpc_obs.comment.x), float(mpc_obs.comment.y), float(mpc_obs.comment.x),
                                     float(mpc_obs.comment.y), mpc_obs.coordinate.ra.degree,
                                     mpc_obs.coordinate.dec.degree, float(mpc_obs.comment.x), float(mpc_obs.comment.y),
                                     observation, ssos=True, from_input_file=True, null_observation=False,
                                     discovery=mpc_obs.discovery)
  
      cutout = _connection_error_wrapper(dlm.download_cutout, reading, needs_apcor=True)
      cutout._zmag = new_zp
  
      if math.fabs(cutout.zmag - old_zp) > 0.3:
          logging.warn("Large change in zeropoint detected: {}  -> {}".format(old_zp, cutout.zmag))
  
      try:
          PHOT = cutout.get_observed_magnitude(centroid=not skip_centroids and mpc_obs.note1 != "H")
          x = PHOT['XCENTER']
          y = PHOT['YCENTER']
          mag = PHOT['MAG']
          merr = PHOT['MERR']
          cutout.update_pixel_location((x, y), hdu_index=cutout.extno)
          x, y = cutout.observed_source_point
      except Exception as ex:
          logging.error("ERROR: {}".format(str(ex)))
          return mpc_obs
  
      try:
          if mpc_obs.comment.mag_uncertainty is not None and mpc_obs.comment.mag is not None and math.fabs(mpc_obs.comment.mag - mag) > 3.5 * mpc_obs.comment.mag_uncertainty:
             logging.warn("recomputed magnitude shift large: {} --> {}".format(mpc_obs.mag, mag[0]))
          if math.sqrt((x.value - mpc_obs.comment.x) ** 2 + (y.value - mpc_obs.comment.y) ** 2) > 1.9:
              logging.warn("Centroid shifted ({},{}) -> ({},{})".format(mpc_obs.comment.x,
                                                                        mpc_obs.comment.y,
                                                                        x.value,
                                                                        y.value))
      except Exception as ex:
          logging.error(str(ex))
  
      # Don't use the new X/Y for Hand measured entries.  (although call to get_observed_magnitude should have changed)
      if str(mpc_obs.note1) != "H" and not skip_centroids:
          mpc_obs.comment.x = x.value
          mpc_obs.comment.y = y.value
  
      try:
          mag = float(mag)
      except:
          return mpc_obs
  
      if math.isnan(mag):
          return mpc_obs
  
      if mag > 10:
          mpc_obs._band = filter_value
          mpc_obs.comment.mag = mag
          mpc_obs.comment.mag_uncertainty = merr
  
      # Update the mpc record magnitude if previous value existed here.
      if (mpc_obs.mag is not None or (mpc_obs.mag is None and mpc_in.comment.photometry_note[0] == "Z")) and mag > 10:
          mpc_obs.mag = mag
  
      return mpc_obs