예제 #1
0
 def __init__(self, *args, **kwargs):
     defaults = dict(projection='mbtfpq',
                     lon_0=0,
                     rsphere=1.0,
                     celestial=True)
     setdefaults(kwargs, defaults)
     super(DECamMcBride, self).__init__(*args, **kwargs)
예제 #2
0
def plotWeights(date, target_fields, weights, options_basemap={}, **kwargs):
    defaults = dict(c=weights,
                    edgecolor='none',
                    s=50,
                    vmin=np.min(weights),
                    vmax=np.min(weights) + 300.,
                    cmap='Spectral')
    setdefaults(kwargs, defaults)

    defaults = dict(date=date, name='ortho')
    options_basemap = dict(options_basemap)
    setdefaults(options_basemap, defaults)
    fig, basemap = makePlot(**options_basemap)

    proj = basemap.proj(target_fields['RA'], target_fields['DEC'])
    basemap.scatter(*proj, **kwargs)

    # Try to draw the colorbar
    try:
        if len(fig.axes) == 2:
            # Draw colorbar in existing axis
            colorbar = plt.colorbar(cax=fig.axes[-1])
        else:
            colorbar = plt.colorbar()
        colorbar.set_label('Tiling')
    except TypeError:
        pass
    plt.sca(fig.axes[0])
예제 #3
0
def plot_bliss_coverage(fields, outfile=None, **kwargs):
    BANDS = ['g', 'r', 'i', 'z']
    filename = fileio.get_datafile('bliss-target-fields.csv')
    target = FieldArray.read(filename)
    target = target[~np.in1d(target.unique_id, fields.unique_id)]

    fig, ax = plt.subplots(2, 2, figsize=(16, 9))
    plt.subplots_adjust(wspace=0.01,
                        hspace=0.02,
                        left=0.01,
                        right=0.99,
                        bottom=0.01,
                        top=0.99)
    defaults = dict(edgecolor='none', s=12, alpha=0.2, vmin=-1, vmax=2)
    setdefaults(kwargs, defaults)

    for i, b in enumerate(BANDS):
        plt.sca(ax.flat[i])

        f = fields[fields['FILTER'] == b]
        t = target[target['FILTER'] == b]

        bmap = DECamMcBride()
        bmap.draw_des()
        bmap.draw_galaxy(10)

        proj = bmap.proj(t['RA'], t['DEC'])
        bmap.scatter(*proj, c='0.7', **kwargs)

        proj = bmap.proj(f['RA'], f['DEC'])
        bmap.scatter(*proj, c=f['TILING'], cmap=CMAPS[b], **kwargs)
        plt.gca().set_title('BLISS %s-band' % b)
예제 #4
0
    def draw_planet9(self, **kwargs):
        from scipy.interpolate import interp1d
        from scipy.interpolate import UnivariateSpline
        defaults = dict(color='b', lw=2)
        setdefaults(kwargs, defaults)

        ra_lo, dec_lo = np.genfromtxt(fileio.get_datafile('p9_lo.txt'),
                                      usecols=(0, 1)).T
        ra_lo, dec_lo = self.roll(ra_lo, dec_lo)
        ra_lo += -360 * (ra_lo > 180)
        ra_lo, dec_lo = ra_lo[::-1], dec_lo[::-1]
        ra_hi, dec_hi = np.genfromtxt(fileio.get_datafile('p9_hi.txt'),
                                      usecols=(0, 1)).T
        ra_hi, dec_hi = self.roll(ra_hi, dec_hi)
        ra_hi += -360 * (ra_hi > 180)
        ra_hi, dec_hi = ra_hi[::-1], dec_hi[::-1]

        spl_lo = UnivariateSpline(ra_lo, dec_lo)
        ra_lo_smooth = np.linspace(ra_lo[0], ra_lo[-1], 360)
        dec_lo_smooth = spl_lo(ra_lo_smooth)

        spl_hi = UnivariateSpline(ra_hi, dec_hi)
        ra_hi_smooth = np.linspace(ra_hi[0], ra_hi[-1], 360)
        dec_hi_smooth = spl_hi(ra_hi_smooth)

        #self.plot(ra_lo_smooth,dec_lo_smooth,latlon=True,**kwargs)
        #self.plot(ra_hi_smooth,dec_hi_smooth,latlon=True,**kwargs)

        orb = fileio.csv2rec(fileio.get_datafile('P9_orbit_Cassini.csv'))[::7]
        #kwargs = dict(marker='o',s=40,edgecolor='none',cmap='jet_r')
        #self.scatter(*self.proj(orb['ra'],orb['dec']),c=orb['cassini'],**kwargs)

        ra, dec = self.roll(orb['ra'], orb['dec'])
        self.plot(ra, dec, latlon=True, **kwargs)
