Skip to main content
28 votes
Accepted

How to interpolate scattered data to a regular grid in Python?

It is straightforward to do so with numpy, scipy.interpolate.griddata, and matplotlib. Here ...
milancurcic's user avatar
  • 4,993
13 votes

How to interpolate scattered data to a regular grid in Python?

You have a lot of options. The easiest solution for this simple task would be to use a GIS software, e.g. the free QGIS. Add delimited text layer and try raster interpolation. Download a free ...
user2821's user avatar
  • 5,946
7 votes

Python - How to write interpolated raster to netcdf file

I changed your model solution a little bit; but it's like Ingvar Lukas wrote in his answer: you redefined xi and yi in the ...
Erik's user avatar
  • 1,999
6 votes
Accepted

Python, R or etc.?

In my opinion, python is a more established global language that is used by many more disciplines/users, compared to R. This can be advantageous because examples/tutorials are everywhere and you can ...
f.thorpe's user avatar
  • 13.7k
6 votes

Python - How to write interpolated raster to netcdf file

You have a shape mismatch, as you are overwritingxi and yi using np.meshgrid, then assigning ...
Ingvar Lukas's user avatar
5 votes
Accepted

Determining if a fine resolution lat/lon point lies in a coarse resolution lat/lon grid box?

Note: I'm assuming that the original data are provided in NetCDF format. There are two (OK, there are more, but I'll focus on these two) relatively quick ways to deal with this issue. Which one to ...
Nemesi's user avatar
  • 1,268
5 votes

Hydrology- flow accumulation

The flow accumulation algorithm essentially determines the upstream contributing area of every grid cell; in other words, what area or how many other cells will drain into a given cell. The flow ...
Rob's user avatar
  • 751
5 votes
Accepted

Problems when interpolating time series data (average problem)

Is it a solution to multiply the B Average Value with 0.7, so the weighted average value will be 3.5? No, this is not a solution. Doing this effectively assigns a value of zero to the stations that ...
Fred's user avatar
  • 24.7k
5 votes
Accepted

ETOPO1 region selection (in python)

It looks like you simply messed up the order of your min and max of the latitude. And you were looking at the wrong place (-44° instead of +44°). ...
smichel's user avatar
  • 380
4 votes

How to solve libnetcdf.so.12: cannot open shared object file in pyferret?

You need to uninstall netCDF4 as it is not compatible with pyferret library as of now. pip uninstall netCDF4 should do.
Manmeet Singh's user avatar
4 votes
Accepted

Error trying to download ERA5 data: Exception: Missing/incomplete configuration file: C:\Users\username/.cdsapirc

I had the same problem but have just found the solution after an hour or so of trawling through forums! The problem was that the code 'api.py' could not find the '.cdsapirc' file. The file type has to ...
Laurie Wilkinson's user avatar
4 votes

Python, R or etc.?

Essentially there is no consensus. To some degree it comes down to personal preference but it also depends on the application - what needs to be done. Python is a very popular language and for smaller ...
Fred's user avatar
  • 24.7k
3 votes

How to calculate Ocean heat content?

The temperature readings are point samples which can occur at various depths depending on who took the reading, how they were taken & the conditions at the time when they were taken. If modeling ...
Fred's user avatar
  • 24.7k
3 votes
Accepted

What CRS does GFS use?

My ansatz for what cyl means is likely Equidistant Cylindrical Projection, because in the older Basemap module, 'cyl' was the ...
BarocliniCplusplus's user avatar
3 votes

Terrain correction for gravity data using Nagy, 1973

Instead of the Nagy prism formula, I suggest you to use the formula quoted in the following paper: B. Banerjee, S.P. Das Gupta (1977): "Gravitational attraction of a rectangular parallelepiped" ...
francesco palmieri's user avatar
3 votes
Accepted

Plotting wind barbs in python (no U,V component)

I can answer this in two steps Calculate $u$ and $v$. This site has formulas for $u$ and $v$. They are as follows: $$u=-|\vec{v}|\sin(\frac{\pi}{180}\phi)$$ and $$v=-|\vec{v}|\cos(\frac{\pi}{180}\phi)...
BarocliniCplusplus's user avatar
3 votes

Plotting wind barbs in python (no U,V component)

The data format you have (magnitude and direction) is usually referred to as polar co-ordinates. The data format you need (horizontal and vertical offsets) is Cartesian co-ordinates. There's plenty of ...
Pont's user avatar
  • 5,429
3 votes

Read SMAP grib data using python

It seems like the GRIB format is being used to distribute the data (probably for storage, ease of processing?), while satellite SMAP doesn't fit under the GRIB standard (see available parameters ...
Ingvar Lukas's user avatar
3 votes

Downloading JRA-3Q efficiently using a python script

The URL strings are base64-encoded, the example given decodes to: /JRA3Q/Client9120/Daily/anl_isentrop/anl_isentrop_bvf2.cglt9103.day0107 With this information, you ...
alex_danielssen's user avatar
3 votes

Efficient way to parse lat-lon grid at certain depth in tripolar model from nc file?

First of all: NEVER, EVER, EVER (I repeat, EVER) loop in Python over an array to subset some values :) xarray was created exactly to avoid having to write something ...
Droid's user avatar
  • 421
2 votes

How to handle negative cosine of Solar Zenith Angle while calculating clear-sky UV Index?

This is only to address the title question. You are right, in a way. I would recommend that you set an if statement up such that ...
BarocliniCplusplus's user avatar
2 votes

Terrain correction for gravity data using Nagy, 1973

I have recently had to deal with the same problem and tackled it in Matlab, If it helps, here's a link to it on the file exchange https://au.mathworks.com/matlabcentral/fileexchange/57349-nagyprism-...
Jack's user avatar
  • 31
2 votes

How to calculate Lifted Index from ERA5 pressure level data?

Metpy 1.0 has a lifted_index function, which requires a profile temperature parameter, which in turn can be calculated using the parcel_profile function. That requires having the dew point temperature,...
climatestudent's user avatar
2 votes

How to map emission inventory from lat&lon corrdinate to WRF model grid

I would suggest using cdo for your purpose. At least for variables, which values are independent of the grid cell size, one can use cdo. cdo cdo (Climate Data Operators) is a command line program to ...
daniel.heydebreck's user avatar
2 votes
Accepted

Wind speed data plot contains blank gaps

The answer is actually pretty easy. The WRF model lies on a grid. The vertical component of the grid is unevenly spaced, though you can manually space it. The vertical coordinate of WRF uses a sigma ...
BarocliniCplusplus's user avatar
2 votes

How to search for the nearest non nan value in 2d xarray dataset

If I were you, I would exclude the NaN values and then perform gridding on the resulting irregularly spaced data. There are already the tools to perform this in Python and using the library SciPy ...
EarlGrey's user avatar
  • 459
1 vote

What is the best way to interpolate isotopic data and display them?

Ok I think there is no similar package. Therefore, the best approach is to do the interpolation with the package Pykrige and for displaying the data I would recommend the package Basemap (...
Weiss's user avatar
  • 2,043

Only top scored, non community-wiki answers of a minimum length are eligible