Ejemplo n.º 1
0
  def LN_ICRS_to_AltAz(self,ra=None,dec=None,ln_pressure_qfe=None,ln_temperature=None,ln_humidity=None,obstime=None,mount_set_icrs=True):
    ln_pos_eq.ra=ra
    ln_pos_eq.dec=dec
    if mount_set_icrs:
      # libnova corrections for catalog data ...
      # ToDo missing see Jean Meeus, Astronomical Algorithms, chapter 23
      # proper motion
      # annual paralax (0".8)
      # gravitational deflection of light (0".003)
      ln.ln_get_equ_prec(byref(ln_pos_eq), c_double(obstime.jd), byref(ln_pos_eq_pr))
      ln_pos_eq_nut=self.LN_nutation_meeus(eq_pr=ln_pos_eq_pr,JD=obstime.jd)
      ln.ln_get_equ_aber(byref(ln_pos_eq_nut), c_double(obstime.jd), byref(ln_pos_eq_ab))
      ln.ln_get_hrz_from_equ(byref(ln_pos_eq_ab), byref(self.ln_obs), c_double(obstime.jd), byref(ln_pos_aa_ab))
      # here we use QFE not pressure at sea level!
      # E.g. at Dome-C this formula:
      # ln_pressure=ln_see_pres * pow(1. - (0.0065 * ln_alt) / 288.15, (9.80665 * 0.0289644) / (8.31447 * 0.0065));
      # is not precise.
      if self.refraction_method is None:
        d_alt_deg=ln.ln_get_refraction_adj(c_double(ln_pos_aa_ab.alt),c_double(ln_pressure_qfe),c_double(ln_temperature))
      else:
        d_alt_deg=180./np.pi* self.refraction_method(alt=ln_pos_aa_ab.alt,tem=ln_temperature,pre=ln_pressure_qfe,hum=ln_humidity)
    else:
      # ... but not for the star position as measured in mount frame
      ln.ln_get_hrz_from_equ(byref(ln_pos_eq), byref(self.ln_obs), c_double(obstime.jd), byref(ln_pos_aa_ab));
      d_alt_deg=0.
  
    a_az=Longitude(ln_pos_aa_ab.az,u.deg)
    a_az.wrap_at(0.*u.degree)
    a_alt=Latitude(ln_pos_aa_ab.alt + d_alt_deg,u.deg)

    pos_aa=SkyCoord(az=a_az.radian,alt=a_alt.radian,unit=(u.radian,u.radian),frame='altaz',location=self.obs,obstime=obstime,obswl=0.5*u.micron, pressure=ln_pressure_qfe*u.hPa,temperature=ln_temperature*u.deg_C,relative_humidity=ln_humidity)
    return pos_aa