예제 #5
0
 def draw_fields(self, fields, **kwargs):
     defaults = dict(edgecolor='none', s=15)
     if self.projection == 'ortho': defaults.update(s=50)
     colors = [COLORS[b] for b in fields['FILTER']]
     defaults.update(c=colors)
     setdefaults(kwargs, defaults)
     self.scatter(*self.proj(fields['RA'], fields['DEC']), **kwargs)
예제 #6
0
 def draw_meridians(self,*args,**kwargs):
     defaults = dict(labels=[1,0,0,1])
     if self.projection in ['ortho','geos','nsper','aeqd']:
         defaults.update(labels=[0,0,0,0])
     if not args: defaults.update(meridians=np.arange(0,420,60))
     setdefaults(kwargs,defaults)
     return self.drawmeridians(*args,**kwargs)
예제 #7
0
    def draw_hpxmap(self, hpxmap, xsize=800, **kwargs):
        """
        Use pcolormesh to draw healpix map
        """
        import healpy
        if not isinstance(hpxmap, np.ma.MaskedArray):
            mask = ~np.isfinite(hpxmap) | (hpxmap == healpy.UNSEEN)
            hpxmap = np.ma.MaskedArray(hpxmap, mask=mask)

        vmin, vmax = np.percentile(hpxmap.compressed(), [0.1, 99.9])

        defaults = dict(latlon=True, rasterized=True, vmin=vmin, vmax=vmax)
        setdefaults(kwargs, defaults)

        ax = plt.gca()

        lon = np.linspace(0, 360., xsize)
        lat = np.linspace(-90., 90., xsize)
        lon, lat = np.meshgrid(lon, lat)

        nside = healpy.get_nside(hpxmap.data)
        try:
            pix = healpy.ang2pix(nside, lon, lat, lonlat=True)
        except TypeError:
            pix = healpy.ang2pix(nside, np.radians(90 - lat), np.radians(lon))

        values = hpxmap[pix]
        #mask = ((values == healpy.UNSEEN) | (~np.isfinite(values)))
        #values = np.ma.array(values,mask=mask)
        if self.projection is 'ortho':
            im = self.pcolor(lon, lat, values, **kwargs)
        else:
            im = self.pcolormesh(lon, lat, values, **kwargs)

        return im
예제 #8
0
    def draw_smash(self,**kwargs):
        defaults=dict(facecolor='none',color='k')
        setdefaults(kwargs,defaults)

        filename = fileio.get_datafile('smash_fields_final.txt')
        smash=np.genfromtxt(filename,dtype=[('ra',float),('dec',float)],usecols=[4,5])
        xy = self.proj(smash['ra'],smash['dec'])
        self.scatter(*xy,**kwargs)
예제 #9
0
    def draw_polygon(self, filename, **kwargs):
        """ Draw a polygon footprint on this Basemap instance.
        """
        defaults = dict(color='k', lw=2)
        setdefaults(kwargs, defaults)

        perim = np.loadtxt(filename, dtype=[('ra', float), ('dec', float)])
        self.draw_polygon_radec(perim['ra'], perim['dec'], **kwargs)
예제 #10
0
    def draw_des(self, **kwargs):
        """ Draw the DES footprint on this Basemap instance.
        """
        defaults = dict(color='red', lw=2)
        setdefaults(kwargs, defaults)

        filename = fileio.get_datafile('round13-poly.txt')
        self.draw_polygon(filename, **kwargs)
