def BedPlotAutomator(Dirname): # This is used to tell the model we want a profile perpendicular to shore axis = 1 for fname in glob(Dirname+"*_BedElev.asc"): # first we need the filename without the path NoDirFname = LSDOst.GetFileNameNoPath(fname) print "fname is: "+ NoDirFname # Now get the prefix of the file splitfname = NoDirFname.split('_BedElev.asc') fprefix = splitfname[0] ElevationSwaths(Dirname, NoDirFname, axis, fprefix) # now do the bed thickness for fname in glob(Dirname+"*_BedThick.asc"): # first we need the filename without the path NoDirFname = LSDOst.GetFileNameNoPath(fname) print "fname is: "+ NoDirFname # Now get the prefix of the file splitfname = NoDirFname.split('_BedThick.asc') fprefix = splitfname[0] ElevationSwaths(Dirname, NoDirFname, axis, fprefix)
def CopyRequiredFilesToGitRepository(ObjectsDirectory,DriverDirectory,TargetDirectory): # Ensure the directories exist ObjectsDirectory,DriverDirectory,TargetDirectory,TargetDriverDirectory = CheckFileStructuresForCopy(ObjectsDirectory,DriverDirectory,TargetDirectory) # Now get the required files print "\n\n\n=================================" required_files_noduplicates = GetRequiredFilesFromFolder(DriverDirectory) print "The required files are: " print required_files_noduplicates print "=================================" # loop through these files, collecting the filenames and directory names # first you need to know what directory level the driver files are in print "\n\n\n======================================" n_level_of_driver_directory = LSDost.GetPathLevel(DriverDirectory) for FileName in required_files_noduplicates: # you need to know what level the file is ThisPath = LSDost.GetPath(FileName) ThisLevel = LSDost.GetPathLevel(ThisPath) #if it is the same level as the driver directory, it is in the driver directory! if ThisLevel == n_level_of_driver_directory: CopyDirectory = TargetDriverDirectory CopyFileName = LSDost.GetFileNameNoPath(FileName) CopyFileNameWithPath = CopyDirectory+CopyFileName else: CopyDirectory = TargetDirectory CopyFileName = LSDost.GetFileNameNoPath(FileName) CopyFileNameWithPath = CopyDirectory+CopyFileName print "The filename is: " + FileName print "The copy filename is: " + CopyFileNameWithPath shutil.copy(FileName, CopyFileNameWithPath) # now copy the files over print "=============================================="
def CollatenewCRONUScomparisonCRNData(): #Directory = "C://code//git_papers//crn_basinwide_paper//Compiled_results//Brauch_vs_newCRONUS//" Directory = "T://Papers_LaTeX//crn_basinwide_paper//Compiled_results//Brauch_vs_newCRONUS//" Dirname = LSDost.ReformatSeperators(Directory) Dirname = LSDost.AppendSepToDirectoryPath(Dirname) Fileformat = 'svg' label_size = 8 axis_size = 12 # Set up fonts for plots rcParams['font.family'] = 'sans-serif' rcParams['font.sans-serif'] = ['arial'] rcParams['font.size'] = label_size rcParams['xtick.major.size'] = 4 rcParams['ytick.major.size'] = 4 rcParams['legend.fontsize'] = label_size rcParams['legend.handletextpad'] = 0.05 rcParams['legend.labelspacing'] = 0.1 rcParams['legend.columnspacing'] = 0.1 P_erate_newCRONUS = [] D_erate_newCRONUS = [] P_newCRONUS = [] D_newCRONUS = [] # loop through the directory, getting the results from the data for fname in glob(Dirname + "*_CRNResults.csv"): # get only the file without the data directory NoDirFname = LSDost.GetFileNameNoPath(fname) # Now get the prefix of the file splitfname = NoDirFname.split('_CRNResults.csv') fprefix = splitfname[0] print "File prefix is: " + fprefix # now read in the data thisCRNData = CRNR.CRNResults(fname) # Only get the newCRONUS dethier and Palumbo data # now get the prefixes if "Dethier" in fprefix: if "newCRONUS" in fprefix: D_erate_newCRONUS = thisCRNData.GetErosionRates_mmperkyr_rho2650( ) elif "Palumbo" in fprefix: if "newCRONUS" in fprefix: P_erate_newCRONUS = thisCRNData.GetErosionRates_mmperkyr_rho2650( ) # Convert the data to arrays (to calculate errors) P_nC_CAIRN = np.asarray(P_erate_newCRONUS) D_nC_CAIRN = np.asarray(D_erate_newCRONUS) #print "P CAIRN is: " #print P_nC_CAIRN #print "D CAIRN is: " #print D_nC_CAIRN # Now get the CRONUScalc data print "Entering second glob loop" for fname in glob(Dirname + "*.csv"): print "I found comparison data! Name is " + fname # Now get the CRONUScalc data print "Entering third glob loop" for fname in glob(Dirname + "*Comparison.csv*"): # get only the file without the data directory NoDirFname = LSDost.GetFileNameNoPath(fname) print "I found comparison data! Name is " + NoDirFname # Now get the prefix of the file splitfname = NoDirFname.split('_newCRONUSCAIRNComparison.csv') fprefix = splitfname[0] print "File prefix is: " + fprefix print "I am woking with the dataset: " + fprefix #See if the parameter files exist if os.access(fname, os.F_OK): this_file = open(fname, 'r') lines = this_file.readlines() # get rid fo the first line lines.pop(0) # create the lists for populating with data CAIRN_erate = [] CAIRN_uncert = [] Report_erate = [] Report_uncert = [] newCRONUS_erate = [] newCRONUS_uncert = [] # now get the data into the dict for line in lines: this_line = LSDost.RemoveEscapeCharacters(line) split_line = this_line.split(',') #print split_line[22]+" " +split_line[23] #print split_line CAIRN_erate.append(float(split_line[16])) CAIRN_uncert.append(float(split_line[17])) Report_erate.append(float(split_line[20])) Report_uncert.append(float(split_line[21])) newCRONUS_erate.append(float(split_line[22])) newCRONUS_uncert.append(float(split_line[23])) # now get the prefixes if fprefix == "Dethier": D_newCRONUS = newCRONUS_erate elif fprefix == "Palumbo": P_newCRONUS = newCRONUS_erate #print "P_newCRONUS is: " #print P_newCRONUS #print "D_newCRONUS is: " #print D_newCRONUS P_nC = np.asarray(P_newCRONUS) D_nC = np.asarray(D_newCRONUS) Perr = np.divide(np.subtract(P_nC_CAIRN, P_nC), P_nC) Derr = np.divide(np.subtract(D_nC_CAIRN, D_nC), D_nC) print "The errors are: " print Perr print Derr print P_nC print P_nC_CAIRN # okay, now you should have the errors #=========================================================================== # now make plots based on these data # 3.26 inches = 83 mm, the size of a 1 column figure Fig1 = plt.figure(1, facecolor='white', figsize=(3.26, 3.26)) # generate a 120,90 grid. gs = GridSpec(100, 75, bottom=0.13, left=0.13, right=0.95, top=0.95) ax = Fig1.add_subplot(gs[10:100, 5:95]) ax.plot(P_nC, Perr, "o", markersize=5, color="maroon", label="Palumbo et al., 2010", markeredgewidth=1) ax.plot(D_nC, Derr, "ro", markersize=5, color="lawngreen", label="Dethier et al., 2014", markeredgewidth=1) ax.spines['top'].set_linewidth(1) ax.spines['left'].set_linewidth(1) ax.spines['right'].set_linewidth(1) ax.spines['bottom'].set_linewidth(1) ax.tick_params(axis='both', width=1) #ax.set_ylim([0.02,0.06]) #plt.title('We are not using this in the paper!! Use CRNCAIRNvsnewCRONUS_erates.py instead!') plt.xlabel('$\epsilon_{CRCalc}$ (g cm$^{-2}$ yr$^{-1}$)', fontsize=axis_size) plt.ylabel( '($\epsilon_{CAIRN-CRCalc}$-$\epsilon_{CRCalc}$)/$\epsilon_{CRCalc}$', fontsize=axis_size) #plt.title('Cosmocalc / New_code',fontsize = label_size+6) handles, labels = ax.get_legend_handles_labels() plt.legend() plt.legend(handles, labels, numpoints=1, loc=4, ncol=1, borderaxespad=1.) plt.savefig(Dirname + "CAIRN_newCRONUS_emulator.svg", format=Fileformat)
def CRBERCvsReported(): Dirname = "T://Papers_LaTeX//crn_basinwide_paper//Compiled_results//" #Dirname = "C://basin_data//CosmoPaper//Results//Compiled//" #Fname = "Palumbo*_CompareResults.csv" SiteNames = [] SiteDicts = [] PaperNames = [] PaperColours = [] # loop through the directory, getting the results from the data for fname in glob(Dirname + "*_CompareResults.csv"): # get only the file without the data directory NoDirFname = LSDost.GetFileNameNoPath(fname) # Now get the prefix of the file splitfname = NoDirFname.split('_CompareResults.csv') fprefix = splitfname[0] print "File prefix is: " + fprefix # add to the sitenames list and create a holding dictionary SiteNames.append(fprefix) thisdict = {} # now get the prefixes if fprefix == "Bierman": PaperNames.append("Bierman et al., 2005") PaperColours.append("blue") elif fprefix == "Dethier": PaperNames.append("Dethier et al., 2014") PaperColours.append("lawngreen") elif fprefix == "Kirchner": PaperNames.append("Kirchner et al., 2001") PaperColours.append("yellow") elif fprefix == "Munack": PaperNames.append("Munack et al., 2014") PaperColours.append("orange") elif fprefix == "Scherler": PaperNames.append("Scherler et al., 2014") PaperColours.append("black") elif fprefix == "Safran": PaperNames.append("Safran et al., 2005") PaperColours.append("powderblue") elif fprefix == "Palumbo": PaperNames.append("Palumbo et al., 2010") PaperColours.append("maroon") #See if the parameter files exist if os.access(fname, os.F_OK): this_file = open(fname, 'r') lines = this_file.readlines() # get rid fo the first line lines.pop(0) # create the lists for populating with data BERC_erate = [] BERC_uncert = [] Report_erate = [] Report_uncert = [] BERC_shield = [] Report_shield = [] # now get the data into the dict for line in lines: this_line = LSDost.RemoveEscapeCharacters(line) split_line = this_line.split(',') BERC_erate.append(float(split_line[4])) BERC_uncert.append(float(split_line[5])) Report_erate.append(float(split_line[6])) Report_uncert.append(float(split_line[7])) BERC_shield.append(float(split_line[2])) Report_shield.append(float(split_line[3])) thisdict["BERC_erate"] = BERC_erate thisdict["BERC_uncert"] = BERC_uncert thisdict["Report_erate"] = Report_erate thisdict["Report_uncert"] = Report_uncert thisdict["BERC_shield"] = BERC_shield thisdict["Report_shield"] = Report_shield SiteDicts.append(thisdict) label_size = 8 axis_size = 12 # Set up fonts for plots rcParams['font.family'] = 'sans-serif' rcParams['font.sans-serif'] = ['arial'] rcParams['font.size'] = label_size rcParams['xtick.major.size'] = 4 rcParams['ytick.major.size'] = 4 rcParams['legend.fontsize'] = label_size rcParams['legend.handletextpad'] = 0.02 rcParams['legend.labelspacing'] = 0.1 rcParams['legend.columnspacing'] = 0.05 # now make plots based on these data Fig1 = plt.figure(1, facecolor='white', figsize=(3.26, 3.26)) # generate a 120,90 grid. gs = GridSpec(100, 75, bottom=0.13, left=0.13, right=0.98, top=0.85) ax = Fig1.add_subplot(gs[10:100, 5:75]) #cmap = plt.cm.jet #colo = 0 for index, thisdict in enumerate(SiteDicts): #colo = colo + (1.000/len(SiteDicts)) plt.plot(thisdict['BERC_shield'], thisdict['Report_shield'], "o", markersize=4, color=PaperColours[index], label=PaperNames[index], markeredgewidth=1) #plt.plot(self.CRNData['AvgProdScaling'],self.CRNData['Error_CR'],color=cmap(self.CRNData['basin_relief']),"o", markersize=8 ) #plt.errorbar(datazz['erate_cosmocalc']*10, datazz['erate_cmperkyr']*10, xerr=datazz['error_cosmocalc'], yerr=datazz['error_newcode'], fmt='o',color = cmap(colo)) ax.spines['top'].set_linewidth(1) ax.spines['left'].set_linewidth(1) ax.spines['right'].set_linewidth(1) ax.spines['bottom'].set_linewidth(1) # This gets all the ticks, and pads them away from the axis so that the corners don't overlap ax.tick_params(axis='both', width=1, pad=2) for tick in ax.xaxis.get_major_ticks(): tick.set_pad(3) for tick in ax.yaxis.get_major_ticks(): tick.set_pad(3) plt.xlabel('CAIRN topographic shielding', fontsize=axis_size) plt.ylabel('Reported topographic shielding', fontsize=axis_size) handles, labels = ax.get_legend_handles_labels() plt.legend(handles, labels, numpoints=1, bbox_to_anchor=(0., 1.02, 1., .102), loc=3, ncol=2, mode="expand", borderaxespad=0.) #plt.show() Fileformat = "svg" plt.savefig(Dirname + "CAIRN_vs_Reported_toposhield.svg", format=Fileformat)
def CRONUS_diff_params(): #Directory = "C://basin_data//CosmoPaper//Results//Compiled//" Directory = "T://Papers_LaTeX//crn_basinwide_paper//Compiled_results//" Dirname = LSDost.ReformatSeperators(Directory) Dirname = LSDost.AppendSepToDirectoryPath(Dirname) Fileformat = 'svg' label_size = 8 axis_size = 12 # Set up fonts for plots rcParams['font.family'] = 'sans-serif' rcParams['font.sans-serif'] = ['arial'] rcParams['font.size'] = label_size rcParams['xtick.major.size'] = 4 rcParams['ytick.major.size'] = 4 rcParams['legend.fontsize'] = label_size rcParams['legend.handletextpad'] = 0.05 rcParams['legend.labelspacing'] = 0.1 rcParams['legend.columnspacing'] = 0.1 fname = Dirname + "Scherler_CRNResults.csv" # get only the file without the data directory NoDirFname = LSDost.GetFileNameNoPath(fname) # Now get the prefix of the file splitfname = NoDirFname.split('_CRNResults.csv') fprefix = splitfname[0] # now produce the cronus name from this prefix CRONUS_name1 = Dirname + fprefix + "_CRONUSEmulator.csv" CRONUS_name2 = Dirname + fprefix + "_CRONUSEmulator_Modified.csv" CRONUS_name3 = Dirname + fprefix + "_CRONUSEmulator_Modified2.csv" print "File prefix is: " + fprefix print "Cronus_name is: " + CRONUS_name1 # now read in the data. We need 3 objects for 3 different results thisCRNData1 = CRNR.CRNResults(fname) thisCRNData2 = CRNR.CRNResults(fname) thisCRNData3 = CRNR.CRNResults(fname) # read in the Cronus data and get the errors thisCRNData1.ReadCRONUSData(CRONUS_name1) thisCRNData1.GetErrorsBetweenMethods() thisCRNData1.GetErrorsBetweenCRONUS() thisCRNData2.ReadCRONUSData(CRONUS_name2) thisCRNData2.GetErrorsBetweenMethods() thisCRNData2.GetErrorsBetweenCRONUS() thisCRNData3.ReadCRONUSData(CRONUS_name3) thisCRNData3.GetErrorsBetweenMethods() thisCRNData3.GetErrorsBetweenCRONUS() #=========================================================================== # now make plots based on these data # 3.26 inches = 83 mm, the size of a 1 column figure Fig1 = plt.figure(1, facecolor='white', figsize=(3.26, 3.26)) # generate a 120,90 grid. # gendepth a grid. gs = GridSpec(100, 100, bottom=0.06, left=0.1, right=1.0, top=1.0) ax = Fig1.add_subplot(gs[10:90, 10:95]) ax.plot(thisCRNData1.GetAverageCombinedScaling(), thisCRNData1.GetError_CR(), "o", markersize=4, color="black", label="CRONUS2.2 default", markeredgewidth=1) ax.plot(thisCRNData2.GetAverageCombinedScaling(), thisCRNData2.GetError_CR(), "o", markersize=4, color="grey", label="Updated spallation", markeredgewidth=1) ax.plot(thisCRNData3.GetAverageCombinedScaling(), thisCRNData3.GetError_CR(), "o", markersize=4, color="white", label="Updated spallation, muons", markeredgewidth=1) ax.spines['top'].set_linewidth(1) ax.spines['left'].set_linewidth(1) ax.spines['right'].set_linewidth(1) ax.spines['bottom'].set_linewidth(1) ax.tick_params(axis='both', width=1) plt.xlabel('Production factor ($S_{tot}$)', fontsize=axis_size) plt.ylabel('($\epsilon_{CR2.2}$-$\epsilon_{CAIRN}$)/$\epsilon_{CAIRN}$', fontsize=axis_size) #plt.title('Cosmocalc / New_code',fontsize = label_size+6) handles, labels = ax.get_legend_handles_labels() plt.legend() plt.legend(handles, labels, numpoints=1, loc=1, ncol=1, borderaxespad=1.) #plt.show() plt.savefig(Dirname + "CRONUS_update_spallation_and_muons.svg", format=Fileformat)
def CollateCRNData(): #Directory = "C://basin_data//CosmoPaper//Results//Compiled//" Directory = "T://Papers_LaTeX//crn_basinwide_paper//Compiled_results//" Dirname = LSDost.ReformatSeperators(Directory) Dirname = LSDost.AppendSepToDirectoryPath(Dirname) Fileformat = 'svg' # This list will store the crn data CRNDataList = [] CRNprefixes = [] PaperNames = [] label_size = 8 axis_size = 12 # Set up fonts for plots rcParams['font.family'] = 'sans-serif' rcParams['font.sans-serif'] = ['arial'] rcParams['font.size'] = label_size rcParams['xtick.major.size'] = 4 rcParams['ytick.major.size'] = 4 rcParams['legend.fontsize'] = label_size rcParams['legend.handletextpad'] = 0.05 rcParams['legend.labelspacing'] =0.1 rcParams['legend.columnspacing'] =0.1 # loop through the directory, getting the results from the data for fname in glob(Dirname+"*_CRNResults.csv"): # get only the file without the data directory NoDirFname = LSDost.GetFileNameNoPath(fname) # Now get the prefix of the file splitfname = NoDirFname.split('_CRNResults.csv') fprefix = splitfname[0] # now produce the cronus name from this prefix CRONUS_name = Dirname+fprefix+"_CRONUS.csv" print "File prefix is: " + fprefix print "Cronus_name is: " + CRONUS_name # now read in the data thisCRNData = CRNR.CRNResults(fname) # read in the Cronus data and get the errors thisCRNData.ReadCRONUSData(CRONUS_name) thisCRNData.GetErrorsBetweenMethods() thisCRNData.GetErrorsBetweenCRONUS() CRNDataList.append(thisCRNData) CRNprefixes.append(fprefix) # now get the prefixes if fprefix == "Bierman": PaperNames.append("Bierman et al., 2005") elif fprefix == "Dethier": PaperNames.append("Dethier et al., 2014") elif fprefix == "Kirchner": PaperNames.append("Kirchner et al., 2001") elif fprefix == "Munack": PaperNames.append("Munack et al., 2014") elif fprefix == "Scherler": PaperNames.append("Scherler et al., 2014") elif fprefix == "Safran": PaperNames.append("Safran et al., 2005") elif fprefix == "Palumbo": PaperNames.append("Palumbo et al., 2010") #=========================================================================== # now make plots based on these data # 3.26 inches = 83 mm, the size of a 1 column figure Fig1 = plt.figure(1, facecolor='white',figsize=(3.26,3.26)) # generate a 120,90 grid. gs = GridSpec(100,75,bottom=0.13,left=0.13,right=0.98,top=0.85) ax = Fig1.add_subplot(gs[10:100,5:75]) # this gets the colors to map to specific sites cmap = plt.cm.jet colo = 0 for index,CRNObj in enumerate( CRNDataList): colo = colo + (1.000/len(CRNprefixes)) ax.plot(CRNObj.GetAverageCombinedScaling(),CRNObj.GetError_CR(), "o", markersize=4, color=cmap(colo), label = PaperNames[index],markeredgewidth=1) ax.spines['top'].set_linewidth(1) ax.spines['left'].set_linewidth(1) ax.spines['right'].set_linewidth(1) ax.spines['bottom'].set_linewidth(1) ax.tick_params(axis='both', width=1) plt.xlabel('Production factor ($S_{tot}$)', fontsize = axis_size) plt.ylabel('($\epsilon_{CR2.2}$-$\epsilon_{CAIRN}$)/$\epsilon_{CAIRN}$', fontsize = axis_size) #plt.title('Cosmocalc / New_code',fontsize = label_size+6) handles, labels = ax.get_legend_handles_labels() plt.legend() plt.legend(handles, labels, numpoints = 1, bbox_to_anchor=(0., 1.02, 1., .102), loc=3, ncol=2, mode="expand", borderaxespad=0.) plt.savefig(Dirname+"Production_vs_error.svg",format = Fileformat) #Fig1.show() Fig1.clf() # These don't work in my version of matplotlib...I must update (!) # have found a workaround below #plt.rcParams['xtick.major.linewidth'] = 4 #plt.rcParams['xtick.minor.width'] = 2 #=========================================================================== # now make plots based on these data # 3.26 inches = 83 mm, the size of a 1 column figure Fig2 = plt.figure(1, facecolor='white',figsize=(3.26,3.5)) # generate a 120,90 grid. gs = GridSpec(100,75,bottom=0.14,left=0.13,right=0.98,top=0.85) ax = Fig2.add_subplot(gs[10:100,5:75]) plt.rcParams['xtick.major.size'] = 4 plt.rcParams['xtick.minor.size'] = 3 plt.rcParams['ytick.major.size'] = 4 # this gets the colors to map to specific sites cmap = plt.cm.jet colo = 0 for index,CRNObj in enumerate( CRNDataList): colo = colo + (1.000/len(CRNprefixes)) ax.plot(CRNObj.GetErosionRates(),CRNObj.GetError_CR(), "o", markersize=4, color=cmap(colo), label = PaperNames[index],markeredgewidth=1) ax.spines['top'].set_linewidth(1) ax.spines['left'].set_linewidth(1) ax.spines['right'].set_linewidth(1) ax.spines['bottom'].set_linewidth(1) #ax.tick_params(axis='both', width=2.5) ax.set_xscale('log') # This gets all the ticks, and pads them away from the axis so that the corners don't overlap # the which command tells the program to get major and minor ticks ax.tick_params(axis='both', width=1, pad = 1, which = 'both') for tick in ax.xaxis.get_major_ticks(): tick.set_pad(3) for tick in ax.yaxis.get_major_ticks(): tick.set_pad(3) #for tick in ax.xaxis.get_minor_ticks(): # tick.tick_params(width = 2.5) plt.xlabel('$\epsilon_{CAIRN}$ (g cm$^{-2}$ yr$^{-1}$)', fontsize = axis_size) plt.ylabel('($\epsilon_{CR2.2}$-$\epsilon_{CAIRN}$)/$\epsilon_{CAIRN}$', fontsize = axis_size) #plt.title('Cosmocalc / New_code',fontsize = label_size+6) handles, labels = ax.get_legend_handles_labels() plt.legend() plt.legend(handles, labels, numpoints = 1, bbox_to_anchor=(0., 1.02, 1., .102), loc=3, ncol=2, mode="expand", borderaxespad=0.) #plt.show() plt.savefig(Dirname+"Erosion_vs_error.svg",format = Fileformat) Fig2.clf() #=========================================================================== # now make plots based on these data Fig3 = plt.figure(1, facecolor='white',figsize=(3.26,3.5)) # generate a 120,90 grid. gs = GridSpec(100,75,bottom=0.14,left=0.14,right=0.97,top=0.85) ax = Fig3.add_subplot(gs[10:100,5:75]) plt.rcParams['xtick.major.size'] = 4 plt.rcParams['ytick.major.size'] = 4 # this gets the colors to map to specific sites cmap = plt.cm.jet colo = 0 for index,CRNObj in enumerate( CRNDataList): colo = colo + (1.000/len(CRNprefixes)) ax.plot(CRNObj.GetAverageCombinedScaling(),CRNObj.GetError_CC(), "o", markersize=4, color=cmap(colo), label = PaperNames[index],markeredgewidth=1) ax.spines['top'].set_linewidth(1) ax.spines['left'].set_linewidth(1) ax.spines['right'].set_linewidth(1) ax.spines['bottom'].set_linewidth(1) #ax.tick_params(axis='both', width=2.5) # This gets all the ticks, and pads them away from the axis so that the corners don't overlap # the which command tells the program to get major and minor ticks ax.tick_params(axis='both', width=1, pad = 1, which = 'both') for tick in ax.xaxis.get_major_ticks(): tick.set_pad(3) for tick in ax.yaxis.get_major_ticks(): tick.set_pad(3) #for tick in ax.xaxis.get_minor_ticks(): # tick.tick_params(width = 2.5) plt.xlabel('Production factor ($S_{CCtot}$)', fontsize = axis_size) plt.ylabel('($\epsilon_{CC}$-$\epsilon_{CAIRN}$)/$\epsilon_{CAIRN}$', fontsize = axis_size) #plt.title('Cosmocalc / New_code',fontsize = label_size+6) handles, labels = ax.get_legend_handles_labels() plt.legend(handles, labels, numpoints = 1, bbox_to_anchor=(0., 1.02, 1., .102), loc=3, ncol=2, mode="expand", borderaxespad=0.) #plt.show() plt.savefig(Dirname+"COSMOCALC_vs_error.svg",format = Fileformat) Fig3.clf() #=========================================================================== # now make plots based on these data Fig4 = plt.figure(1, facecolor='white',figsize=(3.26,3.5)) # generate a 120,90 grid. gs = GridSpec(100,75,bottom=0.14,left=0.14,right=0.97,top=0.85) ax = Fig4.add_subplot(gs[10:100,5:75]) plt.rcParams['xtick.major.size'] = 4 # this gets the colors to map to specific sites cmap = plt.cm.jet colo = 0 for index,CRNObj in enumerate( CRNDataList): colo = colo + (1.000/len(CRNprefixes)) ax.plot(CRNObj.GetAverageCombinedScaling(),CRNObj.GetError_CR_em(), "o", markersize=4, color=cmap(colo), label = PaperNames[index],markeredgewidth=1) ax.spines['top'].set_linewidth(1) ax.spines['left'].set_linewidth(1) ax.spines['right'].set_linewidth(1) ax.spines['bottom'].set_linewidth(1) #ax.tick_params(axis='both', width=2.5) # This gets all the ticks, and pads them away from the axis so that the corners don't overlap # the which command tells the program to get major and minor ticks ax.tick_params(axis='both', width=1, pad = 1, which = 'both') for tick in ax.xaxis.get_major_ticks(): tick.set_pad(3) for tick in ax.yaxis.get_major_ticks(): tick.set_pad(3) #for tick in ax.xaxis.get_minor_ticks(): # tick.tick_params(width = 2.5) plt.xlabel('Production factor ($S_{CRShield}$*$S_{effp}$)', fontsize = axis_size) plt.ylabel('($\epsilon_{CC-CR}$-$\epsilon_{CAIRN}$)/$\epsilon_{CAIRN}$', fontsize = axis_size) #plt.title('Cosmocalc / New_code',fontsize = label_size+6) handles, labels = ax.get_legend_handles_labels() plt.legend(handles, labels, numpoints = 1, bbox_to_anchor=(0., 1.02, 1., .102), loc=3, ncol=2, mode="expand", borderaxespad=0.) #plt.show() plt.savefig(Dirname+"COSMOCALC_CRem_vs_error.svg",format = Fileformat) Fig4.clf()
def CRBERCvsReported_erates(): #Dirname = "C://basin_data//CosmoPaper//Results//Compiled//" Dirname = "T://Papers_LaTeX//crn_basinwide_paper//Compiled_results//" #Fname = "Palumbo*_CompareResults.csv" SiteNames = [] SiteDicts = [] PaperNames = [] PaperColours = [] # loop through the directory, getting the results from the data for fname in glob(Dirname+"*_ErateComparisonNew.csv"): # get only the file without the data directory NoDirFname = LSDost.GetFileNameNoPath(fname) # Now get the prefix of the file splitfname = NoDirFname.split('_ErateComparisonNew.csv') fprefix = splitfname[0] print "File prefix is: " + fprefix # add to the sitenames list and create a holding dictionary SiteNames.append(fprefix) thisdict = {} # now get the prefixes if fprefix == "Bierman": PaperNames.append("Bierman et al., 2005") PaperColours.append("blue") elif fprefix == "Dethier": PaperNames.append("Dethier et al., 2014") PaperColours.append("lawngreen") elif fprefix == "Kirchner": PaperNames.append("Kirchner et al., 2001") PaperColours.append("yellow") elif fprefix == "Munack": PaperNames.append("Munack et al., 2014") PaperColours.append("orange") elif fprefix == "Scherler": PaperNames.append("Scherler et al., 2014") PaperColours.append("black") elif fprefix == "Safran": PaperNames.append("Safran et al., 2005") PaperColours.append("powderblue") elif fprefix == "Palumbo": PaperNames.append("Palumbo et al., 2010") PaperColours.append("maroon") print "I am woking with the dataset: " + fprefix min_erate = 5 max_erate = 5000 #See if the parameter files exist if os.access(fname,os.F_OK): this_file = open(fname, 'r') lines = this_file.readlines() # get rid fo the first line lines.pop(0) # create the lists for populating with data BERC_erate = [] BERC_uncert = [] Report_erate = [] Report_uncert = [] # now get the data into the dict for line in lines: this_line = LSDost.RemoveEscapeCharacters(line) split_line = this_line.split(',') #print split_line BERC_erate.append(float(split_line[16])) BERC_uncert.append(float(split_line[17])) Report_erate.append(float(split_line[20])) Report_uncert.append(float(split_line[21])) # get the maximum and minimum erosion rates if (float(split_line[16]) > max_erate): max_erate = float(split_line[16]) if (float(split_line[20]) > max_erate): max_erate = float(split_line[20]) if (float(split_line[16]) < min_erate): min_erate = float(split_line[16]) if (float(split_line[20]) < min_erate): min_erate = float(split_line[20]) thisdict["BERC_erate"] = BERC_erate thisdict["BERC_uncert"] = BERC_uncert thisdict["Report_erate"] = Report_erate thisdict["Report_uncert"] = Report_uncert SiteDicts.append(thisdict) label_size = 10 axis_size = 12 # Set up fonts for plots rcParams['font.family'] = 'sans-serif' rcParams['font.sans-serif'] = ['arial'] rcParams['font.size'] = label_size rcParams['xtick.major.size'] = 4 rcParams['ytick.major.size'] = 4 rcParams['legend.fontsize'] = label_size rcParams['legend.handletextpad'] = 0.05 rcParams['legend.labelspacing'] =0.1 rcParams['legend.columnspacing'] =0.1 # make a line between the maximum and minimum erate one_line = np.linspace(min_erate,max_erate,1000) # now make plots based on these data Fig1 = plt.figure(1, facecolor='white',figsize=(4.72,4.72)) # generate a 120,90 grid. gs = GridSpec(100,75,bottom=0.13,left=0.13,right=0.98,top=0.85) ax = Fig1.add_subplot(gs[10:100,5:75]) #cmap = plt.cm.jet #colo = 0 # plot the 1:1 line plt.plot(one_line,one_line,'k-',linewidth = 2) for index,thisdict in enumerate(SiteDicts): #colo = colo + (1.000/len(SiteDicts)) plt.errorbar(thisdict['BERC_erate'], thisdict['Report_erate'], thisdict['BERC_uncert'], thisdict['Report_uncert'], fmt='.',color = PaperColours[index], linewidth = 1.5) plt.plot(thisdict['BERC_erate'], thisdict['Report_erate'], "o", markersize=4, color=PaperColours[index], label = PaperNames[index],markeredgewidth=1.) ax.annotate("1:1 line", xy=(3000, 3000), xycoords='data', xytext=(200, 4000), textcoords='data', arrowprops=dict(arrowstyle="fancy", #linestyle="dashed", color="0.5", shrinkB=5, connectionstyle="arc3,rad=-0.3", ), ) #plt.plot(self.CRNData['AvgProdScaling'],self.CRNData['Error_CR'],color=cmap(self.CRNData['basin_relief']),"o", markersize=8 ) #plt.errorbar(datazz['erate_cosmocalc']*10, datazz['erate_cmperkyr']*10, xerr=datazz['error_cosmocalc'], yerr=datazz['error_newcode'], fmt='o',color = cmap(colo)) ax.spines['top'].set_linewidth(1.5) ax.spines['left'].set_linewidth(1.5) ax.spines['right'].set_linewidth(1.5) ax.spines['bottom'].set_linewidth(1.5) # This gets all the ticks, and pads them away from the axis so that the corners don't overlap ax.tick_params(axis='both', width=1.5, pad = 2) for tick in ax.xaxis.get_major_ticks(): tick.set_pad(3) for tick in ax.yaxis.get_major_ticks(): tick.set_pad(3) # logarithmic axes ax.set_yscale('log') ax.set_xscale('log') plt.xlabel('CAIRN denudation rate (mm/kyr)', fontsize = axis_size) plt.ylabel('Reported denudation rate (mm/kyr)', fontsize = axis_size) handles, labels = ax.get_legend_handles_labels() plt.legend(handles, labels, numpoints = 1, bbox_to_anchor=(0., 1.02, 1., .102), loc=3, ncol=2, mode="expand", borderaxespad=0.) #plt.show() Fileformat = "svg" plt.savefig(Dirname+"CAIRN_vs_Reported_erates.svg",format = Fileformat)
def CollatenewCRONUScomparisonCRNData(): #Directory = "C://basin_data//CosmoPaper//Results//Compiled//Brauch_vs_newCRONUS//" Directory = "T://Papers_LaTeX//crn_basinwide_paper//Compiled_results//Brauch_vs_newCRONUS//" Dirname = LSDost.ReformatSeperators(Directory) Dirname = LSDost.AppendSepToDirectoryPath(Dirname) Fileformat = 'svg' # This list will store the crn data CRNDataList = [] CRNprefixes = [] PaperNames = [] PaperColours = [] ScalingNames = [] label_size = 8 axis_size = 12 # Set up fonts for plots rcParams['font.family'] = 'sans-serif' rcParams['font.sans-serif'] = ['arial'] rcParams['font.size'] = label_size rcParams['xtick.major.size'] = 4 rcParams['ytick.major.size'] = 4 rcParams['legend.fontsize'] = label_size rcParams['legend.handletextpad'] = 0.05 rcParams['legend.labelspacing'] = 0.1 rcParams['legend.columnspacing'] = 0.1 # loop through the directory, getting the results from the data for fname in glob(Dirname + "*_CRNResults.csv"): # get only the file without the data directory NoDirFname = LSDost.GetFileNameNoPath(fname) # Now get the prefix of the file splitfname = NoDirFname.split('_CRNResults.csv') fprefix = splitfname[0] print "File prefix is: " + fprefix # now read in the data thisCRNData = CRNR.CRNResults(fname) CRNDataList.append(thisCRNData) CRNprefixes.append(fprefix) # now get the prefixes if "Dethier" in fprefix: PaperNames.append("Dethier et al., 2014") elif "Palumbo" in fprefix: PaperNames.append("Palumbo et al., 2010") # now get lists based on this data and place into a dictionary if "newCRONUS" in fprefix: #print "I found newCRONUS in the file prefix: " + fprefix ScalingNames.append("newCRONUS") else: #print "Sorry, I didn't find the file prefix newCRONUS in " + fprefix ScalingNames.append("Braucher") # now get the errors for index, CRNObj in enumerate(CRNDataList): print "Looking for scaling and paper names" print "paper name is: " + PaperNames[index] print "scaling name is: " + ScalingNames[index] if "Dethier" in PaperNames[index]: if "newCRONUS" in ScalingNames[index]: dethier_index_newCRONUS = index else: dethier_index_braucher = index elif "Palumbo" in PaperNames[index]: if "newCRONUS" in ScalingNames[index]: palumbo_index_newCRONUS = index #print "I got the palumbo newcronus index" else: palumbo_index_braucher = index P_erate_brauch = CRNDataList[palumbo_index_braucher].GetErosionRates() print "Braucher erate palumbo: " print P_erate_brauch P_erate_newCRONUS = CRNDataList[palumbo_index_newCRONUS].GetErosionRates() print "newCRONUS erate palumbo: " print P_erate_newCRONUS P_erate_newCRONUS P_B = np.asarray(P_erate_brauch) P_nC = np.asarray(P_erate_newCRONUS) P_err = np.divide(np.subtract(P_nC, P_B), P_B) print "P_err: " print P_err D_erate_brauch = CRNDataList[dethier_index_braucher].GetErosionRates() D_erate_newCRONUS = CRNDataList[dethier_index_newCRONUS].GetErosionRates() D_B = np.asarray(D_erate_brauch) D_nC = np.asarray(D_erate_newCRONUS) D_err = np.divide(np.subtract(D_nC, D_B), D_B) print "D_err: " print D_err #print "The palumbo error is: " #print P_err #print "The dethier error is: " #print D_err #=========================================================================== # now make plots based on these data # 3.26 inches = 83 mm, the size of a 1 column figure Fig1 = plt.figure(1, facecolor='white', figsize=(3.26, 3.26)) # generate a 120,90 grid. gs = GridSpec(100, 75, bottom=0.13, left=0.13, right=0.98, top=0.85) ax = Fig1.add_subplot(gs[10:100, 5:75]) ax.plot(P_B, P_err, "o", markersize=4, color="magenta", label="Palumbo et al., 2010", markeredgewidth=1) ax.plot(D_B, D_err, "ro", markersize=4, label="Dethier et al., 2014", markeredgewidth=1) ax.spines['top'].set_linewidth(1) ax.spines['left'].set_linewidth(1) ax.spines['right'].set_linewidth(1) ax.spines['bottom'].set_linewidth(1) ax.tick_params(axis='both', width=1) #ax.set_ylim([0.02,0.06]) plt.title( 'We are not using this in the paper!! Use CRNCAIRNvsnewCRONUS_erates.py instead!' ) plt.xlabel('CAIRN denudation rate (g cm$^{-2}$ yr$^{-1}$)', fontsize=axis_size) plt.ylabel('($\epsilon_{CRCalc}$-$\epsilon_{CAIRN}$)/$\epsilon_{CAIRN}$', fontsize=axis_size) #plt.title('Cosmocalc / New_code',fontsize = label_size+6) handles, labels = ax.get_legend_handles_labels() plt.legend() plt.legend(handles, labels, numpoints=1, bbox_to_anchor=(0., 1.02, 1., .102), loc=3, ncol=2, mode="expand", borderaxespad=0.) plt.savefig(Dirname + "CAIRNvsnewCRONUSapprox_erate.svg", format=Fileformat) Fig1.show()