Exemplo n.º 1
0
def bsigchi(fit):
    '''
    Some code from ZEN which calculates the binned-sigma
    relation chi-squared used in the PLD method.
    '''
    zeropoint = fit.sdnr
    sdnr = []
    binlevel = []
    err = []
    resppb = 1.
    resbin = float(len(fit.abscissa))
    num = float(len(fit.normresiduals))
    sigma = np.std(fit.normresiduals)

    while resbin > 16:
        binnedres = bd.bindata(int(resbin), mean=[fit.normresiduals])
        sdnr.append(np.std(binnedres))
        binlevel.append(resppb)
        ebar = sigma / np.sqrt(2. * resbin)
        err.append(ebar)
        resppb *= 2
        resbin = np.floor(num / resppb)

    sdnr[0] = sigma
    err[0] = sigma / np.sqrt(2 * num)

    sdnr = np.asarray(sdnr)
    binlevel = np.asarray(binlevel)
    sdnrchisq, slope = reschisq(sdnr, binlevel, err, zeropoint)

    return sdnrchisq
Exemplo n.º 2
0
plt.figure()
# contour the gridded data, plotting dots at the randomly spaced data points.
#CS = plt.contour(xi,yi,zi,15,linewidths=0.5,colors='k')
#CS = plt.contourf(xi,yi,zi,15,cmap=plt.cm.Spectral_r)
plotbins(xi, yi, zi)
plt.colorbar()
plt.scatter(x, y, marker='o', c='b', s=3)
plt.xlim(xi.min(), xi.max())
plt.ylim(yi.min(), yi.max())
plt.title('Gridded data (%d points)' % npts)
plt.savefig('gridded-data.png')

#####
# bin the data.
zi = bindata(x, y, z, xi, yi)
#zi[zi<-0.3] = np.nan

plt.figure()
# contour the gridded data, plotting dots at the randomly spaced data points.
#CS = plt.contour(xi,yi,zi,15,linewidths=0.5,colors='k')
#CS = plt.contourf(xi,yi,zi,15,cmap=plt.cm.Spectral_r)
plotbins(xi, yi, zi)
plt.colorbar() # draw colorbar
#####

# plot data points.
plt.scatter(x, y, marker='o', c='b', s=3)
plt.xlim(xi.min(), xi.max())
plt.ylim(yi.min(), yi.max())
plt.title('Binned data (%d points)' % npts)
Exemplo n.º 3
0
z = z[ind]

# grid

dx = 0.5  # for contourf !!!
dy = 0.15
#dx = 1.2
#dy = 0.3

left, right = x.min(), x.max()
bottom, top = y.min(), y.max()
xi = np.arange(left, right + dx, dx)
yi = np.arange(bottom, top + dy, dy)
xx, yy = np.meshgrid(xi, yi)

grid, bins = bindata.bindata(x, y, z, xi, yi, ppbin=True)
#grid = griddata(x, y, z, xi, yi)

##### PLOT

fig = plt.figure(figsize=(9, 9))
ax = plt.axes([0, 0, 1, 1])

# Antactic Peninsula
left, right, bottom, top = -80, -50, -74, -61
lon0, lat0, lon1, lat1 = -67.5, -67, -56, -68.7

# use major and minor sphere radii from WGS84 ellipsoid
m = Basemap(projection='lcc', lat_1=-72, lat_2=-62, lon_0=0,
            llcrnrlon=lon0, llcrnrlat=lat0, urcrnrlon=lon1, urcrnrlat=lat1,\
            rsphere=(6378137.00, 6356752.3142))
Exemplo n.º 4
0
plt.figure()
# contour the gridded data, plotting dots at the randomly spaced data points.
#CS = plt.contour(xi,yi,zi,15,linewidths=0.5,colors='k')
#CS = plt.contourf(xi,yi,zi,15,cmap=plt.cm.Spectral_r)
plotbins(xi, yi, zi)
plt.colorbar()
plt.scatter(x, y, marker='o', c='b', s=3)
plt.xlim(xi.min(), xi.max())
plt.ylim(yi.min(), yi.max())
plt.title('Gridded data (%d points)' % npts)
plt.savefig('gridded-data.png')

#####
# bin the data.
zi = bindata(x, y, z, xi, yi)
#zi[zi<-0.3] = np.nan

plt.figure()
# contour the gridded data, plotting dots at the randomly spaced data points.
#CS = plt.contour(xi,yi,zi,15,linewidths=0.5,colors='k')
#CS = plt.contourf(xi,yi,zi,15,cmap=plt.cm.Spectral_r)
plotbins(xi, yi, zi)
plt.colorbar()  # draw colorbar
#####

# plot data points.
plt.scatter(x, y, marker='o', c='b', s=3)
plt.xlim(xi.min(), xi.max())
plt.ylim(yi.min(), yi.max())
plt.title('Binned data (%d points)' % npts)
Exemplo n.º 5
0
z = z[ind]

# grid

dx = 0.5  # for contourf !!!
dy = 0.15
#dx = 1.2
#dy = 0.3

left, right = x.min(), x.max()
bottom, top = y.min(), y.max()
xi = np.arange(left, right+dx, dx)
yi = np.arange(bottom, top+dy, dy)
xx, yy = np.meshgrid(xi, yi)

grid, bins = bindata.bindata(x, y, z, xi, yi, ppbin=True)
#grid = griddata(x, y, z, xi, yi)

##### PLOT

fig = plt.figure(figsize=(9,9))
ax = plt.axes([0,0,1,1])

# Antactic Peninsula
left, right, bottom, top = -80, -50, -74, -61
lon0, lat0, lon1, lat1 = -67.5, -67, -56, -68.7

# use major and minor sphere radii from WGS84 ellipsoid
m = Basemap(projection='lcc', lat_1=-72, lat_2=-62, lon_0=0,
            llcrnrlon=lon0, llcrnrlat=lat0, urcrnrlon=lon1, urcrnrlat=lat1,\
            rsphere=(6378137.00, 6356752.3142))