Ejemplo n.º 1
0
def formula_comparison(pl=None, **kwargs):
    a = IDT()
    frq = linspace(3e9, 7e9, 10000)
    print a._get_coupling(frq)
    print a.max_coupling
    pl, pf = line(frq,
                  a._get_coupling(frq) / a.max_coupling,
                  plotter=pl,
                  linewidth=1.0,
                  **kwargs)
    line(frq,
         a._get_Lamb_shift(frq) / a.max_coupling,
         plotter=pl,
         color="red",
         linewidth=1.0)
    #line(frq, coup, color="purple", plotter=pl, linewidth=0.3)
    line(frq,
         a._get_full_coupling(frq) / a.max_coupling,
         plotter=pl,
         color="green",
         linewidth=0.3)
    line(frq,
         a._get_full_Lamb_shift(frq) / a.max_coupling,
         plotter=pl,
         color="black",
         linewidth=0.3)
    return pl
Ejemplo n.º 2
0
def Lamb_shift_comparison(pl="ls_comp", **kwargs):
    idt = IDT.process_kwargs(kwargs)

    #idt.rs=-0.01j
    #idt.dloss2=0.1*1e6
    #idt.eta=0.4
    frq = linspace(0e9, 10e9, 10000)
    #idt.N_fixed=100000
    idt.fixed_freq_max = 20.0 * idt.f0

    idt.S_type = "RAM"
    pl = line(frq / idt.f0,
              idt._get_Lamb_shift(f=frq),
              plotter=pl,
              color="cyan",
              linewidth=0.5,
              label=idt.S_type,
              **kwargs)
    idt.S_type = "simple"
    idt.fixed_reset()

    idt.Lamb_shift_type = "formula"
    idt.couple_type = "sinc sq"
    pl = line(frq / idt.f0,
              idt._get_Lamb_shift(frq),
              plotter=pl,
              linewidth=0.5,
              label="sinc^2",
              **kwargs)
    idt.couple_type = "giant atom"
    line(frq / idt.f0,
         idt._get_Lamb_shift(frq),
         plotter=pl,
         color="red",
         linewidth=0.5,
         label=idt.couple_type)

    idt.Lamb_shift_type = "hilbert"
    idt.couple_type = "df giant atom"
    line(frq / idt.f0,
         idt._get_Lamb_shift(frq),
         plotter=pl,
         color="green",
         linewidth=0.5,
         label=idt.couple_type)
    idt.couple_type = "full expr"
    line(frq / idt.f0,
         idt._get_Lamb_shift(frq),
         plotter=pl,
         color="black",
         linewidth=0.5,
         label=idt.couple_type)
    #idt.couple_type="full sum"
    #line(frq/idt.f0, idt._get_Lamb_shift(frq), plotter=pl, color="purple", linewidth=0.5, label=idt.couple_type)

    pl.xlabel = "frequency/center frequency"
    pl.ylabel = "Lamb shift"
    pl.set_ylim(-1e9, 1e9)
    pl.legend(loc="lower right")
    return pl
Ejemplo n.º 3
0
def Lamb_shift_comparison(pl="ls_comp", **kwargs):
    idt=IDT.process_kwargs(kwargs)

    #idt.rs=-0.01j
    #idt.dloss2=0.1*1e6
    #idt.eta=0.4
    frq=linspace(0e9, 10e9, 10000)
    #idt.N_fixed=100000
    idt.fixed_freq_max=20.0*idt.f0

    idt.S_type="RAM"
    pl=line(frq/idt.f0, idt._get_Lamb_shift(f=frq), plotter=pl, color="cyan", linewidth=0.5, label=idt.S_type, **kwargs)
    idt.S_type="simple"
    idt.fixed_reset()

    idt.Lamb_shift_type="formula"
    idt.couple_type="sinc sq"
    pl=line(frq/idt.f0, idt._get_Lamb_shift(frq), plotter=pl, linewidth=0.5, label="sinc^2", **kwargs)
    idt.couple_type="giant atom"
    line(frq/idt.f0, idt._get_Lamb_shift(frq), plotter=pl, color="red", linewidth=0.5, label=idt.couple_type)

    idt.Lamb_shift_type="hilbert"
    idt.couple_type="df giant atom"
    line(frq/idt.f0, idt._get_Lamb_shift(frq), plotter=pl, color="green", linewidth=0.5, label=idt.couple_type)
    idt.couple_type="full expr"
    line(frq/idt.f0, idt._get_Lamb_shift(frq), plotter=pl, color="black", linewidth=0.5, label=idt.couple_type)
    #idt.couple_type="full sum"
    #line(frq/idt.f0, idt._get_Lamb_shift(frq), plotter=pl, color="purple", linewidth=0.5, label=idt.couple_type)

    pl.xlabel="frequency/center frequency"
    pl.ylabel="Lamb shift"
    pl.set_ylim(-1e9, 1e9)
    pl.legend(loc="lower right")
    return pl
Ejemplo n.º 4
0
def Lamb_shift_comparison(pl="ls_compare", **kwargs):
    idt=IDT.process_kwargs(kwargs)
    frq=linspace(0.01e9, 10*10e9, 10000)

    idt.fixed_freq_max=20.0*idt.f0
    idt.S_type="RAM"
    idt.eta=0.55

    pl=line(frq/idt.f0, idt._get_Lamb_shift(frq)/idt.max_coupling_approx, plotter=pl, color="cyan", label=idt.S_type, **kwargs)
    idt.S_type="simple"
    idt.fixed_reset()

    idt.Ga_type="giant atom"
    line(frq/idt.f0, idt._get_Lamb_shift(frq)/idt.max_coupling_approx, plotter=pl, color="red", label="full expr", **kwargs)

    idt.Y0_type="center"
    idt.df_type="center"
    idt.mus_type="center"
    idt.Ga_type="sinc"
    idt.Ba_type="formula"
    idt.rs_type="constant"
    pl=line(frq/idt.f0, idt._get_Lamb_shift(frq)/idt.max_coupling_approx, plotter=pl, label=idt.Ga_type, **kwargs)
    idt.Ga_type="giant atom"
    line(frq/idt.f0, idt._get_Lamb_shift(frq)/idt.max_coupling_approx, plotter=pl, color="green", label=idt.Ga_type, **kwargs)
    pl.xlabel="frequency/center frequency"
    pl.ylabel="coupling"
    pl.legend()
    return pl
Ejemplo n.º 5
0
def RAM_single_vs_double(pl="RAM_sf_df", **kwargs):
    idt=IDT.process_kwargs(kwargs)
    frq=linspace(0.01e9, 10e9, 10000)
    #idt.material="GaAs"
    idt.Np=51
    idt.fixed_freq_max=2.0*idt.f0
    idt.S_type="RAM"
    pl=line(frq/idt.f0, idt._get_coupling(frq)/idt.max_coupling_approx, plotter=pl, color="blue", label=idt.S_type, **kwargs)
    line(frq/idt.f0, idt._get_Lamb_shift(frq)/idt.max_coupling_approx, plotter=pl, color="blue", **kwargs)
    idt.S_type="simple"
    idt.fixed_reset()

    idt.Ga_type="giant atom"
    line(frq/idt.f0, idt._get_coupling(frq)/idt.max_coupling_approx, plotter=pl, color="red", label="full expr", **kwargs)
    line(frq/idt.f0, idt._get_Lamb_shift(frq)/idt.max_coupling_approx, plotter=pl, color="red", **kwargs)

    idt.S_type="RAM"
    idt.ft="single"
    idt.fixed_reset()
    line(frq/idt.f0, idt._get_coupling(frq)/idt.max_coupling_approx, plotter=pl, color="green", label="RAM single", **kwargs)
    line(frq/idt.f0, idt._get_Lamb_shift(frq)/idt.max_coupling_approx, plotter=pl, color="green", **kwargs)

    pl.xlabel="frequency/center frequency"
    pl.ylabel="coupling"
    pl.set_ylim(-0.8, 1.1)
    pl.legend()
    return pl
