Beispiel #1
0
def plot2Dprofile(edi_dir,
                  period_index_list=None,
                  zcomponent='det',
                  edi_list=None,
                  tick_params={},
                  save=False,
                  savepath=None,
                  **kwargs):
    #edi_dir = "/Softlab/Githubz/mtpy2/tests/data/edifiles/"
    # edi_dir="E:/Githubz/mtpy2/tests/data/edifiles/"
    # edi_dir=r"E:\Githubz\mtpy2\examples\data/edi2"

    # 1 get a list of edi files, which are suppose to be in a profile.
    edifiles = glob.glob(os.path.join(edi_dir, '*.edi'))

    _logger.debug("edi files: %s", edifiles)

    edis = load_edi_files(edi_dir, file_list=edi_list)
    plot = Depth2D(edis, period_index_list, zcomponent)
    plot.plot(tick_params, **kwargs)
    if save:
        if os.path.isdir(savepath):
            savepath == os.path.join(savepath, 'Depth2D.png')
        if savepath is not None:
            plot._fig.savefig(savepath)
        else:
            savepath = os.path.join(edi_dir, 'Depth2D.png')
    plot.show()
Beispiel #2
0
def plot_latlon_depth_profile(edi_dir,
                              period,
                              zcomponent='det',
                              showfig=True,
                              savefig=True,
                              savepath=None,
                              fig_dpi=400,
                              fontsize=14,
                              file_format='png',
                              ptol=0.1):
    """
    MT penetration depth profile in lat-lon coordinates with pixelsize = 0.002
    :param savefig:
    :param showfig:
    :param edi_dir:
    :param period:
    :param zcomponent:
    :return:
    """

    # edi_dir = "/Softlab/Githubz/mtpy2/tests/data/edifiles/"
    # edi_dir="E:/Githubz/mtpy2/tests/data/edifiles/"
    # edi_dir=r"E:\Githubz\mtpy2\examples\data/edi2"

    # 1 get a list of edi files, which are suppose to be in a profile.
    # edifiles = glob.glob(os.path.join(edi_dir, '*.edi'))

    # logger.debug("edi files: %s", edifiles)

    edis = load_edi_files(edi_dir)

    image = Depth3D(edis=edis, period=period, rho=zcomponent, ptol=ptol)
    if isinstance(period, int):  # period is considered as an index
        image.plot(period_by_index=True, fontsize=fontsize)
    elif isinstance(
            period, float
    ):  # period is considered as the actual value of period in second
        image.plot(fontsize=fontsize)
    else:
        raise Exception("Wrong type of the parameter period, %s" % period)

    if showfig is True:
        image.show()

    if savefig:
        if savepath is None:
            savepath = 'C:/tmp'
        savefn = 'P3Depth_Period%s.%s' % (image.get_period_fmt(), file_format)
        path2savefile = os.path.join(savepath, savefn)
        image.export_image(path2savefile, dpi=fig_dpi, bbox_inches='tight')

    # may want to remove the following 2 lines
    # plt.clf()
    # plt.close()
    return
Beispiel #3
0
    def test_edifiles2_input(self):
        """
        testing to use Z and tipper objects as input

        this fails because the constructor of PlotPhaseTensorMaps only initialize the Mplot object properly when reading from files
        :return:
        """
        edi_path = test_params[4]
        freq = 1
        mt_objs = load_edi_files(edi_path)
        z_objs = [mt.Z for mt in mt_objs]
        tipper = [mt.Tipper for mt in mt_objs]
        save_figure_path = os.path.join(
            self._temp_dir, "%s.png" % inspect.currentframe().f_code.co_name)
        save_param_path = os.path.join(
            self._temp_dir,
            "params_%s" % inspect.currentframe().f_code.co_name)
        pt_obj = PlotPhaseTensorMaps(
            z_object_list=z_objs,
            tipper_object_list=tipper,
            plot_freq=freq,
            ftol=
            0.10,  # freq tolerance,which will decide how many data points included
            mapscale='deg',  # deg or m, or km
            xpad=0.4,  # plot margin; change according to lat-lon in edifiles
            ypad=0.4,  # ~ 2* ellipse size

            # ellipse_dict=self.ellipse_dict, # not implemented
            ellipse_size=.2,
            ellipse_colorby='phimin',
            ellipse_range=(0, 90, 1),
            ellipse_cmap='mt_bl2gr2rd',
            plot_tipper='yr',

            # arrow_dict=self.arrow_dict, # not implemented
            arrow_size=0.5,
            arrow_lw=0.2,
            arrow_head_width=0.04,
            arrow_head_length=0.04,
            arrow_direction=0,
            arrow_threshold=0.8,

            # arrow_legend_dict=arrow_legend_dict,
            # fig_spython examples/plot_phase_tensor_map.py data/edifiles/ 10 /e/MTPY2_Outputs/ptmap3deg.pngize=(6, 5),
            # fig_dpi=300, the default is OK. Higher dpi
            # may distort figure
            save_fn=save_figure_path,
            fig_size=(8, 6),
            fig_dpi=100)
        path2figure = pt_obj.plot()
        pt_obj.save_figure(save_figure_path)
        assert (os.path.isfile(save_figure_path))
        pt_obj.export_params_to_file(save_path=save_param_path)
        assert (os.path.isdir(save_param_path))
Beispiel #4
0
def plot2Dprofile(edi_dir, period_index_list=None, zcomponent='det'):
    #edi_dir = "/Softlab/Githubz/mtpy2/tests/data/edifiles/"
    # edi_dir="E:/Githubz/mtpy2/tests/data/edifiles/"
    # edi_dir=r"E:\Githubz\mtpy2\examples\data/edi2"

    # 1 get a list of edi files, which are suppose to be in a profile.
    edifiles = glob.glob(os.path.join(edi_dir, '*.edi'))

    _logger.debug("edi files: %s", edifiles)

    edis = load_edi_files(edi_dir)
    plot = Depth2D(edis, period_index_list, zcomponent)
    plot.plot()
    plot.show()
Beispiel #5
0
def plot2Dprofile(edi_dir,
                  selected_periods,
                  ptol=0.05,
                  zcomponent='det',
                  edi_list=None,
                  tick_params={},
                  save=False,
                  savepath=None,
                  **kwargs):
    edifiles = glob.glob(os.path.join(edi_dir, '*.edi'))

    _logger.debug("edi files: %s", edifiles)

    edis = load_edi_files(edi_dir, file_list=edi_list)
    plot = Depth2D(selected_periods, edis, ptol, zcomponent)
    plot.plot(tick_params, **kwargs)
    if save:
        if os.path.isdir(savepath):
            savepath == os.path.join(savepath, 'Depth2D.png')
        if savepath is not None:
            plot._fig.savefig(savepath)
        else:
            savepath = os.path.join(edi_dir, 'Depth2D.png')
    plot.show()