Skip to content

Tag: numpy

Why does fftfreq produce negative values?

From the documentation for fftfreq: Why are there negative values in the output array? I am trying to produce a plot of amplitude vs frequency. I can get the amplitude by running the abs() function over the elements of fourier, but how do I convert freq into a series of frequencies that I can use as an x-axis…

Dealing with masked coordinate arrays in pcolormesh

I’m working on visualizing some climate model output. The computation is done on a projected latitude/longitude grid. Since the model is simulating sea ice, all land grid cells are masked. The standard tools for plotting geographical information in Python are Basemap and Cartopy, both of which use matpl…

python how to pad numpy array with zeros

I want to know how I can pad a 2D numpy array with zeros using python 2.6.6 with numpy version 1.5.0. But these are my limitations. Therefore I cannot use np.pad. For example, I want to pad a with zeros such that its shape matches b. The reason why I want to do this is so I can do: such