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
#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)
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'))
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()