Ejemplo n.º 6
0
def giant_atom_check(pl="giant_atom_check", **kwargs):
    idt=IDT.process_kwargs(kwargs)
    idt.Y0_type="center"
    idt.df_type="center"
    idt.mus_type="center"
    idt.Ga_type="giant atom"#, "full sum"
    idt.Ba_type="formula"
    idt.rs_type="constant"
    frq=linspace(0e9, 10e9, 10000)
    idt.fixed_freq_max=20.0*idt.f0
    pl=line(frq/idt.f0, idt._get_Ga(frq)/idt.Ga0_approx, plotter=pl, label=idt.Ga_type, **kwargs)
    line(frq/idt.f0, idt._get_coupling(frq)/idt.max_coupling_approx, plotter=pl, label=idt.Ga_type, color="red",  **kwargs)
    X=idt.Np*pi*(frq-idt.f0)/idt.f0
    Np=idt.Np
    line(frq/idt.f0, (sin(X)/X)**2, plotter=pl, label=idt.Ga_type, color="purple", **kwargs)

    line(frq/idt.f0, (1.0/Np*sin(X)/sin(X/Np))**2, plotter=pl, label=idt.Ga_type, color="green", **kwargs)
    line(frq/idt.f0, idt._get_Ba(frq)/idt.Ga0_approx, plotter=pl, label=idt.Ga_type, **kwargs)
    idt.Ba_type="hilbert"
    line(frq/idt.f0, idt._get_Ba(frq)/idt.Ga0_approx, plotter=pl, label=idt.Ga_type, color="red", **kwargs)
    line(frq/idt.f0, -imag(hilbert(idt._get_Ga(frq)/idt.Ga0_approx)), plotter=pl, label=idt.Ga_type, color="green", **kwargs)
    print idt.Ga0, idt.Ga0_approx
    print idt.Ga0_mult
    print idt.max_coupling, idt.max_coupling_approx
    return pl
Ejemplo n.º 7
0
def Lamb_shift_check(pl="ls_check", **kwargs):
    idt=IDT.process_kwargs(kwargs)
    idt.fixed_freq_max=20.0*idt.f0
    frq=linspace(0e9, 10e9, 10000)

    idt.S_type="RAM"
    pl=line(frq/idt.f0, idt._get_Lamb_shift(f=frq)/idt.max_coupling, plotter=pl, color="cyan", linewidth=0.5, label=idt.S_type, **kwargs)
    idt.S_type="simple"
    idt.fixed_reset()

    idt.Lamb_shift_type="formula"
    idt.couple_type="sinc sq"
    pl=line(frq/idt.f0, idt._get_Lamb_shift(frq)/idt.max_coupling, plotter=pl, linewidth=0.5, label=idt.couple_type, **kwargs)
    idt.couple_type="giant atom"
    line(frq/idt.f0, idt._get_Lamb_shift(frq)/idt.max_coupling, plotter=pl, color="red", linewidth=0.5, label=idt.couple_type)
    idt.couple_type="df giant atom"
    line(frq/idt.f0, idt._get_Lamb_shift(frq)/idt.max_coupling, plotter=pl, color="green", linewidth=0.5, label=idt.couple_type)
    idt.couple_type="full expr"
    line(frq/idt.f0, idt._get_Lamb_shift(frq)/idt.max_coupling, plotter=pl, color="black", linewidth=0.5, label=idt.couple_type)
    #idt.couple_type="full sum"
    #line(frq/idt.f0, idt._get_Lamb_shift(frq)/idt.max_coupling, plotter=pl, color="purple", linewidth=0.5, label=idt.couple_type)
    pl.xlabel="frequency/center frequency"
    pl.ylabel="Lamb shift/max coupling (dB)"
    pl.set_ylim(-1.0, 1.0)
    pl.legend(loc="lower right")

    #line(frq, a._get_full_Lamb_shift(frq)/a.max_coupling, plotter=pl, color="black", linewidth=0.3)
    return pl
Ejemplo n.º 8
0
def giant_atom_variety_check(pl="giant_atom_check", **kwargs):
    idt=IDT.process_kwargs(kwargs)
    idt.Y0_type="center"
    idt.df_type="center"
    idt.mus_type="center"
    idt.Ga_type="giant atom"#, "full sum"
    idt.Ba_type="formula"
    frq=linspace(0e9, 10e9, 10000)
    idt.fixed_freq_max=20.0*idt.f0
    pl=line(frq/idt.f0, idt._get_Ga(frq)/idt.Ga0_approx, plotter=pl, label="giant atom", **kwargs)
    idt.Y0_type="formula"
    line(frq/idt.f0, idt._get_Ga(frq)/idt.Ga0_approx, plotter=pl, label="Y0", color="red", **kwargs)
    idt.Y0_type="center"
    idt.df_type="formula"
    line(frq/idt.f0, idt._get_Ga(frq)/idt.Ga0_approx, plotter=pl, label="df", color="green", **kwargs)
    idt.df_type="center"
    idt.mus_type="formula"
    line(frq/idt.f0, idt._get_Ga(frq)/idt.Ga0_approx, plotter=pl, label="alpha", color="purple", **kwargs)

    X=idt.Np*pi*(frq-idt.f0)/idt.f0
    line(frq/idt.f0, (sin(X)/X)**2, plotter=pl, label="sinc", color="blue", **kwargs)
    #line(frq/idt.f0, idt._get_Ba(frq)/idt.Ga0_approx, plotter=pl, label=idt.Ga_type, **kwargs)
    #idt.Ba_type="hilbert"
    #line(frq/idt.f0, idt._get_Ba(frq)/idt.Ga0_approx, plotter=pl, label=idt.Ga_type, **kwargs)
    #line(frq/idt.f0, -imag(hilbert(idt._get_Ga(frq)/idt.Ga0_approx)), plotter=pl, label=idt.Ga_type, **kwargs)
    #print idt.Ga0, idt.Ga0_approx
    #print idt.Ga0_mult
    #print idt.max_coupling, idt.max_coupling_approx
    return pl
Ejemplo n.º 9
0
def RAM_comparison(pl="RAM_compare", **kwargs):
    idt = IDT.process_kwargs(kwargs)
    frq = linspace(0.01e9, 10e9, 10000)
    #idt.Np=37
    idt.fixed_freq_max = 20.0 * idt.f0
    idt.S_type = "RAM"
    idt.eta = 0.55
    #idt.dloss1=0.19
    #idt.dloss2=0.88#*100

    #idt.Y0_type="center"
    #idt.df_type="center"
    #idt.mus_type="center"
    #idt.Ga_type="sinc"
    #idt.Ba_type="formula"
    #idt.rs_type="constant"
    #idt.rs=-0.017j
    pl = line(frq / idt.f0,
              idt._get_coupling(frq) / idt.max_coupling_approx,
              plotter=pl,
              color="blue",
              label=idt.S_type,
              **kwargs)
    line(frq / idt.f0,
         idt._get_Lamb_shift(frq) / idt.max_coupling_approx,
         plotter=pl,
         color="blue",
         **kwargs)

    idt.S_type = "simple"
    idt.fixed_reset()

    idt.Ga_type = "giant atom"
    line(frq / idt.f0,
         idt._get_coupling(frq) / idt.max_coupling_approx,
         plotter=pl,
         color="red",
         label="full expr",
         **kwargs)
    line(frq / idt.f0,
         idt._get_Lamb_shift(frq) / idt.max_coupling_approx,
         plotter=pl,
         color="red",
         **kwargs)

    #idt.S_type="RAM"
    #idt.ft="single"
    #idt.fixed_reset()
    #pl=line(frq/idt.f0, idt._get_coupling(frq)/idt.max_coupling_approx, plotter=pl, color="green", label="RAM single", **kwargs)
    #line(frq/idt.f0, idt._get_Lamb_shift(frq)/idt.max_coupling_approx, plotter=pl, color="green", label="RAM single", **kwargs)

    #pl=line(frq/idt.f0, idt._get_Lamb_shift(frq)/idt.max_coupling_approx, plotter=pl, label=idt.Ga_type, **kwargs)
    #idt.Ga_type="giant atom"
    #line(frq/idt.f0, idt._get_Lamb_shift(frq)/idt.max_coupling_approx, plotter=pl, color="green", label=idt.Ga_type, **kwargs)
    pl.xlabel = "frequency/center frequency"
    pl.ylabel = "coupling/center coupling"
    pl.set_ylim(-0.7, 1.1)
    pl.legend()
    return pl
Ejemplo n.º 10
0
def giant_atom_check(pl="giant_atom_check", **kwargs):
    idt = IDT.process_kwargs(kwargs)
    idt.Y0_type = "center"
    idt.df_type = "center"
    idt.mus_type = "center"
    idt.Ga_type = "giant atom"  #, "full sum"
    idt.Ba_type = "formula"
    idt.rs_type = "constant"
    frq = linspace(0e9, 10e9, 10000)
    idt.fixed_freq_max = 20.0 * idt.f0
    pl = line(frq / idt.f0,
              idt._get_Ga(frq) / idt.Ga0_approx,
              plotter=pl,
              label=idt.Ga_type,
              **kwargs)
    line(frq / idt.f0,
         idt._get_coupling(frq) / idt.max_coupling_approx,
         plotter=pl,
         label=idt.Ga_type,
         color="red",
         **kwargs)
    X = idt.Np * pi * (frq - idt.f0) / idt.f0
    Np = idt.Np
    line(frq / idt.f0, (sin(X) / X)**2,
         plotter=pl,
         label=idt.Ga_type,
         color="purple",
         **kwargs)

    line(frq / idt.f0, (1.0 / Np * sin(X) / sin(X / Np))**2,
         plotter=pl,
         label=idt.Ga_type,
         color="green",
         **kwargs)
    line(frq / idt.f0,
         idt._get_Ba(frq) / idt.Ga0_approx,
         plotter=pl,
         label=idt.Ga_type,
         **kwargs)
    idt.Ba_type = "hilbert"
    line(frq / idt.f0,
         idt._get_Ba(frq) / idt.Ga0_approx,
         plotter=pl,
         label=idt.Ga_type,
         color="red",
         **kwargs)
    line(frq / idt.f0,
         -imag(hilbert(idt._get_Ga(frq) / idt.Ga0_approx)),
         plotter=pl,
         label=idt.Ga_type,
         color="green",
         **kwargs)
    print idt.Ga0, idt.Ga0_approx
    print idt.Ga0_mult
    print idt.max_coupling, idt.max_coupling_approx
    return pl
