# Tag Info

20

It is straightforward to do so with numpy, scipy.interpolate.griddata, and matplotlib. Here is an example: import matplotlib.pyplot as plt import numpy as np from scipy.interpolate import griddata # data coordinates and values x = np.random.random(100) y = np.random.random(100) z = np.random.random(100) # target grid to interpolate to xi = yi = np.arange(...

14

Your uwnd variable holds 32 bit floats and has shape (1,73,144) corresponding to time, lat, lon and is located in the Dataset you have called 'U'. One way to put this in a numpy array is: uwind = np.zeros((lat,lon), np.float) uwind = U.variables['uwnd'][1,:,:] The first line sets the size of the uwind array, which is helpful from a performance standpoint ...

11

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 coastline vector and clip your raster with the coastline. A few searches at GIS SE can help you out if you get stuck. With a GIS option, it is easy to also plot e.g. ...

11

First off very few people are using Basemap from Matplotlib these days. From this link matplot basemap Basemap is deprecated in favor of the Cartopy project. See notes in Cartopy, New Management, and EoL Announcement for more details. So we are going to use cartopy in addition with matplotlib to plot the grib file that you have provided. Before I ...

5

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 accumulation algorithm is independent of rainfall as it simply determines which areas drain where, which will later be used to determine how much water actually ...

4

You need to uninstall netCDF4 as it is not compatible with pyferret library as of now. pip uninstall netCDF4 should do.

3

My ansatz for what cyl means is likely Equidistant Cylindrical Projection, because in the older Basemap module, 'cyl' was the shortname for that projection. But the reality is that since the GFS is a global spectral model with a latitude-longitude grid, it likely does not require a CRS. That is, it presupposes a sphere, where a CRS projects the spherical ...

3

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)$$ where $\phi$ is the wind direction in the meteorological system, and $|\vec{v}|$ is the wind speed. Having calculated $u$ and $v$, you can plot the wind ...

3

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" Geophysics, vol. 42, n. 5, pp. 1053-1055 doi: 10.1190/1.1440766 I wrote, in Fortran, a TC program based on that formula. If you read the paper you better ...

2

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 process netCDF and GRIB files. It is developed an maintained by Uwe Schulzweida and colleagues at the Max-Planck Institute for Meteorology in Hamburg, Germany. ...

2

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-x1-x2-y1-y2-h-rho- Here is the code: % A function to perform terrain corrections using the Nagy % prism formula. % To calculate the terrain correction for a ...

2

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 good material on this online. For a friendly introduction, see e.g. this page on "Math is Fun!" (or your favourite high-school maths textbook). Converting ...

2

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 if cos(sza)>=0: raw_uvi = 12.50*pow(cos(sza),2.42)*pow(float(ozone)/300,-1.23) else: raw_uvi=0.0 This makes it so that when the sun is beneath the horizon, the sun is not 'taking back' the energy

2

I am not able to give full actual code in Python but I hope I can point you in the right direction if I were to go about calculating diffluence and confluence. One can start with making a streamlines plot using matplotlib first. Once you have that you need to get the actual streamlines data as described in this link - https://matplotlib.org/api/_as_gen/...

2

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 vertical coordinate (even though the namelist calls them eta): $$\sigma=\frac{P-P_{surface}}{P_{top}-P_{surface}}$$. So the values of sigma are specified (or ...

2

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 https://scipy-cookbook.readthedocs.io/items/Matplotlib_Gridding_irregularly_spaced_data.html But please document exactly what step you are doing and why. ...

2

As @gansub implicitly suggested, you may have a better outcome by defining the output grid as well. Check this very similar question: How to interpolate scattered data to a regular grid in Python? After comments, I realize I missed the irregular target grid. Maybe this answer helps: https://stackoverflow.com/questions/3242382/interpolation-over-an-...

1

this is probably a little late in the day to answer. I have a wafo "superficially working" on windows 10 with python 3.7.1: however, so far I have only accessed the wave spectrum models. The recipe I used was clone the repo pip install 2to3 navigate to the cloned folder 2to3 . -w copy folder to src/wafo folder to site-packages/wafo Open cmd.exe or ...

1

If there is no direct function available, you can create a Trace/Stream object yourself. The solution I use (example for one time series) is: read the Ascii file into a numpy array trace = obspy.core.Trace(data=numpy array, header=header dictionnary of your choice) stream = obspy.core.Stream(traces=[trace]) stream.plot()

1

Technically, this is a mathematical modelling problem. You just happen to be using earth science data - satellite LIDAR readings. Ore reserve geologists constantly deal with this, but in three dimensions when they are required to create a block models of a geological deposit from drill hole data. Scientific fields that use 2D data would include: forestry, ...

1

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 actually be 'CDSAPIRC' and not a 'txt' file. The icon for the file will then be displayed in your folder as blank and the name will be '.cdsapirc'. I found the ...

1

using R: Alright, As you have data with different resolution, I would suggest you to convert your data to raster and resample to match the grid cell of your wrf_inputs. Take care of mass conservation. Then convert your raster to a matrix, data.frame, or spatial feature of 'POLYGON' your emissions Then create wrf_chemi files steps: raster your emissions ...

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