# Questions tagged [python]

A general purpose high-level programming language that emphasizes ease of code syntax and readability.

801 questions
Filter by
Sorted by
Tagged with
1 vote
58 views

### How can I reduce the artifact in "Thin Plate Spline" interpolation?

At the Top "right", there is the 2D-density plot of the recorded data (actual), fewer in number. Recorded data has been sampled a on the 8 arms of a regular octagon. These 8 arms are placed ...
6k views

I am self teaching myself python and computational physics via Mark Newmans book Computational Physics the exercise is 2.9 of Computational Physics I have to compute the Madelung constant. . I have ...
26 views

### Complex interpolation for isotopic (precipitation) data

Is there a package that interpolates precipitation data taking into account mountains and oceans? I have so far used Numpy and Basemap but as you can see in the code, the data from Europe affect the ...
47 views

### Fitting gauss-hermite-parametrization to data?

I want to fit this data. I have the following model functions. Classic gaussian: def gauss_model(x, mu, sigma): return np.exp(-0.5*((x-mu)/sigma)**2) And ...
40 views

### Setting up boundary conditions to solve PDEs using method of lines

Objective: To add boundary/initial conditions (BCs/ICs) to a system of ODEs I have used the method of lines to convert a system of PDEs into a system of ODEs. The ODEs themselves involve a lot of ...
97 views

### How to ensure the numeric value is always positive in Optimization Python?

I am currently performing optimization onto a quadratic function by manually coding the algorithm: $$\min f = x^T v x - r^T x\\ \text{subject to } x \geq 0\, .$$ Here, optimizing the function without ...
98 views

### How to improve the efficiency of periodicity detection for long time based lined and gapped datasets

Our data set has $10^4$ data points, but has a long baseline and many gaps. As the histogram shows, the horizontal-axis is time and most of the time, there are no data. The vertical-axis is data ...
1 vote
89 views

### Huygens Fresnel Diffraction integral using dblquad in python

I am attempting to create a python function to assist in calculating the following numerical integration of the Huygens Fresnel integral in the form of ...
242 views

1 vote
48 views

1 vote
56 views

1 vote
63 views

### Help with CVXPY and Disciplined Convex Programming

I'm trying to recreate Figure 1 in this paper. This requires maximizing equation (19), which I have convinced myself is concave, but I am having trouble implementing it in CVXPY. Here is the code I ...
39 views

### Oscillating eigenvectors for 2d-laplace operator

I am trying to calculate the eigenvectors of a Laplace-operator in 2d, with boundary conditions equal to $u=0$ if $x, y$ are outside of a rectangle defined as $(0.5, 0.5), (1.5, 1.5)$. For that I used ...
68 views

### solve Ax=b for outrigger A matrix python

I implement Crank-Nicolson 2D finite-difference method. I get a matrix A which is banded with 1 band above and below the main diagonal, but also contains 2 additional bands , further apart from the ...
1 vote
76 views

### Beam propogation method for a waveguide. How to get single mode?

I am simulating a waveguide using diffractio python library (https://diffractio.readthedocs.io/en/latest/readme.html). The idea is to create a single mode waveguide using wave propogation method. ...
269 views

### What is a good library in Python for correlated fits in both the $x$ and $y$ data?

I have $x$ and $y$ data, both of which have their own covariance matrices. scipy.optimize.curve_fit will accept a covariance matrix for the $y$ data, called ...
453 views

115 views

### Determining the voxels between two boundary surfaces

Issue description I am working on human brain tACS simulations where I have the models of the skin, skull, csf, brain and ventricles in STL format. The shape does not matter and there are no ...
214 views

### Is there any way/any python function to calculate the condition number of the roots of a polynomial directly?

I know that NumPy has linalg.cond(A) to find the condition number of a matrix A. But, if I want to find the condition numbers of the roots of a large polynomial ...
259 views

### Translating the Euler code in scipy's solve_ivp

My code is based on the similarity transformation X=VZ.I simulate the model for transformed equations involving Z by replacing ...
127 views

### Parameters estimation with fewer variables than parameters

I am trying to estimate parameters, 4 of them, by fitting a system of 3 ordinary differential equations. I am using a model published that was using 3 parameters and gave a good fit to the data, and I ...
220 views

### Pseudospectrum of non square Matrix in Python

I have a rectangular matrix $A \in \mathbb{R}^{m \times n}$ ...
89 views

### Are Python/MATLAB/Mathematica numerical eigenvectors affected by eigenvalue degeneracies outside region of calculation?

I have a discretized 2D mesh over which I calculate eigenvalues and eigenvectors of some Hermitian 2 x 2 matrix at each point along a closed loop parameterized by parameter t. The eigenvectors are ...
3k views

### Integration of the Fermi distribution using Python

I want to calculate the carrier concentration of my semiconductor using this equation: $$n(x) = \frac{m^*}{\pi\hbar^2}\int_{E_k}^{\infty}\frac{1}{1+\exp\left(\frac{E-E_f}{k_BT}\right)} \mathrm{d}E$$...
351 views

### Error using scipy.integrate.solve_ivp: index error: the index 0 is out of bounds for axis 0 with size 0

I am recently working on the code based on the stick-slip phenomenon in Python. It's the stick-slip oscillator (chapter 3.4) in https://www.sciencedirect.com/science/article/pii/S0888327020301205. And ...