def __init__(self, dispersion, wvls): """Initialize an instance of N_mixture class to store the index of refraction of a mixture with constant dispersion This method takes 2 arguments: material an instance of a mixture dispersion class; wvls the wavelengths at which to calculate the index of refraction.""" self.wvls = wvls self.dispersion = dispersion if isinstance(self.dispersion, constant_mixture): self.f_N = self.dispersion.set_N_constant_mixture self.f_N_x = self.dispersion.set_N_constant_mixture_by_x self.f_dN = self.dispersion.set_dN_constant_mixture elif isinstance(self.dispersion, table_mixture): self.f_N = self.dispersion.set_N_table_mixture self.f_N_x = self.dispersion.set_N_table_mixture_by_x self.f_dN = self.dispersion.set_dN_table_mixture elif isinstance(self.dispersion, Cauchy_mixture): self.f_N = self.dispersion.set_N_Cauchy_mixture self.f_N_x = self.dispersion.set_N_Cauchy_mixture_by_x self.f_dN = self.dispersion.set_dN_Cauchy_mixture elif isinstance(self.dispersion, Sellmeier_mixture): self.f_N = self.dispersion.set_N_Sellmeier_mixture self.f_N_x = self.dispersion.set_N_Sellmeier_mixture_by_x self.f_dN = self.dispersion.set_dN_Sellmeier_mixture self.N = N(self.wvls) self.dN = N(self.wvls) self.length = 0 self.N_graded = None
def prepare_N_mixture_graded(self, length): """Prepare a mixture index instance to represent graded-index layers This method takes 1 argument: length the number of index levels to prepare.""" self.length = length self.N_graded = [N(self.wvls) for i in range(self.length)]
def __init__(self, num, denum=N(1)): if isinstance(num, N): self.num = num.toZ() elif isinstance(num, Z): self.num = num else: self.num = Z(num) if isinstance(denum, Z): if denum.sign: self.num = self.num * Z(-1) self.denum = abs(denum).toN() elif isinstance(denum, N): self.denum = denum else: self.denum = N(denum) # self.num = num # Числитель. # self.denum = denum # Знаменатель. if self.denum == N(0): raise ZeroDivisionError("Divided by zero")
async def _create_welcome(O,member,test_member_number:I=E): AR='of ';AQ='Welcome';q=test_member_number;K=member;C=await O.config.guild(K.guild).all();AD=C[g];AE=C[h];AF=C[e];AG=C[f];T=C[Z];AH=C[a];AI=C[b];AJ=C[c];AK=C[d];r=G.truetype(AD,AE);U=G.truetype(AF,AG);s=G.truetype(T,AH);t=G.truetype(T,AI);u=G.truetype(T,AJ);v=G.truetype(T,AK);w=F.open(C[A7]).convert(S);AL=F.open(O.imgpath+'/noimage.png');L=F.new(S,(500,150));L=n.fit(w,(500,150),centering=(0.5,0.5));L.paste(w);L=L.resize((500,150),F.NEAREST);V=F.new('L',(512,512),0);AM=R.Draw(V);AM.ellipse(((0,0),(512,512)),fill=255);i=J(C[A9]);V=V.resize(i,F.ANTIALIAS) try:P=m();await K.avatar_url.save(P,seek_begin=A);P=F.open(P).convert(S) except A4 as AS:o.error('ImgWelcome error in create_welcome:\n',exc_info=A);P=AL j=n.fit(P,i,centering=(0,0));j.putalpha(V);k=J(C[A8]);W=J(C[p]);x=J(C[AB]) try:y=J(C[AC]) except A5:y=J(C[p]) M=J(C[AA]);z=F.new('L',(512,512),0);AN=R.Draw(z);AN.ellipse((0,0)+(512,512),fill=255,outline=0);X=F.new(S,(512,512));AO=R.Draw(X);AO.ellipse([0,0,512,512],fill=(k[0],k[1],k[2],180),outline=(255,255,255,250));Y=await O._circle_border(i);X=X.resize(Y,F.ANTIALIAS);AP=z.resize(Y,F.ANTIALIAS);A0=7+I((136-Y[0])/2);A1=11+I((136-Y[0])/2);H=R.Draw(L);L.paste(X,(A0,A0),AP);L.paste(j,(A1,A1),j);E=B(K) def N(original_position:J,text:B,pixel_displacement:I,font,textoutline):D=textoutline;C=font;B=text;A=original_position;E=pixel_displacement;F=A[0]-E,A[1];G=A[0]+E,A[1];I=A[0],A[1]-E;J=A[0],A[1]+E;H.text(F,B,font=C,fill=D);H.text(G,B,font=C,fill=D);H.text(I,B,font=C,fill=D);H.text(J,B,font=C,fill=D);H.text(A,B,font=C,fill=D) N((150,16),AQ,1,r,M);H.text((150,16),AQ,font=r,fill=y) if D(E)<=17:N((152,63),E,1,s,M);H.text((152,63),E,font=s,fill=W) if D(E)>17: if D(E)<=23:N((152,66),E,1,t,M);H.text((152,66),E,font=t,fill=W) if D(E)>=24: if D(E)<=32:N((152,70),E,1,u,M);H.text((152,70),E,font=u,fill=W) if D(E)>=33:N((152,73),E,1,v,M);H.text((152,73),E,font=v,fill=W) if not q: if not O.bot.intents.members:Q=K.guild.member_count+1 else: try:Q=A6(K.guild.members,key=lambda m:m.joined_at).index(K)+1 except A5:Q=K.guild.member_count+1 else:Q=I(q) A2=B(Q)+O._get_suffix(Q);A3=B(K.guild.name)+'!'if D(B(K.guild.name))<=28 else B(K.guild.name)[:23]+'...';N((152,96),f"You are the {B(A2)} member",1,U,M);H.text((152,96),f"You are the {B(A2)} member",font=U,fill=x);N((152,116),AR+A3,1,U,M);H.text((152,116),AR+A3,font=U,fill=x);l=m();L.save(l,format='PNG');l.seek(0);return l
def tryReverseOp(a, b, op): crutch = {type(N(0)): 1, type(Z(0)): 2, type(Q(0)): 3, type(poly(0)): 4 } # print( type( a ), type( b ) ) # print( type(N(0)), type(Z(0)), type(Q(0)), type(poly(0)) ) # print( a, op, b, ": ", type( a ), type( b ) ) # print( self, "__add__", other, ": ", type( self ), type( other ) ) try: if crutch[type(a)] < crutch[type(b)]: return eval('type(b)(a)' + op + 'b') else: # print( str( a ) + op + str( eval( "type(a)(b)" ) ) ) return eval("a" + op + 'type(a)(b)') except: print(a, op, b, ": ", type(a), type(b)) raise RuntimeError
async def _create_welcome(O, member, test_member_number: I = E): AR = 'to ' AQ = 'Welcome' q = test_member_number K = member C = await O.config.guild(K.guild).all() AD = C[g] AE = C[h] AF = C[e] AG = C[f] T = C[Z] AH = C[a] AI = C[b] AJ = C[c] AK = C[d] r = G.truetype(AD, AE) U = G.truetype(AF, AG) s = G.truetype(T, AH) t = G.truetype(T, AI) u = G.truetype(T, AJ) v = G.truetype(T, AK) w = F.open(C[A7]).convert(S) AL = F.open(O.imgpath + '/noimage.png') L = F.new(S, (500, 150)) L = n.fit(w, (500, 150), centering=(0.5, 0.5)) L.paste(w) L = L.resize((500, 150), F.NEAREST) V = F.new('L', (512, 512), 0) AM = R.Draw(V) AM.ellipse(((0, 0), (512, 512)), fill=255) i = J(C[A9]) V = V.resize(i, F.ANTIALIAS) try: P = m() await K.avatar_url.save(P, seek_begin=A) P = F.open(P).convert(S) except A4 as AS: o.error('ImgWelcome error in create_welcome:\n', exc_info=A) P = AL j = n.fit(P, i, centering=(0, 0)) j.putalpha(V) k = J(C[A8]) W = J(C[p]) x = J(C[AB]) try: y = J(C[AC]) except A5: y = J(C[p]) M = J(C[AA]) z = F.new('L', (512, 512), 0) AN = R.Draw(z) AN.ellipse((0, 0) + (512, 512), fill=255, outline=0) X = F.new(S, (512, 512)) AO = R.Draw(X) AO.ellipse([0, 0, 512, 512], fill=(k[0], k[1], k[2], 180), outline=(255, 255, 255, 250)) Y = await O._circle_border(i) X = X.resize(Y, F.ANTIALIAS) AP = z.resize(Y, F.ANTIALIAS) A0 = 7 + I((136 - Y[0]) / 2) A1 = 11 + I((136 - Y[0]) / 2) H = R.Draw(L) L.paste(X, (A0, A0), AP) L.paste(j, (A1, A1), j) E = B(K) def N(original_position: J, text: B, pixel_displacement: I, font, textoutline): D = textoutline C = font B = text A = original_position E = pixel_displacement F = A[0] - E, A[1] G = A[0] + E, A[1] I = A[0], A[1] - E J = A[0], A[1] + E H.text(F, B, font=C, fill=D) H.text(G, B, font=C, fill=D) H.text(I, B, font=C, fill=D) H.text(J, B, font=C, fill=D) H.text(A, B, font=C, fill=D) N((150, 16), AQ, 1, r, M) H.text((150, 16), AQ, font=r, fill=y) if D(E) <= 17: N((152, 63), E, 1, s, M) H.text((152, 63), E, font=s, fill=W) if D(E) > 17: if D(E) <= 23: N((152, 66), E, 1, t, M) H.text((152, 66), E, font=t, fill=W) if D(E) >= 24: if D(E) <= 32: N((152, 70), E, 1, u, M) H.text((152, 70), E, font=u, fill=W) if D(E) >= 33: N((152, 73), E, 1, v, M) H.text((152, 73), E, font=v, fill=W) if not q: if not O.bot.intents.members: Q = K.guild.member_count + 1 else: try: Q = A6(K.guild.members, key=lambda m: m.joined_at).index(K) + 1 except A5: Q = K.guild.member_count + 1 else: Q = I(q) A2 = B(Q) + O._get_suffix(Q) A3 = B(K.guild.name) + '!' if D(B( K.guild.name)) <= 28 else B(K.guild.name)[:23] + '...' N((152, 109), AR + A3, 1, U, M) H.text((152, 109), AR + A3, font=U, fill=x) l = m() L.save(l, format='PNG') l.seek(0) return l
-can be used to compute basis set for a general function f by checking all possible frequencies -don't have to do it for all phases since any phase can be given by weighted sum of integral with sin and cos Fourier Transfor, More Formal -see 2C-L1, video 9 Frequency Spectra -largely only look at |F(w)| -power spectra tends to fall off at higher frequency (for any natural signal) Limitations -Fourier transform, F(w) exists if integral from -inf to inf of |f(x)| exists -if there's an interval T outside of which f is 0, can only do Fourier transform integral on interval Discrete Fourier Transform -see 2C-L1, video 12 -discrete frequency k (cycles per image/interval) can only go from -N/2 to N/2 since min period is 2 (1 sample high, 1 sample low) so number of cycles over N (frequency) would be N/2 2D Fourier Transform -see 2C-L1, video 13 Examples -removing high frequency -ringing- ripples from not having high frequency to smooth image -removing low frequency -gives edges -sharpening filter -accentuate high frequencies -pictures with a lot of angled lines leads to higher magnitude lines in frequency spectrum perpendicular to direction of lines in original image -essentually assumes that image continues periodically past acutal bouds -gives high magnitude line in vertical direction from the Transform "sticking" top and bottom edges together
def toN(self): if (self.isZ() and (self.num // self.denum >= Z(0))): return N(str(self.num // self.denum)) else: raise RuntimeError("Z", str(self), "cannot be presented as N.")
from N import * from Z import * from Q import * from poly import * #poly = polynom( [ N([0]), N([3]), N([0]), Z([-1]) ] ) #print( "f(x) =", poly ) print(N([1, 3])) q1 = Q(Z([2]), N(1)) print("Hello world!") q1 = Q(Z(-24), N(142))
async def _create_welcome(R, member, test_member_number: I = E): AQ = 'of ' AP = 'Welcome' q = test_member_number K = member C = await R.config.guild(K.guild).all() AC = C[f] AD = C[g] AE = C[d] AF = C[e] S = C[Y] AG = C[Z] AH = C[a] AI = C[b] AJ = C[c] r = G.truetype(AC, AD) T = G.truetype(AE, AF) s = G.truetype(S, AG) t = G.truetype(S, AH) u = G.truetype(S, AI) v = G.truetype(S, AJ) w = F.open(C[A6]).convert(Q) AK = F.open(R.imgpath + '/noimage.png') L = F.new(Q, (500, 150)) L = n.fit(w, (500, 150), centering=(0.5, 0.5)) L.paste(w) L = L.resize((500, 150), F.NEAREST) U = F.new('L', (512, 512), 0) AL = P.Draw(U) AL.ellipse(((0, 0), (512, 512)), fill=255) h = J(C[A8]) U = U.resize(h, F.ANTIALIAS) try: O = m() await K.avatar_url.save(O, seek_begin=A) O = F.open(O).convert(Q) except A4 as AR: o.error('ImgWelcome error in create_welcome:\n', exc_info=A) O = AK i = n.fit(O, h, centering=(0, 0)) i.putalpha(U) j = J(C[A7]) V = J(C[p]) x = J(C[AA]) try: y = J(C[AB]) except TypeError: y = J(C[p]) M = J(C[A9]) z = F.new('L', (512, 512), 0) AM = P.Draw(z) AM.ellipse((0, 0) + (512, 512), fill=255, outline=0) W = F.new(Q, (512, 512)) AN = P.Draw(W) AN.ellipse([0, 0, 512, 512], fill=(j[0], j[1], j[2], 180), outline=(255, 255, 255, 250)) X = await R._circle_border(h) W = W.resize(X, F.ANTIALIAS) AO = z.resize(X, F.ANTIALIAS) A0 = 7 + I((136 - X[0]) / 2) A1 = 11 + I((136 - X[0]) / 2) H = P.Draw(L) L.paste(W, (A0, A0), AO) L.paste(i, (A1, A1), i) E = f"{B(K)}" def N(original_position: J, text: B, pixel_displacement: I, font, textoutline): D = textoutline C = font B = text A = original_position E = pixel_displacement F = A[0] - E, A[1] G = A[0] + E, A[1] I = A[0], A[1] - E J = A[0], A[1] + E H.text(F, B, font=C, fill=D) H.text(G, B, font=C, fill=D) H.text(I, B, font=C, fill=D) H.text(J, B, font=C, fill=D) H.text(A, B, font=C, fill=D) N((150, 16), AP, 1, r, M) H.text((150, 16), AP, font=r, fill=y) if D(E) <= 17: N((152, 63), E, 1, s, M) H.text((152, 63), E, font=s, fill=V) if D(E) > 17: if D(E) <= 23: N((152, 66), E, 1, t, M) H.text((152, 66), E, font=t, fill=V) if D(E) >= 24: if D(E) <= 32: N((152, 70), E, 1, u, M) H.text((152, 70), E, font=u, fill=V) if D(E) >= 33: N((152, 73), E, 1, v, M) H.text((152, 73), E, font=v, fill=V) if not q: k = A5(K.guild.members, key=lambda m: m.joined_at).index(K) + 1 else: k = I(q) A2 = B(k) + R._get_suffix(k) A3 = B(K.guild.name) + '!' if D(B( K.guild.name)) <= 28 else B(K.guild.name)[:23] + '...' N((152, 96), f"You are the {B(A2)} member", 1, T, M) H.text((152, 96), f"You are the {B(A2)} member", font=T, fill=x) N((152, 116), AQ + A3, 1, T, M) H.text((152, 116), AQ + A3, font=T, fill=x) l = m() L.save(l, format='PNG') l.seek(0) return l