예제 #11
0
    def draw_bliss(self, **kwargs):
        defaults = dict(color='magenta', lw=2)
        setdefaults(kwargs, defaults)

        filename = fileio.get_datafile('bliss-poly.txt')
        data = np.genfromtxt(filename, names=['ra', 'dec', 'poly'])
        for p in np.unique(data['poly']):
            poly = data[data['poly'] == p]
            self.draw_polygon_radec(poly['ra'], poly['dec'], **kwargs)
예제 #12
0
    def draw_magellanic_stream(self,**kwargs):
        import fitsio
        defaults = dict(xsize=800, vmin=17., vmax=25.0, rasterized=True,
                        cmap=plt.cm.binary)
        setdefaults(kwargs,defaults)

        filename = get_datafile('allms_coldens_gal_nside_1024.fits')
        galhpx = fitsio.read(filename)['coldens']
        celhpx = obztak.utils.projector.hpx_gal2cel(galhpx)
        return self.draw_hpxmap(celhpx,**kwargs)
예제 #13
0
    def draw_sfd(self, **kwargs):
        import healpy as hp
        defaults = dict(rasterized=True, cmap=plt.cm.binary)
        setdefaults(kwargs, defaults)

        filename = fileio.get_datafile('lambda_sfd_ebv.fits')

        galhpx = hp.read_map(filename)
        celhpx = obztak.utils.projector.hpx_gal2cel(galhpx)
        return self.draw_hpxmap(np.log10(celhpx), **kwargs)
예제 #14
0
    def __init__(self,*args,**kwargs):
        self.observatory = CTIO()
        defaults = dict(projection='ortho',celestial=True,rsphere=1.0,
                        lon_0=0,lat_0=self.observatory.lat)
        setdefaults(kwargs,defaults)

        if 'date' in kwargs:
            kwargs.update(lon_0=self.parse_date(kwargs.pop('date')))

        super(DECamOrtho,self).__init__(*args, **kwargs)
예제 #15
0
    def draw_polygons(self, filename, **kwargs):
        """ Draw a polygon footprint on this Basemap instance.
        """
        defaults = dict(color='k', lw=2)
        setdefaults(kwargs, defaults)

        data = np.genfromtxt(filename, names=['ra', 'dec', 'poly'])
        for p in np.unique(data['poly']):
            poly = data[data['poly'] == p]
            self.draw_polygon_radec(poly['ra'], poly['dec'], **kwargs)
예제 #16
0
    def draw_decals(self, **kwargs):
        defaults = dict(color='red', lw=2)
        setdefaults(kwargs, defaults)

        filename = fileio.get_datafile('decals-perimeter.txt')
        decals = np.genfromtxt(filename, names=['poly', 'ra', 'dec'])
        poly1 = decals[decals['poly'] == 1]
        poly2 = decals[decals['poly'] == 2]
        #self.draw_polygon_radec(poly1['ra'],poly1['dec'],**kwargs)
        #self.draw_polygon_radec(poly2['ra'],poly2['dec'],**kwargs)
        self.scatter(*self.proj(poly1['ra'], poly1['dec']))
        self.scatter(*self.proj(poly2['ra'], poly2['dec']))
예제 #17
0
    def draw_zenith(self, observatory,**kwargs):
        """
        Plot a to-scale representation of the focal plane size at the zenith.
        """
        defaults = dict(color='green',alpha=0.75,lw=1.5)
        setdefaults(kwargs,defaults)

        # RA and Dec of zenith
        ra_zenith, dec_zenith = np.degrees(observatory.radec_of(0, '90'))
        xy = self.proj(ra_zenith, dec_zenith)

        self.plot(*xy,marker='+',ms=10,mew=1.5, **kwargs)
        self.tissot(ra_zenith, dec_zenith, constants.DECAM, 100, fc='none',**kwargs)
예제 #18
0
    def draw_airmass(self, observatory, airmass, npts=360, **kwargs):
        defaults = dict(color='green', lw=2)
        setdefaults(kwargs,defaults)

        altitude_radians = (0.5 * np.pi) - np.arccos(1. / airmass)
        ra_contour = np.zeros(npts)
        dec_contour = np.zeros(npts)
        for ii, azimuth in enumerate(np.linspace(0., 2. * np.pi, npts)):
            ra_radians, dec_radians = observatory.radec_of(azimuth, '%.2f'%(np.degrees(altitude_radians)))
            ra_contour[ii] = np.degrees(ra_radians)
            dec_contour[ii] = np.degrees(dec_radians)
        xy = self.proj(ra_contour, dec_contour)
        self.plot(*xy, **kwargs)

        self.draw_zenith(observatory,**kwargs)
