Пример #1
0
def plot():
    """
    Example plot of "Dinkydau flake" location, classic test case for 
    perturbation techinque and glitch correction.
    """
    directory = "./perturb3"
    # A simple showcas using perturbation technique
    x, y = "-0.75", "0."
    dx = "5.e0"
    precision = 150
    nx = 3200
    x = '-1.993101465346811633595616349779370960719700854263460744227885419412572351324445321874004442403503011725492641453441484329872421586639050539267910275781311721259641283288898121495962960511188360859446141741747448336162741635241659807342073817485606900204314068415477260531866235822220430486119843399542682686903115170284286744427789259769672374264750048282753697939441835784223761880144973743249562058785490789121881765822494487680713802365108655723804325265573559505557675274602687698535315326824126504568612493712586162172913902182849175957355201038749736221172166381630971780664574945186600702295814202276821096082583371646391752258136082934974808859285874633438821365019578751567557825904520349615083013659980914914027970434909527071583051834592117828848476162531653958895351112086988431145593103631584906268842017812275327407852982198464690863881669210429524886644612378383194829443312845510612712652609161824242961337428831821452985753354390486290596759804822656081435972288149493458837417345622327424314356121019642859410599076344584439053'
    y = '-0.0000000000000000000001023710512431589570005203798273240286470771650981763139330824251367527539704908652681677255846096018123604758184274291544039306788236186699886780634842327075201516856958710101981983627439650646801970216473720458108184168523830340517163870169919249638047451318365933557979031258177237717753794769207546631778925762244933996868229775839453423976148160460368950010744615992543567659336441278697767936754177402161193387335896316048958999044786173769537636937690325372184302039387809032377492478883386867909568081378343026465718279702082155350634045451662043279571130329807181205168575035218579446441743895034500494162054542465662499561872308796389299543485971550119965555406797513540955180015002773089512902159298036751555750537198269153512054314778106379999904973319311775913118876664658896447125394230182911598486994660593785101070940474199338173235671779027464278763584882649334715308568951689930703319182855450455829071681801598812078546949506703052822064075723064430117087174494686425795962484572598182905448268661576794867514394048126125843131'
    dx = '0.000000000000000000000000000000000000000000000000000001611311677165311992036964188953416400357306950103215815939935672793028078345666262795353854791128193417180028322502563016371152356567374462535929127041725333256467561733290384009069197316210881426462964928434585521650089769009585599250595741136222346428026621232359069818161715344902647536565294138377179149230247747809792678090166161270842118179873716803137049807896171897484336423552754428273143300120233210420317384023816622150052145902931298541283952210479589483643604612244327904646956347253652556190458708451251053597744280720211750536552494355053069572018017158283906744473170534917744052363527030185810701281751448157641033852978421572439410367749824884649311769407121646490987840830692921695850309271975840408355787675238627661695949205488539553336065242972661368264433343340961667491522236015169240810915606280026794402643082165872947330057146892300382601081535552273108633947461317572323488134065825603499355505743581891071053495091972381402991134813796575186487618387985500615976611029133681690931704603523636857668558756510416666667'

    # Set to True if you only want to rerun the post-processing part
    settings.skip_calc = False
    # Set to True to enable multi-processing
    settings.enable_multiprocessing = True

    #    xy_ratio = 1.0
    #    theta_deg = 0.
    # complex_type = np.complex128

    mandelbrot = fsm.Perturbation_mandelbrot(directory)
    mandelbrot.zoom(precision=precision,
                    x=x,
                    y=y,
                    dx=dx,
                    nx=nx,
                    xy_ratio=1.0,
                    theta_deg=0.,
                    projection="cartesian",
                    antialiasing=True)

    mandelbrot.calc_std_div(
        complex_type=np.complex128,
        file_prefix="dev",
        subset=None,
        max_iter=50000,
        M_divergence=1.e3,
        epsilon_stationnary=1.e-3,
        pc_threshold=0.1,
        SA_params={
            "cutdeg": 64,
            "cutdeg_glitch": 8,
            "SA_err": 1.e-4,
            "use_Taylor_shift": True
        },
        glitch_eps=1.e-6,
        interior_detect=False,  #True,
        glitch_max_attempt=20)

    mandelbrot.run()

    mask_codes = [0, 2, 3, 4]
    mask = fs.Fractal_Data_array(
        mandelbrot,
        file_prefix="dev",
        postproc_keys=('stop_reason', lambda x: np.isin(x, mask_codes)),
        mode="r+raw")
    #    cv = fs.Fractal_Data_array(mandelbrot, file_prefix="dev",
    #                postproc_keys=('stop_reason', lambda x: x != 2), mode="r+raw")
    #    potential_data_key = ("potential", {})

    #    gold = np.array([255, 210, 66]) / 255.
    #    black = np.array([0, 0, 0]) / 255.
    #    color_gradient = fs.Color_tools.Lch_gradient(gold, black, 200)
    #    colormap = fs.Fractal_colormap(color_gradient)
    gold = np.array([255, 210, 66]) / 255.
    black = np.array([0, 0, 0]) / 255.
    purple = np.array([181, 40, 99]) / 255.
    colors1 = np.vstack((purple[np.newaxis, :]))
    colors2 = np.vstack((gold[np.newaxis, :]))
    colormap = fscolors.Fractal_colormap(kinds="Lch",
                                         colors1=colors1,
                                         colors2=colors2,
                                         n=200,
                                         funcs=None,
                                         extent="mirror")

    plotter = fs.Fractal_plotter(
        fractal=mandelbrot,
        base_data_key=("potential",
                       {}),  # potential_data_key, #glitch_sort_key,
        base_data_prefix="dev",
        base_data_function=lambda x: x,  # np.sin(x*0.0001),
        colormap=colormap,
        probes_val=[
            0., 0.55
        ],  # 200. + 200, #* 428  - 00.,#[0., 0.5, 1.], #phi * k * 2. + k * np.array([0., 1., 1.5, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0]) / 3.5,
        probes_kind="qt",  #"z", "qt"
        mask=mask)

    #plotter.add_calculation_layer(postproc_key=potential_data_key)

    #    layer1_key = ("DEM_shade", {"kind": "potential",
    #                                "theta_LS": 30.,
    #                                "phi_LS": 50.,
    #                                "shininess": 3.,
    #                                "ratio_specular": 15000.})
    #    plotter.add_grey_layer(postproc_key=layer1_key, intensity=0.75,
    #                         blur_ranges=[],#[[0.99, 0.999, 1.0]],
    #                        disp_layer=False, #skewness=0.2,
    #                         normalized=False, hardness=0.35,
    #            skewness=0.0, shade_type={"Lch": 1.0, "overlay": 1., "pegtop": 4.})

    #    layer2_key = ("field_lines", {})
    #    plotter.add_grey_layer(postproc_key=layer2_key,
    #                         hardness=1.0, intensity=0.68, skewness=0.0,
    ##                         blur_ranges=[[0.50, 0.60, 1.0]],
    #                         shade_type={"Lch": 0., "overlay": 2., "pegtop": 1.})
    plotter.add_grey_layer(postproc_key=("DEM_shade", {
        "kind": "potential",
        "theta_LS": 30.,
        "phi_LS": 50.,
        "shininess": 30.,
        "ratio_specular": 15000.
    }),
                           blur_ranges=[],
                           hardness=0.9,
                           intensity=0.8,
                           shade_type={
                               "Lch": 1.0,
                               "overlay": 0.,
                               "pegtop": 4.
                           })

    plotter.plot("dev", mask_color=(0., 0., 0.))
