Esempio n. 1
0
def test01(tname):

    PF = V3 if tname == '3' else V4
    SHOW_PEAKS = tname != '0'

    ds = data_hdf5_v0(FNAME)
    #ds.print_images()

    alg = peak_finder_algos(pbits=0)
    if PF == V3:
        alg.set_peak_selection_parameters(npix_min=0,
                                          npix_max=1e6,
                                          amax_thr=0,
                                          atot_thr=0,
                                          son_min=6)
    if PF == V4:
        alg.set_peak_selection_parameters(npix_min=0,
                                          npix_max=1e6,
                                          amax_thr=0,
                                          atot_thr=0,
                                          son_min=6)

    img = ds.next_image()
    shape = img.shape
    mask = np.ones(shape, dtype=np.uint16)
    INDS = np.indices((shape[0], shape[1]), dtype=np.int64)
    imRow, imCol = INDS[0, :], INDS[1, :]

    fig1, axim1, axcb1 = gr.fig_img_cbar_axes(gr.figure(figsize=(8, 7)))

    for nev in range(min(EVTMAX, ds.nevmax)):

        img = ds.next_image()

        #ave, rms = img.mean(), img.std()
        #amin, amax = ave-1*rms, ave+8*rms
        #amin, amax = img.min(), img.max()
        amin, amax = 0, img.max()
        axim1.clear()
        axcb1.clear()

        #imsh1,cbar1=\
        gr.imshow_cbar(fig1, axim1, axcb1, img, amin=amin, amax=amax, extent=None,\
                       interpolation='nearest', aspect='auto', origin='upper',\
                       orientation='vertical', cmap='inferno')
        fig1.canvas.set_window_title('Event: %04d random data' % nev)
        gr.move_fig(fig1, x0=400, y0=30)

        if SHOW_PEAKS:
            peaks = alg.peak_finder_v3r3_d2(img, mask, rank=5, r0=7, dr=2, nsigm=9)               if PF == V3 else\
                alg.peak_finder_v4r3_d2(img, mask, thr_low=100, thr_high=200, rank=5, r0=7, dr=2) if PF == V4 else\
                None
            plot_peaks_on_img(peaks, axim1, imRow, imCol, color='w', lw=1)

        gr.show(mode='do not hold')

    gr.show()
Esempio n. 2
0
def plot_image(data):
    fig, axim, axcb = gr.fig_img_cbar_axes(gr.figure(figsize=(10, 5), dpi=80))
    ave, rms = np.mean(data), np.std(data)
    _, _ = gr.imshow_cbar(fig,
                          axim,
                          axcb,
                          data,
                          amin=ave - 1 * rms,
                          amax=ave + 5 * rms,
                          extent=None,
                          cmap='inferno')
    return axim
Esempio n. 3
0
iwf = 3

std = wfs[iwf, basemin:basemax].std()
mean = wfs[iwf, basemin:basemax].mean()
wf = wfs[iwf, binmin:binmax] - mean
nbins = wf.size
THR = -5 * std
print('XXXX wf base level mean:%.3f std:%.3f THR:%.3f' % (mean, std, THR))

ones_wf = np.ones_like(wf)
zeros_wf = np.zeros_like(wf)

kwargs = {}
fig = gr.figure(figsize=(12, 10),
                dpi=80,
                facecolor='w',
                edgecolor='w',
                frameon=True,
                **kwargs)
fig.canvas.set_window_title('Waveform filters', **kwargs)
fig.clear()


def axes_h(fig, naxes=4, x0=0.07, y0=0.03, width=0.87, ygap=0.04):
    dy = 1. / naxes
    return [
        gr.add_axes(fig, axwin=(x0, y0 + i * dy, width, dy - ygap))
        for i in range(naxes)
    ]