Ejemplo n.º 11
0
def Lamb_shift_check(pl="ls_check", **kwargs):
    idt = IDT.process_kwargs(kwargs)
    idt.fixed_freq_max = 20.0 * idt.f0
    frq = linspace(0e9, 10e9, 10000)

    idt.S_type = "RAM"
    pl = line(frq / idt.f0,
              idt._get_Lamb_shift(f=frq) / idt.max_coupling,
              plotter=pl,
              color="cyan",
              linewidth=0.5,
              label=idt.S_type,
              **kwargs)
    idt.S_type = "simple"
    idt.fixed_reset()

    idt.Lamb_shift_type = "formula"
    idt.couple_type = "sinc sq"
    pl = line(frq / idt.f0,
              idt._get_Lamb_shift(frq) / idt.max_coupling,
              plotter=pl,
              linewidth=0.5,
              label=idt.couple_type,
              **kwargs)
    idt.couple_type = "giant atom"
    line(frq / idt.f0,
         idt._get_Lamb_shift(frq) / idt.max_coupling,
         plotter=pl,
         color="red",
         linewidth=0.5,
         label=idt.couple_type)
    idt.couple_type = "df giant atom"
    line(frq / idt.f0,
         idt._get_Lamb_shift(frq) / idt.max_coupling,
         plotter=pl,
         color="green",
         linewidth=0.5,
         label=idt.couple_type)
    idt.couple_type = "full expr"
    line(frq / idt.f0,
         idt._get_Lamb_shift(frq) / idt.max_coupling,
         plotter=pl,
         color="black",
         linewidth=0.5,
         label=idt.couple_type)
    #idt.couple_type="full sum"
    #line(frq/idt.f0, idt._get_Lamb_shift(frq)/idt.max_coupling, plotter=pl, color="purple", linewidth=0.5, label=idt.couple_type)
    pl.xlabel = "frequency/center frequency"
    pl.ylabel = "Lamb shift/max coupling (dB)"
    pl.set_ylim(-1.0, 1.0)
    pl.legend(loc="lower right")

    #line(frq, a._get_full_Lamb_shift(frq)/a.max_coupling, plotter=pl, color="black", linewidth=0.3)
    return pl
Ejemplo n.º 12
0
def RAM_single_vs_double(pl="RAM_sf_df", **kwargs):
    idt = IDT.process_kwargs(kwargs)
    frq = linspace(0.01e9, 10e9, 10000)
    #idt.material="GaAs"
    idt.Np = 51
    idt.fixed_freq_max = 2.0 * idt.f0
    idt.S_type = "RAM"
    pl = line(frq / idt.f0,
              idt._get_coupling(frq) / idt.max_coupling_approx,
              plotter=pl,
              color="blue",
              label=idt.S_type,
              **kwargs)
    line(frq / idt.f0,
         idt._get_Lamb_shift(frq) / idt.max_coupling_approx,
         plotter=pl,
         color="blue",
         **kwargs)
    idt.S_type = "simple"
    idt.fixed_reset()

    idt.Ga_type = "giant atom"
    line(frq / idt.f0,
         idt._get_coupling(frq) / idt.max_coupling_approx,
         plotter=pl,
         color="red",
         label="full expr",
         **kwargs)
    line(frq / idt.f0,
         idt._get_Lamb_shift(frq) / idt.max_coupling_approx,
         plotter=pl,
         color="red",
         **kwargs)

    idt.S_type = "RAM"
    idt.ft = "single"
    idt.fixed_reset()
    line(frq / idt.f0,
         idt._get_coupling(frq) / idt.max_coupling_approx,
         plotter=pl,
         color="green",
         label="RAM single",
         **kwargs)
    line(frq / idt.f0,
         idt._get_Lamb_shift(frq) / idt.max_coupling_approx,
         plotter=pl,
         color="green",
         **kwargs)

    pl.xlabel = "frequency/center frequency"
    pl.ylabel = "coupling"
    pl.set_ylim(-0.8, 1.1)
    pl.legend()
    return pl
Ejemplo n.º 13
0
def giant_atom_variety_check(pl="giant_atom_check", **kwargs):
    idt = IDT.process_kwargs(kwargs)
    idt.Y0_type = "center"
    idt.df_type = "center"
    idt.mus_type = "center"
    idt.Ga_type = "giant atom"  #, "full sum"
    idt.Ba_type = "formula"
    frq = linspace(0e9, 10e9, 10000)
    idt.fixed_freq_max = 20.0 * idt.f0
    pl = line(frq / idt.f0,
              idt._get_Ga(frq) / idt.Ga0_approx,
              plotter=pl,
              label="giant atom",
              **kwargs)
    idt.Y0_type = "formula"
    line(frq / idt.f0,
         idt._get_Ga(frq) / idt.Ga0_approx,
         plotter=pl,
         label="Y0",
         color="red",
         **kwargs)
    idt.Y0_type = "center"
    idt.df_type = "formula"
    line(frq / idt.f0,
         idt._get_Ga(frq) / idt.Ga0_approx,
         plotter=pl,
         label="df",
         color="green",
         **kwargs)
    idt.df_type = "center"
    idt.mus_type = "formula"
    line(frq / idt.f0,
         idt._get_Ga(frq) / idt.Ga0_approx,
         plotter=pl,
         label="alpha",
         color="purple",
         **kwargs)

    X = idt.Np * pi * (frq - idt.f0) / idt.f0
    line(frq / idt.f0, (sin(X) / X)**2,
         plotter=pl,
         label="sinc",
         color="blue",
         **kwargs)
    #line(frq/idt.f0, idt._get_Ba(frq)/idt.Ga0_approx, plotter=pl, label=idt.Ga_type, **kwargs)
    #idt.Ba_type="hilbert"
    #line(frq/idt.f0, idt._get_Ba(frq)/idt.Ga0_approx, plotter=pl, label=idt.Ga_type, **kwargs)
    #line(frq/idt.f0, -imag(hilbert(idt._get_Ga(frq)/idt.Ga0_approx)), plotter=pl, label=idt.Ga_type, **kwargs)
    #print idt.Ga0, idt.Ga0_approx
    #print idt.Ga0_mult
    #print idt.max_coupling, idt.max_coupling_approx
    return pl
Ejemplo n.º 14
0
def formula_comparison(pl=None, **kwargs):
    a=IDT()
    frq=linspace(3e9, 7e9, 10000)
    print a._get_coupling(frq)
    print a.max_coupling
    pl, pf=line(frq, a._get_coupling(frq)/a.max_coupling, plotter=pl, linewidth=1.0, **kwargs)
    line(frq, a._get_Lamb_shift(frq)/a.max_coupling, plotter=pl, color="red", linewidth=1.0)
    #line(frq, coup, color="purple", plotter=pl, linewidth=0.3)
    line(frq, a._get_full_coupling(frq)/a.max_coupling, plotter=pl, color="green", linewidth=0.3)
    line(frq, a._get_full_Lamb_shift(frq)/a.max_coupling, plotter=pl, color="black", linewidth=0.3)
    return pl
Ejemplo n.º 15
0
def metallization_couple(pl="metallization_couple", **kwargs):
    idt = IDT.process_kwargs(kwargs)
    frq = linspace(0e9, 10e9, 10000)
    idt.N_fixed = 100000
    #idt.fixed_freq_max=20.0*idt.f0
    idt.eta = 0.5
    #idt.ft="single"
    #idt.S_type="RAM"
    idt.couple_type = "full expr"
    idt.fixed_reset()
    line(idt.fixed_freq / idt.f0,
         idt.fixed_coupling,
         plot_name="0.5",
         color="blue",
         linewidth=0.3,
         label="0.5",
         **kwargs)

    pl = line(frq / idt.f0,
              idt.get_fix("coupling", frq),
              plotter=pl,
              plot_name="0.5",
              color="blue",
              linewidth=0.3,
              label="0.5",
              **kwargs)
    idt.eta = 0.6
    idt.fixed_reset()
    line(frq / idt.f0,
         idt.get_fix("coupling", frq),
         plotter=pl,
         plot_name="0.6",
         color="red",
         linewidth=0.3,
         label="0.6",
         **kwargs)
    idt.eta = 0.4
    idt.fixed_reset()
    line(frq / idt.f0,
         idt.get_fix("coupling", frq),
         plotter=pl,
         plot_name="0.4",
         color="green",
         linewidth=0.3,
         label="0.4",
         **kwargs)
    idt.eta = 0.5
    pl.xlabel = "frequency/center frequency"
    pl.ylabel = "coupling"
    pl.legend()
    return pl