Пример #2
0
def plot():
    """
    Example plot of "Dinkydau flake" location, classic test case for 
    perturbation techinque and glitch correction.
    """
    directory = "./perturb2"
    # A simple showcas using perturbation technique
    x, y = "-1.74920463345912691e+00", "-2.8684660237361114e-04"
    dx = "5e-12"
    precision = 16
    nx = 800

    # Set to True if you only want to rerun the post-processing part
    settings.skip_calc = False
    # Set to True to enable multi-processing
    settings.enable_multiprocessing = True

    #    xy_ratio = 1.0
    #    theta_deg = 0.
    # complex_type = np.complex128

    mandelbrot = fsm.Perturbation_mandelbrot(directory)
    mandelbrot.zoom(precision=precision,
                    x=x,
                    y=y,
                    dx=dx,
                    nx=nx,
                    xy_ratio=1.0,
                    theta_deg=0.,
                    projection="cartesian",
                    antialiasing=False)

    mandelbrot.calc_std_div(complex_type=np.complex128,
                            file_prefix="dev",
                            subset=None,
                            max_iter=50000,
                            M_divergence=1.e3,
                            epsilon_stationnary=1.e-3,
                            pc_threshold=0.1,
                            SA_params={
                                "cutdeg": 8,
                                "cutdeg_glitch": 8,
                                "SA_err": 1.e-4,
                                "use_Taylor_shift": True
                            },
                            glitch_eps=1.e-6,
                            interior_detect=True,
                            glitch_max_attempt=20)

    mandelbrot.run()

    cv = fs.Fractal_Data_array(mandelbrot,
                               file_prefix="dev",
                               postproc_keys=('stop_reason', lambda x: x == 1),
                               mode="r+raw")
    potential_data_key = ("potential", {})

    citrus2 = np.array([103, 189, 0]) / 255.
    citrus_white = np.array([252, 251, 226]) / 255.

    wheat1 = np.array([244, 235, 158]) / 255.
    wheat2 = np.array([246, 207, 106]) / 255.
    wheat3 = np.array([191, 156, 96]) / 255.

    lavender1 = np.array([154, 121, 144]) / 255.
    lavender2 = np.array([140, 94, 134]) / 255.
    lavender3 = np.array([18, 16, 58]) / 255.

    def wave(x):
        return 0.5 + (0.4 * (x - 0.5) - 0.6 * 0.5 * np.cos(x * np.pi * 3.))

    colormap = fscolors.Fractal_colormap(
        kinds="Lch",
        colors1=np.vstack(
            (citrus_white, wheat2, wheat1, wheat2, wheat1, wheat2, wheat3,
             wheat1, lavender2, wheat1, wheat2, wheat3, wheat1, lavender2,
             wheat1, lavender3, lavender2, lavender3, lavender1, lavender3,
             lavender2)),
        colors2=None,
        n=100,
        funcs=lambda x: wave(x),
        extent="mirror")

    plotter = fs.Fractal_plotter(
        fractal=mandelbrot,
        base_data_key=
        potential_data_key,  # potential_data_key, #glitch_sort_key,
        base_data_prefix="dev",
        base_data_function=lambda x: x,  # np.sin(x*0.0001),
        colormap=colormap,
        probes_val=np.linspace(0., 1., 22) *
        0.5,  # 200. + 200, #* 428  - 00.,#[0., 0.5, 1.], #phi * k * 2. + k * np.array([0., 1., 1.5, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0]) / 3.5,
        probes_kind="qt",  #"z", "qt"
        mask=~cv)

    #plotter.add_calculation_layer(postproc_key=potential_data_key)

    layer1_key = ("DEM_shade", {
        "kind": "potential",
        "theta_LS": 30.,
        "phi_LS": 50.,
        "shininess": 3.,
        "ratio_specular": 15000.
    })
    plotter.add_grey_layer(
        postproc_key=layer1_key,
        intensity=0.75,
        blur_ranges=[],  #[[0.99, 0.999, 1.0]],
        disp_layer=False,  #skewness=0.2,
        normalized=False,
        hardness=0.35,
        skewness=0.0,
        shade_type={
            "Lch": 1.0,
            "overlay": 1.,
            "pegtop": 4.
        })

    layer2_key = ("field_lines", {})
    plotter.add_grey_layer(postproc_key=layer2_key,
                           hardness=1.0,
                           intensity=0.68,
                           skewness=0.4,
                           blur_ranges=[[0.50, 0.60, 1.0]],
                           shade_type={
                               "Lch": 0.,
                               "overlay": 2.,
                               "pegtop": 1.
                           })

    plotter.plot("dev", mask_color=(0., 0., 1.))