Ejemplo n.º 2
0
    def LN_ICRS_to_AltAz(self,
                         ra=None,
                         dec=None,
                         ln_pressure_qfe=None,
                         ln_temperature=None,
                         ln_humidity=None,
                         obstime=None,
                         mount_set_icrs=True):
        ln_pos_eq.ra = ra
        ln_pos_eq.dec = dec
        if mount_set_icrs:
            # libnova corrections for catalog data ...
            # ToDo missing see Jean Meeus, Astronomical Algorithms, chapter 23
            # proper motion
            # annual paralax (0".8)
            # gravitational deflection of light (0".003)
            ln.ln_get_equ_prec(byref(ln_pos_eq), c_double(obstime.jd),
                               byref(ln_pos_eq_pr))
            ln_pos_eq_nut = self.LN_nutation_meeus(eq_pr=ln_pos_eq_pr,
                                                   JD=obstime.jd)
            ln.ln_get_equ_aber(byref(ln_pos_eq_nut), c_double(obstime.jd),
                               byref(ln_pos_eq_ab))
            ln.ln_get_hrz_from_equ(byref(ln_pos_eq_ab), byref(self.ln_obs),
                                   c_double(obstime.jd), byref(ln_pos_aa_ab))
            # here we use QFE not pressure at sea level!
            # E.g. at Dome-C this formula:
            # ln_pressure=ln_see_pres * pow(1. - (0.0065 * ln_alt) / 288.15, (9.80665 * 0.0289644) / (8.31447 * 0.0065));
            # is not precise.
            if self.refraction_method is None:
                d_alt_deg = ln.ln_get_refraction_adj(
                    c_double(ln_pos_aa_ab.alt), c_double(ln_pressure_qfe),
                    c_double(ln_temperature))
            else:
                d_alt_deg = 180. / np.pi * self.refraction_method(
                    alt=ln_pos_aa_ab.alt,
                    tem=ln_temperature,
                    pre=ln_pressure_qfe,
                    hum=ln_humidity)
        else:
            # ... but not for the star position as measured in mount frame
            ln.ln_get_hrz_from_equ(byref(ln_pos_eq), byref(self.ln_obs),
                                   c_double(obstime.jd), byref(ln_pos_aa_ab))
            d_alt_deg = 0.

        a_az = Longitude(ln_pos_aa_ab.az, u.deg)
        a_az.wrap_at(0. * u.degree)
        a_alt = Latitude(ln_pos_aa_ab.alt + d_alt_deg, u.deg)

        pos_aa = SkyCoord(az=a_az.radian,
                          alt=a_alt.radian,
                          unit=(u.radian, u.radian),
                          frame='altaz',
                          location=self.obs,
                          obstime=obstime,
                          obswl=0.5 * u.micron,
                          pressure=ln_pressure_qfe * u.hPa,
                          temperature=ln_temperature * u.deg_C,
                          relative_humidity=ln_humidity)
        return pos_aa
Ejemplo n.º 3
0
    def plot(self):
        ra = Longitude([x.cat_ic.ra.radian for x in self.cats], unit=u.radian)
        ra = ra.wrap_at(180. * u.degree)
        dec = Latitude([x.cat_ic.dec.radian for x in self.cats], unit=u.radian)

        import matplotlib.mlab as mlab
        import matplotlib
        # this varies from distro to distro:
        matplotlib.rcParams["backend"] = "TkAgg"
        import matplotlib.mlab as mlab
        import matplotlib.pyplot as plt
        plt.ioff()
        fig = plt.figure(figsize=(8, 6))
        ax = fig.add_subplot(111, projection='mollweide')
        # eye candy
        mag_min = min([x.mag_v for x in self.cats])
        mag_max = max([x.mag_v for x in self.cats])
        npa = np.asarray([
            np.power(2.512, (x.mag_v - mag_min) / (mag_max - mag_min)) * 5.
            for x in self.cats
        ])
        ax.set_title(
            'selected stars for observatory latitude: {0:.2f} deg'.format(
                self.obs.latitude.degree))
        ax.scatter(ra.radian, dec.radian, s=npa)
        ax.set_xticklabels([
            '14h', '16h', '18h', '20h', '22h', '0h', '2h', '4h', '6h', '8h',
            '10h'
        ])
        ax.grid(True)
        plt.show()
Ejemplo n.º 4
0
    def coordinates(self, coord_type='world', origin=0, mode='center'):
        """
        Sky coordinate images.

        Parameters
        ----------
        coord_type : {'world', 'pix', 'skycoord'}
            Which type of coordinates to return.
        origin : {0, 1}
            Pixel coordinate origin.
        mode : {'center', 'edges'}
            Return coordinate values at the pixels edges or pixel centers.
        """
        if mode == 'center':
            y, x = np.indices(self.data.shape)
        elif mode == 'edges':
            shape = self.data.shape[0] + 1, self.data.shape[1] + 1 
            y, x = np.indices(shape)
            y, x = y - 0.5, x - 0.5
        else:
            raise ValueError('Invalid mode to compute coordinates.')
        
        if coord_type == 'pix':
            return x, y
        else:
            xsky, ysky = self.wcs.wcs_pix2world(x, y, origin)
            l, b = Longitude(xsky, unit='deg'), Latitude(ysky, unit='deg')
            l = l.wrap_at('180d')
            if coord_type == 'world':
                return l.degree, b.degree
            elif coord_type == 'skycoord': 
                return l, b
            else:
                raise ValueError("Not a valid coordinate type. Choose either"
                                 " 'world', 'pix' or 'skycoord'.")