Exemple #1
0
    def __init__(self, basename, time, **kwargs):
        # Required arguments
        self.basename = basename
        self.time = time

        # Optional arguments
        self.directory = kwargs.pop('directory', 'C_profiles')
        self.xlim = kwargs.pop('xlim', None)
        self.ylim = kwargs.pop('ylim', None)
        self.title = kwargs.pop('title', None)
        self.mirror = kwargs.pop('mirror', True)
        self.callback = kwargs.pop('callback', None)

        # Instantiate CProfiles and load carbon profiles
        self.cprofiles = CProfiles(self.basename, self.directory)
        self.cprofiles.load_cprofiles()
        self.cprofiles.load_time()

        self.time_idx = self.cprofiles.where_tlist(self.time, appendto=[])

        # Matplotlib Figure object
        self.fig, self.ax = plt.subplots(**kwargs)

        # Plotting options
        self.ax.set_xlabel(u'Posição ' + r'($\mu m$)')
        self.ax.set_ylabel(u'Teor de carbono (% peso)')
        self.ax.set_xlim(self.xlim)
        self.ax.set_ylim(self.ylim)
        if self.title:
            self.ax.set_title(self.title)

        i = self.time_idx[0]
        z, c, t = self.cprofiles.get_cprofile(i, self.mirror, self.x2wp)
        self.line, = self.ax.plot(z, c, 'k-')

        axis = ''
        if self.xlim is None:
            axis += 'x'
        if self.ylim is None:
            axis += 'y'
        axis = axis.replace('xy', 'both')

        if axis:
            self.ax.autoscale(True, axis=axis, tight=True)
            self.ax.autoscale(False)

        self.time_text = self.ax.text(0.02,
                                      0.98,
                                      '',
                                      va='top',
                                      transform=self.ax.transAxes)

        self.ani = None

        self.artists = []

        # Run callback function
        if self.callback is not None:
            self.artists += self.callback(self.ax)
Exemple #2
0
                labels += [('mart', r"$\alpha' + \theta$", 1)]
            else:
                labels += [('mart', r"$\alpha'$", 1)]
        else:
            labels = [('aus1', r'$\gamma_1$', -1), ('aus2', r'$\gamma_2$', -1),
                      ('aust', r'$\gamma$', -1), ('fer1', r'$\alpha_{b1}$', 1),
                      ('fer2', r'$\alpha_{b2}$', 1)]

            if 'CCEpara' in basename or 'CCEortho' in basename or 'mu' in basename:
                labels += [('mart', r"$\alpha' + \theta$", -1)]
            else:
                labels += [('mart', r"$\alpha'$", -1)]

        try:
            fig, ax = plt.subplots(figsize=args.figsize)
            cprofiles = CProfiles(basename, 'C_profiles')

            last_t = None
            for t in args.time:
                j = cprofiles.where_tlist([t], [])
                if len(j) > 0:
                    j = j[0]
                    strct = cprofiles.ss[j]
                    cprofiles.plot_cprofiles(
                        ax=ax,
                        mirror=args.mirror,
                        func=lambda x: x2mu(x, strct, args.mu, args.sol),
                        tlist=[t])
                    last_t = t
        except Exception:
            print('Failed to plot "{}"'.format(basename))
Exemple #3
0
    # y, c0, and WBs for the high manganese, high carbon region (cell boundary)
    y = dict(Si=0.034356055114394574,
             Mn=0.003731497480722358,
             Cu=0.0027562013887263755)
    y['Fe'] = 1. - sum(y.values())
    c0 = x2wp(3.8553489675740495e-2, y=y)
    WBs = 1.5424

    ###########################################################

    labels = [('aus1', r'$\gamma$', 1), ('aus2', r'$\gamma$', 1),
              ('fer1', r'$\alpha_{b}$', 1), ('fer2', r'$\alpha_{b}$', 1),
              ('fer3', r'$\alpha_{b}$', 1)]

    p0 = CProfiles('bainite_FoFo_375', '../C_profiles')

    ax0.axhline(c0, ls=':', color='k', lw=1)
    ax0.axhline(WBs, ls=':', color='k', lw=1)
    ax0.text(-1.1, c0, r'c$_0$', ha='left', va='bottom', size=10)
    ax0.text(-1.15, WBs, 'WBs', ha='left', va='bottom', size=10)
    p0.plot_cprofiles(tlist=[1, 10, 100, 300],
                      ax=ax0,
                      func=lambda x: x2wp(x, y=y),
                      mirror=True,
                      lw=1)

    ax0.set_xlim(-1.16, 1.16)
    ax0.set_ylim(-.02, 1.9)
    ax0.set_title('Bainite (cell boundary)', y=1.06, size=12)
    add_label(ax0, 'a)', py=0)
        'font.size': 13,
        'mathtext.fontset': 'stix'
    })

    y = dict(Cu=3.55354266E-3,
             Mn=2.05516602E-3,
             Si=5.02504411E-2,
             Fe=9.4414085022e-1)

    parser = argparse.ArgumentParser()
    parser.add_argument('basenames', nargs='+')
    parser.add_argument('-S', '--save', action='store_true', help='Save plot')
    args = parser.parse_args()

    for basename in args.basenames:
        cprofiles = CProfiles(basename)

        print(cprofiles.basename)

        ax = cprofiles.plot_colormap(mirror=True,
                                     func=lambda x: x2wp(x, y=y),
                                     vmin=0,
                                     vmax=1.8)
        ax.set_xlabel(u'Position (μm)')
        ax.set_ylabel('Time (s)')
        ax.set_title(cprofiles.basename)

        if args.save:
            plt.savefig(os.path.join('img', cprofiles.basename + '.png'),
                        dpi=150)
            plt.close()