Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
2 votes
2 answers
234 views

Infinite 2d block world (2d minecraft) with chunk system, physics and slower loading

Follow up from this question. I have added a slower loading system that allows the main game to run faster but I still get under 30 fps with caves even if I allow the player to outrun the loading. I ...
coder's user avatar
  • 121
3 votes
5 answers
2k views

How do I speed up this simulation program

This is a program to solve a differential equation numerically using Euler method. As of now, it is very slow, and I need to run 10000 Monte Carlo simulations. The differential equation is called ...
Jonathan Wick's user avatar
2 votes
1 answer
90 views

"Flattening" a 2D STM image by subtracting an Nth order polynomial without typing out all the terms for each N?

I have some scanning tunneling microscopy (STM) topography images that I need to flatten. I have found that for some data I need a 4th order polynomial, but in other cases a lower order works better. ...
uhoh's user avatar
  • 473
5 votes
2 answers
523 views

Partial pivoting code in python

...
JustAnotherMind's user avatar
3 votes
1 answer
99 views

3ph 2l inverter simulation with SPWM

Here is a code for a simple model of three phase two level inverter with constant DC voltage source and three phase RL load. ...
ppinha's user avatar
  • 51
4 votes
2 answers
173 views

NumPy script to convert BGR to HSL and back

This is a NumPy script that converts BGR arrays to HSL arrays and back, without using OpenCV. Input and output values are arrays of 3 dimensions with values ranging from 0 to 1, the shape of the ...
Ξένη Γήινος's user avatar
3 votes
3 answers
137 views

Calculate length of continuous gaps

I have a list with some nan values, out of which some are continuous, e.g.: list = [1, 2, 3, np.nan, np.nan, 6, 7, np.nan, 9, np.nan,np.nan,np.nan, 12] For some ...
Ranjan Kumar Sahu's user avatar
3 votes
0 answers
146 views

Image generator using prime numbers in polar coordinates

Related This is a Python script that generates images using prime numbers up to a given positive integer, it generates prime numbers using the Sieve of Eratosthenes with some rudimentary Wheel ...
Ξένη Γήινος's user avatar
2 votes
0 answers
90 views

Python script that generates images using Thue-Morse sequence

In mathematics, the Thue–Morse sequence, or Prouhet–Thue–Morse sequence, is the binary sequence (an infinite sequence of 0s and 1s) obtained by starting with 0 and successively appending the Boolean ...
Ξένη Γήινος's user avatar
3 votes
1 answer
162 views

Solve an option pricing PDE in Python - Part 1 [closed]

The Github repository NM-Heston solves call option prices under the Heston 2-factor model using ADI splitting schemes. I am adapting the code to price options under the 3-factor Heston-Hull-White ...
Ruan's user avatar
  • 101
1 vote
1 answer
140 views

Further optimizing the ISING model

I've implemented the 2D ISING model in Python, using NumPy and Numba's JIT: ...
Amirhossein Rezaei's user avatar
2 votes
1 answer
97 views

Optimize python computation of transition matrix

I have an array of integers labels, for instance array([0, 1, 1, 2, 2, 2, 3, 3, 1, 4, 4, 1, 1, 0, 0, -1, -1]). The array can be ...
Mathieu's user avatar
  • 231
9 votes
1 answer
4k views

Python decibel meter-accurate?

...
ijknm's user avatar
  • 99
3 votes
1 answer
127 views

Create a forecast matrix from time series samples

I would like to create a matrix of delay from a time series. For example, given y = [y_0, y_1, y_2, ..., y_N] and W = 5 I need to create this matrix: ...
graille's user avatar
  • 133
1 vote
0 answers
46 views

BoundingBox dataclass implementation with cupy, cudf, and nvector

The dataset I'm working with is rather large so I've been experimenting with cudf and cupy. Here you can find instructions for ...
Jason Leaver's user avatar
3 votes
1 answer
51 views

Simulate a population of agents and compute averaged cumulative efficiency

I have the following code which is a model where each agent makes decisions and accumulates efficiency over time. With the def scenario function, the idea is to ...
pyring's user avatar
  • 163
2 votes
0 answers
226 views

Do Mann-Kendall and Pettitt tests on each CSV file