Пример #3
0
def plot():
    """
    Example plot of "Dinkydau flake" location, classic test case for 
    perturbation technique and glitch correction.
    """
    directory = "./flake"

    # Dinkydau flake
    # http://www.fractalforums.com/announcements-and-news/pertubation-theory-glitches-improvement/msg73027/#msg73027
    # Ball method 1 found period: 7884
    x = "-1.99996619445037030418434688506350579675531241540724851511761922944801584242342684381376129778868913812287046406560949864353810575744772166485672496092803920095332"
    y = "0.00000000000000000000000000000000030013824367909383240724973039775924987346831190773335270174257280120474975614823581185647299288414075519224186504978181625478529"
    dx = "1.8e-157"
    precision = 200

    # Set to True if you only want to rerun the post-processing part
    settings.skip_calc = False
    # Set to True to enable multi-processing
    settings.enable_multiprocessing = True

    nx = 600
    xy_ratio = 0.5
    theta_deg = 0.
    complex_type = np.complex128

    mandelbrot = fsm.Perturbation_mandelbrot(directory)
    mandelbrot.zoom(precision=precision,
                    x=x,
                    y=y,
                    dx=dx,
                    nx=nx,
                    xy_ratio=xy_ratio,
                    theta_deg=theta_deg,
                    projection="cartesian",
                    antialiasing=False)

    mandelbrot.calc_std_div(complex_type=complex_type,
                            file_prefix="dev",
                            subset=None,
                            max_iter=50000,
                            M_divergence=1.e3,
                            epsilon_stationnary=1.e-3,
                            pc_threshold=0.1,
                            SA_params={
                                "cutdeg": 8,
                                "cutdeg_glitch": 8,
                                "SA_err": 1.e-4,
                                "use_Taylor_shift": True
                            },
                            glitch_eps=1.e-6,
                            interior_detect=False,
                            glitch_max_attempt=20)

    mandelbrot.run()

    glitched = fs.Fractal_Data_array(mandelbrot,
                                     file_prefix="dev",
                                     postproc_keys=('stop_reason',
                                                    lambda x: x == 3),
                                     mode="r+raw")
    potential_data_key = ("potential", {})

    citrus2 = np.array([103, 189, 0]) / 255.
    citrus_white = np.array([252, 251, 226]) / 255.

    wheat1 = np.array([244, 235, 158]) / 255.
    wheat2 = np.array([246, 207, 106]) / 255.
    wheat3 = np.array([191, 156, 96]) / 255.

    lavender1 = np.array([154, 121, 144]) / 255.
    lavender2 = np.array([140, 94, 134]) / 255.
    lavender3 = np.array([18, 16, 58]) / 255.

    def wave(x):
        return 0.5 + (0.4 * (x - 0.5) - 0.6 * 0.5 * np.cos(x * np.pi * 3.))

    colormap = fscolors.Fractal_colormap(
        kinds="Lch",
        colors1=np.vstack(
            (citrus_white, wheat2, wheat1, wheat2, wheat1, wheat2, wheat3,
             wheat1, lavender2, wheat1, wheat2, wheat3, wheat1, lavender2,
             wheat1, lavender3, lavender2, lavender3, lavender1, lavender3,
             lavender2)),
        colors2=None,
        n=100,
        funcs=lambda x: wave(x),
        extent="mirror")

    #    colormap.extent = "mirror" #"repeat"

    plotter = fs.Fractal_plotter(
        fractal=mandelbrot,
        base_data_key=
        potential_data_key,  # potential_data_key, #glitch_sort_key,
        base_data_prefix="dev",
        base_data_function=lambda x: x,  # np.sin(x*0.0001),
        colormap=colormap,
        probes_val=np.linspace(0., 1., 22)**
        0.2,  # 200. + 200, #* 428  - 00.,#[0., 0.5, 1.], #phi * k * 2. + k * np.array([0., 1., 1.5, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0]) / 3.5,
        probes_kind="qt",  #"z", "qt"
        mask=glitched)

    #plotter.add_calculation_layer(postproc_key=potential_data_key)

    layer1_key = ("DEM_shade", {
        "kind": "potential",
        "theta_LS": 30.,
        "phi_LS": 50.,
        "shininess": 30.,
        "ratio_specular": 15000.
    })
    plotter.add_grey_layer(
        postproc_key=layer1_key,
        intensity=0.75,
        blur_ranges=[],  #[[0.99, 0.999, 1.0]],
        disp_layer=False,  #skewness=0.2,
        normalized=False,
        hardness=0.35,
        skewness=0.0,
        shade_type={
            "Lch": 1.0,
            "overlay": 1.,
            "pegtop": 4.
        })

    layer2_key = ("field_lines", {})
    plotter.add_grey_layer(postproc_key=layer2_key,
                           hardness=1.0,
                           intensity=0.68,
                           skewness=0.4,
                           blur_ranges=[[0.50, 0.60, 1.0]],
                           shade_type={
                               "Lch": 0.,
                               "overlay": 2.,
                               "pegtop": 1.
                           })

    plotter.plot("dev", mask_color=(0., 0., 1.))
