Category "numpy"

How to plot a streamplot in python for a streamline flow arround a cylinder?

I have written a program where it takes a radius range(R to 5) and theta range(0 to 2pi). It converts the polar coordinates to Cartesian coordinates. Then I hav

How do I check which rows of one small array exists in another larger one?

How do I check which rows of one small array exists in another larger one? Given the following setup: final_batch = np.emtpy((batch_size,2)) batch_size = 4 a =

selecting an xarray dataset by coordinates instead of dimensions (or switching coordinates to dimensions)

I have a, xarray dataset that is ocean color of the Atlantic Ocean called olci_ds. This dataset has dimensions of rows and columns and coordinates of lat, lon a

No BLAS/LAPACK libraries found when installing SciPy on macOS

I am using python 3.9.8 and pycharm on a macbook m1. I have already installed openblas with homebrew but I still get the error below. I tried installing SciPy v

How to calculate average pixel intensity inside a laser line in Python?

I am trying to write a code that calculates the speckle contrast of a laser line. Here is an example of an image that I would be analyzing: The image is black w

Python 3 RuntimeWarning: overflow encountered in double-scalars - trying to fit multiple gaussians and an offset using scipy.optimise.curve_fit

Hi all as with many peeps, I am new to python. Updated script that runs to completion but has a OptimizeWarning: Covariance of the parameters could not be estim

How to optimise reading multiple files containing bytes into a NumPy array

I currently have ~1000 files containing bytes. Each file contains a few thousand messages, each message has identical data types. I've tried several ways of rea

Is there unstack in NumPy?

There is np.stack in NumPy, but is there an opposite np.unstack same as tf.unstack?

How can I use scipy interp1d with N-D array for x without for loop

How can I use scipy.interpolate.interp1d when my x array is an N-D array, instead of a 1-D array, without using a loop? The function f from interp1d then needs

Render NumPy array in FastAPI

I have found return numpy array as image from fastapi but I am still struggling to show my image which just appears as a white square. I read an array into io.B

Getting error while generating heatmap in python:ValueError: Must pass 2-d input. shape=()

I am getting errors while generating maps of h3 moments in python for an image file called "image_test". The error apparently is for the shape of the values tha

Signal correlation shift and lag correct only if arrays subtracted by mean

If I have two arrays that are identical except for a shift: import numpy as np from scipy import signal x = [4,4,4,4,6,8,10,8,6,4,4,4,4,4,4,4,4,4,4,4,4,4,4] y =

How to create a new columns based off of values of other columns which could contain #s or NaN?

I have a few dataframes that I'm merging based on known, populated fields. The resulting dataframe will always contain a set of columns, but may or may not have

Creating multiple figures out of for loop

I am trying to loop through my table and to create 3 different figures. This is my code .... tab_stat = pd.read_table('test.txt', delim_whitespace=True) radius

ValueError: num must be 1 <= num <= 5, not 0 error

I am stuck with this code written in py2 on psychopy. I am not an expert with coding. I am trying to run the function "analyzeStaircases(stairs, stairInfo['Aver

What is a rank 1 array in Numpy

Consider the following vector: import numpy as np u = np.random.randn(5) print(u) [-0.30153275 -1.48236907 -1.09808763 -0.10543421 -1.49627068] When we print

If no conditions are met, how do I raise a value error with np.select?

Working with human labeled data, I have four cases that cover correct behavior, but it is possible for annotators to miss the need to provide a value. When this

C-API register a ufunc loop against builtin ufunc

I am looking to build a numpy extension module which declares a new structured dtype and provides the necessary inner ufunc loops to allow built-in math operati

Finding the shortest path to solve colored water sorting games

So my aunt plays this now popular mobile game, shown in the picture below. She got stuck on a certain level and asked me if I can solve it. Knowing that I'm not

prevent numpy stack method change INT data to float

I try to stack three one dimension array. a and b are int that can be work as index and c is float. After I stack this three with axis=0, the a and b data chang