Here is a function that will take each text file in a directory, do the Mann-Kendall and Pettitt tests, and then write the output to a text file. Would you please suggest me improve the code to make ...
Geoge Cittal's user avatar
1 vote
0 answers
306 views

A collection of Python functions that fill a given region with rectangles

These are what I was working on in the last few days, I wrote a bunch of functions that fill a given region with rectangles of different colors. The functions can: Randomly split a region into sub ...
Ξένη Γήινος's user avatar
2 votes
1 answer
994 views

Python function that shears image by n degrees while keeping the relationship between height and width

I am trying to find a method to shear/skew an image horizontally or vertically by n degrees (n ranges from -90 to 90 excluding the terminals) so that the result would meet the following conditions: ...
Ξένη Γήινος's user avatar
0 votes
0 answers
102 views

Python 3 OpenCV script that scans a giant picture to make a video

This is a Python script that I wrote completely by myself. Basically it scans a giant picture to make a video. They say one picture is worth more than a thousand words. Since a video contains ...
Ξένη Γήινος's user avatar
0 votes
1 answer
70 views

Stacking Z axis on multiple [1440x720] DataFrames (X, Y)

Each datum represents a point in a 1440x720 image of the globe, The values are 0-9. Each new layer is of a higher elevation. I need to structure a DataFrame in a ...
Jason Leaver's user avatar
6 votes
1 answer
2k views

Python 3 script to make photo collages