Пример #4
0
def func(fractal: fsm.Perturbation_mandelbrot = fractal,
         file_prefix: str = "test",
         x: mpmath.mpf = x,
         y: mpmath.mpf = y,
         dx: mpmath.mpf = dx,
         xy_ratio: float = xy_ratio,
         dps: int = dps,
         max_iter: int = max_iter,
         nx: int = nx):  #
    #             interior_detect: bool=True):

    interior_detect = False  # True

    #    fractal.clean_up(file_prefix)

    fractal.zoom(precision=dps,
                 x=x,
                 y=y,
                 dx=dx,
                 nx=nx,
                 xy_ratio=xy_ratio,
                 theta_deg=0.,
                 projection="cartesian",
                 antialiasing=False)
    fractal.calc_std_div(
        complex_type=np.complex128,
        file_prefix=file_prefix,
        subset=None,
        max_iter=max_iter,
        M_divergence=1.e3,
        epsilon_stationnary=1.e-4,
        pc_threshold=0.1,
        SA_params={
            "cutdeg": 8,
            "cutdeg_glitch": 8,
            "SA_err": 1.e-20,  # "SA_err" 1e-6, "cutdeg": 8 fails
            # "SA_err" 1e-20, "cutdeg": 8 fails
            # "SA_err" 1e-20, "cutdeg": 64 fails
            # "SA_err" 1e-50, "cutdeg": 64 fails
            # "SA_err" 1e-200, "cutdeg": 64
            "use_Taylor_shift": True
        },
        glitch_eps=1.e-6,
        interior_detect=interior_detect,
        glitch_max_attempt=4)
    fractal.run()

    gold = np.array([255, 210, 66]) / 255.
    black = np.array([0, 0, 0]) / 255.
    purple = np.array([181, 40, 99]) / 255.
    citrus2 = np.array([103, 189, 0]) / 255.
    colors1 = np.vstack((citrus2[np.newaxis, :]))
    colors2 = np.vstack((black[np.newaxis, :]))
    colormap = fscolors.Fractal_colormap(kinds="Lch",
                                         colors1=colors1,
                                         colors2=colors2,
                                         n=200,
                                         funcs=None,
                                         extent="mirror")

    mask_codes = [2]  #, 3, 4]
    mask = fs.Fractal_Data_array(
        fractal,
        file_prefix=file_prefix,
        postproc_keys=('stop_reason', lambda x: np.isin(x, mask_codes)),
        mode="r+raw")

    plotter = fs.Fractal_plotter(
        fractal=fractal,
        base_data_key=("potential",
                       {}),  # ("field_lines", {"n_iter": 10, "swirl": 1.}), ,
        base_data_prefix=file_prefix,
        base_data_function=lambda x: x,
        colormap=colormap,
        probes_val=[0.25, 0.75],
        probes_kind="qt",
        mask=mask)
    #  plotter.add_calculation_layer(("potential", {}))
    plotter.add_grey_layer(postproc_key=("DEM_shade", {
        "kind": "potential",
        "theta_LS": 30.,
        "phi_LS": 70.,
        "shininess": 300.,
        "ratio_specular": 15000.
    }),
                           blur_ranges=[],
                           hardness=0.9,
                           intensity=0.8,
                           shade_type={
                               "Lch": 1.0,
                               "overlay": 0.,
                               "pegtop": 4.
                           })
    plotter.plot(file_prefix, mask_color=(0., 0., 1.))