Ejemplo n.º 16
0
def fix_couple_comparison(pl="fix couple", **kwargs):
    idt = IDT.process_kwargs(kwargs)
    idt.fixed_freq_max = 20.0 * idt.f0
    idt.couple_type = "sinc sq"
    idt.fixed_reset()
    frq = linspace(0e9, 10e9, 10000)
    pl = line(frq / idt.f0,
              10 * log10(idt.get_fix("coupling", frq) / idt.max_coupling),
              plotter=pl,
              linewidth=0.3,
              label=idt.couple_type,
              **kwargs)
    idt.couple_type = "giant atom"
    idt.fixed_reset()
    line(frq / idt.f0,
         10 * log10(idt.get_fix("coupling", frq) / idt.max_coupling),
         plotter=pl,
         color="red",
         linewidth=0.3,
         label=idt.couple_type)
    idt.couple_type = "df giant atom"
    idt.fixed_reset()
    line(frq / idt.f0,
         10 * log10(idt.get_fix("coupling", frq) / idt.max_coupling),
         plotter=pl,
         color="green",
         linewidth=0.3,
         label=idt.couple_type)
    idt.couple_type = "full expr"
    idt.fixed_reset()
    line(frq / idt.f0,
         10 * log10(idt.get_fix("coupling", frq) / idt.max_coupling),
         plotter=pl,
         color="black",
         linewidth=0.3,
         label=idt.couple_type)
    idt.couple_type = "full sum"
    idt.fixed_reset()
    line(frq / idt.f0,
         10 * log10(idt.get_fix("coupling", frq) / idt.max_coupling),
         plotter=pl,
         color="purple",
         linewidth=0.3,
         label=idt.couple_type)
    pl.xlabel = "frequency/center frequency"
    pl.ylabel = "coupling/max coupling (dB)"
    pl.set_ylim(-30, 1.0)
    pl.legend()
    return pl
Ejemplo n.º 17
0
def Lamb_shift_comparison(pl="ls_compare", **kwargs):
    idt = IDT.process_kwargs(kwargs)
    frq = linspace(0.01e9, 10 * 10e9, 10000)

    idt.fixed_freq_max = 20.0 * idt.f0
    idt.S_type = "RAM"
    idt.eta = 0.55

    pl = line(frq / idt.f0,
              idt._get_Lamb_shift(frq) / idt.max_coupling_approx,
              plotter=pl,
              color="cyan",
              label=idt.S_type,
              **kwargs)
    idt.S_type = "simple"
    idt.fixed_reset()

    idt.Ga_type = "giant atom"
    line(frq / idt.f0,
         idt._get_Lamb_shift(frq) / idt.max_coupling_approx,
         plotter=pl,
         color="red",
         label="full expr",
         **kwargs)

    idt.Y0_type = "center"
    idt.df_type = "center"
    idt.mus_type = "center"
    idt.Ga_type = "sinc"
    idt.Ba_type = "formula"
    idt.rs_type = "constant"
    pl = line(frq / idt.f0,
              idt._get_Lamb_shift(frq) / idt.max_coupling_approx,
              plotter=pl,
              label=idt.Ga_type,
              **kwargs)
    idt.Ga_type = "giant atom"
    line(frq / idt.f0,
         idt._get_Lamb_shift(frq) / idt.max_coupling_approx,
         plotter=pl,
         color="green",
         label=idt.Ga_type,
         **kwargs)
    pl.xlabel = "frequency/center frequency"
    pl.ylabel = "coupling"
    pl.legend()
    return pl
Ejemplo n.º 18
0
def metallization_Lamb(pl="metallization_lamb", **kwargs):
    idt = IDT.process_kwargs(kwargs)
    frq = linspace(0e9, 10e9, 10000)
    idt.eta = 0.5
    idt.N_fixed = 100000
    #idt.fixed_freq_max=20.0*idt.f0

    #idt.ft="single"
    idt.couple_type = "full expr"
    #idt.Lamb_shift_type="hilbert"
    idt.fixed_reset()
    pl = line(frq / idt.f0,
              idt.get_fix("Lamb_shift", frq),
              plotter=pl,
              plot_name="0.5",
              color="blue",
              linewidth=0.3,
              label="0.5",
              **kwargs)
    idt.eta = 0.6
    idt.fixed_reset()
    #line(idt.fixed_freq/idt.f0, idt.fixed_Lamb_shift/idt.max_coupling, plotter=pl, linewidth=0.3, color="purple")
    line(frq / idt.f0,
         idt.get_fix("Lamb_shift", frq),
         plotter=pl,
         plot_name="0.6",
         color="red",
         linewidth=0.3,
         label="0.6",
         **kwargs)
    idt.eta = 0.4
    idt.fixed_reset()
    line(frq / idt.f0,
         idt.get_fix("Lamb_shift", frq),
         plotter=pl,
         plot_name="0.4",
         color="green",
         linewidth=0.3,
         label="0.4",
         **kwargs)
    idt.eta = 0.5
    pl.xlabel = "frequency/center frequency"
    pl.ylabel = "Lamb shift"
    pl.legend()
    return pl
Ejemplo n.º 19
0
 def __init__(self, xsize, zsize, wantCL=True):
     xsize = xsize
     zsize = zsize
     wantCL = wantCL
     numcoords = int(xsize * zsize * Crust.coverage)
     self.shape = (zsize, xsize)
     coords = np.array([(randint(0, zsize - 1), randint(0, xsize - 1))
                        for dummy in xrange(numcoords)],
                       dtype=np.float32)
     values = np.array([
         uniform(Crust.minwidth, Crust.maxwidth)
         for elem in xrange(numcoords)
     ],
                       dtype=np.int32)
     self.base = np.array(
         [(z, x) for z, x in product(xrange(zsize), xrange(xsize))],
         dtype=np.float32)
     self.idt = IDT(coords, values, wantCL=wantCL)
Ejemplo n.º 20
0
def couple_comparison(pl="couple_compare", **kwargs):
    idt=IDT.process_kwargs(kwargs)
    frq=linspace(0.01e9, 10*10e9, 10000)

    idt.fixed_freq_max=20.0*idt.f0
    idt.S_type="RAM"
    idt.eta=0.55
    #idt.Y0_type="center"
    #idt.df_type="center"
    #idt.mus_type="center"
    #idt.Ga_type="sinc"
    #idt.Ba_type="formula"
    #idt.rs_type="constant"

    #(P11, P12, P13,
    # P21, P22, P23,
    # P31, P32, P33), Ga, Ba, Ct=idt._get_RAM_P(frq=frq, Y0=None)
    #pl=line(frq/idt.f0, Ga/idt.Ga0_approx, plotter=pl, color="cyan", label=idt.S_type, **kwargs)

    pl=line(frq/idt.f0, idt._get_coupling(frq)/idt.max_coupling_approx, plotter=pl, color="cyan", label=idt.S_type, **kwargs)
    idt.S_type="simple"
    idt.fixed_reset()

    idt.Ga_type="giant atom"
    line(frq/idt.f0, idt._get_coupling(frq)/idt.max_coupling_approx, plotter=pl, color="red", label="full expr", **kwargs)

    idt.Y0_type="center"
    idt.df_type="center"
    idt.mus_type="center"
    idt.Ga_type="sinc"
    idt.Ba_type="formula"
    idt.rs_type="constant"
    pl=line(frq/idt.f0, idt._get_coupling(frq)/idt.max_coupling_approx, plotter=pl, label=idt.Ga_type, **kwargs)
    idt.Ga_type="giant atom"
    line(frq/idt.f0, idt._get_coupling(frq)/idt.max_coupling_approx, plotter=pl, color="green", label=idt.Ga_type, **kwargs)
    #idt.couple_type="full expr"
    #line(frq/idt.f0, idt._get_coupling(frq)/idt.max_coupling_approx, plotter=pl, color="black", linewidth=0.5, label=idt.couple_type)
    #idt.couple_type="full sum"
    #line(frq/idt.f0, (idt._get_coupling(frq)), plotter=pl, color="purple", linewidth=0.5, label=idt.couple_type)
    pl.xlabel="frequency/center frequency"
    pl.ylabel="coupling"
    #pl.set_ylim(0.0, 1.3e9)
    pl.legend()
    return pl
