Get the mag of the object given the mp_ephem.ephem.Observation
769664
def recompute_mag(mpc_in, skip_centroids=False):
    
    # 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
816579
def _inspect(self,obj,objtype=None):
        """"""
        gen=super(Dynamic,self).__get__(obj,objtype)

        if hasattr(gen,'_Dynamic_last'):
            return gen._Dynamic_last
        else:
            return gen
1210455
def prj_view_dep(self, *args, **kwargs):
        
        if not self.cur_prj:
            return
        i = self.prj_dep_tablev.currentIndex()
        item = i.internalPointer()
        if item:
            dep = item.internal_data()
            self.view_dep(dep)
431325
def get_detector(self, id, **kwargs):
        "
        resp = self._get_object_by_name(self._DETECTOR_ENDPOINT_SUFFIX, id,
                                        **kwargs)
        return resp
288189
def property_observer(self, name):
        """"""
        def wrapper(fun):
            self.observe_property(name, fun)
            fun.unobserve_mpv_properties = lambda: self.unobserve_property(name, fun)
            return fun
        return wrapper
1136276
def known(self, object):
        
        try:
            md = object.__metadata__
            known = md.sxtype
            return known
        except:
            pass
563807
def get_recipe_object(self, mode):
        """"""

        if isinstance(mode, ObservingMode):
            key_mode = mode.key
        elif isinstance(mode, str):
            key_mode = mode
        else:
            key_mode = mode

        recipe_entry = self.recipes[key_mode]
        recipe = self._get_base_object(recipe_entry)

        # Init additional members
        recipe.mode = mode
        recipe.instrument = self.instrument

        return recipe
157731
def expected_mag(RAW_IMU, ATTITUDE, inclination, declination):
    ''''''
    m_body = Vector3(RAW_IMU.xmag, RAW_IMU.ymag, RAW_IMU.zmag)
    field_strength = m_body.length()

    m = rotation(ATTITUDE)

    r = Matrix3()
    r.from_euler(0, -radians(inclination), radians(declination))
    m_earth = r * Vector3(field_strength, 0, 0)

    return m.transposed() * m_earth
811343
function () {
                var info = getValueAndObserved(getterSetter, context),
                    newObserveSet = info.observed;

                var value = info.value;
                matched = !matched;

                // go through every attribute read by this observe
                can.each(newObserveSet, function (ob) {
                    // if the observe/attribute pair is being observed
                    if (observing[ob.obj._cid + "|" + ob.attr]) {
                        // mark at as observed
                        observing[ob.obj._cid + "|" + ob.attr].matched = matched;
                    } else {
                        // otherwise, set the observe/attribute on oldObserved, marking it as being observed
                        observing[ob.obj._cid + "|" + ob.attr] = {
                            matched: matched,
                            observe: ob
                        };
                        ob.obj.bind(ob.attr, onchanged);
                    }
                });

                // Iterate through oldObserved, looking for observe/attributes
                // that are no longer being bound and unbind them
                for (var name in observing) {
                    var ob = observing[name];
                    if (ob.matched !== matched) {
                        ob.observe.obj.unbind(ob.observe.attr, onchanged);
                        delete observing[name];
                    }
                }
                return value;
            }
803605
def get_object_metadata(self, container, obj, prefix=None):
        
        return self._manager.get_object_metadata(container, obj, prefix=prefix)
884325
def inspect_current_object(self):
        """"""
        editor = self.get_current_editor()
        editor.sig_display_signature.connect(self.display_signature_help)
        line, col = editor.get_cursor_line_column()
        editor.request_hover(line, col)
1225913
def get_objects(self):
        """"""
        return rope.base.oi.soi.get_passed_objects(
            self.pyfunction, self.index)
1186279
function getMeta(object) {
  assertObject(object);

  let data = {};
  if (hasOwnSymbol(object, metaSymbol)) {
    Object.assign(data, object[metaSymbol] || {});
  }
  Object.assign(data, metadata.get(object) || {});

  if (data['~inheritsMeta']) {
    return Object.assign({}, getMeta(data['~inheritsMeta']()), data);
  } else {
    return data;
  }
}
541811
def readObject(self):
        
        obj = pyamf.ASObject()
        self.context.addObject(obj)

        obj.update(self.readObjectAttributes(obj))

        return obj
1086344
public static Object getObjectElem(Object obj, Object elem, Context cx, Scriptable scope)
    {
        Scriptable sobj = toObjectOrNull(cx, obj, scope);
        if (sobj == null) {
            throw undefReadError(obj, elem);
        }
        return getObjectElem(sobj, elem, cx);
    }
734161
def orb(self):
        
        for (mag, orb) in FixedStar._ORBS:
            if self.mag < mag:
                return orb
        return 0.5
883043
def get_object(self):
        
        obj = super(PublishActionView, self).get_object()

        if obj:
            if not hasattr(obj, 'publish'):
                raise http.Http404

        return obj