1. Sunwoo Bae

    Comp Sci Python: printing every other input using a for loop

    I want my output to read only the integers. Here's my attempt: number = int(input()) for i in range(2, number+1, 2): print(input())
  2. T

    Python Converting List and tuples using str() function

    I am currently working my way through some w3schools python exercise on tuples and lists etc and one question was to write a program to converted a tuple to a string. Now originally I used the str() function on the tuple and printed the result. I then used the string in a for loop for a...
  3. D

    I need my 'fits' image file data to show up brighter than the background noise

    image_data = fits.getdata(alma_image, ext=0) plt.figure() plt.imshow(image_data, cmap='viridis', vmin=-4, vmax=4) plt.xlim(540,640) plt.ylim(540,640) plt.colorbar(extend='both') plt.clim(0, 1)
  4. JayZ0198

    Multipurpose software that keeps C, Python, DSP, ... in the same file

    I’ve been looking for a certain type of software that can host programming (preferably C or Python) and other process that I’m going to need such as DSP, DSP filters, diagrams (3D graphs, charts,…), and text editing within the same file. It’s mainly so that I can incorporate and use each one...
  5. R

    Example illustraing Quantum programming

    I'm interested in quantum programming. So far I've managed to use Java and Python inside Datamelt computation project for physics simulations and for various statistical plots. Now I want to make a simple code that illustates quantum computing, and maybe even to visualize its principles (for...
  6. Danny Boy

    Animation using matplotlib query

    I am trying to animate a plot of two distinct points (blue and green points) moving about the complex unit circle using Python's Matplotlib library. The problem I am having is that the animation does not remove and update the previous data points but rather sequentially smears it on the unit...
  7. starstruck_

    Python What downloads are required to work with Python?

    Hey everyone! This might be a bit of a dumb question, but I'm not familiar with much in the programming world. I know a few languages that I've learnt on my own (online) or through a course in school (MATLAB). When it comes down to coding outside of matlab or a website, I'm not sure where to...
  8. JD_PM

    Python How to plot vector fields in Matplotlib

    Hi, I want to plot the vector field ##\vec F = ye^x \hat i + (x^2 + e^x) \hat j + z^2e^z \hat k## The code I have tried: # The components of the vector field F_x = y*e**x F_y = x**2 + e**x F_z = z**2*e**z # The grid xf = np.linspace(-0.15, 2.25, 8) yf = np.linspace(-0.15, 2.25, 8) zf =...
  9. C

    Python How to estimate a GARCH model in python (without standard function)?

    Hi, I want to program an GARCH model for exchange rates. To do this, I calculated the residuals. Next, I did the following (in python) def main(): vP0 = (0.1, 0.05, 0.92) a = minimize(garch_loglike, vP0, eps, bounds = ((0.0001, None), (0.0001, None), (0.0001, None))...
  10. JD_PM

    Python How to make an animation in SymPy using Python

    I want to make an animation where a (red) ball departs from (0,0) and draws the function ##f(x) = sin x## This is what I know: How to plot ##f(x) = sin x## To do so I followed instructions from the worksheet. Actually I'd have done: But I guess they want to me to it in that way because...
  11. JD_PM

    Python How to plot a helix in Sympy

    I asked this question on SO, but I am having problems with it (I cannot even get into my account now). It seems that people using the IP I am using are asking a lot and that limits the number of questions I can ask. Please have a look at my question. Here's the link: [Moderators note: bold large...
  12. JD_PM

    Looking for a bunch of solved Sympy problems (Calculus)

    Two weeks ago I had no idea on how to code using Python. Now I have completed an online course on functions, loops and strings. However, in that course I did not practice using the specific library called Sympy. Besides, I will use Python in the Physics-Math background, for solving problems like...
  13. JD_PM

    Python Book for learning Python focusing on vector calculus (matrices, eigenvalues, eigenvectors, etc.)

    I am looking for a book for learning Python so as to compute matrices, eigenvalues, eigenvectors, divergence, curl (i.e vector calculus). If you also have online recommendations please feel free to write them.
  14. A

    Python How to use outputs from previous time steps in tensorflow?

    In the following example, there are three time series and I want to predict another time series y which is a function of the three. How can I use four inputs to predict the time series where the fourth input is the output at previous time step? import tensorflow as tf import numpy as np...
  15. A

    Python How to get output from a layer during training in Keras?

    In Keras, the method is used to train the neural network. How can I get the output from any hidden layer during training? Consider following code where neural network is trained to add two time series #multivariate data preparation #multivariate multiple input cnn example from numpy...
  16. scottdave

    Sites for some practice programming

    This is not a question, but a note, which I thought could help students. I thought I would share this here, as people may be looking for practice problems. My professor in the Python course I just finished recommended as a site to practice using programming skills...
  17. Abimbola1987

    Python How to remove attenuation

    Dear Sirs, I have a signal which has an attenuation of 20dB per decade, how do I remove this attenuation using SCIPY? Alternatively how to do it in MATLAB if there are no SCIPY users here? I'm a SCIPY/MATLAB novice fyg. Thank you for your kind assistance Abim
  18. m4r35n357

    Python More cool automatic differentiation (Hamiltonian)

    Well I think it is cool anyhow ;) Here is a dependency-free variable-order double pendulum simulation in about 120 lines of Python. Have you seen the equations of motion for this system? As usual, this is based on code that I have provided here, but trimmed for maximum impact. Can you see...
  19. N

    Python How to plot integration equation using Python?

    I have a few of integration equations and need to convert it into Python. The problem is when I tried to plot a graph according to the equation, some of the plot is not same with the original one. The first equation is the error probability of authentication in normal operation: cond equation...
  20. K

    Perform an image deconvolution using FFTs and Python

    1. Homework Statement This problem is from Mark Newman's Computational Physics, problem 7.9, found at The problem gives us a blurry convolved image, according to a Gaussian point spread function and our objective is to deconvolve it to...
  21. N

    Python Convert an equation to Python

    I have several equations and need to convert it into Python. The problem is that I tried to plot a graph according to the equation. However, the graph that I get is not the same as the original one. In the paper, the equation of error probability for MIM attack is given by: First Image Second...
  22. TachyonLord

    I The order of calculating velocity and position alters the solution?

    So I tried solving the differential equation for a spring - mass system using Euler's Algorithm in Python. The equation being d2x/dt2= -4π2x (The equation was obtained by Dimensional Analysis) here x and t are both dimensionless equivalents of position...
  23. D

    Python Python program to calculate Kirkwood−Buff Integrals

    I want to write a python program to calculate the Kirkwood−Buff Integrals. The equation is as: G=4π∫0 ∞ r 2 [g(r)-1] dr I have the g(r) values. Any suggestions are highly appreciated. Thank you.
  24. Jozefina Gramatikova

    Comp Sci Python: Simulation of the Solar System and Total energy

    1. Homework Statement I have a project to make the Solar system on Python, which I have done, but they also require from us to calculate the total energy of the system. We don't have to make the orbits of the planets elliptical, they should be circular and I believe I made them like that. Since...
  25. Jozefina Gramatikova

    Python Programming the Solar System

    I have a project to make the solar system. I am trying to start from somwhere. On the notes it says that we need to start by creating a System of Particles Two-body simulation (Circular motion) Implement Gravitational acceleration Each particle (planet) could have its own field. I.e. Each...
  26. J

    Contour plot of Earth's magnetic field in Python

    The Earth's magnetic field is cylindrically symmetric and can be described using cylindrical coordinates, (ρ,z,φ). The components of the magnetic field are given by: (B_φ) = 0 (B_ρ) = −∂A/∂z, (B_z) =(1/ρ) * ∂(ρA)/∂ρ. The vector potential for a dipole field is given by (A_φ) = (B_e)(ρ) *...
  27. NihalRi

    Python Python 3.0 , encoding="utf-8" for encryption

    I had recently upgraded my version of python from 2 to 3. I had a program that encrypted a text file by converting a character to its Unicode value, altering it and then changing it back to a character using the ord() and chr() methods. This does not seem to work with python 3 and I was...
  28. M

    Python How to drop rows when there is a length mismatch?

    I am trying to drop the series size so that it matches the size of the dataframe as I need to copy the index value of the series into the df but I am getting mismatch errors. df has a size of 100 but time has a size of 200 so I want to remove the extra rows in time to match df. how can i handle...
  29. M

    Python How to plot timeseries data in Python

    I have a dataframe that looks as attached. What I aiming to do is to plot the lines for each type where if it is for type A, I want to be able to have two lines in the graph that shows the trend for type A. I was not able to find any examples online especially with the format of the data in this...
  30. astroman707

    Python What's wrong with my if-else statements in Python 3?

    Goal: I'm trying to allow the user to input varying spellings for certain auto services, and still have my code work properly. My goal was to use the if-else statements to ensure that if the user misspelled a service, the code could correct the error by changing the variable assignment to the...