Read about python | 156 Discussions | Page 1

  1. O

    Problem in solving differential equation

    Hello everyone! I was studying chaotic systems and therefore made some computer simulations in python. I simulated the driven damped anhatmonic oscillator. The problem I am facing is with solving the differential equation for t=0s-200s. I used numpy.linspace(0,200,timesteps) for generate a time...
  2. B

    Simulate the temperature inside an aquarium tank

    there's a website to size an aquarium heater or chiller. This is just for learning purposes (not for fish) but I have modified these parameters from default to perform a load calculation on a 100 gallon glass tank... For the tank temperature range I set to be between 150-160 degree F. and a...
  3. Daniel Lima

    Python How to plot a function with multiple parameters on the same set of axes

    I attached a file with some explanations of the variables in the code and the plot that I should get. I don't know what is wrong. Any help will appreciated. from scipy.integrate import quad import numpy as np from scipy.special import gamma as gamma_function from scipy.constants import e...
  4. CrosisBH

    Computing the wave function of a square potential

    The book's procedure for the "shooting method" The point of this program is to compute a wave function and to try and home in on the ground eigenvalue energy, which i should expect pi^2 / 8 = 1.2337.... This is my program (written in python) import matplotlib.pyplot as plt import numpy as...
  5. Avatrin

    Creating noise images with Python and OpenGL

    Hi I am learning how to do a line integral convolution with OpenGL given a vector field. So, as a first step, I need to learn how to create an nxn noise image. Are there any good tutorials/books I can use to learn how to do this?
  6. Jozefina Gramatikova

    Visualising a matrix in Python

    As part of a group project, we have been asked to create a code which produces the following matrix: I want to create the graphics of this in a way that looks similar to this: But of course with different number of cells, different colours, etc. The problem is that from what I have found...
  7. S

    Comp Sci Python Assertion Error Help

    I would like to make output only read: Traceback (most recent call last): AssertionError ... without giving the File "<input>", line 1, in <module>
  8. T

    Python Error due to the arrangement of conditions with an IF statement in while loop with an AND operator

    I am currently doing a leet code problem and came across something, I have not noticed before. Here is a sample of the code I am working on. s = "10#11#12" A=[] B=[] i=0 count=0 while i < len(s): if i+2<len(s) and s[i+2]=='#': A+=[(s[i]+s[i+1]+s[i+2])] i+=3 print(i)...
  9. M

    Python Numerical modeling of a glacier's length -- Coding error(s)

    Hey Physics Forum I am currently doing my bachelor project in geophysics, with focus on the evolution of glaciers in Greenland. My project consists partly of programming, because I want to get better at it. I have, however, hit a wall. I can't seem to figure out what is wrong with my code and I...
  10. B

    Second programming language to get under the belt: python vs C

    Hello everybody, I am a master student in Theoretical Chemistry and I am working in the DFT realm. Both TDDFT and DFT applied to extended systems (eg. using QUANTUM ESPRESSO). Of course I work with these softwares from a end-user point of view, not as a developer. But anyway, even if some of...
  11. L

    Intermediary projects in Python (Biophysics)

    Hello, I am an Undergraduate student looking for ideas for a project in Python. The project should contain a library filled with modules, classes (and preferably something with inheritance), and the unittest module. I would like to do something as follows: First, some kind ob WebScraping to...
  12. antoniacarol

    Python Python Coding-While Loops

    Please help! I am trying to create a Python program for an assignment that will convert Celsius to Fahrenheit and vice versa depending on the input from the user. The numeric conversion portion of the code is working, however, if the user inputs "exit" the while loop is supposed to terminate...
  13. C

    Python How can I evaluate a Chebishev polynomial in python?

    Hello everyone. I need to construct in python a function which returns the evaluation of a Chebishev polynomial of order k evaluated in x. I have tested the function chebval form these documents, but it doesn't provide what I look for, since I have tested the third one, 4t^3-3t and import numpy...
  14. S

    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())
  15. 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...
  16. 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) plt.show()
  17. 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...
  18. 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...
  19. 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...
  20. 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...
  21. 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 =...
  22. 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))...
  23. 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...
  24. 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...
  25. 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...
  26. 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.
  27. K

    Python Visual Python Pendulum

    Hello and thanks in advance for your help. For about a week now, I've been trying to write what should be a simple python program. The idea is first to write a program for a simple harmonic pendulum, then adapt it to a spring pendulum. However, in order to do this, I have to write the simple...
  28. A

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

    In Keras, the method model.fit() 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...
  29. 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 https://projecteuler.net/ as a site to practice using programming skills...
  30. 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
Top