def pickle_ss(args): from readss import unpackxdr import cPickle as cpk f = open(args[0], 'w') #open the file to store pickled data in print('Opened, destination file {0}'.format(args[0])) for ssfile in args[1:]: data_chunk = unpackxdr(ssfile) #read in ssdata from file cpk.dump(data_chunk, f, cpk.HIGHEST_PROTOCOL) #dump the data in the pickle file print('Data pickled...') f.close() print('All data pickled, closed file {0}'.format(args[0]))
from unpickle_chunk import unpickle_chunk import sys, os, math if len(sys.argv)>2: outpath = sys.argv[-1] else: outpath = None E_list = [] if '.dat' in sys.argv[1]: for data_chunk in unpickle_chunk(sys.argv[1]): E_list.append(plot_energy(data_chunk)) #get data for plot #print('Energy of system is {0}'.format(E_list)) else: for data_chunk in [unpackxdr(sys.argv[1:-1])]: E_list.append(plot_energy(data_chunk)) #get data for plot #print('Energy of system is {0}'.format(E_list)) E_list.sort() #sorts by first number in tuple (time) plt.plot([x[0] for x in E_list], [y[1] for y in E_list], 'g-', label='Total Energy')#total energy plt.plot([x[0] for x in E_list], [y[2] for y in E_list], 'r--', label='Planetesimal Energy') #planetesimal energy plt.plot([x[0] for x in E_list], [y[3] for y in E_list], 'b--', label='Jupiter Energy') #jupiter energy #plot the data, 'zorder=0' makes sure that it is drawn first and everything else is on top of it #plt.axis([0,5,0,1]) plt.legend() plt.ticklabel_format(axis='y', scilimits=(-3,3)) #put in lables and titles etc plt.title('Total energy of system') plt.xlabel('Time (Years)')
#!/Library/Frameworks/Python.framework/Versions/Current/bin//python if __name__=="__main__": import sys, os import numpy as np from readss import unpackxdr #assume all files are ss files, output to terminal for arg in sys.argv[1:]: print("file:", arg) #tell filename data = unpackxdr(arg) print("total mass:", np.sum([plist[0] for plist in data[0]]))
from unpickle_chunk import unpickle_chunk import sys, os, math ''' All passed arguments except the last one are assumed to be data files. therefore wildcards are placed before the destination folder. e.g. eVa_graph.py thefiles* ./destination_folder/ ''' if len(sys.argv)>2: outpath = sys.argv[-1] max = -1 else: outpath = None max = 2 if '.dat' in sys.argv[1]: for data_chunk in unpickle_chunk(sys.argv[1]): ident_string = 'ss.{0:05.0f}'.format(data_chunk[1]) outname = os.path.join(outpath,ident_string+'.png') plot_RV(data_chunk, outfname=outname) else: for arg in sys.argv[1:max]: data_chunk = unpackxdr(arg) ident_string = 'ss.{0:05.0f}'.format(data_chunk[1]) if outpath != None: outname = os.path.join(outpath,ident_string+'.png') else: outname = None plot_RV(data_chunk, outfname=outname)
for planet in special: if in_3hillsph(pdata, planet): del_list.append(pdata) return(del_list) def is_planet(colour): #5,2,11,6,7 if colour==5 or colour==2 or colour==11 or colour==6 or colour==7: return(True) else: return(False) if __name__=='__main__': """ This is just to verify initial conditions and remove anything overlapping/unwanted or perform some other feat of initial condition poking """ from readss import unpackxdr, packxdr import sys, os del_list = [] data = [] ssfile = sys.argv[1] data = unpackxdr(ssfile) #data = remove_overlaps(data) del_list = sculpt_sphere(data) print([x[6] for x in del_list]) packxdr(sys.argv[2], data ,[x[6] for x in del_list])
if not os.path.exists(os.path.join(outfolder,label)): #make the second level folders if they don't exist os.mkdir(os.path.join(outfolder,label)) if function in alltimedict: #if graph is using data from entire time series, #create a temporary storage file outname=os.path.join(outfolder,label,'temp') else: #if graph is made new each time, stamp graph name with #timestamp outname = os.path.join(outfolder,label,ident_string+'.png') #execute the function that creates the graph/datapoint function(data_chunk, outfname=outname) else: for arg in sys.argv[1:-1]: for data_chunk in [unpackxdr(arg)]: #create identity string for each graph (timestamp) #time from these files is in "system time" in units of years*2*pi #therefore need to divide by 2*pi to make numbers correct ident_string = 'ss.{0:08.3f}'.format(s2s.year(data_chunk[1])) for label, function in graphlist: #each set of graphs draws to different figures plt.figure(graphlist.index((label,function))) if not os.path.exists(os.path.join(outfolder,label)): #make the second level folders if they don't exist os.mkdir(os.path.join(outfolder,label)) if function in alltimedict: #if graph is using data from entire time series, #create a temporary storage file outname=os.path.join(outfolder,label,'temp') else: