Ejemplo n.º 1
0
def grid2radec(x, y, mjd, height=500):
    """
    compute a screen image to ra,dec coordinates
    """
    az = np.arctan2(y, x)
    r = x / np.cos(az)
    alt = np.arctan2(r, height)
    ra, dec = stupidFast_altAz2RaDec(alt, az, lat, lon, mjd)
    return ra, dec
Ejemplo n.º 2
0
def grid2radec(x, y, mjd, height=500):
    """
    compute a screen image to ra,dec coordinates
    """
    az = np.arctan2(y, x)
    r = x/np.cos(az)
    alt = np.arctan2(r, height)
    ra, dec = stupidFast_altAz2RaDec(alt, az, lat, lon, mjd)
    return ra, dec
Ejemplo n.º 3
0
def screen2hp(nside, mjd, npix=600, height=500.):

    # generate a screen
    xx, yy = np.meshgrid(np.arange(-npix, npix, 1), np.arange(-npix, npix, 1), indexing='ij')
    r = (xx**2+yy**2)**0.5
    az = np.arctan2(yy, xx)
    alt = np.arctan(height/r)
    ra, dec = stupidFast_altAz2RaDec(alt, az, lat, lon, mjd)
    # Ah, I can convert these alt,az coords to ra,dec, then there's no problem using an ra,dec cloud map.
    hpids = _raDec2Hpid(nside, ra, dec)

    return hpids
Ejemplo n.º 4
0
    def testaltaz2radec(self):
        np.random.seed(42)
        az = np.random.rand(100) * np.pi * 2
        alt = np.random.rand(100) * np.pi - np.pi / 2
        site = Site('LSST')
        mjd = 55000
        omd = ObservationMetaData(mjd=mjd, site=site)

        trueRA, trueDec = _raDecFromAltAz(alt, az, omd)
        fastRA, fastDec = sb.stupidFast_altAz2RaDec(alt, az, site.latitude_rad,
                                                    site.longitude_rad, mjd)
        distanceDiff = haversine(trueRA, trueDec, fastRA, fastDec)
        degreeTol = 2.  # 2-degree tolerance on the fast transform
        assert (np.degrees(distanceDiff.max()) < degreeTol)
    def testaltaz2radec(self):
        np.random.seed(42)
        az = np.random.rand(100)*np.pi*2
        alt = np.random.rand(100)*np.pi-np.pi/2
        site = Site('LSST')
        mjd = 55000
        omd = ObservationMetaData(mjd=mjd,site=site)

        trueRA,trueDec = _raDecFromAltAz(alt,az, omd)
        fastRA,fastDec = sb.stupidFast_altAz2RaDec(alt,az,site.latitude_rad,
                                                   site.longitude_rad,mjd)
        distanceDiff = haversine(trueRA,trueDec, fastRA,fastDec)
        degreeTol =2.  # 2-degree tolerance on the fast transform
        assert(np.degrees(distanceDiff.max()) < degreeTol)
Ejemplo n.º 6
0
def screen2hp(nside, mjd, npix=600, height=500.):

    # generate a screen
    xx, yy = np.meshgrid(np.arange(-npix, npix, 1),
                         np.arange(-npix, npix, 1),
                         indexing='ij')
    r = (xx**2 + yy**2)**0.5
    az = np.arctan2(yy, xx)
    alt = np.arctan(height / r)
    ra, dec = stupidFast_altAz2RaDec(alt, az, lat, lon, mjd)
    # Ah, I can convert these alt,az coords to ra,dec, then there's no problem using an ra,dec cloud map.
    hpids = _raDec2Hpid(nside, ra, dec)

    return hpids
Ejemplo n.º 7
0
def read_opsim(dbFileName):
    conn = sqlite3.connect(dbFileName)
    # Opsim angles are in radians.
    query = "select obsHistID, fieldRA, fieldDec, altitude, azimuth, expMJD, filter, "
    query += "visitExpTime, FWHMeff, airmass, moonPhase, moonAlt, moonAz, sunAlt, "
    query += "sunAz from summary"
    df = pd.read_sql_query(query, conn)
    conn.close()
    eclipLat, eclipLon = convert_ecliptic(df.fieldRA, df.fieldDec)
    df['eclipLat'] = eclipLat
    df['eclipLon'] = eclipLon
    # Grab LSST longitude/latitude for ra/dec to alt/az conversion.
    telescope = Site('LSST')
    sunEclipLon = np.zeros(len(df))
    for i, row in df.iterrows():
        sunRA, sunDec = skybrightness.stupidFast_altAz2RaDec([row['sunAlt']], [row['sunAz']],
                                                             telescope.latitude_rad,
                                                             telescope.longitude_rad, row['expMJD'])
        sunEclLat, sunEclipLon[i] = convert_ecliptic(sunRA[0], sunDec[0])
    df['sunEclipLon'] = sunEclipLon
    return df
Ejemplo n.º 8
0
def read_opsim(dbFileName):
    conn = sqlite3.connect(dbFileName)
    # Opsim angles are in radians.
    query = "select obsHistID, fieldRA, fieldDec, altitude, azimuth, expMJD, filter, "
    query += "visitExpTime, FWHMeff, airmass, moonPhase, moonAlt, moonAz, sunAlt, "
    query += "sunAz from summary"
    df = pd.read_sql_query(query, conn)
    conn.close()
    eclipLat, eclipLon = convert_ecliptic(df.fieldRA, df.fieldDec)
    df['eclipLat'] = eclipLat
    df['eclipLon'] = eclipLon
    # Grab LSST longitude/latitude for ra/dec to alt/az conversion.
    telescope = Site('LSST')
    sunEclipLon = np.zeros(len(df))
    for i, row in df.iterrows():
        sunRA, sunDec = skybrightness.stupidFast_altAz2RaDec(
            [row['sunAlt']], [row['sunAz']], telescope.latitude_rad,
            telescope.longitude_rad, row['expMJD'])
        sunEclLat, sunEclipLon[i] = convert_ecliptic(sunRA[0], sunDec[0])
    df['sunEclipLon'] = sunEclipLon
    return df