ax0, ax1, ax2, ax3 = axes = axes_h(fig)
Esempio n. 4
0
def test01(tname='1', NUMBER_OF_EVENTS=5, DO_PRINT=True):

    print('local extrema : %s' % ('minimums' if tname in ('1','2')\
                             else 'maximums' if tname in ('3','4')\
                             else 'maximums runk=1 cross' if tname in ('5','6')\
                             else 'two-threshold maximums' if tname == '7'\
                             else 'unknown test'))

    from time import time  #, sleep
    from psana.pyalgos.generic.NDArrUtils import print_ndarr
    import psana.pyalgos.generic.Graphics as gr

    sh, fs = (50, 50), (7, 6)
    fig1, axim1, axcb1 = gr.fig_img_cbar_axes(gr.figure(figsize=fs))
    fig2, axim2, axcb2 = gr.fig_img_cbar_axes(gr.figure(figsize=fs))
    imsh1 = None
    imsh2 = None

    print('Image shape: %s' % str(sh))

    mu, sigma = 200, 25

    for evnum in range(NUMBER_OF_EVENTS):

        data = 10.*np.ones(sh, dtype=np.float64) if tname in ('2','4','6') else\
               np.array(mu + sigma*np.random.standard_normal(sh), dtype=np.float64)
        mask = np.ones(sh, dtype=np.uint16)
        extrema = np.zeros(sh, dtype=np.uint16)
        rank = 5

        thr_low = mu + 3 * sigma
        thr_high = mu + 4 * sigma

        nmax = 0

        if DO_PRINT: print_ndarr(data, '        input data')
        t0_sec = time()
        #----------
        if tname in ('1', '2'):
            nmax = algos.local_minimums(data, mask, rank, extrema)
        elif tname in ('3', '4'):
            nmax = algos.local_maximums(data, mask, rank, extrema)
        elif tname in ('5', '6'):
            nmax = algos.local_maximums_rank1_cross(data, mask, extrema)
        elif tname == '7':
            nmax = algos.threshold_maximums(data, mask, rank, thr_low,
                                            thr_high, extrema)
        elif tname == '8':
            nmax = algos.local_maximums_rank1_cross(data, mask, extrema)
        else:
            contunue
        #----------
        print('Event: %2d,  consumed time = %10.6f(sec),  nmax = %d' %
              (evnum, time() - t0_sec, nmax))

        if DO_PRINT: print_ndarr(extrema, '        output extrema')

        img1 = data
        img2 = extrema

        axim1.clear()
        axcb1.clear()
        if imsh1 is not None: del imsh1
        imsh1 = None

        axim2.clear()
        axcb2.clear()
        if imsh2 is not None: del imsh2
        imsh2 = None

        #ave, rms = img1.mean(), img1.std()
        #amin, amax = ave-1*rms, ave+5*rms
        amin, amax = img1.min(), img1.max()
        #imsh1,cbar1=\
        gr.imshow_cbar(fig1, axim1, axcb1, img1, amin=amin, amax=amax, extent=None,\
                       interpolation='nearest', aspect='auto', origin='upper',\
                       orientation='vertical', cmap='inferno')
        fig1.canvas.set_window_title('Event: %d Random data' % evnum)
        gr.move_fig(fig1, x0=560, y0=30)

        #imsh2,cbar2=\
        gr.imshow_cbar(fig2, axim2, axcb2, img2, amin=0, amax=img2.max(), extent=None,\
                       interpolation='nearest', aspect='auto', origin='upper',\
                       orientation='vertical', cmap='inferno')
        fig2.canvas.set_window_title('Event: %d Local extrema' % evnum)
        gr.move_fig(fig2, x0=0, y0=30)

        gr.show(mode='DO_NOT_HOLD')

    gr.show()
Esempio n. 5
0
    'X1',
    'X2',
    'Y1',
    'Y2',
    'MCP',
    'XX',
    'YY',
)

dy = 1. / naxes
lw = 1
w = 0.87
h = dy - 0.04
x0, y0 = 0.07, 0.03

fig = gr.figure(figsize=(15, 15), title='Image')
fig.clear()
ax = [gr.add_axes(fig, axwin=(x0, y0 + i * dy, w, h)) for i in range(naxes)]


def array_of_selected_channels(a, ch=(2, 3, 4, 5, 6)):
    """converts shape:(8, 44000) -> shape:(5, 44000)"""
    return a[ch, :]


def draw_waveforms(wfs, wts, nev):
    """Draws all waveforms on figure axes, one waveform per axis.
       Parameters:
       - wfs [np.array] shape=(NUM_CHANNELS, NUM_SAMPLES) - waveform intensities
       - wts [np.array] shape=(NUM_CHANNELS, NUM_SAMPLES) - waveform times
    """