예제 #19
0
    def draw_galaxy(self,width=10,**kwargs):
        defaults = dict(color='k',lw=1.5,ls='-')
        setdefaults(kwargs,defaults)

        glon = np.linspace(0,360,200)
        glat = np.zeros_like(glon)
        ra,dec = self.roll(*gal2cel(glon,glat))

        self.draw_polygon_radec(ra,dec,**kwargs)
        
        if width:
            kwargs.update(dict(ls='--',lw=1))
            for delta in [+width,-width]:
                ra,dec = self.roll(*gal2cel(glon,glat+delta))
                self.draw_polygon_radec(ra,dec,**kwargs)
예제 #20
0
 def draw_focal_planes(self, ra, dec, **kwargs):
     defaults = dict(alpha=0.2,color='red',edgecolors='none',lw=0)
     setdefaults(kwargs,defaults)
     ra,dec = np.atleast_1d(ra,dec)
     if len(ra) != len(dec):
         msg = "Dimensions of 'ra' and 'dec' do not match"
         raise ValueError(msg)
     decam = DECamFocalPlane()
     # Should make sure axis exists....
     ax = plt.gca()
     for _ra,_dec in zip(ra,dec):
         corners = decam.project(self,_ra,_dec)
         collection = matplotlib.collections.PolyCollection(corners,**kwargs)
         ax.add_collection(collection)
     plt.draw()
예제 #21
0
    def query(cls, **kwargs):
        """ Generate the database query.

        Parameters:
        -----------
        kwargs : Keyword arguments to fill the query.

        Returns:
        --------
        query  : The query string.
        """
        defaults = dict(propid=cls.SISPI_DICT['propid'], limit='',
                        object_fmt = cls.OBJECT_FMT%'')
        kwargs = setdefaults(kwargs,copy.deepcopy(defaults))

        query ="""
        SELECT object, seqid, seqnum, telra as RA, teldec as dec,
        expTime, filter,
        --to_char(to_timestamp(utc_beg), 'YYYY/MM/DD HH24:MI:SS.MS') AS DATE,
        to_char(date, 'YYYY/MM/DD HH24:MI:SS.MS') AS DATE,
        COALESCE(airmass,-1) as AIRMASS, COALESCE(moonangl,-1) as MOONANGLE,
        COALESCE(ha, -1) as HOURANGLE, COALESCE(slewangl,-1) as SLEW, PROGRAM
        --FROM exposure where propid = '%(propid)s' and exptime > 89
        --2019B-1014: Felipe Olivares
        FROM exposure where propid in ('%(propid)s','2019B-1014') and exptime > 89
        and discard = False and delivered = True and flavor = 'object'
        and object like '%(object_fmt)s%%'
        -- and id NOT IN (860597, 860598, 860599, 860600, 860601, 860602)
        and (
             COALESCE(qc_teff,-1) NOT BETWEEN 0 and 0.1
             OR to_timestamp(utc_beg) > (now() - interval '14 hours')
        )
        ORDER BY utc_beg %(limit)s
        """%kwargs
        return query
예제 #22
0
파일: field.py 프로젝트: kadrlica/obztak
    def query(cls, **kwargs):
        """ Generate the database query.

        Parameters:
        -----------
        kwargs : Keyword arguments to fill the query.

        Returns:
        --------
        query  : The query string.
        """
        from obztak.utils.date import setdefaults
        defaults = dict(propid=cls.SISPI_DICT['propid'], limit='')
        kwargs = setdefaults(kwargs, copy.deepcopy(defaults))

        query = """
        SELECT object, seqid, seqnum, telra as RA, teldec as dec,
        expTime, filter,
        to_char(to_timestamp(utc_beg), 'YYYY/MM/DD HH24:MI:SS.MS') AS DATE,
        COALESCE(airmass,-1) as AIRMASS, COALESCE(moonangl,-1) as MOONANGLE,
        COALESCE(ha, -1) as HOURANGLE, COALESCE(slewangl,-1) as SLEW
        FROM exposure where exptime > 59 and qc_teff > 0.1
        and propid != '2012B-0001' and propid not like '%%-9999'
        and discard = False and delivered = True and flavor = 'object'
        ORDER BY utc_beg %(limit)s
        """ % kwargs
        return query