Пример #5
0
    def make_M2_img(self, x, y, dx, precision, nx, complex_type, test_name,
                    prefix, interior_detect=False, mask_codes=[3, 4], 
                    SA_params={"cutdeg": 64, "cutdeg_glitch": 8},
                    antialiasing=False, colormap=None, hardness=0.75,
                    intensity=0.95,
                    probes_val=[0., 0.25], blur_ranges=[],
                    grey_layer_key=None,
                    glitch_max_attempt=1, xy_ratio=1.0):
        """
        
        """
        test_dir = os.path.join(self.image_dir, test_name)

        mandelbrot = fsmodels.Perturbation_mandelbrot(test_dir)
        mandelbrot.zoom(
             precision=precision,
             x=x,
             y=y,
             dx=dx,
             nx=nx,
             xy_ratio=xy_ratio,
             theta_deg=0.,
             projection="cartesian",
             antialiasing=antialiasing)

        mandelbrot.prepare_calc(
            kind="calc_std_div",
            complex_type=complex_type,
            file_prefix=prefix,
            subset=None,
            max_iter=50000,
            M_divergence=1.e3,
            epsilon_stationnary=1.e-3,
            pc_threshold=0.1,
            SA_params=SA_params,
            glitch_eps=1.e-6,
            interior_detect=interior_detect,
            glitch_max_attempt=glitch_max_attempt)

        mandelbrot.run()

        mask = fs.Fractal_Data_array(mandelbrot, file_prefix=prefix,
            postproc_keys=('stop_reason', lambda x: np.isin(x, mask_codes)),
            mode="r+raw")

        potential = ("potential", {})
        if colormap is None:
            colormap = self.colormap
        if grey_layer_key is None:
            grey_layer_key = ("DEM_shade", 
                {"kind": "potential", "theta_LS": 50., "phi_LS": 40.,
                 "shininess": 40., "ratio_specular": 8.})

        plotter = fs.Fractal_plotter(
            fractal=mandelbrot,
            base_data_key=potential,
            base_data_prefix=prefix,
            base_data_function=lambda x:x,
            colormap=colormap,
            probes_val=probes_val,
            probes_kind="qt",
            mask=mask)

        plotter.add_grey_layer(
                postproc_key=grey_layer_key,
                blur_ranges=blur_ranges,
                hardness=hardness,
                intensity=intensity,
                shade_type={"Lch": 1.0, "overlay": 0., "pegtop": 4.})

        plotter.plot(prefix, mask_color=(0., 0., 1.))
        new_file = os.path.join(self.image_dir,
                                test_name + "_" + prefix + ".png")
        shutil.move(os.path.join(test_dir, prefix + ".png"), new_file)
        shutil.rmtree(test_dir)
        return new_file