Esempio n. 6
0
def test01(tname='1', NUMBER_OF_EVENTS=3, DO_PRINT=False):

    print('local extrema : %s' % ('minimums' if tname in ('1','2')\
                             else 'maximums' if tname in ('3','4')\
                             else 'maximums runk=1 cross' if tname in ('5','6')\
                             else 'two-threshold maximums' if tname == '7'\
                             else 'unknown test'))

    from time import time
    from psana.pyalgos.generic.NDArrUtils import print_ndarr
    import psana.pyalgos.generic.Graphics as gg

    #sh, fs = (185,388), (11,5)
    sh, fs = (50, 50), (7, 7)
    fig1, axim1, axcb1 = gg.fig_img_cbar_axes(gg.figure(figsize=fs),
                                              (0.05, 0.05, 0.87, 0.90),
                                              (0.923, 0.05, 0.02, 0.90))
    fig2, axim2, axcb2 = gg.fig_img_cbar_axes(gg.figure(figsize=fs),
                                              (0.05, 0.05, 0.87, 0.90),
                                              (0.923, 0.05, 0.02, 0.90))

    print('Image shape: %s' % str(sh))

    mu, sigma = 200, 25

    for evnum in range(NUMBER_OF_EVENTS):

        data = 10.*np.ones(sh, dtype=np.float64) if tname in ('2','4','6') else\
               np.array(mu + sigma*np.random.standard_normal(sh), dtype=np.float64)
        mask = np.ones(sh, dtype=np.uint16)
        extrema = np.zeros(sh, dtype=np.uint16)
        rank = 5

        thr_low = mu + 3 * sigma
        thr_high = mu + 4 * sigma

        nmax = 0

        if DO_PRINT: print_ndarr(data, 'input data')
        t0_sec = time()
        #----------
        if tname in ('1', '2'):
            nmax = algos.local_minimums(data, mask, rank, extrema)
        elif tname in ('3', '4'):
            nmax = algos.local_maximums(data, mask, rank, extrema)
        elif tname in ('5', '6'):
            nmax = algos.local_maximums_rank1_cross(data, mask, extrema)
        elif tname == '7':
            nmax = algos.threshold_maximums(data, mask, rank, thr_low,
                                            thr_high, extrema)
        else:
            contunue
        #----------
        print('Event: %4d,  consumed time = %10.6f(sec),  nmax = %d' %
              (evnum, time() - t0_sec, nmax))

        if DO_PRINT: print_ndarr(extrema, 'output extrema')

        img1 = data
        img2 = extrema

        axim1.clear()
        axim2.clear()

        ave, rms = img1.mean(), img1.std()
        amin, amax = ave - 1 * rms, ave + 5 * rms
        gg.imshow_cbar(fig1,
                       axim1,
                       axcb1,
                       img1,
                       amin=amin,
                       amax=amax,
                       cmap='inferno')
        axim1.set_title('Event: %d, Data' % evnum, color='k', fontsize=20)
        gg.move_fig(fig1, x0=550, y0=30)

        gg.imshow_cbar(fig2,
                       axim2,
                       axcb2,
                       img2,
                       amin=0,
                       amax=5,
                       cmap='inferno')
        axim2.set_title('Event: %d, Local extrema' % evnum,
                        color='k',
                        fontsize=20)
        gg.move_fig(fig2, x0=0, y0=30)

        gg.show(mode='DO_NOT_HOLD')
    gg.show()
import psana.pyalgos.generic.Graphics as gr
from psana.pyalgos.generic.NDArrUtils import print_ndarr

#----------

tname = sys.argv[1] if len(sys.argv) > 1 else '1'
print('%s\nTEST %s' % (50 * '_', tname))

ifname = '/reg/g/psdm/detector/data2_test/npy/wavelets-amox27716-r0091.npy' if tname=='1' else\
         '/reg/g/psdm/detector/data2_test/npy/waveforms-amox27716-r0100-e000010.npy'

wf = np.load(ifname)
print('Waveforms loaded from file %s' % ifname)
print_ndarr(wf, 'Array of waveforms')

fig = gr.figure(figsize=(15, 15), title='Waveforms')
fig.clear()