예제 #23
0
파일: bliss.py 프로젝트: kadrlica/obztak
    def query(cls, **kwargs):
        """ Generate the database query.

        Parameters:
        -----------
        kwargs : Keyword arguments to fill the query.

        Returns:
        --------
        query  : The query string.
        """
        defaults = dict(propid=cls.SISPI_DICT['propid'],
                        limit='',
                        object_fmt=cls.OBJECT_FMT % '')
        kwargs = setdefaults(kwargs, copy.deepcopy(defaults))

        # Should pull this out to be accessible (self.query())?
        query = """
        SELECT object, seqid, seqnum, telra as RA, teldec as dec,
        expTime, filter,
        to_char(to_timestamp(utc_beg), 'YYYY/MM/DD HH24:MI:SS.MS') AS DATE,
        COALESCE(airmass,-1) as AIRMASS, COALESCE(moonangl,-1) as MOONANGLE,
        COALESCE(ha, -1) as HOURANGLE, COALESCE(slewangl,-1) as SLEW
        FROM exposure where propid = '%(propid)s' and exptime > 89
        and discard = False and delivered = True and flavor = 'object'
        and object like '%(object_fmt)s%%'
        -- i-band AOS failures 'sqrt(pow(qc_fwhm,2)-pow(dimm2see,2)) > 0.9'
        and id not in (652771,652794,652795,652796,652797,652799,652800,652803,652804,652806,652807,652808,652809,652810,652812,652813,652814,652815,652816,652817,652818,652819,652820,652821,652822,652823,652824,652825,652826,652827,652828,652829,652830,652831,652832,652833,652834,652835,652836,652837,652838,652839)
        -- z-band AOS failers 'sqrt(pow(qc_fwhm,2)-pow(dimm2see,2)) > 0.7'
        and id not in (652692,652693,652694,652695,652702,652703,652704,652705,652706,652707,652709,652752,652753,652760,652762,652763,652764,652765,652773,652774,652775,652776,652777,652781,652782,652784,652785,652786,652787,652788,652789,652790,652791,652792,652801,652802,652811)
        -- t_eff values (careful about nulls)
        and not (qc_teff < 0.1 and date < '2017/08/07 12:00:00')
        ORDER BY utc_beg %(limit)s
        """ % kwargs
        return query
예제 #24
0
파일: field.py 프로젝트: kadrlica/obztak
    def query(cls, **kwargs):
        """ Generate the database query.

        Parameters:
        -----------
        kwargs : Keyword arguments to fill the query.

        Returns:
        --------
        query  : The query string.
        """
        defaults = dict(propid=cls.SISPI_DICT['propid'],
                        limit='',
                        object_fmt=cls.OBJECT_FMT % '')
        kwargs = setdefaults(kwargs, copy.deepcopy(defaults))

        # Should pull this out to be accessible (self.query())?
        query = """
        SELECT object, seqid, seqnum, telra as RA, teldec as dec,
        expTime, filter,
        to_char(to_timestamp(utc_beg), 'YYYY/MM/DD HH24:MI:SS.MS') AS DATE,
        COALESCE(airmass,-1) as AIRMASS, COALESCE(moonangl,-1) as MOONANGLE,
        COALESCE(ha, -1) as HOURANGLE, COALESCE(slewangl,-1) as SLEW
        FROM exposure where propid = '%(propid)s' and exptime > 89
        and discard = False and delivered = True and flavor = 'object'
        and object like '%(object_fmt)s%%'
        ORDER BY utc_beg %(limit)s
        """ % kwargs
        return query