Пример #6
0
    def run(self
            ):  #, FP_loop, FP_params, SA_init, SA_loop, SA_params, max_iter,
        # initialize, iterate, subset, codes,
        # file_prefix, pc_threshold, iref=0, glitch_stop_index=None,
        # glitch_sort_key=None, glitch_max_attempt=0):
        """
        glitch_stop_index : All points with a stop_reason >= glitch_stop_index
                are considered glitched (early ref exit glitch, or dynamic
                glitch). Subset of pixel for which 
                stop_reason == glitch_stop_index will be sorted according to 
                minimum value of field `glitch_sort_key` the minimal  point
                used as new reference.
                
        glitch_sort_key : the complex (Z array) field where is stored our
            'priority value' to select the next reference pixel.
        """
        file_prefix = self.file_prefix
        max_iter = self.max_iter
        SA_params = copy.deepcopy(self.SA_params)

        self.iref = 0

        FP_params, ref_path = self.ensure_ref_point(self.FP_loop(),
                                                    self.max_iter,
                                                    file_prefix,
                                                    iref=self.iref,
                                                    c0=None)
        FP_params0 = self.reload_ref_point(0, file_prefix, scan_only=True)

        # If SA is activated :
        # Reload SA coefficient, otherwise compute them.
        cutdeg_glitch = None
        if SA_params is not None:
            use_Taylor_shift = SA_params.pop("use_Taylor_shift", True)
            cutdeg_glitch = SA_params.pop("cutdeg_glitch", None)
            try:
                SA_params = self.reload_SA(self.iref, file_prefix)
            except FileNotFoundError:
                SA_params = self.series_approx(self.SA_init(), self.SA_loop(),
                                               SA_params, self.iref,
                                               file_prefix)
                self.save_SA(SA_params, self.iref, file_prefix)

        # First a standard "perturbation" cycle, no glitch correction
        self._iterate = self.iterate()
        self.cycles(chunk_slice=None, SA_params=SA_params)

        # Exit if glitch correction inactive
        if self.glitch_stop_index is None or fssettings.skip_calc:
            return

        # Glitch correction loops
        # Lopping cycles until no more glitched areas remain
        # First inspecting already computed data, completing partial loop
        # (if any). Note that super.cycles will escape pixels irefs >= iref
        glitch_sort_key = self.glitch_sort_key
        glitch_stop_index = self.glitch_stop_index

        dyn_glitched = fs.Fractal_Data_array(
            self,
            file_prefix=file_prefix,
            postproc_keys=('stop_reason',
                           lambda x: x == self.glitch_stop_index),
            mode="r+raw")
        # We store this one as an attribute, as this is the pixels which will
        # need an update "escaped_or_glitched"
        self.all_glitched = fs.Fractal_Data_array(
            self,
            file_prefix=file_prefix,
            postproc_keys=('stop_reason', lambda x: x >= glitch_stop_index),
            mode="r+raw")
        glitch_sorts = fs.Fractal_Data_array(self,
                                             file_prefix=file_prefix,
                                             postproc_keys=(glitch_sort_key,
                                                            None),
                                             mode="r+raw")
        stop_iters = fs.Fractal_Data_array(self,
                                           file_prefix=file_prefix,
                                           postproc_keys=("stop_iter", None),
                                           mode="r+raw")

        #        _gcc = 0
        #        _gcc_max = self.glitch_max_attempt

        # This looping is for dynamic glitches, we loop the largest glitches
        # first, a glitch being defined as 'same stop iteration'

        all_glitch_count = self.all_glitched.nansum()
        dyn_glitch_count = dyn_glitched.nansum()
        print("ANY glitched ? ", dyn_glitch_count, all_glitch_count)

        while ((self.iref < self.glitch_max_attempt)
               and (all_glitch_count > 0)):  #glitched.nanmax():
            #            _gcc += 1

            self.iref += 1
            print("Launching glitch correction cycle, iref = ", self.iref)

            # We need to define c0
            #            glitched = fs.Fractal_Data_array(self, file_prefix=file_prefix,
            #                    postproc_keys=('stop_reason',
            #                    lambda x: x == glitch_stop_index), mode="r+raw")

            print("with glitch pixel total count", dyn_glitch_count,
                  glitch_sort_key)
            print("with glitch and escaped pixel combined count",
                  all_glitch_count)

            if dyn_glitch_count > 0:
                glitched = dyn_glitched
                flag = 'dyn'
            else:
                glitched = self.all_glitched
                flag = 'escape'
                print("ESCAPE GLITCH !!!")

            # Minimize sort criteria over the selected glitch
            if flag == 'dyn':
                glitch_iter = self.largest_glitch_iter(stop_iters, glitched)
                (min_glitch_chunk,
                 min_glitch_arg) = self.min_glitch_pt(glitch_sorts, stop_iters,
                                                      glitched, glitch_iter)
            elif flag == 'escape':
                print("ESCAPE mode, count", all_glitch_count)
                (min_glitch_chunk, min_glitch_arg) = self.random_glitch_pt(
                    all_glitch_count, self.all_glitched)

            print("candidate", flag, min_glitch_chunk, min_glitch_arg)
            # Now lets define ci. offset from image center is known
            offset_x, offset_y = self.offset_chunk(min_glitch_chunk)
            #            offset_x = np.ravel(offset_x)
            #            offset_y = np.ravel(offset_y)
            #            if self.subset is not None:
            #                chunk_mask = np.ravel(self.subset[min_glitch_chunk])
            #                offset_x = offset_x[chunk_mask]
            #                offset_y = offset_y[chunk_mask]

            if self.Xrange_complex_type:
                print("With shift from center coords:\n",
                      fsx.Xrange_to_mpfc(offset_x[min_glitch_arg]) / self.dx,
                      fsx.Xrange_to_mpfc(offset_y[min_glitch_arg]) / self.dy)
            else:
                print("With shift from center coords:\n",
                      offset_x[min_glitch_arg] / self.dx,
                      offset_y[min_glitch_arg] / self.dy)

            if self.Xrange_complex_type:
                ci = (self.x + fsx.Xrange_to_mpfc(offset_x[min_glitch_arg]) +
                      1j *
                      (self.y + fsx.Xrange_to_mpfc(offset_y[min_glitch_arg])))
            else:
                ci = (self.x + offset_x[min_glitch_arg] + 1j *
                      (self.y + offset_y[min_glitch_arg]))

            if flag == 'dyn':
                # Overall slightly counter-productive to add a Newton step here
                # (less robust), we keep the raw selected point
                FP_params, Z_path = self.ensure_ref_point(self.FP_loop(),
                                                          max_iter,
                                                          file_prefix,
                                                          iref=self.iref,
                                                          c0=ci,
                                                          newton="None",
                                                          order=glitch_iter)
            elif flag == 'escape':
                # just keep the raw point
                FP_params, Z_path = self.ensure_ref_point(self.FP_loop(),
                                                          max_iter,
                                                          file_prefix,
                                                          iref=self.iref,
                                                          c0=ci,
                                                          newton="None",
                                                          order=-1)

            if (SA_params is not None):
                print("SA_params cutdeg / iref:", SA_params["cutdeg"],
                      SA_params["iref"])
                try:
                    SA_params = self.reload_SA(self.iref, file_prefix)
                except FileNotFoundError:
                    if use_Taylor_shift:
                        # We will shift the SA params coefficient from the first
                        # reference point
                        print("Shifting SA from pt0 to new reference point")
                        SA_params0 = self.reload_SA(0, file_prefix)
                        P0 = SA_params0["P"]
                        dc_ref = (fsx.mpc_to_Xrange(
                            FP_params["ref_point"] - FP_params0["ref_point"],
                            self.base_complex_type) / SA_params0["kc"])
                        print("##### dc_ref", dc_ref)
                        P_shifted = []
                        for P0i in P0:
                            P_shifted += [P0i.taylor_shift(dc_ref)]
                        # For fields known at FP, we have to correct the 1st
                        # coeff which  is by definition 0 (due to the FP ref
                        # point shift)
                        print("P_shifted[0].coeffs[0]", P_shifted[0].coeffs[0])
                        P_shifted[0].coeffs[0] = 0.
                        SA_params = {
                            "cutdeg": SA_params0["cutdeg"],
                            "iref": self.iref,
                            "kc": SA_params0["kc"],
                            "n_iter": SA_params0["n_iter"],
                            "P": P_shifted
                        }
                        self.save_SA(SA_params, self.iref, file_prefix)
                    else:
                        # Shift of SA approx is vetoed (no 'Taylor shift')
                        # -> Fall back to full SA recompute
                        if cutdeg_glitch is not None:
                            SA_params["cutdeg"] = cutdeg_glitch
                        SA_params = self.series_approx(self.SA_init(),
                                                       self.SA_loop(),
                                                       SA_params, self.iref,
                                                       file_prefix)
                        self.save_SA(SA_params, self.iref, file_prefix)

            self.cycles(chunk_slice=None, SA_params=SA_params)

            #            glitched = fs.Fractal_Data_array(self, file_prefix=file_prefix,
            #                    postproc_keys=('stop_reason',
            #                    lambda x: x == glitch_stop_index), mode="r+raw")

            # Recomputing the exit condition
            all_glitch_count = self.all_glitched.nansum()
            dyn_glitch_count = dyn_glitched.nansum()
            print("ANY glitched ? ", all_glitch_count)