Ejemplo n.º 21
0
def RAM_comparison(pl="RAM_compare", **kwargs):
    idt=IDT.process_kwargs(kwargs)
    frq=linspace(0.01e9, 10e9, 10000)
    #idt.Np=37
    idt.fixed_freq_max=20.0*idt.f0
    idt.S_type="RAM"
    idt.eta=0.55
    #idt.dloss1=0.19
    #idt.dloss2=0.88#*100


    #idt.Y0_type="center"
    #idt.df_type="center"
    #idt.mus_type="center"
    #idt.Ga_type="sinc"
    #idt.Ba_type="formula"
    #idt.rs_type="constant"
    #idt.rs=-0.017j
    pl=line(frq/idt.f0, idt._get_coupling(frq)/idt.max_coupling_approx, plotter=pl, color="blue", label=idt.S_type, **kwargs)
    line(frq/idt.f0, idt._get_Lamb_shift(frq)/idt.max_coupling_approx, plotter=pl, color="blue",  **kwargs)

    idt.S_type="simple"
    idt.fixed_reset()

    idt.Ga_type="giant atom"
    line(frq/idt.f0, idt._get_coupling(frq)/idt.max_coupling_approx, plotter=pl, color="red", label="full expr", **kwargs)
    line(frq/idt.f0, idt._get_Lamb_shift(frq)/idt.max_coupling_approx, plotter=pl, color="red",  **kwargs)

    #idt.S_type="RAM"
    #idt.ft="single"
    #idt.fixed_reset()
    #pl=line(frq/idt.f0, idt._get_coupling(frq)/idt.max_coupling_approx, plotter=pl, color="green", label="RAM single", **kwargs)
    #line(frq/idt.f0, idt._get_Lamb_shift(frq)/idt.max_coupling_approx, plotter=pl, color="green", label="RAM single", **kwargs)

    #pl=line(frq/idt.f0, idt._get_Lamb_shift(frq)/idt.max_coupling_approx, plotter=pl, label=idt.Ga_type, **kwargs)
    #idt.Ga_type="giant atom"
    #line(frq/idt.f0, idt._get_Lamb_shift(frq)/idt.max_coupling_approx, plotter=pl, color="green", label=idt.Ga_type, **kwargs)
    pl.xlabel="frequency/center frequency"
    pl.ylabel="coupling/center coupling"
    pl.set_ylim(-0.7, 1.1)
    pl.legend()
    return pl
Ejemplo n.º 22
0
def hilbert_check(pl="hilbert", **kwargs):
    idt = IDT.process_kwargs(kwargs)
    frq = linspace(0e9, 10e9, 10000)
    #idt.N_fixed=100000
    idt.fixed_freq_max = 20.0 * idt.f0
    idt.Lamb_shift_type = "formula"
    idt.couple_type = "sinc sq"
    pl = line(frq / idt.f0,
              idt._get_Lamb_shift(frq),
              plotter=pl,
              linewidth=1.0,
              label="sinc^2",
              **kwargs)
    idt.couple_type = "giant atom"
    line(frq / idt.f0,
         idt._get_Lamb_shift(frq),
         plotter=pl,
         color="red",
         linewidth=1.0,
         label=idt.couple_type)
    idt.Lamb_shift_type = "hilbert"
    idt.couple_type = "sinc sq"
    line(frq / idt.f0,
         idt._get_Lamb_shift(frq),
         plotter=pl,
         color="green",
         linewidth=0.5,
         label="h(sinc^2)")
    idt.couple_type = "giant atom"
    line(frq / idt.f0,
         idt._get_Lamb_shift(frq),
         plotter=pl,
         color="black",
         linewidth=0.5,
         label="h(giant atom)")

    pl.xlabel = "frequency/center frequency"
    pl.ylabel = "Lamb shift"
    pl.set_ylim(-1e9, 1e9)
    pl.legend(loc="lower right")
    return pl
Ejemplo n.º 23
0
def hilbert_check(pl="hilbert", **kwargs):
    idt=IDT.process_kwargs(kwargs)
    frq=linspace(0e9, 10e9, 10000)
    #idt.N_fixed=100000
    idt.fixed_freq_max=20.0*idt.f0
    idt.Lamb_shift_type="formula"
    idt.couple_type="sinc sq"
    pl=line(frq/idt.f0, idt._get_Lamb_shift(frq), plotter=pl, linewidth=1.0, label="sinc^2", **kwargs)
    idt.couple_type="giant atom"
    line(frq/idt.f0, idt._get_Lamb_shift(frq), plotter=pl, color="red", linewidth=1.0, label=idt.couple_type)
    idt.Lamb_shift_type="hilbert"
    idt.couple_type="sinc sq"
    line(frq/idt.f0, idt._get_Lamb_shift(frq), plotter=pl, color="green", linewidth=0.5, label="h(sinc^2)")
    idt.couple_type="giant atom"
    line(frq/idt.f0, idt._get_Lamb_shift(frq), plotter=pl, color="black", linewidth=0.5, label="h(giant atom)")

    pl.xlabel="frequency/center frequency"
    pl.ylabel="Lamb shift"
    pl.set_ylim(-1e9, 1e9)
    pl.legend(loc="lower right")
    return pl
Ejemplo n.º 24
0
def fix_couple_comparison(pl="fix couple", **kwargs):
    idt=IDT.process_kwargs(kwargs)
    idt.fixed_freq_max=20.0*idt.f0
    idt.couple_type="sinc sq"
    idt.fixed_reset()
    frq=linspace(0e9, 10e9, 10000)
    pl=line(frq/idt.f0, 10*log10(idt.get_fix("coupling", frq)/idt.max_coupling), plotter=pl, linewidth=0.3, label=idt.couple_type, **kwargs)
    idt.couple_type="giant atom"
    idt.fixed_reset()
    line(frq/idt.f0, 10*log10(idt.get_fix("coupling", frq)/idt.max_coupling), plotter=pl, color="red", linewidth=0.3, label=idt.couple_type)
    idt.couple_type="df giant atom"
    idt.fixed_reset()
    line(frq/idt.f0, 10*log10(idt.get_fix("coupling", frq)/idt.max_coupling), plotter=pl, color="green", linewidth=0.3, label=idt.couple_type)
    idt.couple_type="full expr"
    idt.fixed_reset()
    line(frq/idt.f0, 10*log10(idt.get_fix("coupling", frq)/idt.max_coupling), plotter=pl, color="black", linewidth=0.3, label=idt.couple_type)
    idt.couple_type="full sum"
    idt.fixed_reset()
    line(frq/idt.f0, 10*log10(idt.get_fix("coupling", frq)/idt.max_coupling), plotter=pl, color="purple", linewidth=0.3, label=idt.couple_type)
    pl.xlabel="frequency/center frequency"
    pl.ylabel="coupling/max coupling (dB)"
    pl.set_ylim(-30, 1.0)
    pl.legend()
    return pl
Ejemplo n.º 25
0
def metallization_Lamb(pl="metallization_lamb", **kwargs):
    idt=IDT.process_kwargs(kwargs)
    frq=linspace(0e9, 10e9, 10000)
    idt.eta=0.5
    idt.N_fixed=100000
    #idt.fixed_freq_max=20.0*idt.f0

    #idt.ft="single"
    idt.couple_type="full expr"
    #idt.Lamb_shift_type="hilbert"
    idt.fixed_reset()
    pl=line(frq/idt.f0, idt.get_fix("Lamb_shift", frq), plotter=pl, plot_name="0.5", color="blue", linewidth=0.3, label="0.5", **kwargs)
    idt.eta=0.6
    idt.fixed_reset()
    #line(idt.fixed_freq/idt.f0, idt.fixed_Lamb_shift/idt.max_coupling, plotter=pl, linewidth=0.3, color="purple")
    line(frq/idt.f0, idt.get_fix("Lamb_shift", frq), plotter=pl, plot_name="0.6", color="red", linewidth=0.3, label="0.6", **kwargs)
    idt.eta=0.4
    idt.fixed_reset()
    line(frq/idt.f0, idt.get_fix("Lamb_shift", frq), plotter=pl, plot_name="0.4", color="green", linewidth=0.3, label="0.4", **kwargs)
    idt.eta=0.5
    pl.xlabel="frequency/center frequency"
    pl.ylabel="Lamb shift"
    pl.legend()
    return pl
