I have plotted the function for ##T=15## and ##\tau=T/30## below with the following code in Python:
import numpy as np
import matplotlib.pyplot as plt
def p(t,T,tau):
n=np.floor(t/T)
t=t-n*T
if t<(2*np.pi*tau):
p=np.sin(t/tau)
else:
p=0
return p...
So I am trying to do this tutorials but I want to use my own dataset. I am having problems "Build an input pipeline with tf.data."
My question is about their code:
def load_image_train(image_file):
input_image, real_image = load(image_file)
input_image, real_image =...
I am trying to replicate the space time plot (the 2nd plot with Proper distance vs Time) as in this thread: space-time
I wrote everything in python using the astropy cosmology package.
Everything went smooth, but I am stuck at plotting the light path on the 'purple path', as per the above...
I've been trying to find a way to calculate Gaussian curvature from a 4D metric tensor. I found a program that does this in Mathematica using the Brioschi formula. However, this only seems to work for a 2D metric or formula (I would need to use something with more dimensions). I've found...
Hey'all. First of all, I'm not fluent in English, so forgive me for the spelling mistakes. So, I'm trying to make a simulation of a solar system using python 3.9. It's not complicated, but my teacher wants me to do it using the Basic Verlet method, and that's what is bugging me. He told me do do...
I am attempting this homework exercise part b).
I've modified my code but I get error overflow message. My goal is to modify my code so it returns kinetic and potential energy of Earth's orbit.
I made a new f(z,t) and modified the rows 99 and 100 with dz[2]=-G*M*m/r, and dz[3]=0.5*m*y**2 but...
I am attempting this homework exercise but my plot does not show the whole trajectory. I don't know if it is something wrong with my equations or if it is a plotting matter.
Cheers!
This is my code:
import matplotlib.pyplot as plt
import numpy as np
import scipy.integrate as spi
G =...
Let's say that my_mock.method_calls gives me this array:
[call.thing.pop(3, 4), call.thing.bob.smash(6, 7), call.thing.jig.slurp(4)]
How can I extract the names 'thing', 'pop', 'bob', 'smash' etc. from this array?
I am trying setting up flask email for outlook. I had it working with gmail I found this link https://superuser.com/questions/1521236/how-to-allow-less-secure-app-access-in-microsoft-email I tried
MAIL_SERVER= 'smtp.office365.com'
MAIL_PORT = 587
MAIL_USE_TLS = True...
Hi,
Question:
Why is the error 'Error parsing inputs' in CVXPy occurring?
Context:
I am trying to solve a semidefinite program in CVXPy (using Google Colab). I went to the documentation (HERE) and I copied the example code into a cell. It doesn't work for some reason and I don't understand...
I am absolutely new to Polymer simulation. I am trying to understand the simulation by analyzing source code written by others.
Can anyone tell me what are the differences between the following three source code in terms of their objectives?
Monte-Carlo-simulation-of-polymers...
I wanted to declare a local variable inside a static method main().
My code looks like this -
class Operator
{
static int a;
public static void input() {
Scanner in=new Scanner(System.in);
System.out.println("Enter the number:");
a=in.nextInt(); //this is...
https://blog.miguelgrinberg.com/post/how-to-add-flask-migrate-to-an-existing-project
I am using Visual Studio Code and have a database file already created called test.db. My environment variables for test.db name is SQLALCHEMY_DATABASE_URI and the value is sqlite:///test.db In the actual code...
Images comparison
What are the best softwares available for comparing two images having similarity and differences?
Two photos each of Margaret and Enid.
1 Margaret's first photo with her second photo comparison.
2 Enid's first photo with her second photo comparision.
3 Margaret's first...
Hi everyone,
I have to classify a DNA sequence with a LSTM neural network but I have a problem with the inputs shame. Both the sequence and the class are encoded with One Hot Encoding and my code is this:
import pandas as pd
import numpy as np
data = pd.read_csv('splice.data', header = None)...
Hi everyone,
Hopefully I'm writing this in the correct part of PhysicsForum.
Here is my problem:
I'm really struggling with my programming class (basics of python3 - loops, dictionaries, numpy).
What I did this semester:
1. Participated in every class
2. Solved everything our course offered...
Here's what I've done:
Mentor note: replaced icode tags with code=python and \code pair.
def valid_braces_placement(s, L):
if len(L)==0:
return False
string = ''
for element in L:
string = string + str(element)
D = ['+','-','*']
return...
I have been using Visual Studio Code for a couple months now and it has been fine. When I want to run some code, there is usually a little green triangle button in the top right corner that I can click on. A few days ago, that triangle turned white only for Python files (it is still green for...
I need to calculate H-bonds in a specific direction of a C-alpha atom of a protein. And, I need to calculate that from a PDB file.
Can anyone give me a general guideline/direction/idea regarding how to do that?
N.B. I need to write a python program.
Hello, I am learning trying to set up a code that searches for a certain pattern in the text by implementing Rabin-Karp Algorithm.
When setting up the Rabin Karp hash function, I have been told that I should set a value q in order to lower the time complexity of the function, and that q should...
I'm a physics major (Junior) who would like to learn a programming language. Many suggest Python as a good starting language, so let's suppose that is the language I want to first learn. This isn't for employability or general usefulness; rather, I'm just curious.
How exactly does one go about...
I've tried to make an animation using python to demonstrate the 1-D simple harmonic oscillator and step potential examples. Hope that it can be useful for some of you. Have fun~ :)
https://blog.gwlab.page/solving-1-d-schrodinger-equation-in-python-dcb3518ce454
By the way, If you are...
Hello everyone !
I am working on ultrasound scan and the processing of the signal received by the probe. I made the model I wanted and as I do not have an ultrasound scan machine I want to simulate the signal processing.
I will do that with the Python package Scipy and the function...
The Coupled ODE Model
Below are my coupled differential equations, where the only variable I try to meddle with is the ITMblood. The motivation here is if I try to increase ITMblood (in the next section I will show how I do it), at some concentration of ITMblood (most likely a very huge one) ...
I have to perform a calculation on my data. Here is an example of data from just one time step (data from other time steps would appear as additional rows).
X
Y
Z
Total
2
2
1
3
Total = SQRT(X2 + Y2 + Z2).
The calculation I have to do is: (N • N), where "N" is an average.
I tried...
Check this link: How to override the copy/deep-copy operations for a Python object?
Can anyone explain, in layman's terms, what is going on in this source code?
from copy import copy, deepcopy
class MyClass(object):
def __init__(self):
print('init')
self.v = 10...
Hi,
I'm new to programming in python [total beginner in programming] and I would like to ask you for your help.
Here is what I got so far:
import numpy as np
import random
from math import sqrt
p = np.array([(0, 0), (1, 0), (1, (1/sqrt(2)))], dtype=float)
t = np.array((0, 0)...
In a self learning project I am fooling around book https://faculty.washington.edu/rjl/fdmbook/
I want to do some of the computation myself to better understand the concepts but the book is Matlab based and Matlab is too expensive.
Does anyone by any chance have some of the codes provided by...
I'm given this code to plot the system for task 1 where my teacher have used some random numbers just to show us how the code can be used:
The code makes a plot that is given below:
So my professor just gave us this code and plot without saying anything more. All the students in the class...
Hallo at all!
I'm learning statistic in python and I have a problem to show you.
I have this parametric function:
$$P(S|t, \gamma, \beta)=\langle s(t) \rangle
\left( \frac{\gamma-\beta}{\gamma\langle
s(t) \rangle -\beta}\right)^2\left( 1- \frac{\gamma-\beta}{\gamma\langle
s(t) \rangle...
How to run a numerical simulation of Laplace equation if one of the boundary condition is like this: $$V(x,y) = 0 \text{ when } x \to \infty$$
I am trying to use Python to plot the solution of this Example 3.5. in Griffins EM
Hello
I am struggeling with a problem, or perhaps more with understanding the problem.
I have to simulate a one dimensional percolation in Python and that part I can do. The issue is understanding the next line of the problem, which I will post here:
"For the largest cluster size S, use finite...
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...
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...
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...
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...
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?
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...
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)...
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...
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...
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...
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...
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...
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...
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...