def estimate_haversine(self): if self.verbose: print("Estimating Spatial locality with Haversine distance .") self.haversine = DistanceMetric.get_metric("haversine") # prepare features Coordinates longi, lat = pl.deg2rad( hp.pix2ang( nside=self._nside, ipix=pl.arange(hp.nside2npix(self._nside)), lonlat=True, )) mask = pl.ma.masked_inside(longi, 0, pl.pi).mask longi[mask] = -longi[mask] longi[pl.logical_not(mask)] = 2 * pl.pi - longi[pl.logical_not(mask)] Theta = pl.array([lat[self.galactic_mask], longi[self.galactic_mask]]).T angdist_matr = self.haversine.pairwise(Theta) angdist_matr = pl.ma.fix_invalid(angdist_matr, fill_value=pl.pi).data # all the distances are equally weighted and so far range in 0,1 weight_eucl = 1.0 / self._distance_matr.max() weight_hav = 1.0 / angdist_matr.max() self._distance_matr = pl.multiply(weight_eucl * self._distance_matr, weight_hav * angdist_matr) self._X = pl.concatenate([self._X, Theta], axis=1) pass
def xyamb(xytab,qu,xyout=''): mytb=taskinit.tbtool() if not isinstance(qu,tuple): raise Exception,'qu must be a tuple: (Q,U)' if xyout=='': xyout=xytab if xyout!=xytab: os.system('cp -r '+xytab+' '+xyout) QUexp=complex(qu[0],qu[1]) print 'Expected QU = ',qu # , ' (',pl.angle(QUexp)*180/pi,')' mytb.open(xyout,nomodify=False) QU=mytb.getkeyword('QU')['QU'] P=pl.sqrt(QU[0,:]**2+QU[1,:]**2) nspw=P.shape[0] for ispw in range(nspw): st=mytb.query('SPECTRAL_WINDOW_ID=='+str(ispw)) if (st.nrows()>0): q=QU[0,ispw] u=QU[1,ispw] qufound=complex(q,u) c=st.getcol('CPARAM') fl=st.getcol('FLAG') xyph0=pl.angle(pl.mean(c[0,:,:][pl.logical_not(fl[0,:,:])]),True) print 'Spw = '+str(ispw)+': Found QU = '+str(QU[:,ispw]) # +' ('+str(pl.angle(qufound)*180/pi)+')' #if ( (abs(q)>0.0 and abs(qu[0])>0.0 and (q/qu[0])<0.0) or # (abs(u)>0.0 and abs(qu[1])>0.0 and (u/qu[1])<0.0) ): if ( pl.absolute(pl.angle(qufound/QUexp)*180/pi)>90.0 ): c[0,:,:]*=-1.0 xyph1=pl.angle(pl.mean(c[0,:,:][pl.logical_not(fl[0,:,:])]),True) st.putcol('CPARAM',c) QU[:,ispw]*=-1 print ' ...CONVERTING X-Y phase from '+str(xyph0)+' to '+str(xyph1)+' deg' else: print ' ...KEEPING X-Y phase '+str(xyph0)+' deg' st.close() QUr={} QUr['QU']=QU mytb.putkeyword('QU',QUr) mytb.close() QUm=pl.mean(QU[:,P>0],1) QUe=pl.std(QU[:,P>0],1) Pm=pl.sqrt(QUm[0]**2+QUm[1]**2) Xm=0.5*atan2(QUm[1],QUm[0])*180/pi print 'Ambiguity resolved (spw mean): Q=',QUm[0],'U=',QUm[1],'(rms=',QUe[0],QUe[1],')','P=',Pm,'X=',Xm stokes=[1.0,QUm[0],QUm[1],0.0] print 'Returning the following Stokes vector: '+str(stokes) return stokes
def fixfeedpa(vis, defband='', forceband=''): mytb = taskinit.tbtool() mytb.open(vis + '/SPECTRAL_WINDOW') spwnames = mytb.getcol('NAME') mytb.close() if len(forceband) > 0: print 'Forcing band = ', forceband spwnames[:] = forceband defband = forceband mytb.open(vis + '/FEED', nomodify=False) spwids = mytb.getcol('SPECTRAL_WINDOW_ID') ra = mytb.getcol('RECEPTOR_ANGLE') ra[:, :] = 0.0 spwmask = (spwids > -1) ra[0, spwmask] = [bandpa(spwnames[ispw]) for ispw in spwids[spwmask]] spwmask = pl.logical_not(spwmask) if (sum(spwmask) > 0): if (len(defband) > 0): print 'NB: Setting spwid=-1 rows in FEED table to RECEPTOR_ANGLE for band=' + str( defband) ra[0, spwmask] = bandpa(defband) else: print 'NB: Setting spwid=-1 rows in FEED table to RECEPTOR_ANGLE=(0,pi/2)' ra[1, :] = ra[0, :] + (pi / 2.) mytb.putcol('RECEPTOR_ANGLE', ra) mytb.close()
def fixfeedpa(vis,defband='',forceband=''): mytb=taskinit.tbtool() mytb.open(vis+'/SPECTRAL_WINDOW') spwnames=mytb.getcol('NAME') mytb.close() if len(forceband)>0: print 'Forcing band = ',forceband spwnames[:]=forceband defband=forceband mytb.open(vis+'/FEED',nomodify=False) spwids=mytb.getcol('SPECTRAL_WINDOW_ID') ra=mytb.getcol('RECEPTOR_ANGLE') ra[:,:]=0.0 spwmask=(spwids>-1) ra[0,spwmask]=[bandpa(spwnames[ispw]) for ispw in spwids[spwmask]] spwmask=pl.logical_not(spwmask) if (sum(spwmask)>0): if (len(defband)>0): print 'NB: Setting spwid=-1 rows in FEED table to RECEPTOR_ANGLE for band='+str(defband) ra[0,spwmask]=bandpa(defband) else: print 'NB: Setting spwid=-1 rows in FEED table to RECEPTOR_ANGLE=(0,pi/2)' ra[1,:]=ra[0,:]+(pi/2.) mytb.putcol('RECEPTOR_ANGLE',ra) mytb.close()
def crunchZfile(f, aCol, sCol, bCol, normFactor): ''' Takes a zAveraged... data file generated from the crunchData function of this library and produces the arithmetic mean as well as the standard error from all seeds. The error is done through the propagation of errors as: e = sqrt{ \sum_k (c_k e_k)^2 } where e_k are the individual seed's standard errors and c_k are the weighting coefficients obeying \sum_k c_k = 1. ''' avgs, stds, bins = pl.genfromtxt(f, usecols=(aCol, sCol, bCol), unpack=True, delimiter=',') # get rid of any items which are not numbers.. # this is some beautiful Python juju. bins = bins[pl.logical_not(pl.isnan(bins))] stds = stds[pl.logical_not(pl.isnan(stds))] avgs = avgs[pl.logical_not(pl.isnan(avgs))] # normalize data. stds *= normFactor avgs *= normFactor weights = bins / pl.sum(bins) avgs *= weights stds *= weights # over-estimates error bars stds *= stds avg = pl.sum(avgs) stdErr = pl.sum(stds) stdErr = stdErr**0.5 return avg, stdErr
def get_not_annotation_indexes(_annotation, _excluded_annotations): """ method returns indexes of not annotation's values in _annotation parameter, annotation values are defined in _excluded_annotations parameter """ if len(_annotation) == 0: return EMPTY_ARRAY elif _excluded_annotations == ALL_ANNOTATIONS: return pl.array(pl.find(_annotation == 0)) else: #find indexes of an annotation array which are NOT included #in _excluded_annotations list return pl.array(pl.where(pl.logical_not( pl.in1d(_annotation, _excluded_annotations)))[0], dtype=int)
def crunchZfile(f,aCol,sCol,bCol,normFactor): ''' Takes a zAveraged... data file generated from the crunchData function of this library and produces the arithmetic mean as well as the standard error from all seeds. The error is done through the propagation of errors as: e = sqrt{ \sum_k (c_k e_k)^2 } where e_k are the individual seed's standard errors and c_k are the weighting coefficients obeying \sum_k c_k = 1. ''' avgs,stds,bins = pl.genfromtxt(f, usecols=(aCol, sCol, bCol), unpack=True, delimiter=',') # get rid of any items which are not numbers.. # this is some beautiful Python juju. bins = bins[pl.logical_not(pl.isnan(bins))] stds = stds[pl.logical_not(pl.isnan(stds))] avgs = avgs[pl.logical_not(pl.isnan(avgs))] # normalize data. stds *= normFactor avgs *= normFactor weights = bins/pl.sum(bins) avgs *= weights stds *= weights # over-estimates error bars stds *= stds avg = pl.sum(avgs) stdErr = pl.sum(stds) stdErr = stdErr**0.5 return avg, stdErr
def xyamb(xytab, qu, xyout=''): mytb = taskinit.tbtool() if not isinstance(qu, tuple): raise Exception, 'qu must be a tuple: (Q,U)' if xyout == '': xyout = xytab if xyout != xytab: os.system('cp -r ' + xytab + ' ' + xyout) QUexp = complex(qu[0], qu[1]) print 'Expected QU = ', qu # , ' (',pl.angle(QUexp)*180/pi,')' mytb.open(xyout, nomodify=False) QU = mytb.getkeyword('QU')['QU'] P = pl.sqrt(QU[0, :]**2 + QU[1, :]**2) nspw = P.shape[0] for ispw in range(nspw): st = mytb.query('SPECTRAL_WINDOW_ID==' + str(ispw)) if (st.nrows() > 0): q = QU[0, ispw] u = QU[1, ispw] qufound = complex(q, u) c = st.getcol('CPARAM') fl = st.getcol('FLAG') xyph0 = pl.angle(pl.mean(c[0, :, :][pl.logical_not(fl[0, :, :])]), True) print 'Spw = ' + str(ispw) + ': Found QU = ' + str( QU[:, ispw]) # +' ('+str(pl.angle(qufound)*180/pi)+')' #if ( (abs(q)>0.0 and abs(qu[0])>0.0 and (q/qu[0])<0.0) or # (abs(u)>0.0 and abs(qu[1])>0.0 and (u/qu[1])<0.0) ): if (pl.absolute(pl.angle(qufound / QUexp) * 180 / pi) > 90.0): c[0, :, :] *= -1.0 xyph1 = pl.angle( pl.mean(c[0, :, :][pl.logical_not(fl[0, :, :])]), True) st.putcol('CPARAM', c) QU[:, ispw] *= -1 print ' ...CONVERTING X-Y phase from ' + str( xyph0) + ' to ' + str(xyph1) + ' deg' else: print ' ...KEEPING X-Y phase ' + str(xyph0) + ' deg' st.close() QUr = {} QUr['QU'] = QU mytb.putkeyword('QU', QUr) mytb.close() QUm = pl.mean(QU[:, P > 0], 1) QUe = pl.std(QU[:, P > 0], 1) Pm = pl.sqrt(QUm[0]**2 + QUm[1]**2) Xm = 0.5 * atan2(QUm[1], QUm[0]) * 180 / pi print 'Ambiguity resolved (spw mean): Q=', QUm[0], 'U=', QUm[ 1], '(rms=', QUe[0], QUe[1], ')', 'P=', Pm, 'X=', Xm stokes = [1.0, QUm[0], QUm[1], 0.0] print 'Returning the following Stokes vector: ' + str(stokes) return stokes
def main(): # --- Set up all options -------------------------------------------------- # parse command line, getting algorithmic and plotting options. args = jk.parseCMD() reduceType = args.reduceType direc = args.fileNames[0] Lx = 12.0 # some plotting color and label options colors = ['Salmon','MediumSpringGreen','DarkViolet','Fuchsia','Blue', 'Maroon'] if args.RandomColors: random.shuffle(colors) # set up figure that displays all data figg = pl.figure(1) ax = figg.add_subplot(111) pl.xlabel(r'$T\ [K]$', fontsize=20) pl.ylabel('Spatial Density '+r'$[\si{\angstrom}^{-d}]$', fontsize=20) pl.grid(True) pl.xlim([0.5,3.0]) pl.ylim([0,0.07]) pl.tick_params(axis='both', which='major', labelsize=16) pl.tick_params(axis='both', which='minor', labelsize=16) yticks = ax.yaxis.get_major_ticks() yticks[0].set_visible(False) # set up bulk SVP densities for plot bulkVert = -30 minMus = 0.5 maxMus = 2.5 boxSubtract = 1.6 pl.plot([minMus, maxMus], [0.02198, 0.02198], 'k-', lw=3) pl.annotate('3d SVP', xy=(maxMus - boxSubtract, 0.02195), #xycoords='data', xytext=(-50, bulkVert), textcoords='offset points', bbox=dict(boxstyle="round", fc="0.8"), arrowprops=dict(arrowstyle="->", connectionstyle="angle,angleA=0,angleB=90,rad=10"), ) pl.plot([minMus, maxMus], [0.0432, 0.0432], 'k-', lw=3) pl.annotate('2d SVP', xy=(maxMus - boxSubtract, 0.0432), #xycoords='data', xytext=(-50, 30), textcoords='offset points', bbox=dict(boxstyle="round", fc="0.8"), arrowprops=dict(arrowstyle="->", connectionstyle="angle,angleA=0,angleB=90,rad=10"), ) pl.figure(2) pl.xlabel(r'$T\ [K]$', fontsize=20) pl.ylabel('Number of Particles', fontsize=20) pl.grid(True) pl.xlim([0.5,3.0]) pl.ylim([0,2]) pl.tick_params(axis='both', which='major', labelsize=16) pl.tick_params(axis='both', which='minor', labelsize=16) yticks = ax.yaxis.get_major_ticks() yticks[0].set_visible(False) # --- loop over all values of S ------------------------------------------- os.chdir(direc) Svals = glob.glob('S*') for nS, Sval in enumerate(Svals): os.chdir(Sval) # store bulk separation value S = re.search(r'\d+',Sval).group(0) # projected area of film region projArea = float(S)*Lx # set label for plot if 'distinguishable' in Sval: labell = 'S = '+str(S)+', Boltzmannons' else: labell = 'S = '+str(S)+', Bosons' # get all temperature directory names Tdirs = sorted(glob.glob('T*')) Ts = pl.array([]) Films = pl.array([]) Bulks = pl.array([]) filmErrs = pl.array([]) bulkErrs = pl.array([]) # --- loop over all temperature values -------------------------------- for Tdir in Tdirs: os.chdir(Tdir) # build array of temperatures Ts = pl.append(Ts, float(Tdir[1:])) # get data file name f = glob.glob('*Bipart*')[0] #densData = pl.genfromtxt(f, delimiter=',') filmavg,filmstd,filmbins,bulkavg,bulkstd,bulkbins = pl.genfromtxt(f, unpack=True, usecols=(0,1,2,3,4,5), delimiter=',') # get rid of any items which are not numbers.. # this is some beautiful Python juju. filmbins = filmbins[pl.logical_not(pl.isnan(filmbins))] filmstd = filmstd[pl.logical_not(pl.isnan(filmstd))] filmavg = filmavg[pl.logical_not(pl.isnan(filmavg))] bulkbins = bulkbins[pl.logical_not(pl.isnan(bulkbins))] bulkstd = bulkstd[pl.logical_not(pl.isnan(bulkstd))] bulkavg = bulkavg[pl.logical_not(pl.isnan(bulkavg))] filmweights = filmbins/pl.sum(filmbins) bulkweights = bulkbins/pl.sum(bulkbins) filmavg *= filmweights bulkavg *= bulkweights filmstd *= filmweights bulkstd *= bulkweights film = pl.sum(filmavg) bulk = pl.sum(bulkavg) filmstdErr = pl.sum(filmstd) bulkstdErr = pl.sum(bulkstd) Films = pl.append(Films, film) Bulks = pl.append(Bulks, bulk) filmErrs = pl.append(filmErrs, filmstdErr) bulkErrs = pl.append(bulkErrs, bulkstdErr) os.chdir('..') # add data to plot for given S value. pl.figure(1) pl.errorbar(Ts, Films, filmErrs, fmt='-o', color=colors[nS], label=labell+', 2d') pl.errorbar(Ts, Bulks, bulkErrs, fmt = '--d', color=colors[nS], label=labell+', 3d') pl.figure(2) pl.errorbar(Ts, Films*projArea, fmt='-o', color=colors[nS], label = labell+', 2d') os.chdir('..') pl.figure(1) pl.legend() #pl.savefig('Densities_vs_T_allS.pdf', format='pdf', # bbox_inches='tight') pl.figure(2) pl.legend() pl.show()
def main(): args = parseCMD() Temp = args.Temperature Lx = 12.0 Ly = 12.0 az = 47.5 ay = 2.0 Svals = glob.glob('S*') # define some plotting colors colors = [ 'Salmon', 'Blue', 'DarkViolet', 'MediumSpringGreen', 'Fuchsia', 'Yellow', 'Maroon' ] # set up figure that displays all data figg = pl.figure(1) ax = figg.add_subplot(111) pl.xlabel(r'$\mu\ [K]$', fontsize=20) pl.ylabel('Spatial Density ' + r'$[\si{\angstrom}^{-d}]$', fontsize=20) pl.grid(True) #pl.xlim([0.5,3.0]) #pl.ylim([0,0.07]) pl.tick_params(axis='both', which='major', labelsize=16) pl.tick_params(axis='both', which='minor', labelsize=16) yticks = ax.yaxis.get_major_ticks() yticks[0].set_visible(False) # set up bulk SVP densities for plot bulkVert = -30 minMus = -3.0 maxMus = 5.0 boxSubtract = 1.6 pl.plot([minMus, maxMus], [0.02198, 0.02198], 'k-', lw=3) pl.annotate( '3d SVP', xy=(maxMus - boxSubtract, 0.02195), #xycoords='data', xytext=(-50, bulkVert), textcoords='offset points', bbox=dict(boxstyle="round", fc="0.8"), arrowprops=dict(arrowstyle="->", connectionstyle="angle,angleA=0,angleB=90,rad=10"), ) pl.plot([minMus, maxMus], [0.0432, 0.0432], 'k-', lw=3) pl.annotate( '2d SVP', xy=(maxMus - boxSubtract, 0.0432), #xycoords='data', xytext=(-50, 30), textcoords='offset points', bbox=dict(boxstyle="round", fc="0.8"), arrowprops=dict(arrowstyle="->", connectionstyle="angle,angleA=0,angleB=90,rad=10"), ) solidDens = True if solidDens: pl.plot([minMus, maxMus], [0.0248, 0.0248], 'k-', lw=3) pl.annotate( 'HCP solid SVP', xy=(maxMus - boxSubtract, 0.0248), #xycoords='data', xytext=(-50, 30), textcoords='offset points', bbox=dict(boxstyle="round", fc="0.8"), arrowprops=dict(arrowstyle="->", connectionstyle="angle,angleA=0,angleB=90,rad=10"), ) # plot just the bulk density as a function of chemical potential figg2 = pl.figure(2) ax2 = figg2.add_subplot(111) pl.xlabel(r'$\mu\ [K]$', fontsize=20) pl.ylabel('Spatial Density ' + r'$[\si{\angstrom}^{-d}]$', fontsize=20) pl.grid(True) #pl.xlim([0.5,3.0]) #pl.ylim([0,0.07]) pl.tick_params(axis='both', which='major', labelsize=16) pl.tick_params(axis='both', which='minor', labelsize=16) yticks = ax.yaxis.get_major_ticks() yticks[0].set_visible(False) # set up bulk SVP densities for plot bulkVert = -30 minMus = -3.0 maxMus = 5.0 boxSubtract = 1.6 pl.plot([minMus, maxMus], [0.02198, 0.02198], 'k-', lw=3) pl.annotate( '3d SVP', xy=(maxMus - boxSubtract, 0.02195), #xycoords='data', xytext=(-50, bulkVert), textcoords='offset points', bbox=dict(boxstyle="round", fc="0.8"), arrowprops=dict(arrowstyle="->", connectionstyle="angle,angleA=0,angleB=90,rad=10"), ) # number of particles in film region vs chemical potential pl.figure(3) pl.xlabel(r'$\mu\ [K]$', fontsize=20) pl.ylabel('Number of Particles', fontsize=20) pl.grid(True) #pl.xlim([0.5,3.0]) #pl.ylim([0,2]) pl.tick_params(axis='both', which='major', labelsize=16) pl.tick_params(axis='both', which='minor', labelsize=16) yticks = ax.yaxis.get_major_ticks() yticks[0].set_visible(False) # normalized angular winding vs chemical potential pl.figure(4) pl.xlabel(r'$\mu\ [K]$', fontsize=20) pl.ylabel(r'$\Omega$', fontsize=20) pl.grid(True) pl.tick_params(axis='both', which='major', labelsize=16) pl.tick_params(axis='both', which='minor', labelsize=16) yticks = ax.yaxis.get_major_ticks() yticks[0].set_visible(False) # actual density in cell pl.figure(5) pl.xlabel(r'$\mu\ [K]$', fontsize=20) pl.ylabel(r'$\rho\ [\si{\angstrom}^{-3}]$', fontsize=20) pl.grid(True) pl.tick_params(axis='both', which='major', labelsize=16) pl.tick_params(axis='both', which='minor', labelsize=16) yticks = ax.yaxis.get_major_ticks() yticks[0].set_visible(False) # --- loop through known directory structure ------------------------------ for nS, Sval in enumerate(sorted(Svals)): os.chdir(Sval) # get bipartition file name f = glob.glob('*Bipart*')[0] # get angular winding file name fw = glob.glob('*Ntwind*')[0] # get estimator file name (includes total number) fe = glob.glob('*Estimator*')[0] # store bulk separation value S = re.search(r'\d+', Sval).group(0) # get label for plot if 'distinguishable' in Sval: labell = 'S = ' + str(S) + ', Boltzmannons' else: labell = 'S = ' + str(S) + ', Bosons' # projected area of film region projArea = float(S) * Lx # accessible volume in cell accessibleVol = Lx * Ly * (2.0 * az + float(S)) - Lx * float(S) * (Ly - 2.0 * ay) # multiply angular winding by normalization to be fixed in code later omegaNorm = 4.0 * (float(S) + 1.0 * Ly)**2 # get chemical potential headers = getHeadersFromFile(f) mus = pl.array([]) Films = pl.array([]) Bulks = pl.array([]) filmErrs = pl.array([]) bulkErrs = pl.array([]) Omegas = pl.array([]) omegaErrs = pl.array([]) NumParts = pl.array([]) NumPartErrs = pl.array([]) n = 0 nw = 3 nn = 12 for head in headers: # get values of chemical potential from file header mus = pl.append(mus, float(head)) # --- Densities --------------------------------------------------- filmavg, filmstd, filmbins, bulkavg, bulkstd, bulkbins = pl.genfromtxt( f, unpack=True, usecols=(n, n + 1, n + 2, n + 3, n + 4, n + 5), delimiter=',') n += 6 # get rid of any items which are not numbers.. # this is some beautiful Python juju. filmbins = filmbins[pl.logical_not(pl.isnan(filmbins))] filmstd = filmstd[pl.logical_not(pl.isnan(filmstd))] filmavg = filmavg[pl.logical_not(pl.isnan(filmavg))] bulkbins = bulkbins[pl.logical_not(pl.isnan(bulkbins))] bulkstd = bulkstd[pl.logical_not(pl.isnan(bulkstd))] bulkavg = bulkavg[pl.logical_not(pl.isnan(bulkavg))] filmweights = filmbins / pl.sum(filmbins) bulkweights = bulkbins / pl.sum(bulkbins) filmavg *= filmweights bulkavg *= bulkweights filmstd *= filmweights bulkstd *= bulkweights film = pl.sum(filmavg) bulk = pl.sum(bulkavg) filmstdErr = pl.sum(filmstd) bulkstdErr = pl.sum(bulkstd) Films = pl.append(Films, film) Bulks = pl.append(Bulks, bulk) filmErrs = pl.append(filmErrs, filmstdErr) bulkErrs = pl.append(bulkErrs, bulkstdErr) # ---- angular winding -------------------------------------------- omegaAvg, omegaStd, omegaBins = pl.genfromtxt(fw, unpack=True, usecols=(nw, nw + 1, nw + 2), delimiter=',') nw += 9 # get rid of any items which are not numbers.. omegaBins = omegaBins[pl.logical_not(pl.isnan(omegaBins))] omegaStd = omegaStd[pl.logical_not(pl.isnan(omegaStd))] omegaAvg = omegaAvg[pl.logical_not(pl.isnan(omegaAvg))] # normalize data. omegaStd *= omegaNorm omegaAvg *= omegaNorm weights = omegaBins / pl.sum(omegaBins) omegaAvg *= weights omegaStd *= weights Omega = pl.sum(omegaAvg) omegaErr = pl.sum(omegaStd) Omegas = pl.append(Omegas, Omega) omegaErrs = pl.append(omegaErrs, omegaErr) # ---- total number ----------------------------------------------- numAvg, numStd, numBins = pl.genfromtxt(fe, unpack=True, usecols=(nn, nn + 1, nn + 2), delimiter=',') nn += 15 # get rid of any items which are not numbers.. numBins = numBins[pl.logical_not(pl.isnan(numBins))] numStd = numStd[pl.logical_not(pl.isnan(numStd))] numAvg = numAvg[pl.logical_not(pl.isnan(numAvg))] # normalize data. numStd /= (1.0 * accessibleVol) numAvg /= (1.0 * accessibleVol) weights = numBins / pl.sum(numBins) numAvg *= weights numStd *= weights numPart = pl.sum(numAvg) numPartErr = pl.sum(numStd) NumParts = pl.append(NumParts, numPart) NumPartErrs = pl.append(NumPartErrs, numPartErr) # Sort data in order of increasing chemical potential. I love Python. # This is another bit of magical Python juju. mus, Films, Bulks, filmErrs, bulkErrs, Omegas, omegaErrs, NumParts, NumPartErrs = pl.asarray( zip(*sorted( zip(mus, Films, Bulks, filmErrs, bulkErrs, Omegas, omegaErrs, NumParts, NumPartErrs)))) pl.figure(1) pl.errorbar(mus, Films, filmErrs, fmt='--o', color=colors[nS], label=labell + ', 2d', markersize=8) pl.errorbar(mus, Bulks, bulkErrs, fmt='-d', color=colors[nS], label=labell + ', 3d', markersize=8) pl.figure(2) pl.errorbar(mus, Bulks, bulkErrs, fmt='-d', color=colors[nS], label=labell + ', 3d', markersize=8) pl.figure(3) pl.errorbar(mus, Films * projArea, fmt='-o', color=colors[nS], label=labell + ', 2d', markersize=8) pl.figure(4) pl.errorbar(mus, Omegas, omegaErrs, fmt='-o', color=colors[nS], label=labell, markersize=8) pl.figure(5) pl.errorbar(mus, NumParts, NumPartErrs, fmt='-o', color=colors[nS], label=labell, markersize=8) os.chdir('..') pl.figure(1) pl.legend(loc=2) pl.savefig('densities_vs_chemicalPotential_allS_1APR.pdf', format='pdf', bbox_inches='tight') pl.figure(2) pl.legend(loc=2) pl.figure(3) pl.legend(loc=2) pl.figure(4) pl.legend(loc=2) pl.figure(5) pl.legend(loc=2) pl.show()
def main(): savePDF = True solidDens = False Lx = 12.0 Ly = 12.0 az = 47.5 ay = 2.0 bulkVol = 2.0 * Lx * Ly * az lowX7 = -6.0 #lowX7 = -4.0 # boltzmannons highX7 = 2.9 #highX7 = 2.5 # boltzmannons # define some plotting colors colors = [ 'Navy', 'DarkViolet', 'MediumSpringGreen', 'Salmon', 'Fuchsia', 'Yellow', 'Maroon', 'Salmon', 'Blue' ] # ------------------------------------------------------------------------- # bulk and film density on same plot figg = pl.figure(1) ax = figg.add_subplot(111) pl.xlabel(r'$\text{Potential Shift}\ [K]$', fontsize=20) pl.ylabel('Spatial Density ' + r'$[\si{\angstrom}^{-d}]$', fontsize=20) pl.grid(True) pl.xlim([-5.5, 3.5]) #pl.ylim([0,0.07]) pl.tick_params(axis='both', which='major', labelsize=16) pl.tick_params(axis='both', which='minor', labelsize=16) yticks = ax.yaxis.get_major_ticks() yticks[0].set_visible(False) # bulk SVP density line bulkVert = -30 minMus = -5.5 maxMus = 2.0 boxSubtract = 1.6 pl.plot([minMus, maxMus], [0.02198, 0.02198], 'k-', lw=3) pl.annotate( '3d SVP', xy=(maxMus - boxSubtract, 0.02195), #xycoords='data', xytext=(-10, bulkVert), textcoords='offset points', bbox=dict(boxstyle="round", fc="0.8"), arrowprops=dict(arrowstyle="->", connectionstyle="angle,angleA=0,angleB=90,rad=10"), ) # film SVP density line pl.plot([minMus, maxMus], [0.0432, 0.0432], 'k-', lw=3) pl.annotate( '2d SVP', xy=(maxMus - boxSubtract, 0.0432), #xycoords='data', xytext=(30, -30), textcoords='offset points', bbox=dict(boxstyle="round", fc="0.8"), arrowprops=dict(arrowstyle="->", connectionstyle="angle,angleA=0,angleB=90,rad=10"), ) if solidDens: pl.plot([minMus, maxMus], [0.0248, 0.0248], 'k-', lw=3) pl.annotate( 'HCP solid SVP', xy=(maxMus - boxSubtract, 0.0248), #xycoords='data', xytext=(-10, 30), textcoords='offset points', bbox=dict(boxstyle="round", fc="0.8"), arrowprops=dict(arrowstyle="->", connectionstyle="angle,angleA=0,angleB=90,rad=10"), ) # ------------------------------------------------------------------------- # bulk density figg2 = pl.figure(2) ax2 = figg2.add_subplot(111) pl.xlabel(r'$\text{Potential Shift}\ [K]$', fontsize=20) pl.ylabel('Bulk Density ' + r'$[\si{\angstrom}^{-3}]$', fontsize=20) pl.grid(True) pl.xlim([-5.5, 0.5]) pl.tick_params(axis='both', which='major', labelsize=16) pl.tick_params(axis='both', which='minor', labelsize=16) yticks = ax.yaxis.get_major_ticks() yticks[0].set_visible(False) # set up bulk SVP densities for plot bulkVert = 30 # changes text box above (positive) or below (negative) line boxSubtract = 1.6 pl.plot([minMus, maxMus], [0.02198, 0.02198], 'k-', lw=3) pl.annotate( '3d SVP', xy=(maxMus - boxSubtract, 0.02198), #xycoords='data', xytext=(-50, bulkVert), textcoords='offset points', bbox=dict(boxstyle="round", fc="0.8"), arrowprops=dict(arrowstyle="->", connectionstyle="angle,angleA=0,angleB=90,rad=10"), ) # ------------------------------------------------------------------------- # number of particles in film region pl.figure(3) pl.xlabel(r'$\text{Potential Shift}\ [K]$', fontsize=20) pl.ylabel(r'$N_{\text{film}}$', fontsize=20) pl.grid(True) pl.tick_params(axis='both', which='major', labelsize=16) pl.tick_params(axis='both', which='minor', labelsize=16) yticks = ax.yaxis.get_major_ticks() yticks[0].set_visible(False) # ------------------------------------------------------------------------- # normalized angular winding pl.figure(4) pl.xlabel(r'$\text{Potential Shift}\ [K]$', fontsize=20) pl.ylabel(r'$\Omega$', fontsize=20) pl.grid(True) pl.tick_params(axis='both', which='major', labelsize=16) pl.tick_params(axis='both', which='minor', labelsize=16) yticks = ax.yaxis.get_major_ticks() yticks[0].set_visible(False) # ------------------------------------------------------------------------- # film density figg5 = pl.figure(5) ax5 = figg5.add_subplot(111) pl.xlabel(r'$\text{Potential Shift}\ [K]$', fontsize=20) pl.ylabel(r'$\text{Film Density}\ [\si{\angstrom}^{-2}]$', fontsize=20) pl.ylim([0.03, 0.05]) pl.xlim([-5.5, 0.5]) pl.grid(True) pl.tick_params(axis='both', which='major', labelsize=16) pl.tick_params(axis='both', which='minor', labelsize=16) yticks = ax.yaxis.get_major_ticks() yticks[0].set_visible(False) # film SVP density line pl.plot([lowX7, highX7], [0.0432, 0.0432], 'k-', lw=3) pl.annotate( '2d SVP', xy=(-4, 0.0432), #xycoords='data', xytext=(30, -30), textcoords='offset points', bbox=dict(boxstyle="round", fc="0.8"), arrowprops=dict(arrowstyle="->", connectionstyle="angle,angleA=0,angleB=90,rad=10"), ) # ------------------------------------------------------------------------- # superfluid fraction pl.figure(6) pl.xlabel(r'$\text{Potential Shift}\ [K]$', fontsize=20) pl.ylabel(r'$\rho_S/\rho$', fontsize=20) pl.grid(True) pl.xlim([-5.5, 0.5]) pl.tick_params(axis='both', which='major', labelsize=16) pl.tick_params(axis='both', which='minor', labelsize=16) yticks = ax.yaxis.get_major_ticks() yticks[0].set_visible(False) # ------------------------------------------------------------------------- # film/bulk densities subplot pl.figure(7) ax7a = pl.subplot(211) pl.ylabel(r'$\text{Film Density}\ [\si{\angstrom}^{-2}]$', fontsize=20) pl.ylim([0.035, 0.05]) pl.grid(True) pl.tick_params(axis='both', which='major', labelsize=16) pl.tick_params(axis='both', which='minor', labelsize=16) yticks = ax.yaxis.get_major_ticks() yticks[0].set_visible(False) # film SVP density line pl.plot([lowX7, highX7], [0.0432, 0.0432], 'k-', lw=3) pl.annotate( '2d SVP', xy=(-2, 0.0432), #xycoords='data', xytext=(30, -30), textcoords='offset points', bbox=dict(boxstyle="round", fc="0.8"), arrowprops=dict(arrowstyle="->", connectionstyle="angle,angleA=0,angleB=90,rad=10"), ) pl.setp(ax7a.get_xticklabels(), visible=False) ax7b = pl.subplot(212, sharex=ax7a) pl.xlabel(r'$\text{Potential Shift}\ [K]$', fontsize=20) pl.ylabel('Bulk Density ' + r'$[\si{\angstrom}^{-3}]$', fontsize=20) pl.grid(True) pl.xlim([lowX7, highX7]) pl.tick_params(axis='both', which='major', labelsize=16) pl.tick_params(axis='both', which='minor', labelsize=16) yticks = ax7b.yaxis.get_major_ticks() yticks[0].set_visible(False) # set up bulk SVP densities for plot bulkVert = 15 # changes text box above (positive) or below (negative) line boxSubtract = 1.6 pl.plot([lowX7, highX7], [0.02198, 0.02198], 'k-', lw=3) pl.annotate( '3d SVP', xy=(1.2, 0.02198), #xycoords='data', xytext=(-50, bulkVert), textcoords='offset points', bbox=dict(boxstyle="round", fc="0.8"), arrowprops=dict(arrowstyle="->", connectionstyle="angle,angleA=0,angleB=90,rad=10"), ) # ------------------------------------------------------------------------- # number of particles in bulk pl.figure(8) pl.xlabel(r'$\text{Potential Shift}\ [K]$', fontsize=20) pl.ylabel(r'$N_{\text{bulk}}$', fontsize=20) pl.grid(True) pl.xlim([-5.5, 0.5]) pl.tick_params(axis='both', which='major', labelsize=16) pl.tick_params(axis='both', which='minor', labelsize=16) yticks = ax.yaxis.get_major_ticks() yticks[0].set_visible(False) # ------------------------------------------------------------------------- Tvals = glob.glob('*T*') Markers = ['-o', '-d', '-*'] for nT, Tval in enumerate(sorted(Tvals)): os.chdir(Tval) T = Tval[1:] Svals = glob.glob('S*') # --- loop through known directory structure -------------------------- for nS, Sval in enumerate(sorted(Svals)): os.chdir(Sval) Vdirs = glob.glob('*V*') print os.getcwd() # store bulk separation value S = re.search(r'\d+', Sval).group(0) # get label for plot if 'distinguishable' in Sval: labell = 'S = ' + str(S) + ', Boltzmannons, T=' + str(T) else: labell = 'S = ' + str(S) + ', Bosons, T=' + str(T) shortlabell = 'S = ' + str(S) + ', T=' + str(T) # projected area of film region projArea = float(S) * Lx # accessible volume in cell #accessibleVol = Lx*(Ly*(float(S)+2.0*az) - float(S)*(Ly-2.0*ay)) accessibleVol = 2.0 * Lx * Ly * az + 2.0 * ay * Lx * float(S) # multiply angular winding by norm. to be fixed in code later omegaNorm = 4.0 * (float(S) + 1.0 * Ly)**2 # Arrays to hold all data Vs = pl.array([]) Films = pl.array([]) Bulks = pl.array([]) filmErrs = pl.array([]) bulkErrs = pl.array([]) Omegas = pl.array([]) omegaErrs = pl.array([]) NumParts = pl.array([]) NumPartErrs = pl.array([]) Supers = pl.array([]) SuperErrs = pl.array([]) # pass potential shift directories for current S value for Vdir in Vdirs: os.chdir(Vdir) # get bipartition file name f = glob.glob('*Bipart*')[0] # get angular winding file name fw = glob.glob('*Ntwind*')[0] # get estimator file name (includes total number) fe = glob.glob('*Estimator*')[0] # get superfrac file name fs = glob.glob('*Super*')[0] # build array of film potential shifts from directory names Vs = pl.append(Vs, float(Vdir[1:])) # --- Densities ----------------------------------------------- filmavg, filmstd, filmbins, bulkavg, bulkstd, bulkbins = pl.genfromtxt( f, unpack=True, usecols=(0, 1, 2, 3, 4, 5), delimiter=',') # get rid of any items which are not numbers.. # this is some beautiful Python juju. filmbins = filmbins[pl.logical_not(pl.isnan(filmbins))] filmstd = filmstd[pl.logical_not(pl.isnan(filmstd))] filmavg = filmavg[pl.logical_not(pl.isnan(filmavg))] bulkbins = bulkbins[pl.logical_not(pl.isnan(bulkbins))] bulkstd = bulkstd[pl.logical_not(pl.isnan(bulkstd))] bulkavg = bulkavg[pl.logical_not(pl.isnan(bulkavg))] filmweights = filmbins / pl.sum(filmbins) bulkweights = bulkbins / pl.sum(bulkbins) filmavg *= filmweights bulkavg *= bulkweights filmstd *= filmweights bulkstd *= bulkweights film = pl.sum(filmavg) bulk = pl.sum(bulkavg) filmstdErr = pl.sum(filmstd) bulkstdErr = pl.sum(bulkstd) Films = pl.append(Films, film) Bulks = pl.append(Bulks, bulk) filmErrs = pl.append(filmErrs, filmstdErr) bulkErrs = pl.append(bulkErrs, bulkstdErr) # ---- angular winding ---------------------------------------- omegaAvg, omegaStd, omegaBins = pl.genfromtxt(fw, unpack=True, usecols=(3, 4, 5), delimiter=',') # get rid of any items which are not numbers.. omegaBins = omegaBins[pl.logical_not(pl.isnan(omegaBins))] omegaStd = omegaStd[pl.logical_not(pl.isnan(omegaStd))] omegaAvg = omegaAvg[pl.logical_not(pl.isnan(omegaAvg))] # normalize data. omegaStd *= omegaNorm omegaAvg *= omegaNorm weights = omegaBins / pl.sum(omegaBins) omegaAvg *= weights omegaStd *= weights Omega = pl.sum(omegaAvg) omegaErr = pl.sum(omegaStd) Omegas = pl.append(Omegas, Omega) omegaErrs = pl.append(omegaErrs, omegaErr) # ---- total number ------------------------------------------- numAvg, numStd, numBins = pl.genfromtxt(fe, unpack=True, usecols=(12, 13, 14), delimiter=',') # get rid of any items which are not numbers.. numBins = numBins[pl.logical_not(pl.isnan(numBins))] numStd = numStd[pl.logical_not(pl.isnan(numStd))] numAvg = numAvg[pl.logical_not(pl.isnan(numAvg))] weights = numBins / pl.sum(numBins) numAvg *= weights numStd *= weights numPart = pl.sum(numAvg) numPartErr = pl.sum(numStd) NumParts = pl.append(NumParts, numPart) NumPartErrs = pl.append(NumPartErrs, numPartErr) # ---- superfluid fraction ------------------------------------ supAvg, supStd, supBins = pl.genfromtxt(fs, unpack=True, usecols=(0, 1, 2), delimiter=',') # get rid of any items which are not numbers.. supBins = supBins[pl.logical_not(pl.isnan(supBins))] supStd = supStd[pl.logical_not(pl.isnan(supStd))] supAvg = supAvg[pl.logical_not(pl.isnan(supAvg))] # normalize data. #supStd /= (1.0*accessibleVol) #supAvg /= (1.0*accessibleVol) weights = supBins / pl.sum(supBins) supAvg *= weights supStd *= weights supPart = pl.sum(supAvg) supPartErr = pl.sum(supStd) Supers = pl.append(Supers, supPart) SuperErrs = pl.append(SuperErrs, supPartErr) os.chdir('..') # Sort data in order of increasing chemical potential. # This is another bit of magical Python juju. Vs, Films, Bulks, filmErrs, bulkErrs, Omegas, omegaErrs,\ NumParts, NumPartErrs, Supers, SuperErrs = pl.asarray( zip(*sorted(zip(Vs, Films, Bulks, filmErrs, bulkErrs, Omegas, omegaErrs, NumParts, NumPartErrs, Supers, SuperErrs)))) pl.figure(1) pl.errorbar(Vs, Films, filmErrs, fmt=Markers[nT], color=colors[nS], label=labell + ', 2d', markersize=8) pl.errorbar(Vs, Bulks, bulkErrs, fmt=Markers[nT], mec=colors[nS], label=labell + ', 3d', mfc='None', markersize=8) pl.figure(2) pl.errorbar(Vs, Bulks, bulkErrs, fmt=Markers[nT], color=colors[nS], label=labell, markersize=8) pl.figure(3) pl.errorbar(Vs, Films * projArea, fmt=Markers[nT], color=colors[nS], label=labell, markersize=8) pl.figure(4) pl.errorbar(Vs, Omegas, omegaErrs, fmt=Markers[nT], color=colors[nS], label=labell, markersize=8) pl.figure(5) pl.errorbar(Vs, Films, filmErrs, fmt=Markers[nT], color=colors[nS], label=labell, markersize=8) pl.figure(6) pl.errorbar(Vs, Supers, SuperErrs, fmt=Markers[nT], color=colors[nS], label=labell, markersize=8) pl.figure(7) ax7a.errorbar(Vs, Films, filmErrs, fmt=Markers[nT], color=colors[nS], label=shortlabell, markersize=8) ax7b.errorbar(Vs, Bulks, bulkErrs, fmt=Markers[nT], color=colors[nS], label=shortlabell, markersize=8) pl.figure(8) pl.errorbar(Vs, Bulks * bulkVol, bulkErrs * bulkVol, fmt=Markers[nT], color=colors[nS], label=labell, markersize=8) os.chdir('..') os.chdir('..') pl.figure(1) pl.legend(loc=1) pl.tight_layout() pl.figure(2) pl.legend(loc=1) pl.tight_layout() pl.figure(3) pl.legend(loc=1) pl.tight_layout() pl.figure(4) pl.legend(loc=1) pl.tight_layout() pl.figure(5) pl.legend(loc=1) pl.tight_layout() pl.figure(6) pl.legend(loc=1) pl.tight_layout() pl.figure(7) pl.legend(loc=1, bbox_to_anchor=(1., 2.1)) major_formatter = FuncFormatter(my_formatter) ax7a.yaxis.set_major_formatter(major_formatter) pl.tight_layout() if savePDF: pl.savefig('Bulk_Film_Dens_vs_Vshift_allS_allT_18APR.pdf', format='pdf', bbox_inches='tight') pl.figure(8) pl.legend(loc=1) pl.tight_layout() pl.show()
def main(): args = parseCMD() Temp = args.Temperature Lx = 12.0 Ly = 12.0 az = 47.5 ay = 2.0 Svals = glob.glob('S*') # define some plotting colors colors = ['Salmon','Blue','DarkViolet','MediumSpringGreen','Fuchsia', 'Yellow','Maroon'] # set up figure that displays all data figg = pl.figure(1) ax = figg.add_subplot(111) pl.xlabel(r'$\mu\ [K]$', fontsize=20) pl.ylabel('Spatial Density '+r'$[\si{\angstrom}^{-d}]$', fontsize=20) pl.grid(True) #pl.xlim([0.5,3.0]) #pl.ylim([0,0.07]) pl.tick_params(axis='both', which='major', labelsize=16) pl.tick_params(axis='both', which='minor', labelsize=16) yticks = ax.yaxis.get_major_ticks() yticks[0].set_visible(False) # set up bulk SVP densities for plot bulkVert = -30 minMus = -3.0 maxMus = 5.0 boxSubtract = 1.6 pl.plot([minMus, maxMus], [0.02198, 0.02198], 'k-', lw=3) pl.annotate('3d SVP', xy=(maxMus - boxSubtract, 0.02195), #xycoords='data', xytext=(-50, bulkVert), textcoords='offset points', bbox=dict(boxstyle="round", fc="0.8"), arrowprops=dict(arrowstyle="->", connectionstyle="angle,angleA=0,angleB=90,rad=10"), ) pl.plot([minMus, maxMus], [0.0432, 0.0432], 'k-', lw=3) pl.annotate('2d SVP', xy=(maxMus - boxSubtract, 0.0432), #xycoords='data', xytext=(-50, 30), textcoords='offset points', bbox=dict(boxstyle="round", fc="0.8"), arrowprops=dict(arrowstyle="->", connectionstyle="angle,angleA=0,angleB=90,rad=10"), ) solidDens = True if solidDens: pl.plot([minMus, maxMus], [0.0248, 0.0248], 'k-', lw=3) pl.annotate('HCP solid SVP', xy=(maxMus - boxSubtract, 0.0248), #xycoords='data', xytext=(-50, 30), textcoords='offset points', bbox=dict(boxstyle="round", fc="0.8"), arrowprops=dict(arrowstyle="->", connectionstyle="angle,angleA=0,angleB=90,rad=10"), ) # plot just the bulk density as a function of chemical potential figg2 = pl.figure(2) ax2 = figg2.add_subplot(111) pl.xlabel(r'$\mu\ [K]$', fontsize=20) pl.ylabel('Spatial Density '+r'$[\si{\angstrom}^{-d}]$', fontsize=20) pl.grid(True) #pl.xlim([0.5,3.0]) #pl.ylim([0,0.07]) pl.tick_params(axis='both', which='major', labelsize=16) pl.tick_params(axis='both', which='minor', labelsize=16) yticks = ax.yaxis.get_major_ticks() yticks[0].set_visible(False) # set up bulk SVP densities for plot bulkVert = -30 minMus = -3.0 maxMus = 5.0 boxSubtract = 1.6 pl.plot([minMus, maxMus], [0.02198, 0.02198], 'k-', lw=3) pl.annotate('3d SVP', xy=(maxMus - boxSubtract, 0.02195), #xycoords='data', xytext=(-50, bulkVert), textcoords='offset points', bbox=dict(boxstyle="round", fc="0.8"), arrowprops=dict(arrowstyle="->", connectionstyle="angle,angleA=0,angleB=90,rad=10"), ) # number of particles in film region vs chemical potential pl.figure(3) pl.xlabel(r'$\mu\ [K]$', fontsize=20) pl.ylabel('Number of Particles', fontsize=20) pl.grid(True) #pl.xlim([0.5,3.0]) #pl.ylim([0,2]) pl.tick_params(axis='both', which='major', labelsize=16) pl.tick_params(axis='both', which='minor', labelsize=16) yticks = ax.yaxis.get_major_ticks() yticks[0].set_visible(False) # normalized angular winding vs chemical potential pl.figure(4) pl.xlabel(r'$\mu\ [K]$', fontsize=20) pl.ylabel(r'$\Omega$', fontsize=20) pl.grid(True) pl.tick_params(axis='both', which='major', labelsize=16) pl.tick_params(axis='both', which='minor', labelsize=16) yticks = ax.yaxis.get_major_ticks() yticks[0].set_visible(False) # actual density in cell pl.figure(5) pl.xlabel(r'$\mu\ [K]$', fontsize=20) pl.ylabel(r'$\rho\ [\si{\angstrom}^{-3}]$', fontsize=20) pl.grid(True) pl.tick_params(axis='both', which='major', labelsize=16) pl.tick_params(axis='both', which='minor', labelsize=16) yticks = ax.yaxis.get_major_ticks() yticks[0].set_visible(False) # --- loop through known directory structure ------------------------------ for nS, Sval in enumerate(sorted(Svals)): os.chdir(Sval) # get bipartition file name f = glob.glob('*Bipart*')[0] # get angular winding file name fw = glob.glob('*Ntwind*')[0] # get estimator file name (includes total number) fe = glob.glob('*Estimator*')[0] # store bulk separation value S = re.search(r'\d+',Sval).group(0) # get label for plot if 'distinguishable' in Sval: labell = 'S = '+str(S)+', Boltzmannons' else: labell = 'S = '+str(S)+', Bosons' # projected area of film region projArea = float(S)*Lx # accessible volume in cell accessibleVol = Lx*Ly*(2.0*az+float(S)) - Lx*float(S)*(Ly-2.0*ay) # multiply angular winding by normalization to be fixed in code later omegaNorm = 4.0*(float(S)+1.0*Ly)**2 # get chemical potential headers = getHeadersFromFile(f) mus = pl.array([]) Films = pl.array([]) Bulks = pl.array([]) filmErrs = pl.array([]) bulkErrs = pl.array([]) Omegas = pl.array([]) omegaErrs = pl.array([]) NumParts = pl.array([]) NumPartErrs = pl.array([]) n = 0 nw = 3 nn = 12 for head in headers: # get values of chemical potential from file header mus = pl.append(mus, float(head)) # --- Densities --------------------------------------------------- filmavg,filmstd,filmbins,bulkavg,bulkstd,bulkbins = pl.genfromtxt(f, unpack=True, usecols=(n,n+1,n+2,n+3,n+4,n+5), delimiter=',') n += 6 # get rid of any items which are not numbers.. # this is some beautiful Python juju. filmbins = filmbins[pl.logical_not(pl.isnan(filmbins))] filmstd = filmstd[pl.logical_not(pl.isnan(filmstd))] filmavg = filmavg[pl.logical_not(pl.isnan(filmavg))] bulkbins = bulkbins[pl.logical_not(pl.isnan(bulkbins))] bulkstd = bulkstd[pl.logical_not(pl.isnan(bulkstd))] bulkavg = bulkavg[pl.logical_not(pl.isnan(bulkavg))] filmweights = filmbins/pl.sum(filmbins) bulkweights = bulkbins/pl.sum(bulkbins) filmavg *= filmweights bulkavg *= bulkweights filmstd *= filmweights bulkstd *= bulkweights film = pl.sum(filmavg) bulk = pl.sum(bulkavg) filmstdErr = pl.sum(filmstd) bulkstdErr = pl.sum(bulkstd) Films = pl.append(Films, film) Bulks = pl.append(Bulks, bulk) filmErrs = pl.append(filmErrs, filmstdErr) bulkErrs = pl.append(bulkErrs, bulkstdErr) # ---- angular winding -------------------------------------------- omegaAvg,omegaStd,omegaBins = pl.genfromtxt(fw, unpack=True, usecols=(nw,nw+1,nw+2), delimiter=',') nw += 9 # get rid of any items which are not numbers.. omegaBins = omegaBins[pl.logical_not(pl.isnan(omegaBins))] omegaStd = omegaStd[pl.logical_not(pl.isnan(omegaStd))] omegaAvg = omegaAvg[pl.logical_not(pl.isnan(omegaAvg))] # normalize data. omegaStd *= omegaNorm omegaAvg *= omegaNorm weights = omegaBins/pl.sum(omegaBins) omegaAvg *= weights omegaStd *= weights Omega = pl.sum(omegaAvg) omegaErr = pl.sum(omegaStd) Omegas = pl.append(Omegas, Omega) omegaErrs = pl.append(omegaErrs, omegaErr) # ---- total number ----------------------------------------------- numAvg,numStd,numBins = pl.genfromtxt(fe, unpack=True, usecols=(nn,nn+1,nn+2), delimiter=',') nn += 15 # get rid of any items which are not numbers.. numBins = numBins[pl.logical_not(pl.isnan(numBins))] numStd = numStd[pl.logical_not(pl.isnan(numStd))] numAvg = numAvg[pl.logical_not(pl.isnan(numAvg))] # normalize data. numStd /= (1.0*accessibleVol) numAvg /= (1.0*accessibleVol) weights = numBins/pl.sum(numBins) numAvg *= weights numStd *= weights numPart = pl.sum(numAvg) numPartErr = pl.sum(numStd) NumParts = pl.append(NumParts, numPart) NumPartErrs = pl.append(NumPartErrs, numPartErr) # Sort data in order of increasing chemical potential. I love Python. # This is another bit of magical Python juju. mus, Films, Bulks, filmErrs, bulkErrs, Omegas, omegaErrs, NumParts, NumPartErrs = pl.asarray( zip(*sorted(zip(mus, Films, Bulks, filmErrs, bulkErrs, Omegas, omegaErrs, NumParts, NumPartErrs)))) pl.figure(1) pl.errorbar(mus, Films, filmErrs, fmt='--o', color=colors[nS], label=labell+', 2d', markersize=8) pl.errorbar(mus, Bulks, bulkErrs, fmt = '-d', color=colors[nS], label=labell+', 3d', markersize=8) pl.figure(2) pl.errorbar(mus, Bulks, bulkErrs, fmt = '-d', color=colors[nS], label=labell+', 3d', markersize=8) pl.figure(3) pl.errorbar(mus, Films*projArea, fmt='-o', color=colors[nS], label = labell+', 2d', markersize=8) pl.figure(4) pl.errorbar(mus, Omegas, omegaErrs, fmt='-o', color=colors[nS], label = labell, markersize=8) pl.figure(5) pl.errorbar(mus, NumParts, NumPartErrs, fmt='-o', color=colors[nS], label = labell, markersize=8) os.chdir('..') pl.figure(1) pl.legend(loc=2) pl.savefig('densities_vs_chemicalPotential_allS_1APR.pdf', format='pdf', bbox_inches='tight') pl.figure(2) pl.legend(loc=2) pl.figure(3) pl.legend(loc=2) pl.figure(4) pl.legend(loc=2) pl.figure(5) pl.legend(loc=2) pl.show()
def main(): savePDF = True solidDens = False Lx = 12.0 Ly = 12.0 az = 47.5 ay = 2.0 bulkVol = 2.0*Lx*Ly*az lowX7 = -6.0 #lowX7 = -4.0 # boltzmannons highX7 = 2.9 #highX7 = 2.5 # boltzmannons # define some plotting colors colors = ['Navy','DarkViolet','MediumSpringGreen','Salmon','Fuchsia', 'Yellow','Maroon','Salmon','Blue'] # ------------------------------------------------------------------------- # bulk and film density on same plot figg = pl.figure(1) ax = figg.add_subplot(111) pl.xlabel(r'$\text{Potential Shift}\ [K]$', fontsize=20) pl.ylabel('Spatial Density '+r'$[\si{\angstrom}^{-d}]$', fontsize=20) pl.grid(True) pl.xlim([-5.5,3.5]) #pl.ylim([0,0.07]) pl.tick_params(axis='both', which='major', labelsize=16) pl.tick_params(axis='both', which='minor', labelsize=16) yticks = ax.yaxis.get_major_ticks() yticks[0].set_visible(False) # bulk SVP density line bulkVert = -30 minMus = -5.5 maxMus = 2.0 boxSubtract = 1.6 pl.plot([minMus, maxMus], [0.02198, 0.02198], 'k-', lw=3) pl.annotate('3d SVP', xy=(maxMus - boxSubtract, 0.02195), #xycoords='data', xytext=(-10, bulkVert), textcoords='offset points', bbox=dict(boxstyle="round", fc="0.8"), arrowprops=dict(arrowstyle="->", connectionstyle="angle,angleA=0,angleB=90,rad=10"), ) # film SVP density line pl.plot([minMus, maxMus], [0.0432, 0.0432], 'k-', lw=3) pl.annotate('2d SVP', xy=(maxMus - boxSubtract, 0.0432), #xycoords='data', xytext=(30, -30), textcoords='offset points', bbox=dict(boxstyle="round", fc="0.8"), arrowprops=dict(arrowstyle="->", connectionstyle="angle,angleA=0,angleB=90,rad=10"), ) if solidDens: pl.plot([minMus, maxMus], [0.0248, 0.0248], 'k-', lw=3) pl.annotate('HCP solid SVP', xy=(maxMus - boxSubtract, 0.0248), #xycoords='data', xytext=(-10, 30), textcoords='offset points', bbox=dict(boxstyle="round", fc="0.8"), arrowprops=dict(arrowstyle="->", connectionstyle="angle,angleA=0,angleB=90,rad=10"), ) # ------------------------------------------------------------------------- # bulk density figg2 = pl.figure(2) ax2 = figg2.add_subplot(111) pl.xlabel(r'$\text{Potential Shift}\ [K]$', fontsize=20) pl.ylabel('Bulk Density '+r'$[\si{\angstrom}^{-3}]$', fontsize=20) pl.grid(True) pl.xlim([-5.5,0.5]) pl.tick_params(axis='both', which='major', labelsize=16) pl.tick_params(axis='both', which='minor', labelsize=16) yticks = ax.yaxis.get_major_ticks() yticks[0].set_visible(False) # set up bulk SVP densities for plot bulkVert = 30 # changes text box above (positive) or below (negative) line boxSubtract = 1.6 pl.plot([minMus, maxMus], [0.02198, 0.02198], 'k-', lw=3) pl.annotate('3d SVP', xy=(maxMus - boxSubtract, 0.02198), #xycoords='data', xytext=(-50, bulkVert), textcoords='offset points', bbox=dict(boxstyle="round", fc="0.8"), arrowprops=dict(arrowstyle="->", connectionstyle="angle,angleA=0,angleB=90,rad=10"), ) # ------------------------------------------------------------------------- # number of particles in film region pl.figure(3) pl.xlabel(r'$\text{Potential Shift}\ [K]$', fontsize=20) pl.ylabel(r'$N_{\text{film}}$', fontsize=20) pl.grid(True) pl.tick_params(axis='both', which='major', labelsize=16) pl.tick_params(axis='both', which='minor', labelsize=16) yticks = ax.yaxis.get_major_ticks() yticks[0].set_visible(False) # ------------------------------------------------------------------------- # normalized angular winding pl.figure(4) pl.xlabel(r'$\text{Potential Shift}\ [K]$', fontsize=20) pl.ylabel(r'$\Omega$', fontsize=20) pl.grid(True) pl.tick_params(axis='both', which='major', labelsize=16) pl.tick_params(axis='both', which='minor', labelsize=16) yticks = ax.yaxis.get_major_ticks() yticks[0].set_visible(False) # ------------------------------------------------------------------------- # film density figg5 = pl.figure(5) ax5 = figg5.add_subplot(111) pl.xlabel(r'$\text{Potential Shift}\ [K]$', fontsize=20) pl.ylabel(r'$\text{Film Density}\ [\si{\angstrom}^{-2}]$', fontsize=20) pl.ylim([0.03,0.05]) pl.xlim([-5.5,0.5]) pl.grid(True) pl.tick_params(axis='both', which='major', labelsize=16) pl.tick_params(axis='both', which='minor', labelsize=16) yticks = ax.yaxis.get_major_ticks() yticks[0].set_visible(False) # film SVP density line pl.plot([lowX7, highX7], [0.0432, 0.0432], 'k-', lw=3) pl.annotate('2d SVP', xy=(-4, 0.0432), #xycoords='data', xytext=(30, -30), textcoords='offset points', bbox=dict(boxstyle="round", fc="0.8"), arrowprops=dict(arrowstyle="->", connectionstyle="angle,angleA=0,angleB=90,rad=10"), ) # ------------------------------------------------------------------------- # superfluid fraction pl.figure(6) pl.xlabel(r'$\text{Potential Shift}\ [K]$', fontsize=20) pl.ylabel(r'$\rho_S/\rho$', fontsize=20) pl.grid(True) pl.xlim([-5.5,0.5]) pl.tick_params(axis='both', which='major', labelsize=16) pl.tick_params(axis='both', which='minor', labelsize=16) yticks = ax.yaxis.get_major_ticks() yticks[0].set_visible(False) # ------------------------------------------------------------------------- # film/bulk densities subplot pl.figure(7) ax7a = pl.subplot(211) pl.ylabel(r'$\text{Film Density}\ [\si{\angstrom}^{-2}]$', fontsize=20) pl.ylim([0.035,0.05]) pl.grid(True) pl.tick_params(axis='both', which='major', labelsize=16) pl.tick_params(axis='both', which='minor', labelsize=16) yticks = ax.yaxis.get_major_ticks() yticks[0].set_visible(False) # film SVP density line pl.plot([lowX7, highX7], [0.0432, 0.0432], 'k-', lw=3) pl.annotate('2d SVP', xy=(-2, 0.0432), #xycoords='data', xytext=(30, -30), textcoords='offset points', bbox=dict(boxstyle="round", fc="0.8"), arrowprops=dict(arrowstyle="->", connectionstyle="angle,angleA=0,angleB=90,rad=10"), ) pl.setp(ax7a.get_xticklabels(), visible=False) ax7b = pl.subplot(212, sharex=ax7a) pl.xlabel(r'$\text{Potential Shift}\ [K]$', fontsize=20) pl.ylabel('Bulk Density '+r'$[\si{\angstrom}^{-3}]$', fontsize=20) pl.grid(True) pl.xlim([lowX7,highX7]) pl.tick_params(axis='both', which='major', labelsize=16) pl.tick_params(axis='both', which='minor', labelsize=16) yticks = ax7b.yaxis.get_major_ticks() yticks[0].set_visible(False) # set up bulk SVP densities for plot bulkVert = 15 # changes text box above (positive) or below (negative) line boxSubtract = 1.6 pl.plot([lowX7, highX7], [0.02198, 0.02198], 'k-', lw=3) pl.annotate('3d SVP', xy=(1.2, 0.02198), #xycoords='data', xytext=(-50, bulkVert), textcoords='offset points', bbox=dict(boxstyle="round", fc="0.8"), arrowprops=dict(arrowstyle="->", connectionstyle="angle,angleA=0,angleB=90,rad=10"), ) # ------------------------------------------------------------------------- # number of particles in bulk pl.figure(8) pl.xlabel(r'$\text{Potential Shift}\ [K]$', fontsize=20) pl.ylabel(r'$N_{\text{bulk}}$', fontsize=20) pl.grid(True) pl.xlim([-5.5,0.5]) pl.tick_params(axis='both', which='major', labelsize=16) pl.tick_params(axis='both', which='minor', labelsize=16) yticks = ax.yaxis.get_major_ticks() yticks[0].set_visible(False) # ------------------------------------------------------------------------- Tvals = glob.glob('*T*') Markers = ['-o','-d','-*'] for nT,Tval in enumerate(sorted(Tvals)): os.chdir(Tval) T = Tval[1:] Svals = glob.glob('S*') # --- loop through known directory structure -------------------------- for nS,Sval in enumerate(sorted(Svals)): os.chdir(Sval) Vdirs = glob.glob('*V*') print os.getcwd() # store bulk separation value S = re.search(r'\d+',Sval).group(0) # get label for plot if 'distinguishable' in Sval: labell = 'S = '+str(S)+', Boltzmannons, T='+str(T) else: labell = 'S = '+str(S)+', Bosons, T='+str(T) shortlabell = 'S = '+str(S)+', T='+str(T) # projected area of film region projArea = float(S)*Lx # accessible volume in cell #accessibleVol = Lx*(Ly*(float(S)+2.0*az) - float(S)*(Ly-2.0*ay)) accessibleVol = 2.0*Lx*Ly*az + 2.0*ay*Lx*float(S) # multiply angular winding by norm. to be fixed in code later omegaNorm = 4.0*(float(S)+1.0*Ly)**2 # Arrays to hold all data Vs = pl.array([]) Films = pl.array([]) Bulks = pl.array([]) filmErrs = pl.array([]) bulkErrs = pl.array([]) Omegas = pl.array([]) omegaErrs = pl.array([]) NumParts = pl.array([]) NumPartErrs = pl.array([]) Supers = pl.array([]) SuperErrs = pl.array([]) # pass potential shift directories for current S value for Vdir in Vdirs: os.chdir(Vdir) # get bipartition file name f = glob.glob('*Bipart*')[0] # get angular winding file name fw = glob.glob('*Ntwind*')[0] # get estimator file name (includes total number) fe = glob.glob('*Estimator*')[0] # get superfrac file name fs = glob.glob('*Super*')[0] # build array of film potential shifts from directory names Vs = pl.append(Vs,float(Vdir[1:])) # --- Densities ----------------------------------------------- filmavg,filmstd,filmbins,bulkavg,bulkstd,bulkbins = pl.genfromtxt(f, unpack=True, usecols=(0,1,2,3,4,5), delimiter=',') # get rid of any items which are not numbers.. # this is some beautiful Python juju. filmbins = filmbins[pl.logical_not(pl.isnan(filmbins))] filmstd = filmstd[pl.logical_not(pl.isnan(filmstd))] filmavg = filmavg[pl.logical_not(pl.isnan(filmavg))] bulkbins = bulkbins[pl.logical_not(pl.isnan(bulkbins))] bulkstd = bulkstd[pl.logical_not(pl.isnan(bulkstd))] bulkavg = bulkavg[pl.logical_not(pl.isnan(bulkavg))] filmweights = filmbins/pl.sum(filmbins) bulkweights = bulkbins/pl.sum(bulkbins) filmavg *= filmweights bulkavg *= bulkweights filmstd *= filmweights bulkstd *= bulkweights film = pl.sum(filmavg) bulk = pl.sum(bulkavg) filmstdErr = pl.sum(filmstd) bulkstdErr = pl.sum(bulkstd) Films = pl.append(Films, film) Bulks = pl.append(Bulks, bulk) filmErrs = pl.append(filmErrs, filmstdErr) bulkErrs = pl.append(bulkErrs, bulkstdErr) # ---- angular winding ---------------------------------------- omegaAvg,omegaStd,omegaBins = pl.genfromtxt(fw, unpack=True, usecols=(3,4,5), delimiter=',') # get rid of any items which are not numbers.. omegaBins = omegaBins[pl.logical_not(pl.isnan(omegaBins))] omegaStd = omegaStd[pl.logical_not(pl.isnan(omegaStd))] omegaAvg = omegaAvg[pl.logical_not(pl.isnan(omegaAvg))] # normalize data. omegaStd *= omegaNorm omegaAvg *= omegaNorm weights = omegaBins/pl.sum(omegaBins) omegaAvg *= weights omegaStd *= weights Omega = pl.sum(omegaAvg) omegaErr = pl.sum(omegaStd) Omegas = pl.append(Omegas, Omega) omegaErrs = pl.append(omegaErrs, omegaErr) # ---- total number ------------------------------------------- numAvg,numStd,numBins = pl.genfromtxt(fe, unpack=True, usecols=(12,13,14), delimiter=',') # get rid of any items which are not numbers.. numBins = numBins[pl.logical_not(pl.isnan(numBins))] numStd = numStd[pl.logical_not(pl.isnan(numStd))] numAvg = numAvg[pl.logical_not(pl.isnan(numAvg))] weights = numBins/pl.sum(numBins) numAvg *= weights numStd *= weights numPart = pl.sum(numAvg) numPartErr = pl.sum(numStd) NumParts = pl.append(NumParts, numPart) NumPartErrs = pl.append(NumPartErrs, numPartErr) # ---- superfluid fraction ------------------------------------ supAvg,supStd,supBins = pl.genfromtxt(fs, unpack=True, usecols=(0,1,2), delimiter=',') # get rid of any items which are not numbers.. supBins = supBins[pl.logical_not(pl.isnan(supBins))] supStd = supStd[pl.logical_not(pl.isnan(supStd))] supAvg = supAvg[pl.logical_not(pl.isnan(supAvg))] # normalize data. #supStd /= (1.0*accessibleVol) #supAvg /= (1.0*accessibleVol) weights = supBins/pl.sum(supBins) supAvg *= weights supStd *= weights supPart = pl.sum(supAvg) supPartErr = pl.sum(supStd) Supers = pl.append(Supers, supPart) SuperErrs = pl.append(SuperErrs, supPartErr) os.chdir('..') # Sort data in order of increasing chemical potential. # This is another bit of magical Python juju. Vs, Films, Bulks, filmErrs, bulkErrs, Omegas, omegaErrs,\ NumParts, NumPartErrs, Supers, SuperErrs = pl.asarray( zip(*sorted(zip(Vs, Films, Bulks, filmErrs, bulkErrs, Omegas, omegaErrs, NumParts, NumPartErrs, Supers, SuperErrs)))) pl.figure(1) pl.errorbar(Vs, Films, filmErrs, fmt=Markers[nT], color=colors[nS], label=labell+', 2d', markersize=8) pl.errorbar(Vs, Bulks, bulkErrs, fmt=Markers[nT], mec=colors[nS], label=labell+', 3d', mfc='None', markersize=8) pl.figure(2) pl.errorbar(Vs, Bulks, bulkErrs, fmt = Markers[nT], color=colors[nS], label=labell, markersize=8) pl.figure(3) pl.errorbar(Vs, Films*projArea, fmt=Markers[nT], color=colors[nS], label = labell, markersize=8) pl.figure(4) pl.errorbar(Vs, Omegas, omegaErrs, fmt=Markers[nT], color=colors[nS], label = labell, markersize=8) pl.figure(5) pl.errorbar(Vs, Films, filmErrs, fmt=Markers[nT], color=colors[nS], label = labell, markersize=8) pl.figure(6) pl.errorbar(Vs, Supers, SuperErrs, fmt=Markers[nT], color=colors[nS], label = labell, markersize=8) pl.figure(7) ax7a.errorbar(Vs, Films, filmErrs, fmt=Markers[nT], color=colors[nS], label=shortlabell, markersize=8) ax7b.errorbar(Vs, Bulks, bulkErrs, fmt = Markers[nT], color=colors[nS], label=shortlabell, markersize=8) pl.figure(8) pl.errorbar(Vs, Bulks*bulkVol, bulkErrs*bulkVol, fmt = Markers[nT], color=colors[nS], label=labell, markersize=8) os.chdir('..') os.chdir('..') pl.figure(1) pl.legend(loc=1) pl.tight_layout() pl.figure(2) pl.legend(loc=1) pl.tight_layout() pl.figure(3) pl.legend(loc=1) pl.tight_layout() pl.figure(4) pl.legend(loc=1) pl.tight_layout() pl.figure(5) pl.legend(loc=1) pl.tight_layout() pl.figure(6) pl.legend(loc=1) pl.tight_layout() pl.figure(7) pl.legend(loc=1,bbox_to_anchor=(1.,2.1)) major_formatter = FuncFormatter(my_formatter) ax7a.yaxis.set_major_formatter(major_formatter) pl.tight_layout() if savePDF: pl.savefig('Bulk_Film_Dens_vs_Vshift_allS_allT_18APR.pdf', format='pdf', bbox_inches='tight') pl.figure(8) pl.legend(loc=1) pl.tight_layout() pl.show()