Skip to main content
0 votes
1 answer
191 views

How to use numpy masked arrays to create a masked xarray DataArray?

I'm using metpy.calc.windchill in order to calculate wind chill values, and it automatically spits out an array with a numpy mask on it. t2m, uwind, and vwind all come from ERA5 (on the Google Cloud: ...
user29903541's user avatar
0 votes
1 answer
58 views

RuntimeWarning: invalid value encountered in double_scalars with function working in calculators

I have an equation that I try to run in python for a range of values: T = 15 H = range(0, 100) for hum in H: ED = 0.942 * (hum ** 0.679) + 11 * exp((hum - 100) / 10) + 0.18 * (21.1 - T) ** (1 - exp(-...
Elsri's user avatar
  • 61
1 vote
0 answers
91 views

Numpy add.at not working with masked array

I'm trying to sum some numbers in a masked array using np.add.at as follows: acc = np.ma.zeros((1,), dtype=np.float64) arr = np.ma.masked_array([1.,2.,3.,4.,5.], mask=[0, 1, 0, 0, 0]) np.add.at(acc, [...
Rob Allsopp's user avatar
  • 3,557
-2 votes
1 answer
29 views

Why some data is missing on a figure when I define the axes? My dataset is a DataArray and some values are masked [duplicate]

I would like to be able to define my axis and not lose information. Currently, I am missing the last data point in both dimensions I defined (see figure). DATA = xr.DataArray(np.random.rand(74,13),...
Anne Sophie 's user avatar
0 votes
0 answers
42 views

Why does np.ma.median work for only certain sizes of nan matrices and give the MaskError('Cannot alter the masked element.') for other sizes

I am trying to build a code that can be given an matrix of nans and not break. I wrote a simplified version here that recreates the problem. I am using numpy version 1.23.5 Basically the code takes a ...
loberhel's user avatar
0 votes
0 answers
484 views

Masked array from list of one-element masked arrays: Cannot convert masked element to a Python int

I want to create a 1d masked array from a list of one-element (0d) masked arrays using numpy.ma. This works as expected if the values are not masked, it does not in the other case: import numpy.ma as ...
sebschub's user avatar
  • 223
0 votes
1 answer
37 views

Adding 3D masked arrays results in TypeError: 'numpy.bool_' object is not iterable

I have two 3D masked arrays (netCDF4 files output from climate model) that I want to add together. I followed this thread and got the following (simplified) code out of it: import numpy as np from ...
Elsri's user avatar
  • 61
0 votes
0 answers
180 views

correlation calculation of masked array:

I have a sea surface temperature time series, and I want to calculate the correlation coefficients among the nodes in the tropics(30.0N to 30S). In the time series, the land information is present as ...
Ruby's user avatar
  • 51
3 votes
2 answers
350 views

in numpy, what is the difference between calling MA.masked_where and MA.masked_array?

Calling masked_array (the class constructor) and the masked_where function both seem to do exactly the same thing, in terms of being able to construct a numpy masked array given the data and mask ...
alani's user avatar
  • 13.2k
0 votes
1 answer
122 views

problem with setting numpy's maskedarray fill_value

I cannot figure out how to set the fill_value of a real masked array to be np.nan. The array is the result of the calculation of two complex maskedarrays. Somehow, the calculated array's fill_value ...
jbiz's user avatar
  • 45
0 votes
1 answer
488 views

How to solve numpy.ma.core.MaskError: Cannot alter the masked element?

I am new to python and I am trying to convert python 2 code I found on github (https://github.com/RDCEP/psims) into python 3. It went quite well, but now I am stuck with the following error message: ...
albren's user avatar
  • 109
1 vote
0 answers
182 views

matplotlib.pyplot.scatter does not respect mask rules with datetime

matplotlib version 3.5.3 Plotting a numpy masked array against a list of datetime objects, plt.plot functions as expected, but plt.scatter still displays the masked data. Auto-axis limits do respect ...
Ben Pickering's user avatar
0 votes
1 answer
223 views

How to apply a function element-wise with inputs from multiple numpy masked arrays to create a new masked array?

I have a function that takes in 4 single value inputs to return a singular float output, for example: from scipy.stats import multivariate_normal grid_step = 0.25 #in units of sigma grid_x, grid_y = ...
Ho-Hin Leung's user avatar
0 votes
1 answer
345 views

Irregular/Inhomogeneous Arrays with JAX

What is the recommended approach to implement array behaviour/methods on irregular/inhomogeneous data (possesses some inherient dimensionality) within JAX? Two principle options come to mind: make ...
DavidJ's user avatar
  • 440
0 votes
1 answer
485 views

How to implement masked array fitting using lmfit (prior using sigma option of curve_fit)

I am trying to implement masked-array fitting using lmfit. Prior I was using curve_fit using the following code snippet. I have omitted the def spec due to its line length. Essentially def spec is ...
cosmic noise's user avatar

15 30 50 per page
1
2 3 4 5
11