Tuesday, June 9, 2020

How to extract specific information from GRIB files?



https://gis.stackexchange.com/questions/173775/how-to-extract-specific-information-from-grib-files



https://github.com/jswhit/pygrib/issues/27

Coordinates, spatial grids
https://confluence.ecmwf.int/display/CKB/ERA5%3A+data+documentation#ERA5:datadocumentation-Spatialgrid

To find specific coordinates within this 720 x 360 array i just extrapolate the coordinates to the array. Ex: If I want to find data for New York New York coordinates ~40.5N 74 W I'll map those coordinates to the array to by doing 2x(90-40.5) and 2x (180-74) to find the following result:
grbs_old = pygrib.open('nomads.ncep.noaa.gov/cgi-bin/'+str(grib_filename))
data=grbs_old[6].values
data[99][212]
Grid box
https://confluence.ecmwf.int/display/CKB/Model+grid+box+and+time+step
Horizontal
In the horizontal the discrete points are arranged in a two dimensional grid and hence are referred to as grid points. The grid can be regular or irregular. An example of a regular latitude/longitude grid would be where the grid points are located every 1 degree of longitude in the east-west direction and every 1 degree of latitude in the north-south direction. Each grid point is associated with an area that either surrounds the grid point or lies between the grid points. This area is referred to as the "grid box".
Grid point values cannot properly represent variability on spatial scales smaller than the grid box.
(In addition to using grid points, the ECMWF Integrated Forecasting System (IFS) also uses an additional mathematical concept, spectral space, to represent horizontal space. This concept uses a set of wavy basis functions, spherical harmonics, to describe variations in the horizontal. The IFS switches between spectral space and grid point space, in order to perform specific computations.)


For Hong's Pygrib file,
grbs = pygrib.open('2019-2020June10.grib')
valuesTmp = grbs[1].values
valuesTmp.shape #return (721, 1440)

so, 720/180 = 4

1440/360 = 4

It turns out that GRIB use 0-360 longitude and many software use -180W, 180E longitude. 

Hong tried ( - 180W mod 360), and temperature results from DC matches AccuWeather results,





No comments:

Post a Comment