Ejemplo n.º 26
0
def metallization_couple(pl="metallization_couple", **kwargs):
    idt=IDT.process_kwargs(kwargs)
    frq=linspace(0e9, 10e9, 10000)
    idt.N_fixed=100000
    #idt.fixed_freq_max=20.0*idt.f0
    idt.eta=0.5
    #idt.ft="single"
    #idt.S_type="RAM"
    idt.couple_type="full expr"
    idt.fixed_reset()
    line(idt.fixed_freq/idt.f0, idt.fixed_coupling, plot_name="0.5", color="blue", linewidth=0.3, label="0.5", **kwargs)

    pl=line(frq/idt.f0, idt.get_fix("coupling", frq), plotter=pl, plot_name="0.5", color="blue", linewidth=0.3, label="0.5", **kwargs)
    idt.eta=0.6
    idt.fixed_reset()
    line(frq/idt.f0, idt.get_fix("coupling", frq), plotter=pl, plot_name="0.6", color="red", linewidth=0.3, label="0.6", **kwargs)
    idt.eta=0.4
    idt.fixed_reset()
    line(frq/idt.f0, idt.get_fix("coupling", frq), plotter=pl, plot_name="0.4", color="green", linewidth=0.3, label="0.4", **kwargs)
    idt.eta=0.5
    pl.xlabel="frequency/center frequency"
    pl.ylabel="coupling"
    pl.legend()
    return pl
Ejemplo n.º 27
0
    #line(frq, coup, color="purple", plotter=pl, linewidth=0.3)
    line(frq,
         a._get_full_coupling(frq) / a.max_coupling,
         plotter=pl,
         color="green",
         linewidth=0.3)
    line(frq,
         a._get_full_Lamb_shift(frq) / a.max_coupling,
         plotter=pl,
         color="black",
         linewidth=0.3)
    return pl


if 0:
    idt = IDT()
    element_factor_plot(idt=idt)  #.show()

    Lamb_shift_comparison(idt=idt)

    couple_comparison(idt=idt)  #.show()

    fix_couple_comparison(idt=idt)  #.show()

    Lamb_shift_check(idt=idt).show()

#formula_comparison()#.show()

#element_factor_plot(idt=idt).show()
if __name__ == "__main__":
    #a=IDT(dloss1=0.0, dloss2=0.0, eta=0.6, ft="double")
Ejemplo n.º 28
0
    def build_map(self, wantCL=True, do_pickle=False):
        """Use downloaded files and other parameters to build multi-raster map."""

        # set pickle variable
        if do_pickle:
            pickle_name = self.name
        else:
            pickle_name = None

        # warp elevation data into new format
        # NB: can't do this to landcover until mode algorithm is supported
        eltif = os.path.join(self.mapsdir, '%s.tif' % self.ellayer)
        elfile = os.path.join(self.mapsdir, '%s-new.tif' % self.ellayer)
        elextents = self.albersextents['elevation']
        warpcmd = 'gdalwarp -q -multi -tr %d %d -te %d %d %d %d -r cubic "%s" "%s" -srcnodata "-340282346638529993179660072199368212480.000" -dstnodata 0' % (
            self.scale, self.scale, elextents['xmin'], elextents['ymin'],
            elextents['xmax'], elextents['ymax'], eltif, elfile)

        try:
            os.remove(elfile)
        except OSError:
            pass
        # NB: make this work on Windows too!
        os.system('%s' % warpcmd)

        elds = gdal.Open(elfile, GA_ReadOnly)
        elgeotrans = elds.GetGeoTransform()
        elband = elds.GetRasterBand(1)
        elarray = elband.ReadAsArray(0, 0, elds.RasterXSize, elds.RasterYSize)
        (elysize, elxsize) = elarray.shape

        # update sealevel, trim and vscale
        elmin = elband.GetMinimum()
        elmax = elband.GetMaximum()
        if elmin is None or elmax is None:
            (elmin, elmax) = elband.ComputeRasterMinMax(False)
        elmin = int(elmin)
        elmax = int(elmax)
        elband = None
        elds = None

        # sealevel depends upon elmin
        minsealevel = 2
        # if minimum elevation is below sea level, add extra space
        if elmin < 0:
            minsealevel += int(-1.0 * elmin / self.scale)
        maxsealevel = Region.tileheight - Region.headroom
        oldsealevel = self.sealevel
        if oldsealevel > maxsealevel or oldsealevel < minsealevel:
            print "warning: sealevel value %d outside %d-%d range" % (
                oldsealevel, minsealevel, maxsealevel)
        self.sealevel = int(min(max(oldsealevel, minsealevel), maxsealevel))

        # maxdepth depends upon sealevel
        minmaxdepth = 1
        maxmaxdepth = self.sealevel - 1
        oldmaxdepth = self.maxdepth
        if oldmaxdepth > maxmaxdepth or oldmaxdepth < minmaxdepth:
            print "warning: maxdepth value %d outside %d-%d range" % (
                oldmaxdepth, minmaxdepth, maxmaxdepth)
        self.maxdepth = int(min(max(oldmaxdepth, minmaxdepth), maxmaxdepth))

        # trim depends upon elmin (if elmin < 0, trim == 0)
        mintrim = Region.trim
        maxtrim = max(elmin, mintrim)
        oldtrim = self.trim
        if oldtrim > maxtrim or oldtrim < mintrim:
            print "warning: trim value %d outside %d-%d range" % (
                oldtrim, mintrim, maxtrim)
        self.trim = int(min(max(oldtrim, mintrim), maxtrim))

        # vscale depends on sealevel, trim and elmax
        # NB: no maximum vscale, the sky's the limit (hah!)
        eltrimmed = elmax - self.trim
        elroom = Region.tileheight - Region.headroom - self.sealevel
        minvscale = ceil(eltrimmed / elroom)
        oldvscale = self.vscale
        if oldvscale < minvscale:
            print "warning: vscale value %d smaller than minimum value %d" % (
                oldvscale, minvscale)
        self.vscale = int(max(oldvscale, minvscale))

        # GeoTIFF
        # four bands: landcover, elevation, bathy, crust
        # data type is GDT_Int16 (elevation can be negative)
        driver = gdal.GetDriverByName("GTiff")
        mapds = driver.Create(self.mapfile, elxsize, elysize,
                              len(Region.rasters), GDT_Int16)
        # overall map transform should match elevation map transform
        mapds.SetGeoTransform(elgeotrans)
        srs = osr.SpatialReference()
        srs.ImportFromProj4(Region.albers)
        mapds.SetProjection(srs.ExportToWkt())

        # modify elarray and save it as raster band 2
        elevObj = Elev(elarray, wantCL=wantCL)
        actualel = elevObj(self.trim,
                           self.vscale,
                           self.sealevel,
                           pickle_name=pickle_name)
        mapds.GetRasterBand(Region.rasters['elevation']).WriteArray(actualel)
        elarray = None
        actualel = None

        # generate crust and save it as raster band 4
        newcrust = Crust(mapds.RasterXSize, mapds.RasterYSize, wantCL=wantCL)
        crustarray = newcrust(pickle_name=pickle_name)
        mapds.GetRasterBand(Region.rasters['crust']).WriteArray(crustarray)
        crustarray = None
        newcrust = None

        # read landcover array
        lctif = os.path.join(self.mapsdir, '%s.tif' % self.lclayer)
        lcfile = os.path.join(self.mapsdir, '%s-new.tif' % self.lclayer)
        # here are the things that need to happen
        lcextents = self.albersextents['landcover']

        # if True, use new code, if False, use gdalwarp
        if Region.gdalwarp_broken_for_landcover:
            # 1. the new file must be read into an array and flattened
            tifds = gdal.Open(lctif, GA_ReadOnly)
            tifgeotrans = tifds.GetGeoTransform()
            tifband = tifds.GetRasterBand(1)
            xminarr = int(
                (lcextents['xmin'] - tifgeotrans[0]) / tifgeotrans[1])
            xmaxarr = int(
                (lcextents['xmax'] - tifgeotrans[0]) / tifgeotrans[1])
            yminarr = int(
                (lcextents['ymax'] - tifgeotrans[3]) / tifgeotrans[5])
            ymaxarr = int(
                (lcextents['ymin'] - tifgeotrans[3]) / tifgeotrans[5])
            values = tifband.ReadAsArray(xminarr, yminarr, xmaxarr - xminarr,
                                         ymaxarr - yminarr)
            # nodata is treated as water, which is 11
            tifnodata = tifband.GetNoDataValue()
            if tifnodata is None:
                tifnodata = 0
            values[values == tifnodata] = 11
            values = values.flatten()
            tifband = None
            # 2. a new array of original scale coordinates must be created
            tifxrange = [
                tifgeotrans[0] + tifgeotrans[1] * x
                for x in xrange(xminarr, xmaxarr)
            ]
            tifyrange = [
                tifgeotrans[3] + tifgeotrans[5] * y
                for y in xrange(yminarr, ymaxarr)
            ]
            tifds = None
            coords = np.array([(x, y) for y in tifyrange for x in tifxrange])
            # 3. a new array of goal scale coordinates must be made
            # landcover extents are used for the bathy depth array
            # yes, it's confusing.  sorry.
            depthxlen = int(
                (lcextents['xmax'] - lcextents['xmin']) / self.scale)
            depthylen = int(
                (lcextents['ymax'] - lcextents['ymin']) / self.scale)
            depthxrange = [
                lcextents['xmin'] + self.scale * x for x in xrange(depthxlen)
            ]
            depthyrange = [
                lcextents['ymax'] - self.scale * y for y in xrange(depthylen)
            ]
            depthbase = np.array([(x, y) for y in depthyrange
                                  for x in depthxrange],
                                 dtype=np.float32)
            # 4. an inverse distance tree must be built from that
            lcIDT = IDT(coords, values.ravel().astype(np.int32), wantCL=wantCL)
            # 5. the desired output comes from that inverse distance tree
            depthshape = (depthylen, depthxlen)
            deptharray = lcIDT(depthbase, depthshape, pickle_name=pickle_name)
            lcIDT = None
        else:
            warpcmd = 'gdalwarp -q -multi -tr %d %d -te %d %d %d %d -r near "%s" "%s"' % (
                self.scale, self.scale, lcextents['xmin'], lcextents['ymin'],
                lcextents['xmax'], lcextents['ymax'], lctif, lcfile)

            try:
                os.remove(lcfile)
            except OSError:
                pass
            # NB: make this work on Windows too!
            os.system('%s' % warpcmd)
            lcds = gdal.Open(lcfile, GA_ReadOnly)
            lcband = lcds.GetRasterBand(1)
            # depth array is entire landcover region, landcover array is subset
            deptharray = lcband.ReadAsArray(0, 0, lcds.RasterXSize,
                                            lcds.RasterYSize)
        lcarray = deptharray[self.maxdepth:-1 * self.maxdepth,
                             self.maxdepth:-1 * self.maxdepth]
        geotrans = [
            lcextents['xmin'], self.scale, 0, lcextents['ymax'], 0,
            -1 * self.scale
        ]
        projection = srs.ExportToWkt()
        bathyObj = Bathy(deptharray, geotrans, projection, wantCL=wantCL)
        bathyarray = bathyObj(self.maxdepth, pickle_name=pickle_name)
        mapds.GetRasterBand(Region.rasters['bathy']).WriteArray(bathyarray)
        # perform terrain translation
        # NB: figure out why this doesn't work up above
        lcpid = self.lclayer[:3]
        if lcpid in Terrain.translate:
            trans = Terrain.translate[lcpid]
            for key in trans:
                lcarray[lcarray == key] = trans[key]
            for value in np.unique(lcarray).flat:
                if value not in Terrain.terdict:
                    print "bad value: ", value
        mapds.GetRasterBand(Region.rasters['landcover']).WriteArray(lcarray)

        # close the dataset
        mapds = None
