def test_fun():
    """
    test function
    :return: T/F
    """

    # path to directory containing inversion files
    idir = os.path.join(SAMPLE_DIR,'Occam2d')

    # save path, to save plots to
    savepath = TEMP_OUT_DIR
    offset = 0


    #go to model results directory and find the latest iteration file
    iterfile = max([f for f in os.listdir(idir) if f[-5:]=='.iter'])
    respfile = max([f for f in os.listdir(idir) if f[-5:]=='.resp'])

    datafn = 'OccamDataFile.dat'
    # get the iteration number
    iterno = iterfile[-7:-5]
    outfilename = iterfile[:-5]

    plotmodel = True # set to True to plot the resistivity model
    plotresponses = True # set to True to plot the responses
    save = True

    #plot the model
    figure = plt.Figure()

    # horizontal padding on the edges for plotting, in km
    xpad = 1

    # plot the model
    if plotmodel:
        plotm = o2d.PlotModel(iter_fn=op.join(idir,iterfile),
                          data_fn=op.join(idir,datafn),
                          station_font_pad = 0.5,
                          station_font_size = 6,
                          station_font_rotation = 75,
                          climits=(0.,2.5),# colour scale limits
                          xpad=xpad,
                          dpi=300,# resolution of figure
                          fig_aspect = 0.5,   # aspect ratio between horizontal and vertical scale
                          ylimits = (0,10), # depth limits
                          stationid=(-1,3)) # index of station name to plot
        if save:
            plotm.save_figure(op.join(savepath, outfilename+'_resmodel.png') ) # this will produce 1 figure .png


    # plot the responses
    if plotresponses:
        plotresponse = o2d.PlotResponse(op.join(idir,datafn),
                                        resp_fn = op.join(idir,respfile),
                                        plot_type = ['pb35','pb40']
                                        )
        if save:
            plotresponse.save_figures(savepath) # this will produce 2 .pdf file
save = True

#plot the model
figure = plt.Figure()

# horizontal padding on the edges for plotting, in km
xpad = 1

# plot the model
if plotmodel:
    o2d.PlotModel(
        iter_fn=op.join(idir, iterfile),
        data_fn=op.join(idir, datafn),
        station_font_pad=0.5,
        station_font_size=6,
        station_font_rotation=75,
        climits=(0., 2.5),  # colour scale limits
        xpad=xpad,
        dpi=300,  # resolution of figure
        fig_aspect=0.5,  # aspect ratio between horizontal and vertical scale
        ylimits=(0, 10),  # depth limits
        stationid=(-1, 3))  # index of station name to plot
    if save:
        plt.savefig(op.join(savepath, outfilename + '_resmodel.png'), dpi=300)

# plot the responses
if plotresponses:
    plotresponse = o2d.PlotResponse(op.join(idir, datafn),
                                    resp_fn=op.join(idir, respfile),
                                    plot_type=['pb35', 'pb40'])
    if save:
        plotresponse.save_figures(savepath)
# -*- coding: utf-8 -*-
"""
Created on Thu Feb 04 16:41:25 2016

@author: jpeacock
"""

import mtpy.modeling.occam2d as occam
import mtpy.imaging.mtcolors as mtcolors

#mfn = r"c:\MinGW32-xy\Peacock\occam\MountainPass\inv01_tm_sm3\ITER20.iter"
#dfn = r"c:\MinGW32-xy\Peacock\occam\MountainPass\inv01_tm_sm3\OccamDataFile_rw.dat"
mfn = r"c:\MinGW32-xy\Peacock\occam\MountainPass\inv05_tm_rot\ITER15.iter"
dfn = r"c:\MinGW32-xy\Peacock\occam\MountainPass\inv05_tm_rot\OccamDataFile.dat"
#mfn = r"c:\MinGW32-xy\Peacock\occam\MountainPass\inv01_tm_rot_sm3_no13\ITER25.iter"
#dfn = r"c:\MinGW32-xy\Peacock\occam\MountainPass\inv01_tm_rot_sm3_no13\OccamDataFile_rw.dat"

