image = rescaleImage(image.real, sigma_goal, kappa) imsize = len(image) pixscale = pixscale rad_fov = imsize/2.0*pixscale print 'Image After Trimming: Rad_fov', rad_fov, 'Imsize', imsize, 'Pixscale', pixscale, 'deg/pix', '(', pixscale*60.*60., 'arcsec/pix)' im2.setImage(image.real) imageStats(im2.image) im2.showImage(copy=True) im2.hanningFilter() im2.calcAll() im2.showPsd2d() im2.showAcovf2d() im2.showAcovf1d(comparison=im) # Compare structure functions, but scaled (due to loss of amplitude info with random phases) im.sfx = im.sfx * pixscale im2.sfx = im2.sfx * pixscale scaleval = im.sf[numpy.abs(im.sfx - goal_rad_fov)<0.05].mean() print 'Cloud 1 scaleval', scaleval im.sf = im.sf/scaleval scaleval = im2.sf[numpy.abs(im2.sfx - goal_rad_fov)<0.05].mean() print 'Cloud 2 scaleval', scaleval im2.sf = im2.sf/scaleval im.showSf(linear=True, comparison=im2, legendlabels=['Clouds 1', 'Clouds 2']) scaleval = SF[numpy.where(numpy.abs(xsf - goal_rad_fov)<0.2)].mean() print 'ARMA scaleval', scaleval SF2 = SF / scaleval pylab.plot(xsf, SF2, 'k:', label='Original/ARMA') pylab.xlim(0, goal_rad_fov*1.2) pylab.ylim(0, 1.2) pylab.legend(numpoints=1, fancybox=True, fontsize='smaller')
def clouds(): """Read an example of the french group's cloud generation.""" # oldCloud.npy and newCloud.npy are images of size 240x240 that cover a fov of 4.0 deg # (if cloud generation code is understood correctly). # old clouds oldClouds = numpy.load('oldCloud.npy') fov = 4.0 #rad_fov = 2.0 nx = len(oldClouds) pixscale = fov / float(nx) im = PImagePlots(shift=True) im.setImage(oldClouds) im.showImage() pylab.savefig('clouds_oldimage.%s' %(figformat), format='%s' %(figformat)) #im.hanningFilter() im.calcAll(min_npix=2, min_dr=1) im.plotMore() pylab.savefig('clouds_old.%s' %(figformat), format='%s' %(figformat)) # new clouds newClouds = numpy.load('newCloud.npy') im2 = PImagePlots(shift=True) im2.setImage(newClouds) im2.showImage() pylab.savefig('clouds_newimage.%s' %(figformat), format='%s' %(figformat)) #im2.hanningFilter() im2.calcAll(min_npix=2, min_dr=1) im2.plotMore() pylab.savefig('clouds_new.%s' %(figformat), format='%s' %(figformat)) # compare structure functions # translate x axis from pixels to degrees .. 240 pix = 4.0 deg (?) im.sfx = im.sfx *pixscale im2.sfx = im2.sfx *pixscale # and scale SF's to just run between 0 and 1 (because of loss of amplitude info with random phases) im.sf = im.sf / im.sf.max() im2.sf = im2.sf / im2.sf.max() legendlabels = ['Old clouds (scaled SF)', 'New clouds (scaled SF)'] im.showSf(comparison=im2, legendlabels=legendlabels, linear=True) pylab.xlim(0, fov/2.0) pylab.ylim(0, 1.2) pylab.title('Structure Function') pylab.xlabel('Degrees') pylab.savefig('clouds_sf.%s' %(figformat), format='%s' %(figformat)) # look at phase spectrum pylab.figure() n, b, p = pylab.hist(im.phasespec.flatten(), bins=75, range=[-numpy.pi, numpy.pi], alpha=0.2, label='Old clouds phases') n, b, p = pylab.hist(im2.phasespec.flatten(), bins=b, range=[-numpy.pi, numpy.pi], alpha=0.2, label='New clouds phases') pylab.legend(fancybox=True, fontsize='smaller') pylab.savefig('clouds_phasehist.%s' %(figformat), format='%s' %(figformat)) # the phase spectrum seems to be flatly distributed between -pi and pi pylab.figure() pylab.subplot(121) pylab.title('Old clouds') pylab.imshow(im.phasespec, origin='lower') pylab.colorbar(shrink=0.6) pylab.subplot(122) pylab.title('New clouds') pylab.imshow(im2.phasespec, origin='lower') pylab.colorbar(shrink=0.6) pylab.suptitle('Phase spectrum') pylab.savefig('clouds_phasespec.%s' %(figformat), format='%s' %(figformat)) pylab.close() return