Ejemplo n.º 29
0
def couple_comparison(pl="couple_compare", **kwargs):
    idt = IDT.process_kwargs(kwargs)
    frq = linspace(0.01e9, 10 * 10e9, 10000)

    idt.fixed_freq_max = 20.0 * idt.f0
    idt.S_type = "RAM"
    idt.eta = 0.55
    #idt.Y0_type="center"
    #idt.df_type="center"
    #idt.mus_type="center"
    #idt.Ga_type="sinc"
    #idt.Ba_type="formula"
    #idt.rs_type="constant"

    #(P11, P12, P13,
    # P21, P22, P23,
    # P31, P32, P33), Ga, Ba, Ct=idt._get_RAM_P(frq=frq, Y0=None)
    #pl=line(frq/idt.f0, Ga/idt.Ga0_approx, plotter=pl, color="cyan", label=idt.S_type, **kwargs)

    pl = line(frq / idt.f0,
              idt._get_coupling(frq) / idt.max_coupling_approx,
              plotter=pl,
              color="cyan",
              label=idt.S_type,
              **kwargs)
    idt.S_type = "simple"
    idt.fixed_reset()

    idt.Ga_type = "giant atom"
    line(frq / idt.f0,
         idt._get_coupling(frq) / idt.max_coupling_approx,
         plotter=pl,
         color="red",
         label="full expr",
         **kwargs)

    idt.Y0_type = "center"
    idt.df_type = "center"
    idt.mus_type = "center"
    idt.Ga_type = "sinc"
    idt.Ba_type = "formula"
    idt.rs_type = "constant"
    pl = line(frq / idt.f0,
              idt._get_coupling(frq) / idt.max_coupling_approx,
              plotter=pl,
              label=idt.Ga_type,
              **kwargs)
    idt.Ga_type = "giant atom"
    line(frq / idt.f0,
         idt._get_coupling(frq) / idt.max_coupling_approx,
         plotter=pl,
         color="green",
         label=idt.Ga_type,
         **kwargs)
    #idt.couple_type="full expr"
    #line(frq/idt.f0, idt._get_coupling(frq)/idt.max_coupling_approx, plotter=pl, color="black", linewidth=0.5, label=idt.couple_type)
    #idt.couple_type="full sum"
    #line(frq/idt.f0, (idt._get_coupling(frq)), plotter=pl, color="purple", linewidth=0.5, label=idt.couple_type)
    pl.xlabel = "frequency/center frequency"
    pl.ylabel = "coupling"
    #pl.set_ylim(0.0, 1.3e9)
    pl.legend()
    return pl
Ejemplo n.º 30
0
def RAM_comparison(pl="RAM_compare", **kwargs):
    idt = IDT.process_kwargs(kwargs)
    #idt2=IDT.process_kwargs(kwargs)

    frq = linspace(0.01e9, 10e9, 10000)
    idt.fixed_freq_max = 2.0 * idt.f0

    def _get_RAM_P_one_f(self, f, Dvv, epsinf, W, vf, rs, p, N_IDT, alpha, ft,
                         Np, f0, dloss1, dloss2, L_IDT):
        #Y0=self._get_Y0(f=f, Dvv=Dvv, epsinf=epsinf, W=W)
        #rs=self._get_rs(f=f)
        #print rs
        k = 2 * pi * f / vf  #-1.0j*(f/f0*dloss1+dloss2*(f/f0)**2)
        ts = sqrt(1.0 - absolute(rs)**2)
        A = 1.0 / ts * matrix([[exp(-1.0j * k * p), rs],
                               [-rs, exp(1.0j * k * p)]])  #.astype(complex128)
        #AN=A**int(N_IDT)
        #AN11, AN12, AN21, AN22= AN[0,0], AN[0,1], AN[1,0], AN[1,1]
        #P11=-AN21/AN22
        #P21=AN11-AN12*AN21/AN22
        #P12=1.0/AN22
        #P22=AN12/AN22
        #D = -1.0j*alpha*Dvv*sqrt(Y0)
        #B = matrix([(1.0-rs/ts+1.0/ts)*exp(-1.0j*k*p/2.0), (1.0+rs/ts+1.0/ts)*exp(1.0j*k*p/2.0)])
        I = eye(2)

        P1 = (I + A)
        P2 = inv(I - A**4) * (I - A**(4 * int(Np)))
        return 1 / sqrt(2) * absolute(P1[1, 1] * exp(
            -1.0j * k * p / 2.0)) * absolute(P2[1, 1])**2  ##, P2

    #idt.Np=37
    #idt.ft="single"
    #idt.couple_type="full expr"
    #pl=line(frq/idt.f0, idt._get_coupling(frq), plotter=pl, linewidth=0.5, label=idt.couple_type, **kwargs)
    #data=[_get_RAM_P_one_f(idt, f=f, Dvv=idt.Dvv, epsinf=idt.epsinf, W=idt.W, vf=idt.vf, rs=idt.rs, p=idt.p,
    #                             N_IDT=idt.N_IDT, alpha=idt.alpha0, ft=idt.ft, Np=idt.Np, f0=idt.f0, dloss1=idt.dloss1, dloss2=idt.dloss2, L_IDT=idt.L_IDT) for f in frq]
    #data=array(data)
    #print data.shape
    #line(frq, array(data), pl=pl, color="green")
    Np = idt.Np
    gX = idt._get_X(f=frq)
    #line(frq, 1/81.0*(sqrt(2.0)*cos(pi*frq/(4.0*idt.f0))*sin(gX)/sin(gX/Np))**2, pl=pl)#.show()
    #line(frq, 2.0*cos(pi*frq/(4.0*idt.f0)), pl=pl).show()
    print idt.f0, idt.Dvv, idt.epsinf, idt.W, idt.vf, idt.rs, idt.p, idt.N_IDT, idt.alpha, idt.ft, idt.Np, idt.f0, idt.dloss1, idt.dloss2, idt.L_IDT
    #idt.S_type="RAM"
    idt.couple_type = "full expr"
    idt.fixed_reset()

    #P=idt._get_RAM_P()
    gamma = idt._get_couple_factor(f=idt.fixed_freq)
    line(idt.fixed_freq,
         idt._get_couple_factor(f=idt.fixed_freq),
         plotter=pl,
         color="red",
         linewidth=0.5,
         label=idt.ft)  #.show()
    line(idt.fixed_freq,
         gamma,
         plotter=pl,
         color="blue",
         linewidth=0.5,
         label=idt.ft).show()

    #line(idt.fixed_freq, gamma*2*idt.Ct*2*pi*P[1], plotter=pl, color="red", linewidth=0.5, label=idt.ft)#.show()
    #line(idt.fixed_freq, P[2], plotter=pl, color="green", linewidth=0.5, label=idt.ft)
    idt.S_type = "simple"
    #idt.ft="double"
    idt.couple_type = "df giant atom"  #"full expr"
    idt.fixed_reset()
    line(idt.fixed_freq,
         gamma * 2 * idt.Ct * 2 * pi * idt._get_Ga(idt.fixed_freq) / idt.Ga0,
         plotter=pl,
         color="blue",
         linewidth=0.5,
         label=idt.ft).show()
    line(idt.fixed_freq,
         idt._get_Ba(idt.fixed_freq),
         plotter=pl,
         color="black",
         linewidth=0.5,
         label=idt.ft).show()

    #idt.Np=37
    #idt.fixed_freq_max=20.0*idt.f0

    #idt2.ft="single"

    #idt.fixed_reset()
    line(frq / idt.f0,
         idt._get_coupling(frq),
         plotter=pl,
         color="red",
         linewidth=0.5,
         label=idt.ft)
    idt.ft = "single"
    idt.fixed_reset()
    line(frq / idt.f0,
         idt._get_coupling(frq),
         plotter=pl,
         color="green",
         linewidth=0.5,
         label=idt.ft)
    idt.S_type = "simple"
    idt.ft = "double"
    idt.couple_type = "full expr"
    idt.fixed_reset()
    pl = line(frq / idt.f0,
              idt._get_coupling(frq),
              plotter=pl,
              linewidth=0.5,
              label=idt.couple_type,
              **kwargs)

    pl.xlabel = "frequency/center frequency"
    pl.ylabel = "coupling"
    #pl.set_ylim(-30, 1.0)
    pl.legend()
    return pl
