Hi,
My aim is to get a series of images in 2D space that run over different timestamps and put them through a 3D Fourier Transform. So my 3D FT has 2 spatial axes and one temporal axis. However I have never done anything like this before, and I have a very basic knowledge of Python.
So...
I'm reading the online tutorial "How to Think Like a Computer Scientist", which is a Python tutorial. There is an exercise, which I'm trying to figure out.
What happens if you call a function and you don't do anything with the result (i.e., you don't assign it to a variable or use it as part of...
Hey,
This might sound like something that I should have posted to the "computing & technology" forums, but I disagree.
I know that beginners should probably start with Python 3 instead of python 2, as "python 2 is legacy and python 3 is the future".
I already bought a book on python 2...
I want to write program in python that gives "redshift", range of "M" and range of "dn/dM" as input and plots "Press-Schechter" function and delivers a graph as output. would you please give some hints? I'm beginner in programming and I don't know how to start.
Hello. I am creating a text-based video game using python, and I was wondering how I could put pictures from my Mac into the game. I am using JGrasp if it helps to know.
Hello,
I would like to self learn python for my physics degree, but I don't really have an idea where to start. Could anyone recommend a good book out there for beginners (zero experience with programming)?
I don't want anything too comprehensive; that's for comp sci majors. I'm really...
I'm starting this web scraper, and all I'm trying to do so far is to just retrieve the source code from the sites.
Code:
import urllib.request
from urllib.request import urlopen
urls = ["http://google.com", "http://nytimes.com", "http://www.rockpapershotgun.com/"]
i = 0
while i...
I'm taking linear algebra through edx just to get my eyes on the subject. Some of the work in the class requires you to to vector operations on Python. Is it going to be useful for me to learn this stuff for engineering? Or should i just focus on the linear algebra.
Thanks
Homework Statement
The problem shows as follows:
An arithmetic progression is a sequence of numbers in which the distance (or difference) between any two successive numbers if the same. This in the sequence 1, 3, 5, 7, ... , the distance is 2 while in the sequence 6, 12, 18, 24, ... , the...
Python (numpy) question:
I have two 2D numpy arrays, A[i,j] and B[k,l], but the indexes are unrelated to each other (A and B won't even have the same dimensions in general). I want to be able to add/multiply these two together to get a 4D matrix: C[i,j,k,l] = A[i,j] + B[k,l] or C[i,j,k,l] =...
Homework Statement
Lets say we have two strings 'movies' and ' goto'. Now the question indicates to return this combination concatenated n times, except if n is negative, it is the same as if it were 0.
The Attempt at a Solution
Concatenation n times would yield: n*"movies goto"...
I have the following system of 3 nonlinear equations that I need to solve in python:
7 = -10zt + 4yzt - 5yt + 4tz^2
3 = 2yzt + 5yt
1 = - 10t + 2yt + 4zt
Therefore I need to solve for y,z, and t.
Attempt to solve the problem:
def equations(p):
y,z,t = p
f1 = -10*z*t + 4*y*z*t - 5*y*t...
Homework Statement
I'm supposed to solve the spring pendulum numerically on python 2.7, using odeint. The system is supposed to solved for the y -direction and the x-direction in terms of time. In class we did this for pendulum DE, but that only had x as the dependent variable, this system has...
background information is that I have been working on code for a rocket launch to the ISS and I have gotten it close. The problem is when calculating the Force of drag, the problem occurs with it. As entering space, and for this "model" were going to say that temperature is 0 K in space or...
Does anyone have a good tutorial or start-up advice for building a database in Python? The only database software I've ever used is Microsoft Access, but I've heard it's possible to build databases in Python.
I was thinking I'd start off with a simple database: a few tables that can draw...
I am fiddling with python v2.7.5,i am using Pyscripter version 2.5.3.0 x86 to write my program and i do not know how to deal with this problem when i run my program:
PROBLEM:
___________________________________________
IOError:[Errno 2] No such file or directory:'words.txt' |...
I don't know python, yet I am trying to code something, just for fun. But I have hit some strange obstacle and I don't know if it is a bug in my Python version (dated, it is over a year old, under Raspbian), or is it me misunderstanding something?
pattern = re.compile('\[(\d+)\]\[(\d+)\](.*)')...
I have recently learned Python programming as a self study and am proficient in using the syntax. I can currently make calculators and other operational tools in Python, but I can't use Python to actually manipulate a computer; there is ample instruction in basic programming on-line but not much...
I am trying to find all combinations of a four element vector that contains only 1's and -1's.
Ex (1,1,1,1),(-1,1,1,1),...(-1,-1,-1,-1) etc
My idea to do this is pretty inefficient I am sure but I can't think of another way to do it, so here is what I was trying to do.
I found how many total...
How do if you have a .csv file with 3 columns (independent, dependent, uncertainty in dependent variable), how do you make a graph so that the independent variable is the x-axis and the dependent is the y axis?
All I've done is
pylab.plot(data,"ko")
pylab.show()
The graph I get seems to...
I hope I'm in the right section.
This part is not important but this is thought behind the program.
If you have n-mathematicians and each has a secret number. How many phone calls have to be made for all mathematicians to know all numbers? In this brute force approach I, hypothesize that you...
Hi,
I am working on a device simulation algorithm, and am implementing it in Python on my laptop that runs Arch Linux. A particular step requires me to perform a computation of the form
\tilde{G} = G \Sigma_{c}^{in} G^{\dagger}
where G and \Sigma_{c}^{in} are both N \times N matrices, and...
Homework Statement
Hello. I want to write a program which finds the largest number in the sequence typed in by the user. However, when I type in a number it not only gets printed as the input value but gets re-printed as if I have done the print function of that number (though the final answer...
I feel very stupid right now. Should be an easy question, but I googled it to no avail.
Basically, I have an class.object in my code which should be managed by a class.function
For example, I want the following code:
class Z:
a=0
def mod(self):
self.a=self.a+1...
I am using python to get tuples from a db.
I am doing
cur.execute("Select Statement");
I use cur.fetchall to get the tuples.
My question is how do you iterate over the returned tuples and store the columns into an array? I want to iterate over n tuples, not all the returned results...
I'd like to try to pick up Python over the summer, while I have the free time. I do have some programming experience, and I've heard it's not too difficult to pick up. I've found some things here and there, but if anybody has any strong recommendations of a particular resource (pdf document...
If this is better served in a section like Nuclear Engineering please let me know.
Homework Statement
Simulate the projection of a radiation source onto the plane of a collimated detector. Check if said projection is circular.
The attempt at a solution
What I want to do is...
My code isn't working, and the reason seems to be because nested for loops in python don't work according to my expectations. If I have some code like this:
f1 = open('name_of_file1.txt', 'r')
f2 = open('name_of_file2.txt', 'r')
for line1 in f1:
#stuff at this level should happen...
I'm writing a function to take a string like "aXYb" and return a regex in which the lower case letters act like actual character and the upper case become free variables.
The regex generated from "aXYb" should match anything of the form a([a-z]+)([a-z]+)b. It does. But not exactly as "freely"...
I'm trying to understand a function which draws a koch curve using a library which draws (lt = left turn, fd = move forward, t represents an object class).
def koch(t, n):
if n<3:
fd(t, n)
return
m = n/3.0
koch(t, m)
lt(t, 60)
koch(t, m)
rt(t, 120)...
Hi I built this code that runs well. Is about calculating a student loan... The problem is that I wish I could create a table that will tell me in each column "payment number", "remaining balance", "interest amount", "principal amount" Can you help me do this? I am new to python and this is not...
I am creating a program in Python 3.3 that converts miles to feet, my code is as follows:
def Miles2Feet():
Miles = input('Enter distance in miles: ');
Feet = 5280 * Miles;
print (Miles, 'Miles =', Feet, 'Feet');
When I run this using 1 as an input number of miles, it does not...
I've decided to learn Python (having a background in C++ and Matlab), and I'm a little unsure about which version to get. I've read in a few places that Python 2.x is better because packages like numpy and scipy don't work with Python 3.x, but this seems to be out of date since as far as I can...
Homework Statement
To modify a future value program so that a user inputs the data w/ a GUI
Homework Equations
principal = principal * (1+apr)
The Attempt at a Solution
Anyone familiar w/ python coding? I'm a beginner. I'm absolutely stuck on this problem, I seem to have...
I'm playing around in Python at the moment, and I came across an exercise to perform bitwise operations manually (without the built in & | ^ ~ operators).
I understand the operations on paper, and I have a function here that performs them (& in this case, the others are similar):
def...
Hey everyone I am looking to learn the Sage software as an alternative to MATLAB. I would like to leaern Python as well. I have a bit of a limited programming experience (A in a Programming Principles course last semester which used Java). So I know loops, stacks, methods, class variables...
Hello :smile:
As strange thing is happening. I have created a simple file using emacs (on a Mac) that contains the following:
def main():
print "hello!"
if __name__ == "__main__":
main()
And I have saved it in the working directory as hello.py
In a terminal...
I'm trying to convert my __init__ to __new__, but I can't find any docs on how the syntax differs or anything really, that pertains to how this bug could be caused by it. What am I doing wrong here?
import copy;
class grid(list):
def __new__(self, size):
self.size = size...
I'm not looking for the answer, I just want some help with understanding the question. The main thing I'm stuck on is the characteristic binding energy and the characteristic molecular size. I've tried searching for these but I'm finding a lot of different stuff.
Homework Statement
All to...
Hello everyone
I have been supplied with this eqn
n=\frac{Nat}{16r^2}(\frac{2Ze^2}{4\pi\epsilon_0E_K})^2cosec^4(\frac{\phi}{2})
for Rutherford scattering.
N is the number of alpha particles incident on a unit area of foil
t is the thickness of the foil
a is the number of atoms...
I was wondering if anyone could by any chance give me some help. I used Euler's method and the program runs, however, it doesn't give the correct solution. I honestly have no idea what's happening in the program, the problem has to be in the way I implemented Euler's Method. But I can't seem to...
Any python/matplotlib experts out there?? This one has been driving me crazy all day. I have three vectors, azimuth, frequency and power, which I would like to histogram and plot on a polar axis. I can plot a scatter plot this way no problem but the histogram gets messed up somehow. An example...
Hi all, I'm not quite sure if this is the right place to post my question, so forgive me if its not...
I've written a program in Python that analyses data that I got from a compression experiment (mechanical testing of rocks and such), and I've written a piece of code that estimates the...
Homework Statement
I have this problem essentially figured out. There's just one tiny problem that I can't seem to solve. I'm supposed to write a function bfs(G, v) which takes a graph G stored as a dictionary, and a starting vertex v. The function bfs performs a breadth-first-search...
Hi there!
I'm currently having great fun using numpy/scipy in python for astronomical data analysis. (I've been using C for this before, but it takes too much time to implement simple things that are in numpy/scipy already)
Recently I've been told that most of people are using C or Fortran...
I'm trying to write a python program that is able to numerically execute functions of the form:
y(t) = exp(Integrate[A(x),x]) within the bounds of 0 and t
I tried using quad from scipy.integrate but it seems not to be able to evaluate expressions of this form.
Any other suggestions on...
So I am writing a program in python to do RK4 for the two body problem. I want it to display a sphere moving around another. It currently displays one sphere for a split second and then it goes blank. Any suggestions?
from __future__ import division
from visual import *
from visual.graph import...