TL;DR Summary: How to understand the code determining the plot
Hi; this is the code I have been given for a H-R diagram of M35; I understand the inversion concept.. The plot is below. I am trying to understand the code that creates its position and size and how to alter it to a more...
I've got some code in a public repo with a module containing my model and a python script which runs the model and returns a .parquet file with data. I've parallelized all of the important processes with Joblib, and the underlying code is written in pure C so I can't make it much faster (at...
All day I have been trying to find a method of finding the difference between two input (body of text), and get the difference but in order. I have tried breaking down the text into separate lines, then try to find the difference between both lines, but somehow this doesn't solve the problem and...
Question: How to find solutions using Newton-Raphson method with keeping the sum of solutions?
I am currently working on solving a high-dimensional equation to obtain accurate solutions using the Newton-Raphson method, which I have implemented in Python.
However, my problem requires that the...
I am trying to implement a cone search for a catalog with the HEALPix-alchemy package. I have the following models set up, based on the examples here: https://arxiv.org/pdf/2112.06947
class Field(Base):
"""
Represents a collection of FieldTiles making up the area of...
I'm currently working on reproducing a graph from the Gutzwiller-RVB theory of high-temperature superconductivity using Python. The graph plots χ_BBxy versus Δ, where Δ ranges from 16 to 26. I've implemented the theory's iterative parameter update scheme but encountered discrepancies in the...
Hello,
I want to learn about servers and deploying Python applications simply (without going to AWS, Azure, etc. but something a little more complicated than deploying my app to streamlit Cloud). I would like to get some recommendations given the multitude of options.
My goal is to create a...
Hello,
I have been focusing on iterators and generators and I understood a lot but still have some subtle questions...
An iterator, which is a Python object with both the __iter__ and the __next__ methods, saves its current state. Applying the next() method to an iterator gives us one item of...
Some python function f(x) defines an (unnormalised) pdf between x_min and x_max
and say we want to draw x randomly from this distribution
if we had the CDF F(x) and its inverse F^{-1}(x), we could take values y uniformly in [0,1], and then our random values of x would be x = F^{-1}(y).
but...
Hello,
I have been experimenting with the socket library in python creating small scripts, one called server.py and the other client.py, that can communicate with each other using a TCP protocol. The server script has an infinite loop that listens for request from the client.py script and...
If you just typed in a command into the Python repl, and it is stuck in a synchronous "waiting-for-something-to-happen", how can we terminate just that command and return to the same repl session?
For example, say we typed websocket.recv() and the websocket is waiting for a message... how can...
Say I have n parameters X1, X2, ..., Xn, and to each "grid-point" X = (X1, X2, ..., Xn) I want to associate a value f(X).
So in the end I will have a structure like an n-dimensional matrix.
Assume this data-set is going to be very large, i.e. each parameter Xi ranges over hundreds or thousands...
I'm working on a Python-based project to simulate fission energy containment. Details and GitHub link for collaboration coming soon. Looking forward to contributions.
I'm looking at a book called python crash course for beginners (eric mathes), does anyone have experience of using this book or any other book that you would recommend for learning python
if not that, is there a specific course you'd suggest that isn't in book form?
I'm completely new to...
Hey guys, I'm a first year student studying theoretical physics in England.
My physics modules include a fair bit of python programming and I want to apply to ICGs cosmology PhD in England.
Can I escape learning python by choosing maths modules?
Idea:
Given a system of two coupled oscillators in which 2 masses are connected to a spring in the middle. Each of the two masses is coupled to another spring on the left and right, which have fixed ends but are not connected to each other. So we have 3 springs, two masses and the springs also...
Hello,
anyone on Physics Forums using Docker? I have understood the overarching idea behind Docker (packaging code, dependencies, etc. into a container that can be shared across OSs) but I have some doubts:
I am confused about the base image line of code in the Dockerfile (which is simple text...
Hi everyone
I'd like to cut and paste a list of words into an array. I'll need to put quotation marks around them all. Is there a way to do this other than to go through each word one by one?
Thanks
t I'm feeling lost.
Currently, I'm trying to learn how to do web-development stuff in Python, so that I can have a project to show-off to prospective employers. I'm also aware that I may be deluding myself into thinking that one project is all it takes to get noticed. Moreover, I just lack...
I would like to analyse mdata of tmesh in MCNP6 by python, but I am struggling how to convert mdata (unformatted binary) to any text file in python.
I used GRIDCONV but it's not suitable for automations.
I also used scipy.io.Fortrunfile but could not convert the file because I was not sure...
Hello everyone.
I have four thermometers which measure the temperature in four different positions. The data is distributed as a matrix, where each column is a sensor, and each row is a measurement. All measurements are made at exactly the same times, one measurement each hour. I have...
Hello everyone,
As mentioned in past threads, jupyter notebook is a popular application that is used to code in Python (and other languages as well). The jupyter notebook installation includes 3 software components working together:
1) kernel: it interact with the web server
2) server: web...
Hello,
Simple clarification about the built-in function dir() if possible: if we don't provide any argument, i.e. we use the function simply as dir(), the function displays the namespace of the function, of the module, etc.
However, if we provide an input, the function dir() displays a list...
There's stuff on here relevant to my day-to-day, which means I may also be able to contribute. I'm primarily focused on programming in C, C++, Python and Perl. Nothing now, just introducing myself - hello all!
If there any solved papers or even python simulations to find this please share
I understood the process of thermodynamic integration but computationally I want to see how this integration of average of derivative of coupled potential energy is done
Good afternoon!
I am fumbling my way through setting up a JC model in python, I was hoping I could get some feedback on it please. I just want to make sure everything looks good and the data I am collecting is valid. Any advice or feedback would be very welcome...
My code is as follow:
import pandas as pd
from bs4 import BeautifulSoup
import requests
import os
url = 'https://www.goodschool.hk/ss'
response = requests.get(url)
html = response.content
soup = BeautifulSoup(html, 'html.parser')
school_items = soup.find_all('div', {'class'...
I recently made a Python library for modelling (very basic) finite difference problems. The Github readme goes into details of what it does and how it works, and I put together a Google Colab with some examples (diffusion, advection, water wave refraction) with interactive visuals.
I'd love to...
Hi,
I have a piece of Fortran code but I'm not Fortran literate. I'm trying to translate it into Python. I have already made it, but I need someone who can run the Fortran code to compare the values of the variables.
Homework Statement: I am trying to write a Python code to do a project about smart parking system. I want to create a Mask RCNN model to detect the vehicles in the parking slots.
My code is attached below, I got an error in the last line (creating Mask_RCNN model) and do not know how to solve...
I am trying to write a python script to plot the function,
Where
##V_0 = 5~V##
##t_0 = 10~ms##
##\tau = 5~ms##
My script that I have written to try to do this is,
Which plots,
However, the plot is meant to look like this with the horizontal line.
Can someone please give me some guidance to...
I could really use some help here, I am a transfer student so my course load is all out of order. I have a statistics course that requires me to use Python to solve this one question (the 2 parts shown below). I never took any sort of coding before, I don't know where to even start. Can anyone...
An observation I made earlier- something like
def f(...):
...
return ...
def g:
... = f(...)
was quite a bit slower than doing
def g:
f = lambda ... : ...
... = f(...)
any reasons why?
I want to fine-tune the Pixel2Style2Pixel model with my custom data set, but I keep getting an error when I'm trying to load in the pre-train weights. Here is my code :
# Load the pre-trained model
os.chdir("/content/pixel2style2pixel")
from models.psp import pSp
config = {
"lr": 0.0001...
LBM model for phase change- relevant equations found here. Also here.
#Thermal LBM
#solves 1D 1 phase phase-change
#D2Q5 Lattice
nx=100 # the number of nodes in x direction lattice direction
ny=5 # the number of nodes in y...
TL;DR Summary: How to automatically detect the parking slots using Python?
I have a Deep Machine Learning course and would like to do my course project about "Available Parking Slots Detection using Deep Machine Learning Based on Image Processing".
My plan is to split the project into two...
See this story here in a press release from MIT:
https://news.mit.edu/2023/codon-python-based-compiler-achieve-orders-magnitude-speedups-0314
Basically, any working Python module can be compiled one time only, and then run 10+ times faster than interpreted code, with no further changes to...
Hello, everyone
I am now working on this project quite a while now and I just wanted to share it with this forum, which I was a member for a long time. I am working on a python application about GR and I believe I managed to create a very user-friendly layout.
It's called GTRPy, and it allows...
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...
Okay so far I have come up with the following:
The objective function is:
30LADA + 40LAHO + 50SADA + 40SAHO + 110DANY + 125DACH + 105HONY + 115HOCH (to read this please see the table above as I have just used the first two letters of each except NY which I have represented by NY). In these I...
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 using "Introducing Python" (Lubanovic) to teach myself Python.
I read that Python strings are immutable, then I see code like this -
string1 = 'base_val'
string1= 'new_val'
not throw up an error. A little investigation shows me that the interpreter created two strings and string1 is a...
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...
Hi PF!
I've posted a bunch lately and you have been SO helpful (seriously, thank you all). Can you corroborate if my python script below matches the math? I'd seriously appreciate it!
The math: $$\max_{x\in [0.7,1)}F(x) : F(x) := \sum_{t = 250}^{750} \log\left( P_{\nu=3} \left(...
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...
Hi PF!
I typically code in MATLAB. Here, if I run the following program
%% Section 1
x = 5;
y = 2;
%% Section 2
z = x + y;
everything works. But now let's say I wanted to change line 5 to z = x - y. In MATLAB this is simple: I can simply change line 5 and rerun section 2. Is there a way to...
Hey! 😊
I have written a code in Python for a server to search for movies. At the site for the user I have added at the html template the options to change the password and to delete the account. For this do I have to write a separate html or a separate endpoint for these ones or can I write...
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...
Hey! 😊
I want to write a one-line Python generator or iterator expression that returns the sequence of integers generated by repeatedly adding the ascii values of each letter in the word “Close” to itself. The first 10 integers in this sequence are: 67, 175, 286, 401, 502, 569, 677, 788, 903...