예제 #25
0
파일: maglites.py 프로젝트: mcnanna/obztak
    def query(cls, **kwargs):
        """ Generate the database query.

        Parameters:
        -----------
        kwargs : Keyword arguments to fill the query.

        Returns:
        --------
        query  : The query string.
        """
        defaults = dict(propid=cls.SISPI_DICT['propid'],
                        limit='',
                        object_fmt=cls.OBJECT_FMT % '')
        kwargs = setdefaults(kwargs, copy.deepcopy(defaults))

        query = """
        SELECT object, seqid, seqnum, telra as RA, teldec as dec,
        expTime, filter,
        to_char(to_timestamp(utc_beg), 'YYYY/MM/DD HH24:MI:SS.MS') AS DATE,
        COALESCE(airmass,-1) as AIRMASS, COALESCE(moonangl,-1) as MOONANGLE,
        COALESCE(ha, -1) as HOURANGLE, COALESCE(slewangl,-1) as SLEW
        FROM exposure where propid = '%(propid)s' and exptime > 89
        and discard = False and delivered = True and flavor = 'object'
        and object like '%(object_fmt)s%%'
        -- Discard exposures with teff < 0.1
        --and not (qc_teff < 0.1 and date < '2017/01/01')
        and
        (
          -- All exposures from tonight
          (date > '2017/06/20 18:00:00')
          -- Or pass teff cut or NULL from past nights
          or ((qc_teff is NULL or qc_teff > 0.1) and date < '2017/06/20 18:00:00')
          -- Or teff = 0 from February
          or (qc_teff = 0 and date < '2017/03/01' and date > '2017/02/01')
        )
        ORDER BY utc_beg %(limit)s
        """ % kwargs
        return query
예제 #26
0
파일: ortho.py 프로젝트: kadrlica/obztak
def plot_coverage(fields,nitestr,outfile=None,**kwargs):
    """ Plot the BLISS survey coverage

    Parameters:
    -----------
    fields  : the bliss fields to plot
    outfile : the output file to write to
    kwargs  : plotting keyword arguments

    Returns:
    --------
    None
    """
    from obztak import factory

    filename = factory.scheduler_factory()._defaults['targets']

    target = factory.field_factory().read(filename)
    target = target[~np.in1d(target.unique_id,fields.unique_id)]

    fig,ax = plt.subplots(2,2,figsize=(16,9))
    plt.subplots_adjust(wspace=0.01,hspace=0.02,left=0.01,right=0.99,
                        bottom=0.01,top=0.99)
    defaults = dict(edgecolor='none', alpha=0.2, vmin=-1, vmax=2)
    setdefaults(kwargs,defaults)
    kwargs['s'] = 12 # roughly scaled to image

    bands = ['g','r','i','z']
    for i,b in enumerate(bands):
        plt.sca(ax.flat[i])

        f = fields[fields['FILTER'] == b]
        t = target[target['FILTER'] == b]

        bmap = DECamMcBride()
        bmap.draw_des()
        bmap.draw_galaxy(10)

        proj = bmap.proj(t['RA'],t['DEC'])
        bmap.scatter(*proj, c='0.7', **kwargs)

        proj = bmap.proj(f['RA'],f['DEC'])
        bmap.scatter(*proj, c=f['TILING'], cmap=CMAPS[b], **kwargs)
        plt.gca().set_title('DECam %s-band'%b)

    plt.suptitle('Coverage (%s)'%nitestr,fontsize=16)
    plt.savefig('nightsum_summary_%s_mbt.png'%nitestr)

    kwargs['s'] = 45 # scaled to image
    fig,ax = plt.subplots(2,2,figsize=(12,12))
    plt.subplots_adjust(wspace=0.01,hspace=0.05,left=0.01,right=0.99,
                        bottom=0.01,top=0.97)
    for i,b in enumerate(bands):
        plt.sca(ax.flat[i])

        f = fields[fields['FILTER'] == b]
        t = target[target['FILTER'] == b]

        bmap = DECamOrtho(date='2016/2/11 03:00', lon_0=0, lat_0=-90)
        bmap.draw_des()
        bmap.draw_galaxy(10)

        proj = bmap.proj(t['RA'],t['DEC'])
        bmap.scatter(*proj, c='0.7', **kwargs)

        proj = bmap.proj(f['RA'],f['DEC'])
        bmap.scatter(*proj, c=f['TILING'], cmap=CMAPS[b], **kwargs)
        plt.gca().set_title('DECam %s-band'%b)
        
    plt.suptitle('Coverage (%s)'%nitestr,fontsize=16)
    plt.savefig('nightsum_summary_%s_ort.png'%nitestr)