naxes = 5
dy = 1. / naxes
w, h = 0.87, (dy - 0.04)
x0, y0 = 0.07, 0.03
gfmt = (
    'b-',
    'r-',
    'g-',
    'k-',
    'm-',
    'y-',
    'c-',
)
Esempio n. 8
0
def test_pf(tname):

    ##-----------------------------

    PF = V4  # default
    if tname == '1': PF = V1
    if tname == '2': PF = V2
    if tname == '3': PF = V3
    if tname == '4': PF = V4

    SKIP = 0
    EVTMAX = 10 + SKIP

    DO_PLOT_IMAGE = True
    DO_PLOT_PIXEL_STATUS = False  #True if PF in (V2,V4) else False
    DO_PLOT_CONNECED_PIXELS = False  #True if PF in (V2,V3,V4) else False
    DO_PLOT_LOCAL_MAXIMUMS = False  #True if PF == V3 else False
    DO_PLOT_LOCAL_MINIMUMS = False  #True if PF == V3 else False

    shape = (1000, 1000)

    mask = np.ones(shape, dtype=np.uint16)

    # Pixel image indexes
    #arr3d = np.array((1,shape[0],shape[1]))

    INDS = np.indices((1, shape[0], shape[1]), dtype=np.int64)
    imRow, imCol = INDS[1, :], INDS[2, :]
    #iX  = np.array(det.indexes_x(evt), dtype=np.int64) #- xoffset
    #iY  = np.array(det.indexes_y(evt), dtype=np.int64) #- yoffset

    ##-----------------------------
    fs = (8, 7)  # (11,10)
    fig1, axim1, axcb1 = gr.fig_img_cbar_axes(gr.figure(
        figsize=fs)) if DO_PLOT_IMAGE else (None, None, None)
    fig2, axim2, axcb2 = gr.fig_img_cbar_axes(gr.figure(
        figsize=fs)) if DO_PLOT_PIXEL_STATUS else (None, None, None)
    fig3, axim3, axcb3 = gr.fig_img_cbar_axes(gr.figure(
        figsize=fs)) if DO_PLOT_CONNECED_PIXELS else (None, None, None)
    fig4, axim4, axcb4 = gr.fig_img_cbar_axes(gr.figure(
        figsize=fs)) if DO_PLOT_LOCAL_MAXIMUMS else (None, None, None)
    fig5, axim5, axcb5 = gr.fig_img_cbar_axes(gr.figure(
        figsize=fs)) if DO_PLOT_LOCAL_MINIMUMS else (None, None, None)
    imsh1 = None
    imsh2 = None
    imsh3 = None
    imsh4 = None
    imsh5 = None
    ##-----------------------------

    alg = peak_finder_algos(pbits=0)

    if PF == V1:
        alg.set_peak_selection_parameters(npix_min=0,
                                          npix_max=1e6,
                                          amax_thr=0,
                                          atot_thr=0,
                                          son_min=6)

    elif PF == V2:
        alg.set_peak_selection_parameters(npix_min=0,
                                          npix_max=1e6,
                                          amax_thr=0,
                                          atot_thr=0,
                                          son_min=6)

    elif PF == V3:
        alg.set_peak_selection_parameters(npix_min=0,
                                          npix_max=1e6,
                                          amax_thr=0,
                                          atot_thr=0,
                                          son_min=8)

    elif PF == V4:
        alg.set_peak_selection_parameters(npix_min=0,
                                          npix_max=1e6,
                                          amax_thr=0,
                                          atot_thr=0,
                                          son_min=6)

    #alg.print_attributes()

    for ev in range(EVTMAX):
        ev1 = ev + 1

        if ev < SKIP: continue
        #if ev>=EVTMAX : break

        print(50 * '_', '\nEvent %04d' % ev1)

        img, peaks_sim = image_with_random_peaks(shape)

        # --- for debugging
        #np.save('xxx-image', img)
        #np.save('xxx-peaks', np.array(peaks_sim))

        #img = np.load('xxx-image-crash.npy')
        #peaks_sim = np.load('xxx-peaks-crash.npy')
        # ---

        peaks_gen = [(0, r, c, a, a * s, 9 * s * s)
                     for r, c, a, s in peaks_sim]

        t0_sec = time()

        peaks = alg.peak_finder_v3r3_d2(img, mask, rank=5, r0=7, dr=2, nsigm=3)                 if PF == V3 else\
                alg.peak_finder_v4r3_d2(img, mask, thr_low=20, thr_high=40, rank=6, r0=7, dr=2) if PF == V4 else\
                None
        #alg.peak_finder_v3r3_d2(img, rank=5, r0=7, dr=2, nsigm=3)        if PF == V3 else\
        #alg.peak_finder_v4r3_d2(img, thr_low=20, thr_high=40, rank=6, r0=7, dr=2) if PF == V3 else\

        print('  Time consumed by the peak_finder = %10.6f(sec)' %
              (time() - t0_sec))

        map2 = reshape_to_2d(alg.maps_of_pixel_status(
        )) if DO_PLOT_PIXEL_STATUS else None  # np.zeros((10,10))
        map3 = reshape_to_2d(alg.maps_of_connected_pixels(
        )) if DO_PLOT_CONNECED_PIXELS else None  # np.zeros((10,10))
        map4 = reshape_to_2d(alg.maps_of_local_maximums(
        )) if DO_PLOT_LOCAL_MAXIMUMS else None  # np.zeros((10,10))
        map5 = reshape_to_2d(alg.maps_of_local_minimums(
        )) if DO_PLOT_LOCAL_MINIMUMS else None  # np.zeros((10,10))

        print('arrays are extracted')

        #print_arr(map2, 'map_of_pixel_status')
        #print_arr(map3, 'map_of_connected_pixels')
        #maps.shape = shape

        print('Simulated peaks:')
        for i, (r0, c0, a0, sigma) in enumerate(peaks_sim):
            print('  %04d  row=%6.1f  col=%6.1f  amp=%6.1f  sigma=%6.3f' %
                  (i, r0, c0, a0, sigma))
        #plot_image(img)

        print('Found peaks:')
        print(hdr)
        reg = 'IMG'
        #for pk in peaks :
        #    seg,row,col,npix,amax,atot,rcent,ccent,rsigma,csigma,\
        #    rmin,rmax,cmin,cmax,bkgd,rms,son = pk[0:17]
        #    rec = fmt % (ev, reg, seg, row, col, npix, amax, atot, rcent, ccent, rsigma, csigma,\
        #          rmin, rmax, cmin, cmax, bkgd, rms, son) #,\
        #          #imrow, imcol, xum, yum, rum, phi)
        #    print(rec)

        for p in peaks:
            #print('  algos:', p.parameters())
            print('  row:%4d, col:%4d, npix:%4d, son:%4.1f amp_tot:%4.1f' %
                  (p.row, p.col, p.npix, p.son, p.amp_tot))

        if DO_PLOT_PIXEL_STATUS:
            gr.plot_imgcb(fig2,
                          axim2,
                          axcb2,
                          imsh2,
                          map2,
                          amin=0,
                          amax=30,
                          title='Pixel status, ev: %04d' % ev1)
            gr.move_fig(fig2, x0=0, y0=30)

        if DO_PLOT_CONNECED_PIXELS:
            cmin, cmax = (map3.min(),
                          map3.max()) if map3 is not None else (None, None)
            print('Connected pixel groups min/max:', cmin, cmax)
            gr.plot_imgcb(fig3,
                          axim3,
                          axcb3,
                          imsh3,
                          map3,
                          amin=cmin,
                          amax=cmax,
                          title='Connected pixel groups, ev: %04d' % ev1)
            gr.move_fig(fig3, x0=100, y0=30)

        if DO_PLOT_LOCAL_MAXIMUMS:
            gr.plot_imgcb(fig4,
                          axim4,
                          axcb4,
                          imsh4,
                          map4,
                          amin=0,
                          amax=10,
                          title='Local maximums, ev: %04d' % ev1)
            gr.move_fig(fig4, x0=200, y0=30)

        if DO_PLOT_LOCAL_MINIMUMS:
            gr.plot_imgcb(fig5,
                          axim5,
                          axcb5,
                          imsh5,
                          map5,
                          amin=0,
                          amax=10,
                          title='Local minimums, ev: %04d' % ev1)
            gr.move_fig(fig5, x0=300, y0=30)

        if DO_PLOT_IMAGE:
            #nda = maps_of_conpix_arc
            #nda = maps_of_conpix_equ
            #img = det.image(evt, nda)[xoffset:xoffset+xsize,yoffset:yoffset+ysize]
            #img = det.image(evt, mask_img*nda)[xoffset:xoffset+xsize,yoffset:yoffset+ysize]
            #img = det.image(evt, maps_of_conpix_equ)[xoffset:xoffset+xsize,yoffset:yoffset+ysize]

            ave, rms = img.mean(), img.std()
            amin, amax = ave - 1 * rms, ave + 8 * rms
            axim1.clear()
            if imsh1 is not None: del imsh1
            imsh1 = None
            gr.imshow_cbar(fig1, axim1, axcb1, img, amin=amin, amax=amax, extent=None,\
                           interpolation='nearest', aspect='auto', origin='upper',\
                           orientation='vertical', cmap='inferno')
            #gr.plot_imgcb(fig1, axim1, axcb1, imsh1, img, amin=amin, amax=amax, title='Image, ev: %04d' % ev1)
            fig1.canvas.set_window_title('Event: %04d random data' % ev1)
            gr.move_fig(fig1, x0=400, y0=30)

            #plot_peaks_on_img(peaks_gen, axim1, imRow, imCol, color='g', lw=5)
            plot_peaks_on_img(peaks, axim1, imRow, imCol, color='w', lw=1)

            fig1.canvas.draw()  # re-draw figure content

            #gr.plotHistogram(nda, amp_range=(-100,100), bins=200, title='Event %d' % i)
            gr.show(mode='do not hold')

    gr.show()
