Exemple #1
0
 def healpix(self, nside):
     time = self.date_obs + TimeDelta(self.time, format='sec')
     c2h = Cartesian2HealpixOperator(nside)
     e2g = CartesianEquatorial2GalacticOperator()
     h2e = CartesianHorizontal2EquatorialOperator('NE', time, self.latitude,
                                                  self.longitude)
     rotation = c2h(e2g(h2e))
     return rotation(self.cartesian)
Exemple #2
0
def create_hall_pointing(d,
                         az,
                         el,
                         hor_center,
                         angspeed_psi=0,
                         maxpsi=0,
                         period=0,
                         fillfield=False,
                         date_obs=None,
                         latitude=None,
                         longitude=None,
                         doplot=False,
                         fix_azimuth=None,
                         random_hwp=True,
                         verbose=False):
    '''
    Model of the pointing used in the hall. No back and forth. 
    
    Input coordinates are az, el. The function authomatically will convert (az, el) into (phi, theta) 
    defined as qubic.sampling.create_random_pointing to match with qubicsoft. 
    
    The coverage map center the region in hor_center coordinates. Take it into account for 
    plotting and projecting maps
    
    Parameters:
        d: QUBIC dictionary
        az, el: azimuth and elevation data from housekeeping data or fits file. 1-d array
        period: QubicSampling parameter. If equal to zero, it matches with transformation from az,el
        to ra, dec using qubic.hor2equ(az, el time = 0). Otherwise is not equal. Default: zero. 
        hor_center: center of the FOV
    Return: 
        QUBIC's pointing object
    '''

    if fillfield:
        az = np.arange(az[0], az[-1],
                       hp.nside2resol(d['nside'], arcmin=True) / 60)
        el = np.arange(el[0], el[-1],
                       hp.nside2resol(d['nside'], arcmin=True) / 60)

    nsamples = len(az) * len(el)

    mult_az, mult_el = generate_region(az, el)
    theta = np.array(mult_el)  #- np.mean(el)
    phi = np.array(mult_az[0])  #- np.mean(az)

    # By defalut it computes HorizontalSampling in with SphericalSamplig
    pp = qubic.QubicSampling(
        nsamples,  #azimuth = mult_az[0], elevation = mult_el[0],
        date_obs=d['date_obs'],
        period=period,
        latitude=latitude,
        longitude=longitude)

    time = pp.date_obs + TimeDelta(pp.time, format='sec')
    print("time", np.shape(time))
    c2s = Cartesian2SphericalOperator('azimuth,elevation', degrees=True)
    h2e = CartesianHorizontal2EquatorialOperator('NE', time, pp.latitude,
                                                 pp.longitude)
    s2c = Spherical2CartesianOperator('elevation,azimuth', degrees=True)

    rotation = c2s(h2e(s2c))
    coords = rotation(np.asarray([theta.T, phi.T]).T)

    pp.elevation = mult_el
    pp.azimuth = mult_az[0]
    pp.equatorial[:, 0] = coords[:, 0]
    pp.equatorial[:, 1] = coords[:, 1]

    if doplot:
        fig, ax = subplots(nrows=1, ncols=1, figsize=(14, 6))
        pixsH = hp.ang2pix(d['nside'], np.radians(90 - theta), np.radians(phi))
        mapaH = np.ones((12 * d['nside']**2))
        mapaH[pixsH] = 100
        axes(ax)
        hp.gnomview(mapaH,
                    title="Horizontal coordinates Nside = {}".format(
                        d['nside']),
                    reso=12,
                    xsize=320,
                    ysize=190,
                    rot=[np.mean(phi), np.mean(theta)],
                    hold=True,
                    cbar=False)
        hp.graticule(verbose=False, dmer=10, dpar=10)
        #pixsEq = hp.ang2pix(d['nside'], np.radians(90 - pp.equatorial[:,1]), np.radians(pp.equatorial[:,0]))
        #mapaEq = np.ones((12*d['nside']**2))
        #mapaEq[pixsEq] = 100
        #axes(ax[1])
        #hp.mollview(mapaEq, title = "Equatorial coordinates", hold = True)
        #hp.graticule(verbose = False)

    azcen_fov, elcen_fov = hor_center[0], hor_center[1]
    if period < 1e-4:
        newcenter = qubic.hor2equ(azcen_fov, elcen_fov, 0)
    else:
        newcenter = qubic.hor2equ(azcen_fov, elcen_fov,
                                  pp.time[int(len(pp.time) / 2)])

    warn("Update RA, DEC in dictionary")
    d['RA_center'], d['DEC_center'] = newcenter[0], newcenter[1]
    # center = ra, dec
    #center = (d['RA_center'], d['DEC_center'])

    if verbose:
        print("Time: len(time) = {} \n t0 {} \n time/2 {} \n tf {}".format(
            time, time[0], time[int(len(time) / 2)], time[-1]))

    ### scan psi as well,
    pitch = pp.time * angspeed_psi
    pitch = pitch % (4 * maxpsi)
    mask = pitch > (2 * maxpsi)
    pitch[mask] = -pitch[mask] + 4 * maxpsi
    pitch -= maxpsi

    pp.pitch = pitch

    if random_hwp:
        pp.angle_hwp = np.random.randint(0, 7, nsamples) * 11.25

    if d['fix_azimuth']['apply']:
        pp.fix_az = True
        if d['fix_azimuth']['fix_hwp']:
            pp.angle_hwp = pp.pitch * 0 + 11.25
        if d['fix_azimuth']['fix_pitch']:
            pp.pitch = 0
    else:
        pp.fix_az = False

    return pp