예제 #27
0
    def draw_maglites(self, **kwargs):
        defaults = dict(color='blue', lw=2)
        setdefaults(kwargs, defaults)

        filename = fileio.get_datafile('maglites-poly.txt')
        self.draw_polygon(filename, **kwargs)
예제 #28
0
    def draw_blissII(self, **kwargs):
        defaults = dict(color='darkorange', lw=2)
        setdefaults(kwargs, defaults)

        filename = fileio.get_datafile('blissII-poly.txt')
        self.draw_polygons(filename, **kwargs)
예제 #29
0
def plotField(field,
              target_fields=None,
              completed_fields=None,
              options_basemap={},
              **kwargs):
    """
    Plot a specific target field.

    Parameters:
    -----------
    field            : The specific field of interest.
    target_fields    : The fields that will be observed
    completed_fields : The fields that have been observed
    options_basemap  : Keyword arguments to the basemap constructor
    kwargs           : Keyword arguments to the matplotlib.scatter function

    Returns:
    --------
    basemap : The basemap object
    """
    if isinstance(field, np.core.records.record):
        tmp = FieldArray(1)
        tmp[0] = field
        field = tmp
    band = field[0]['FILTER']
    cmap = matplotlib.cm.get_cmap(CMAPS[band])
    defaults = dict(marker='H',
                    s=100,
                    edgecolor='',
                    vmin=-1,
                    vmax=4,
                    cmap=cmap)
    #defaults = dict(edgecolor='none', s=50, vmin=0, vmax=4, cmap='summer_r')
    #defaults = dict(edgecolor='none', s=50, vmin=0, vmax=4, cmap='gray_r')
    setdefaults(kwargs, defaults)

    msg = "%s: id=%10s, " % (datestring(field['DATE'][0], 0), field['ID'][0])
    msg += "ra=%(RA)-6.2f, dec=%(DEC)-6.2f, secz=%(AIRMASS)-4.2f" % field[0]
    logging.info(msg)

    defaults = dict(date=field['DATE'][0], name='ortho')
    options_basemap = dict(options_basemap)
    setdefaults(options_basemap, defaults)
    fig, basemap = makePlot(**options_basemap)
    plt.subplots_adjust(left=0.03, right=0.97, bottom=0.03, top=0.97)

    # Plot target fields
    if target_fields is not None and len(target_fields):
        sel = target_fields['FILTER'] == band
        x, y = basemap.proj(target_fields['RA'], target_fields['DEC'])
        kw = dict(kwargs, c='w', edgecolor='0.6', s=0.8 * kwargs['s'])
        basemap.scatter(x[sel], y[sel], **kw)
        kw = dict(kwargs, c='w', edgecolor='0.8', s=0.8 * kwargs['s'])
        basemap.scatter(x[~sel], y[~sel], **kw)

    # Plot completed fields
    if completed_fields is not None and len(completed_fields):
        sel = completed_fields['FILTER'] == band
        x, y = basemap.proj(completed_fields['RA'], completed_fields['DEC'])
        kw = dict(kwargs)
        basemap.scatter(x[~sel], y[~sel], c='0.6', **kw)
        basemap.scatter(x[sel],
                        y[sel],
                        c=completed_fields['TILING'][sel],
                        **kw)

    # Try to draw the colorbar
    try:
        if len(fig.axes) == 2:
            # Draw colorbar in existing axis
            colorbar = plt.colorbar(cax=fig.axes[-1])
        else:
            colorbar = plt.colorbar()
        colorbar.set_label('Tiling (%s-band)' % band)
    except TypeError:
        pass
    plt.sca(fig.axes[0])

    # Show the selected field
    x, y = basemap.proj(field['RA'], field['DEC'])
    kw = dict(kwargs, edgecolor='k')
    basemap.scatter(x, y, c=COLORS[band], **kw)

    return basemap
예제 #30
0
 def draw_parallels(self, *args, **kwargs):
     defaults = dict()
     if not args: defaults.update(circles=np.arange(-90, 120, 30))
     setdefaults(kwargs, defaults)
     self.pardict = self.drawparallels(*args, **kwargs)
     return self.pardict