Commit 8847c145 authored by Nicolas Nunez Barreto's avatar Nicolas Nunez Barreto
Browse files

saque la barra superior, arregle el invert, y arregle los Nx y Ny

parent 284d7b21
Loading
Loading
Loading
Loading
Loading
+22 −20
Changes for fullcode_patterns.py: 22 added lines, 20 removed lines.
Original line number Original line Diff line number Diff line
@@ -11,13 +11,16 @@ import matplotlib.pyplot as plt
from scipy import signal
from scipy import signal




def Grating(k, l, size, Binary=True, Blaze=False, powerblaze=1, BinaryFactor=0.25, Nx=10000, Ny = 5000, phase1storder=0, mini=0, maxi=255, x0=0, y0=0):
def Grating(k, l, size, Binary=True, Blaze=False, Inverted=False, powerblaze=1, BinaryFactor=0.25, Nx=10000, Ny = 5000, phase1storder=0, mini=0, maxi=255, x0=0, y0=0):
    
    
    x = np.linspace(-size, size, Nx)
    x = np.linspace(-size, size, Nx)
    y = np.linspace(-size, size, Ny)
    y = np.linspace(-size, size, Ny)
    
    
    if Binary:
    if Binary:
        if not Inverted:
            Pattern = [[maxi if 0.5*(1 - np.cos(k*xi - l*np.arctan2(xi, yj) - phase1storder)) > BinaryFactor else mini for xi in x] for yj in y]
            Pattern = [[maxi if 0.5*(1 - np.cos(k*xi - l*np.arctan2(xi, yj) - phase1storder)) > BinaryFactor else mini for xi in x] for yj in y]
        else:
            Pattern = [[maxi if 0.5*(1 - np.cos(k*xi - l*np.arctan2(xi, yj) - phase1storder)) > BinaryFactor else mini for yj in y] for xi in x]


    else:
    else:
        if Blaze:
        if Blaze:
@@ -67,13 +70,13 @@ def on_key(event):
    step_sizey = (max(ylim) - min(ylim))/len(y)
    step_sizey = (max(ylim) - min(ylim))/len(y)


    if event.key == "right":
    if event.key == "right":
        ax.set_xlim(xlim[0] + step_sizex, xlim[1] + step_sizex)  # Mover derecha
        ax.set_xlim(xlim[0] - step_sizex, xlim[1] - step_sizex)  # Mover derecha
    elif event.key == "left":
    elif event.key == "left":
        ax.set_xlim(xlim[0] - step_sizex, xlim[1] - step_sizex)  # Mover izquierda
        ax.set_xlim(xlim[0] + step_sizex, xlim[1] + step_sizex)  # Mover izquierda
    elif event.key == "up":
    elif event.key == "up":
        ax.set_ylim(ylim[0] + step_sizey, ylim[1] + step_sizey)  # Mover arriba
        ax.set_ylim(ylim[0] - step_sizey, ylim[1] - step_sizey)  # Mover arriba
    elif event.key == "down":
    elif event.key == "down":
        ax.set_ylim(ylim[0] - step_sizey, ylim[1] - step_sizey)  # Mover abajo
        ax.set_ylim(ylim[0] + step_sizey, ylim[1] + step_sizey)  # Mover abajo


    fig.canvas.draw_idle()  # Redibujar la imagen sin regenerarla
    fig.canvas.draw_idle()  # Redibujar la imagen sin regenerarla


@@ -82,10 +85,10 @@ def on_key(event):
#%%
#%%


size=1 #esto en realidad no cambia absolutamente nada
size=1 #esto en realidad no cambia absolutamente nada
Nx = 600
Nx = 800
Ny = 800
Ny = 600


linewidth = 150
linewidth = 300


k = 1*np.pi/((linewidth/10000)*size)
k = 1*np.pi/((linewidth/10000)*size)


@@ -94,13 +97,12 @@ l = 1 #para usar redes comunes pone l=0
mini, maxi = 0,255 #numeros de 0 a 255 que definen los tonos de gris de las franjas
mini, maxi = 0,255 #numeros de 0 a 255 que definen los tonos de gris de las franjas


binary = 'binary'  #posibles: binary o notbinary. para usar blaze usa notbinary
binary = 'binary'  #posibles: binary o notbinary. para usar blaze usa notbinary
'''

si pones inverted cambiá Nx y Ny también!! Ny 800, Nx 600
Inverted=True
'''
orientation='inverted' #posibles: inverted o notinverted si se quiere poner a 90° el patron


Blaze=False
Blaze=False
bfactor = 2
bfactor = 2
print("aguante boca")


# Phase = [0,45,90,135,180]
# Phase = [0,45,90,135,180]


@@ -111,15 +113,10 @@ for p in Phase:
    binaryfactor = 0.5
    binaryfactor = 0.5
    
    
    if binary == 'binary':
    if binary == 'binary':
        Pattern, x, y = Grating(np.pi/((linewidth/10000)*size), l, size, Binary=True, Blaze=Blaze, powerblaze=bfactor, BinaryFactor=binaryfactor, Nx=Nx, Ny=Ny, phase1storder=phase, mini=mini, maxi=maxi)
        Pattern, x, y = Grating(np.pi/((linewidth/10000)*size), l, size, Binary=True, Blaze=Blaze, Inverted=Inverted, powerblaze=bfactor, BinaryFactor=binaryfactor, Nx=Nx, Ny=Ny, phase1storder=phase, mini=mini, maxi=maxi)
    else:
    else:
        Pattern, x, y = Grating(np.pi/((linewidth/10000)*size), l, size, Binary=False, Blaze=Blaze, powerblaze=bfactor, BinaryFactor=binaryfactor, Nx=Nx, Ny=Ny, phase1storder=phase, mini=mini, maxi=maxi)
        Pattern, x, y = Grating(np.pi/((linewidth/10000)*size), l, size, Binary=False, Blaze=Blaze, Inverted=Inverted, powerblaze=bfactor, BinaryFactor=binaryfactor, Nx=Nx, Ny=Ny, phase1storder=phase, mini=mini, maxi=maxi)



if orientation=='inverted':
    fig, ax = plt.subplots(figsize=(6, 8), dpi = 100)
    c = plt.pcolor(np.transpose(Pattern),cmap='gray', vmin=0,vmax=255)
else:
fig, ax = plt.subplots(figsize=(8, 6), dpi = 100)
fig, ax = plt.subplots(figsize=(8, 6), dpi = 100)
c = plt.pcolor(Pattern,cmap='gray', vmin=0,vmax=255)
c = plt.pcolor(Pattern,cmap='gray', vmin=0,vmax=255)


@@ -130,7 +127,12 @@ plt.gca().set_position([0,0,1,1])
#plt.subplots_adjust(left=0, right=1, top=1. bottom=0)
#plt.subplots_adjust(left=0, right=1, top=1. bottom=0)
#plt.rcParams["figure.autolayout"] = False
#plt.rcParams["figure.autolayout"] = False
manager = plt.get_current_fig_manager()
manager = plt.get_current_fig_manager()
manager.full_screen_toggle()

manager.full_screen_toggle() #con f o ctrl+f se sale del full screen

fig.canvas.window().statusBar().setVisible(False)

manager.toolbar.hide()


print(f'done {p}')
print(f'done {p}')