I have written a Python script that takes a list of filenames of pictures and generates a photo collage of them. This is my most complex project yet, and I have written it completely by myself (like I ...
Ξένη Γήινος's user avatar
2 votes
1 answer
75 views

dataframe mean outliers to NaN to derive a higher quality mean for area,speed,azimuth

I have some data that represents the area, speed(meters per second), and azimuth(rads) of a polygon. The objective is to determine the mean for each set of parameters. With that mean value, apply a ...
Jason Leaver's user avatar
1 vote
1 answer
68 views

numpy mean azimuth with functools.reduce

From the left to the right column calculating the mean azimuth, and using that mean value to calculate the subsequent columns mean value data (azimuth radians) ...
Jason Leaver's user avatar
3 votes
1 answer
228 views

pandas dataframe of temps and numpy.linalg.lstsq

The problem is this. Forecast model data indicates at 0700Z the 1000 milibar temps will be -4C°. The forecaster knows that is incorrect, so they choose to make a correction. This correction should ...
Jason Leaver's user avatar
3 votes
1 answer
683 views

Vincenty's distance Direct formulae numpy

I've refactored a function from the pygc library used to generate the great_circle. The Vincenty's equation below can be found ...
Jason Leaver's user avatar
4 votes
1 answer
125 views

pandas conditions across rows and columns

Is there a better way to accomplish this? The function determines the Category for each row based on some conditions. Another set of conditions determines the <...
Jason Leaver's user avatar
1 vote
0 answers
49 views

Pandas Numpy Nvector to generate a storm track algorithm

I made previous post here, relating to this topic. The class uses now uses some additional 3rd party libs nvector & pygc. ...
Jason Leaver's user avatar
1 vote
1 answer
126 views

Multiple GeoJSON Feature Collections to a Pandas MultiIndex DataFrame

Edit: The end objective is to monitor the movement of severe weather, determine its vector and make a prediction. I'm working with a GeoJSON ...
Jason Leaver's user avatar
1 vote
1 answer
1k views

Calculate a time weighted average of a feature

I'm trying to calculate a time weighted average of a feature (feat) based on previous rows by date for a given ...
Jossy's user avatar
  • 153
1 vote
1 answer
747 views

Calculating all combinations from arrays AND (arrays OR floats)

Context: My question comes from needing to iterate different np.arange arrays. The main motivation is to calculate all the possible combinations between the arrays, ...
nuwe's user avatar
  • 163
4 votes
1 answer
685 views

Function to calculate the GC content variation in a sequence

I came across this BMC Genomics paper: Analysis of intra-genomic GC content homogeneity within prokaryotes And I implemented some Python functions to make this available as part of a personal project. ...
Paulo Sergio Schlogl's user avatar
3 votes
1 answer
746 views

Implementing histogram in python

I was trying to implement my own version of matplotlib's hist function and I came up with this: ...
Amirhossein Rezaei's user avatar
2 votes
1 answer
135 views

Using arrays more effectively with numpy

I previously posted some code I've been working on and had a fantastic answer, but as I didn't post the full code I was then unable to bring it all together using the much faster numpy implementation, ...
Zbee's user avatar
  • 75
2 votes
1 answer
185 views

Calculating a function over a large array

I have written some code to determine an interpolation matrix over a grid of points. I originally wrote the code in matlab, where under the specified parameters it took just over 2 minutes. The ...
Zbee's user avatar
  • 75
0 votes
1 answer
2k views

line-circle intersection [closed]

I have this code that generates a random line and a random circle. ...
Paulo's user avatar
  • 109
2 votes
2 answers
1k views

Applying Minimum Image Convention in Python

I am computing pairwise Euclidean distances for 3-D vectors representing particle positions in a periodic system. The minimum image convention is applied for each periodic boundary such that a ...
Daniel's user avatar
  • 21
8 votes
1 answer
1k views

Genetic algorithm to guess coefficient of a polynomial

I have tried to code a genetic algorithm to guess the coefficients of a degree 4 polynomial. The information initially provided is values of y = f(x) for different x using the original polynomial. I ...
Roni Saiba's user avatar
4 votes
1 answer
105 views

Dataframe transformation to numpy ndarray takes ages to complete

I would like to transform my dataframe into an array of fixed-sized chunks from each unique segment. Specifically, I would like to transform the ...
super_ask's user avatar
  • 143
3 votes
1 answer
827 views

Using Numba works slower than not using it for my Python code

I thought this community is better place to ask my question so I ask here rather than at StackOverflow. Recently, I learned that Numba can make Python function ...
Senna's user avatar
  • 41
1 vote
1 answer
71 views

Python utility to clean noise from flat text files

I have created simple code in which it takes flat file (txt) and eliminate the noise and error and only return clean rows, i.e. return flat file with the data I am interested in. it works fine but ...
Sam.H's user avatar
  • 143
2 votes
1 answer
37 views

Reducing running time of creating integration field in flow field algorithm (python)

The integration field needs to get recalculated every time the starting or goal coordinates change. I wanted to use the flow field algorithm for a problem that includes bigger mazes with changing ...
LisaD's user avatar
  • 31
5 votes
3 answers
265 views

Optimizing an implementation of the RKF method

This is an algorithm regarding the RKF method: ...
Amirhossein Rezaei's user avatar
3 votes
1 answer
73 views

Generating multiple new arrays using numpy

Say I have the following two different states: state1 = [0, 1, 0, 1, 1] state2 = [1, 1, 0, 0, 1] And I want to generate n number of new states by only changing the ...
Omar AlSuwaidi's user avatar
4 votes
1 answer
65 views

Fuzzy clustering index functions

I reimplemented the functions RI.F (Fuzzy Rand index), ARI.F (Fuzzy adjusted Rand index) and JACCARD.F (Fuzzy Jaccard index) of the R package fclust in Python. However, it seems - even though I use ...
Make42's user avatar
  • 191
2 votes
2 answers
111 views

Downloading COVID data and uploading graphs

So this is a project I have been working on for the last few weeks. Just started learning Python. Started out with bash scripting and got the itch to learn more. Anyway code fetches covid-19 data from ...
drebrb's user avatar
  • 137
5 votes
1 answer
202 views

compare between two labels /objects -dominance rules

I have a function dominates() that seems to be the bottleneck of my algorithm (after profiling it). the function is as follows: ...
sos's user avatar
  • 151
2 votes
1 answer
52 views

Hardware driven data processing and ploting in need of better control flow

This is code for a measurement setup that receives a steady stream of UDP data, finds the trigger in one channel and operates on the data in the other channel to enhance the signal and remove noise, ...
Andreas Schuldei's user avatar
2 votes
1 answer
68 views

Resource reservation system

I'm using a function to determine if resources can be used again or not. This is the numpy array I'm using. ...
Mounir Hafsa's user avatar
3 votes
2 answers
95 views

SineCosine Wave

As a beginner this is my first code. Any comments? ...
Arpit's user avatar
  • 131