Esempio n. 9
0
def test01(tname='1', NUMBER_OF_EVENTS=10, DO_PRINT=False):

    print('local extrema : %s' % ('minimums' if tname in ('1','2')\
                             else 'maximums'))

    #sh, fs = (200,200), (11,10)
    sh, fs = (50, 50), (7, 6)
    #sh, fs = (185,388), (11,5)
    fig1, axim1, axcb1 = gr.fig_img_cbar_axes(gr.figure(figsize=fs))
    fig2, axim2, axcb2 = gr.fig_img_cbar_axes(gr.figure(figsize=fs))
    imsh1 = None
    imsh2 = None

    print('Image shape: %s' % str(sh))

    mu, sigma = 200, 25

    for evnum in range(NUMBER_OF_EVENTS):

        data = 10*np.ones(sh, dtype=np.float64) if tname in ('2','4') else\
               np.array(mu + sigma*np.random.standard_normal(sh), dtype=np.float64)
        mask = np.ones(sh, dtype=np.uint16).flatten()
        #mask = np.random.binomial(2, 0.80, data.size).astype(dtype=np.uint16)
        extrema = np.zeros(sh, dtype=np.uint16).flatten()

        rank = 5

        nmax = 0

        if DO_PRINT: print_ndarr(data, 'input data')
        t0_sec = time()

        #----------
        if tname in ('1', '2'):
            nmax = algos.local_minima_1d(data.flatten(), mask, rank, extrema)
        elif tname in ('3', '4'):
            nmax = algos.local_maxima_1d(data.flatten(), mask, rank, extrema)
        #----------
        print('Event: %4d,  consumed time = %10.6f(sec),  nmax = %d' %
              (evnum, time() - t0_sec, nmax))

        extrema.shape = sh

        if DO_PRINT: print_ndarr(extrema, 'output extrema')

        img1 = data
        img2 = extrema

        axim1.clear()
        axcb1.clear()
        if imsh1 is not None: del imsh1
        imsh1 = None

        axim2.clear()
        axcb2.clear()
        if imsh2 is not None: del imsh2
        imsh2 = None

        ave, rms = img1.mean(), img1.std()
        amin, amax = ave - 1 * rms, ave + 5 * rms
        #imsh1,cbar1=\
        gr.imshow_cbar(fig1, axim1, axcb1, img1, amin=amin, amax=amax, extent=None,\
                       interpolation='nearest', aspect='auto', origin='upper',\
                       orientation='vertical', cmap='inferno')
        fig1.canvas.set_window_title('Event: %d Random data' % evnum)
        gr.move_fig(fig1, x0=560, y0=30)

        #imsh2,cbar2=\
        gr.imshow_cbar(fig2, axim2, axcb2, img2, amin=0, amax=5, extent=None,\
                       interpolation='nearest', aspect='auto', origin='upper',\
                       orientation='vertical', cmap='inferno')
        fig2.canvas.set_window_title(
            'Event: %d Local extrema (1d-folded in image)' % evnum)
        gr.move_fig(fig2, x0=0, y0=30)

        gr.show(mode='DO_NOT_HOLD')
    gr.show()