Ejemplo n.º 31
0
    couple_comparison(idt=idt)#.show()

    fix_couple_comparison(idt=idt)#.show()

    Lamb_shift_check(idt=idt).show()

#formula_comparison()#.show()

#element_factor_plot(idt=idt).show()
if __name__=="__main__":
    #a=IDT(dloss1=0.0, dloss2=0.0, eta=0.6, ft="double")
    a=IDT(material='LiNbYZ',
          ft="double",
          a=80.0e-9, #f0=5.35e9,
          Np=9,
          #Rn=3780.0, #(3570.0+4000.0)/2.0, Ejmax=h*44.0e9,
          W=25.0e-6,
          eta=0.5,)
          #flux_factor=0.515, #0.2945, #0.52,
          #voltage=1.21,
          #offset=-0.07)
    #print a.fixed_P
    a.fixed_reset()
    #a.Y0_type="center"
    #a.mus_type="center"
    #a.df_type="center"
    #print a.f0
    #Y0, mus/Dvv, df_corr, cpl_form
    #2.0*/a.K2*absolute(mus/Dvv *Dvv *df_corr*1.0)**2
    #(mus/Dvv*df_corr)**2  Dvv*(Np**2)
Ejemplo n.º 32
0
def RAM_comparison(pl="RAM_compare", **kwargs):
    idt=IDT.process_kwargs(kwargs)
    #idt2=IDT.process_kwargs(kwargs)

    frq=linspace(0.01e9, 10e9, 10000)
    idt.fixed_freq_max=2.0*idt.f0

    def _get_RAM_P_one_f(self, f, Dvv, epsinf, W, vf,  rs, p, N_IDT, alpha, ft, Np, f0, dloss1, dloss2, L_IDT):
        #Y0=self._get_Y0(f=f, Dvv=Dvv, epsinf=epsinf, W=W)
        #rs=self._get_rs(f=f)
        #print rs
        k=2*pi*f/vf#-1.0j*(f/f0*dloss1+dloss2*(f/f0)**2)
        ts = sqrt(1.0-absolute(rs)**2)
        A = 1.0/ts*matrix([[exp(-1.0j*k*p),       rs      ],
                           [-rs,             exp(1.0j*k*p)]])#.astype(complex128)
        #AN=A**int(N_IDT)
        #AN11, AN12, AN21, AN22= AN[0,0], AN[0,1], AN[1,0], AN[1,1]
        #P11=-AN21/AN22
        #P21=AN11-AN12*AN21/AN22
        #P12=1.0/AN22
        #P22=AN12/AN22
        #D = -1.0j*alpha*Dvv*sqrt(Y0)
        #B = matrix([(1.0-rs/ts+1.0/ts)*exp(-1.0j*k*p/2.0), (1.0+rs/ts+1.0/ts)*exp(1.0j*k*p/2.0)])
        I = eye(2)

        P1=(I+A)
        P2=inv(I-A**4)*(I-A**(4*int(Np)))
        return 1/sqrt(2)*absolute(P1[1,1]*exp(-1.0j*k*p/2.0))*absolute(P2[1,1])**2 ##, P2

    #idt.Np=37
    #idt.ft="single"
    #idt.couple_type="full expr"
    #pl=line(frq/idt.f0, idt._get_coupling(frq), plotter=pl, linewidth=0.5, label=idt.couple_type, **kwargs)
    #data=[_get_RAM_P_one_f(idt, f=f, Dvv=idt.Dvv, epsinf=idt.epsinf, W=idt.W, vf=idt.vf, rs=idt.rs, p=idt.p,
    #                             N_IDT=idt.N_IDT, alpha=idt.alpha0, ft=idt.ft, Np=idt.Np, f0=idt.f0, dloss1=idt.dloss1, dloss2=idt.dloss2, L_IDT=idt.L_IDT) for f in frq]
    #data=array(data)
    #print data.shape
    #line(frq, array(data), pl=pl, color="green")
    Np=idt.Np
    gX=idt._get_X(f=frq)
    #line(frq, 1/81.0*(sqrt(2.0)*cos(pi*frq/(4.0*idt.f0))*sin(gX)/sin(gX/Np))**2, pl=pl)#.show()
    #line(frq, 2.0*cos(pi*frq/(4.0*idt.f0)), pl=pl).show()
    print idt.f0, idt.Dvv, idt.epsinf, idt.W, idt.vf,  idt.rs, idt.p, idt.N_IDT, idt.alpha, idt.ft, idt.Np, idt.f0, idt.dloss1, idt.dloss2, idt.L_IDT
    #idt.S_type="RAM"
    idt.couple_type="full expr"
    idt.fixed_reset()

    #P=idt._get_RAM_P()
    gamma=idt._get_couple_factor(f=idt.fixed_freq)
    line(idt.fixed_freq, idt._get_couple_factor(f=idt.fixed_freq), plotter=pl, color="red", linewidth=0.5, label=idt.ft)#.show()
    line(idt.fixed_freq, gamma, plotter=pl, color="blue", linewidth=0.5, label=idt.ft).show()

    #line(idt.fixed_freq, gamma*2*idt.Ct*2*pi*P[1], plotter=pl, color="red", linewidth=0.5, label=idt.ft)#.show()
    #line(idt.fixed_freq, P[2], plotter=pl, color="green", linewidth=0.5, label=idt.ft)
    idt.S_type="simple"
    #idt.ft="double"
    idt.couple_type="df giant atom" #"full expr"
    idt.fixed_reset()
    line(idt.fixed_freq, gamma*2*idt.Ct*2*pi*idt._get_Ga(idt.fixed_freq)/idt.Ga0, plotter=pl, color="blue", linewidth=0.5, label=idt.ft).show()
    line(idt.fixed_freq, idt._get_Ba(idt.fixed_freq), plotter=pl, color="black", linewidth=0.5, label=idt.ft).show()

    #idt.Np=37
    #idt.fixed_freq_max=20.0*idt.f0

    #idt2.ft="single"

    #idt.fixed_reset()
    line(frq/idt.f0, idt._get_coupling(frq), plotter=pl, color="red", linewidth=0.5, label=idt.ft)
    idt.ft="single"
    idt.fixed_reset()
    line(frq/idt.f0, idt._get_coupling(frq), plotter=pl, color="green", linewidth=0.5, label=idt.ft)
    idt.S_type="simple"
    idt.ft="double"
    idt.couple_type="full expr"
    idt.fixed_reset()
    pl=line(frq/idt.f0, idt._get_coupling(frq), plotter=pl, linewidth=0.5, label=idt.couple_type, **kwargs)

    pl.xlabel="frequency/center frequency"
    pl.ylabel="coupling"
    #pl.set_ylim(-30, 1.0)
    pl.legend()
    return pl