Sunday 15 September 2013

matplotlib - Python: My python plot is reflecting across y = 0.5 line -


Why will my Python plot y = 0.5 appear across the line? There is no single conspiracy in mathematica. I checked the equations 5-10 times and I do not see any difference if I have put -1 in front of the dragon conspiracy, then this unit will have 1 code Y = -0.5 and drop it below.

Additionally, the definitions for alpha and betag are correct.

  import as NP import Pailab R1 = 1 # AU Earth R2 = 1.524 # AU Mars Deltanu = 75 * Anpeepiai / 180 # angle in radians mu = 38.86984154054163 C = NP Skyuarti (R 1 ** 2 + R2 ** 2 - 2 * R1 * R2 * NP COOS (Daltanu) S = (R1 + R2 + c) / 2 am = s / 2 def g (a): alpha = 2 * np.pi - 2 * np.arcsin (np.sqrt (s / (2 * a)) betag = -2 * np.arcsin (np.sqrt ((s - c) / (2 * a)) ) returns (np.sqrt (a ** 3 / mu) * (Alfag - Bitag - (np.sin (alphag) - np. Sin (betag)) - dt) a = np.linspace (am, 2, 500000) Dt = np.linspace (0, 2, 500000) fig = pylab.figure () ax = fig.add_subplot (111) ax plot (A Pylab.xlim ((, 0, 2)) pylab.show ()   

Python:

Enter image details here

Edit 2:

There are actually 2 plots which I am scrutinizing and thanking the comments, I have found that anything strange is going to happen.

There are two plots:

  dt = np.sqrt (a ** 3 / mu) * (alpha - beta - (sin (alpha) - sin (beta) ))   

Where alpha is 2 * np.arcsin (np.sqrt (s / (2 * a))) or 2 * np.pi - 2 * np.arcsin (np.sqrt (s / (2 * a))) and beta 2 * np.arcsin (Np.sqrt ((s - c)) / (2 * a))) or the previous negative.

 in  [13]: = r1 = 1; R2 = 1.524; DNU = 75 degrees; Mu = 38.86984154054163; In [17]: = c = sqrt [r1 ^ 2 + r2 ^ 2 - 2 * r1 * r2 * cos [dnu]] [17] = 1.5 9 76 in [18]: = s = (r1 + r2 + c ) / 2 out [18] = 2.05788 in [19]: = ALP = 2 \ [pi] - 2 * arcicin [acr [s / (2 * a)]]; Condition = -2 * ArcSin [Sqrt [(S-C) / (2 * A)]]; In [22]: = plot [Sqrt [a ^ 3 / mu] * (alp - bet - (sin [alpa] - sin [condition]), {a, 0, 2}, plotrange -> {{. 8, 2}, {0, 2}}]   

creates this:

 Enter image details here

and

  alp2 = 2 * ArcSin [Sqrt [s / (2 * A)] ]; Bet2 = 2 * ArcSin [Sqrt [(S-C) / (2 * A)]]; plot [Sqrt [a ^ 3 / mu] * (Alpa 2 - Beta 2 - (Sin [Alpa 2] - Sin [B2]), {A, 0, 2}, plotrange -> {{.8, 2}, {0, 2}}]   

Enter the image details here

Therefore, the Python code should be first from the mathematical code Account, but the second picture for the second mathamatika code and my Python code first produces the flipped image for the first methametika picture.

I think you only need to remove -dt from the Python Code:

  Import NMP as import matplotlib.pyplot plt r1 = 1 # AU Earth r2 = 1.524 # AU Tue Deltanu = 75 * np.pi / 180 # angle in radians mu = 38.86984154054163 C = Np.sqrt (r1 ** 2 + r2 ** 2 - 2 * r1 * r2 * Np.cos (deltanu) s = (r1 + r2 + c) / 2 AM = s / 2 def g (a): alpha = 2 * np.pi - 2 * np.arcsin (np.sqrt (s / (2 * a)) betag = -2 * np.arcsin (np.sqrt ( (S - C) / (2 * A)) Return (np.sqrt (a ** 3 / mu) * (Algag - Betag - (NPSI (Algag) - NP (Bitag))) def 2G (A): Alfag = 2 * NP .arcsin (np.sqrt (s / (2 * a))) betag = 2 * np.arcsin (np.sqrt ((s - c) / (2 * a))) return (np.sqrt (a ** 3 / MU) * (Alfag - Bitag - (NP. Aisin (Algag) - NP. Aisin (Bitag))) A = Anpiklinspas (I. , 2, 500000) DT = NP Linspace (0, 2, 500000) (A, G (A), color = 'R') ax [1]. Plot (A, G2 (A), color = 'fig , Akgh = PLT. subplots (Ancol = 2) AX [0]. Plot (A, G) R ') AX [0] .set_xlim ((0.9, 2)) AX [0] Kset_ylim ((0, 2) ) AX [1] .set_xlim ((0.9, 2)) AX [1] .set_ylim ((0, 2)) plt.s How ()   

yield

Enter image details here Do

No comments:

Post a Comment