pm = occam.PlotModel(iter_fn=mfn, data_fn=dfn, plot_yn='n')
pm.ylimits = (-1.5, 12)
pm.cmap = mtcolors.mt_rd2gr2bl
pm.climits = (.5, 3.5)
pm.station_font_pad = 1.2
pm.station_id = [2, 5]
pm.cb_shrink = .4  
pm.fig_num = 4
pm.station_font_pad = 1.7
pm.plot()

#pm.save_figure(r"c:\Users\jpeacock\Documents\MountainPass\Figures\mp_tm_sm3_iter60_aseg_2016.jpg",
#               fig_dpi=600)
plotmodel = True  # set to True to plot the resistivity model
plotresponses = False  # set to True to plot the responses
save = True

#plot the model
figure = plt.Figure()

if plotmodel:
    pltm = o2d.PlotModel(
        iter_fn=op.join(idir, iterfile),
        data_fn=op.join(idir, datafn),
        station_font_pad=0.7,
        station_font_size=4,
        station_font_rotation=90,
        font_size=4,
        climits=(0., 2.5),  # colour scale limits
        xpad=0.1,
        yscale='m',
        yminorticks=0.250,
        dpi=300,  # resolution of figure
        fig_aspect=0.25,  # aspect ratio between horizontal and vertical scale
        ylimits=(0, 2),  # depth limits
        stationid=(-1, 3))  # index of station name to plot
    if save:
        pltm.save_figure(op.join(savepath, filename + '_model.png'))

if plotresponses:
    plts = o2d.PlotResponse(op.join(idir, datafn),
                            resp_fn=op.join(idir, respfile))
    plts.save_figures(op.join(idir, 'Copna_response'))
Exemple #5
0
    def test_plot_model_and_responses(self):
        """
            test function
            :return: T/F
            """

        # path to directory containing inversion files
        idir = os.path.join(SAMPLE_DIR, 'Occam2d')

        # save path, to save plots to
        savepath = self._temp_dir
        offset = 0

        # go to model results directory and find the latest iteration file
        iterfile = 'ITER12.iter'
        respfile = 'RESP12.resp'

        datafn = 'OccamDataFile.dat'
        # get the iteration number
        iterno = iterfile[-7:-5]
        outfilename = iterfile[:-5]

        plotmodel = True  # set to True to plot the resistivity model
        plotresponses = True  # set to True to plot the responses
        save = True

        # horizontal padding on the edges for plotting, in km
        xpad = 1

        # plot the model
        if plotmodel:
            plotm = occam2d.PlotModel(
                iter_fn=os.path.join(idir, iterfile),
                data_fn=os.path.join(idir, datafn),
                station_font_pad=0.5,
                station_font_size=6,
                station_font_rotation=75,
                climits=(0., 2.5),  # colour scale limits
                xpad=xpad,
                dpi=300,  # resolution of figure
                fig_aspect=
                0.5,  # aspect ratio between horizontal and vertical scale
                ylimits=(0, 10),  # depth limits
                stationid=(-1, 3),  # index of station name to plot
                plot_yn='n')
            plotm.plot()
            if save:
                plotm.save_figure(
                    os.path.join(savepath, outfilename + '_resmodel.png'),
                    close_fig='n')  # this will produce 1 figure .png
            plt_wait(1)

        # plot the responses
        if plotresponses:
            plotresponse = occam2d.PlotResponse(os.path.join(idir, datafn),
                                                resp_fn=os.path.join(
                                                    idir, respfile),
                                                plot_type=['pb35', 'pb40'])
            if save:
                plotresponse.save_figures(
                    savepath, close_fig='n')  # this will produce 2 .pdf file
            plt_wait(1)

        plt_close()