def pixtoradec(self, x, y, format='deg', coords='data'): args = [x, y] + self.revnaxis ra_deg, dec_deg = self.wcs.pixtoradec(args, coords=coords) if format == 'deg': return ra_deg, dec_deg return wcs.deg2fmt(ra_deg, dec_deg, format)
def pixtoradec(self, x, y, format="deg", coords="data"): args = [x, y] + self.revnaxis ra_deg, dec_deg = self.wcs.pixtoradec(args, coords=coords) if format == "deg": return ra_deg, dec_deg return wcs.deg2fmt(ra_deg, dec_deg, format)
def _make_report(self, image, qs): d = Bunch.Bunch() try: x, y = qs.objx, qs.objy equinox = float(image.get_keyword('EQUINOX', 2000.0)) try: ra_deg, dec_deg = image.pixtoradec(x, y, coords='data') ra_txt, dec_txt = wcs.deg2fmt(ra_deg, dec_deg, 'str') except Exception as e: self.logger.warning("Couldn't calculate sky coordinates: %s" % (str(e))) ra_deg, dec_deg = 0.0, 0.0 ra_txt = dec_txt = 'BAD WCS' # Calculate star size from pixel pitch try: header = image.get_header() ((xrot, yrot), (cdelt1, cdelt2)) = wcs.get_xy_rotation_and_scale(header) starsize = self.iqcalc.starsize(qs.fwhm_x, cdelt1, qs.fwhm_y, cdelt2) except Exception as e: self.logger.warning("Couldn't calculate star size: %s" % (str(e))) starsize = 0.0 rpt_x = x + self.pixel_coords_offset rpt_y = y + self.pixel_coords_offset # make a report in the form of a dictionary d.setvals( x=rpt_x, y=rpt_y, ra_deg=ra_deg, dec_deg=dec_deg, ra_txt=ra_txt, dec_txt=dec_txt, equinox=equinox, fwhm=qs.fwhm, fwhm_x=qs.fwhm_x, fwhm_y=qs.fwhm_y, ellipse=qs.elipse, background=qs.background, skylevel=qs.skylevel, brightness=qs.brightness, starsize=starsize, time_local=time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()), time_ut=time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime()), ) except Exception as e: self.logger.error("Error making report: %s" % (str(e))) return d
def make_report(self, image, qs): d = Bunch.Bunch() try: x, y = qs.objx, qs.objy equinox = float(image.get_keyword('EQUINOX', 2000.0)) try: ra_deg, dec_deg = image.pixtoradec(x, y, coords='data') ra_txt, dec_txt = wcs.deg2fmt(ra_deg, dec_deg, 'str') except Exception as e: self.logger.warning("Couldn't calculate sky coordinates: %s" % (str(e))) ra_deg, dec_deg = 0.0, 0.0 ra_txt = dec_txt = 'BAD WCS' # Calculate star size from pixel pitch try: header = image.get_header() ((xrot, yrot), (cdelt1, cdelt2)) = wcs.get_xy_rotation_and_scale(header) starsize = self.iqcalc.starsize(qs.fwhm_x, cdelt1, qs.fwhm_y, cdelt2) except Exception as e: self.logger.warning("Couldn't calculate star size: %s" % (str(e))) starsize = 0.0 rpt_x = x + self.pixel_coords_offset rpt_y = y + self.pixel_coords_offset # make a report in the form of a dictionary d.setvals(x = rpt_x, y = rpt_y, ra_deg = ra_deg, dec_deg = dec_deg, ra_txt = ra_txt, dec_txt = dec_txt, equinox = equinox, fwhm = qs.fwhm, fwhm_x = qs.fwhm_x, fwhm_y = qs.fwhm_y, ellipse = qs.elipse, background = qs.background, skylevel = qs.skylevel, brightness = qs.brightness, starsize = starsize, time_local = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()), time_ut = time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime()), ) except Exception as e: self.logger.error("Error making report: %s" % (str(e))) return d