Example #1
0
def saveFigure(fig, outName):
    '''
    Save figure to file.
    '''
    # Confirm output directory exists
    confirmOutputDir(inps.outName)

    # Format save name
    if outName[-4:] not in ['.png', '.PNG']: outName += '.png'

    # Save
    fig.savefig(outName, dpi=600)
Example #2
0
def computeIncrRates(scheme, args):
    '''
    This function acts to ensure consistency in slip rate formatting and output
     structure between the two methods for computation: MCMC, and analytical
     formulation.
    INPUTS
        scheme is the type of method to be used (MCMC, analytical)
        args come directly from argparse, and is an object comprising all
         input arguments
    '''
    ## Setup
    # Determine workflow
    scheme = scheme.lower()  # format

    # Check output directory exists
    outName = confirmOutputDir(args.outName, verbose=args.verbose)

    # Start text file
    txtFile = slipRateTxtFile(args.outName, scheme)


    ## Load input data
    # Load data from YAML file
    DspAgeData = loadDspAgeInputs(args.dataFile, 
        verbose=args.verbose, printDetails=args.xtrVerbose, plotInputs=args.plotInputs)

    # Plot raw data
    figNb = 1  # start figure counter
    _, _, figNb = plotRawData(DspAgeData, figNb, label=args.labelMarkers,
        ageUnits=args.ageUnits, dspUnits=args.dspUnits, outName=args.outName)


    ## Compute incremental slip rates
    if scheme in ['analytical']:
        # Compute rates using analytical wrapper function below
        Rates = computeAnalyticalRates(DspAgeData, args, txtFile)

    elif scheme in ['mcmc']:
        # Compute rates using MC wrapper function below
        Rates = computeMCMCrates(DspAgeData, args, txtFile)

        # Update figure counter
        figNb += 1


    ## Analyze PDFs
    # Compute statistics based on PDFs
    analyzePDFs(Rates, method=args.pdfAnalysis, confidence=args.rateConfidence,
        verbose=args.verbose, outName=args.outName)

    # Plot incremental slip rates on same plot
    plotIncSlipRates(Rates, args.pdfAnalysis, figNb, plotMax=args.maxRate2plot, 
        rateUnits=args.rateUnits, outName=args.outName)

    # Print intervals to file
    printIncSlipRates(txtFile, Rates, args.pdfAnalysis, args.rateConfidence, rateUnits=args.rateUnits)

    if args.plotOutputs == True or args.plotInputs == True:
        plt.show()
Example #3
0
        # Finalize
        self.fig.tight_layout()

        # Save to file
        if outName:
            savename = '{:s}.pdf'.format(outName)
            self.fig.savefig(savename, type='pdf')
            print('Saved to: {:s}'.format(savename))


### MAIN ---
if __name__ == '__main__':
    # Gather arguments
    inps = cmdParser()

    # Confirm output directory exists
    confirmOutputDir(inps.outName)

    # Plot displacements
    displacements = dspPlot(inps.dspList)

    displacements.plotData(pdfScale=inps.pdfScale,
                           genericColor=inps.genericColor,
                           genericAlpha=inps.genericAlpha)

    displacements.finalizeFig(title=inps.title,
                              xlabel=inps.xlabel,
                              labelRotation=inps.labelRotation,
                              outName=inps.outName)

    plt.show()