Try to draw a "weather map-like front" by machine learning based on weather data (2)

Let's draw a "weather map-like front" by machine learning based on meteorological data (2) Story of weather data visualization as input

Last time, [Let's draw a "weather map-like front" by machine learning based on meteorological data (1)](https://qiita.com/m-taque/items/80a87052fde00fb96fab "Based on meteorological data," I posted the whole flow as trying to draw a "weather map-like front" by machine learning (1) "). Part 2 summarizes the story of visualizing numerical data in GPV format.

0. My environment

I'm using a Mac OS environment. I used to study using a Mac book pro and iPhone (Pythonista), but I bought it when the Mac mini was renewed. As a result, it was good to increase the memory.

Hardware and software

Mac mini(2018) Processor 3.2GHz 6-core Intel Core i7 Memory 32GB 2667 MHz DDR4

OS macOS Catalina When it was first introduced, it was one generation older than mojave.

Development environment

Although atom is included in the integrated development environment, I don't use it much. Because it is the generation that came to anything with vi ...

1. Meteorological data related to fronts

1.1 What is the target for drawing the front?

** Fronts ** are analyzed by the Japan Meteorological Agency and are depicted in ** Asian Ground Analysis Map (ASAS) ** and ** Breaking Weather Map (SPAS) **.

About the weather map on the Japan Meteorological Agency website

As a sample, the one at 21:00 UTC on December 2, 2019 is shown. SPAS_COLOR_201912021200.v8.512.png

This is the ** weather map ** that we are aiming for.

On the other hand, the meteorological data obtained from Kyoto University this time is ** Global Forecast Model (GSM) **, which is one of the numerical weather prediction models of the Japan Meteorological Agency.

Please see below for explanations such as numerical weather prediction. What is the Japan Meteorological Agency Homepage Numerical Weather Prediction

GSM data includes data on meteorological factors such as ** temperature ** and ** barometric pressure **, but we don't know where ** is the front. It can be said that this machine learning is to learn from this GSM data that "it recognizes where the front should be drawn and draws the front" like ** weather map **.

Then, let's target the data of the initial time of GSM. This is because it is the same as the target time when the Japan Meteorological Agency analyzes and creates the weather map, and it is thought that almost the same weather conditions are expressed.

Initial time data and observed values Based on the initial time data, GSM will calculate future atmospheric conditions, such as 3 hours later, 6 hours later, and so on. The "initial time data" here is the "most confusing atmospheric condition" obtained from a finite observation point at a certain time at regular grid positions by making full use of statistical methods. This is called "objective analysis", and "data assimilation", which has recently begun to be applied to various fields, has been used for some time. [Japan Meteorological Agency Homepage Objective Analysis](https://www.jma.go.jp/jma/kishou/know/whitep/1-3-3.html "Objective Analysis")

1.2 Meteorological factors that determine the front

The front is the boundary between air masses with different properties, usually the boundary between ** warm air ** and ** cold air **, but when the meteorological data is visualized, it seems that such a boundary exists everywhere. I will.

First of all, how do you decide where to draw the front? There is not much specific story in the specialized books on meteorology, but I found that the reference book for the weather forecaster test has such a description (in the weather forecaster test, look at the weather map Front analysis is one big genre because of the problem of drawing weather fronts).

[Weather Forecaster Easy Pass Text](https://www.amazon.co.jp/ Weather Forecaster Easy Pass Text-% E3% 80% 88 Practical Edition>-Easy Breakthrough-Weather Forecaster Examination Support Group / dp / 4774149950 / ref = pd_sbs_14_img_1 / 355-1239468-1368320? _encoding = UTF8 & pd_rd_i = 4774149950 & pd_rd_r = 5f510193-a636-44b6-9ee7-011e7278ba9c & pd_rd_w = wCuCw & pd_rd_wg = ZGywm & pf_rd_p = ca22fd73-0f1e-4b39-9917-c84a20b3f3a8 & pf_rd_r = R77VP37VM7V6TX7BMPWE & psc = 1 & refRID = R77VP37VM7V6TX7BMPWE "weather Forecaster Easy Pass Text ") 51RlzcuwIBL.SX351_BO1,204,203,200.jpg

according to it,

  1. Boundary on the warm air side where ** isotherms ** are concentrated (ground, 850hPa surface)
  2. The southern end (850hPa surface) where ** equivalent potential temperature lines ** are concentrated
  3. ** The part where the wind speed and direction ** change suddenly
  4. Comprehensively judge the ** wet area ** and ** rising basin **

It seems to draw a front based on that. So it seems good to use the corresponding meteorological factors.

  1. pygrib

2.1 What is pygrib?

pygrib is a library that can read GRIB2 format files. For example, the installation method is explained by the following ancestors.

Prepare an environment to touch grib2 format files with python (Docker edition)

2.2 Open the GRIB file

ʻOpen the file with the open` method to get the object.

pygrib-open.py


import pygrib
import sys
import numpy as np
import math

(Omitted)

# GRIB file settings.
_sourcedir = "./hogehoge/"
_GSMfilename = _sourcedir + "Z__C_RJTD_" + _yearstr + _monstr + _daystr + _hrstr + "0000_GSM_GPV_Rgl_FD0000_grib2.bin"

# Open GRIB file
grbs = pygrib.open(_GSMfilename)

For _yearstr, _monstr, _daystr, and _hrstr, give the target year, month, day, and hour as strings. Extract the desired data from the object grbs by using the select method with some parameters.

2.3 Extract by specifying meteorological factors, altitude plane, and forecast time

This time, we will use three, parameterName, level, and forecastTime.

Specific parameter names differ depending on the institution that publishes the data and the weather model. In the case of data released by the Japan Meteorological Agency

Japan Meteorological Agency Homepage: Technical Information on Distribution Materials

As explained in, is it not supposed to use pygrib, and what should be specified for parameterName? I can't tell you about it.

Table 2-1. Parameter specified for parameterName

Specified parameter Contents
Pressure reduced to MSL Sea level correction pressure((Pa unit)
Temperature Temperature (Note that it is absolute temperature)
Relative humidity Relative humidity
Vertical velocity [pressure] Vertical wind velocity (barometric pressure coordinates)
u-component of wind East-west component of horizontal wind speed
v-component of wind North-south component of horizontal wind speed
Geopotential height Geopotential height
Low cloud cover Lower cloud cloud amount
Medium cloud cover Middle cloud cover
High cloud cover Upper cloud cloud amount
Total cloud cover Total cloud cover

Table 2-2. Level specification parameters

Specified parameter Contents
850 850hPa surface data
700 700hPa surface data
500 Data on 500hPa surface
300 300hPa surface data
0 Ground surface data (used at sea level correction pressure)
2 Ground surface data (used for temperature and relative humidity)
10 Ground surface data (used at horizontal wind speed)

Table 2-3. Specified parameters of forecastTime

Specified parameter Contents
0 Forecast initial time
6 Data 6 hours after the initial time
12 Data 12 hours after the initial time
(Continued at 6-hour intervals thereafter)

By specifying a combination of these, you can extract the type and altitude of the weather data you want to use from the GRIB2 format file.

pygrib-select.py



#- parameterName for select from GRIB file

letter_mslp = "Pressure reduced to MSL"
letter_tmp  = "Temperature"
letter_rh   = "Relative humidity"
letter_vv   = "Vertical velocity [pressure]"
letter_wu   = "u-component of wind"
letter_wv   = "v-component of wind"
letter_gh   = "Geopotential height"
letter_lc   = "Low cloud cover"
letter_mc   = "Medium cloud cover"
letter_hc   = "High cloud cover"
letter_tc   = "Total cloud cover"

#-- Surface

grb_tmp = grbs.select(parameterName=letter_tmp  , level=2 , forecastTime=0)
grb_prs = grbs.select(parameterName=letter_mslp , level=0 , forecastTime=0)
grb_wu  = grbs.select(parameterName=letter_wu   , level=10, forecastTime=0)
grb_wv  = grbs.select(parameterName=letter_wv   , level=10, forecastTime=0)
grb_rh  = grbs.select(parameterName=letter_rh   , level=2 , forecastTime=0)

#-- 850 hPa level

grb_tmp85 = grbs.select(parameterName=letter_tmp  , level=850 , forecastTime=0)
grb_wu85  = grbs.select(parameterName=letter_wu   , level=850 , forecastTime=0)
grb_wv85  = grbs.select(parameterName=letter_wv   , level=850 , forecastTime=0)
grb_rh85  = grbs.select(parameterName=letter_rh   , level=850 , forecastTime=0)
grb_gh85  = grbs.select(parameterName=letter_gh   , level=850 , forecastTime=0) 

#-- 700 hPa level 

grb_tmp70 = grbs.select(parameterName=letter_tmp  , level=700 , forecastTime=0)
grb_rh70  = grbs.select(parameterName=letter_rh   , level=700 , forecastTime=0)
grb_vv70  = grbs.select(parameterName=letter_vv   , level=700 , forecastTime=0)

#-- 500 hPa level

grb_tmp50 = grbs.select(parameterName=letter_tmp  , level=500 , forecastTime=0)
grb_wu50  = grbs.select(parameterName=letter_wu   , level=500 , forecastTime=0)
grb_wv50  = grbs.select(parameterName=letter_wv   , level=500 , forecastTime=0)
grb_rh50  = grbs.select(parameterName=letter_rh   , level=500 , forecastTime=0)
grb_gh50  = grbs.select(parameterName=letter_gh   , level=500 , forecastTime=0)

#-- 300 hPa level

grb_wu30  = grbs.select(parameterName=letter_wu   , level=300 , forecastTime=0)
grb_wv30  = grbs.select(parameterName=letter_wv   , level=300 , forecastTime=0)
grb_rh30  = grbs.select(parameterName=letter_rh   , level=300 , forecastTime=0) 

#-- Cloud coverage

grb_lc  = grbs.select(parameterName=letter_lc   , forecastTime=0)
grb_mc  = grbs.select(parameterName=letter_mc   , forecastTime=0)
grb_hc  = grbs.select(parameterName=letter_hc   , forecastTime=0)
grb_tc  = grbs.select(parameterName=letter_tc   , forecastTime=0)

For example, the temperature data on the 850hPa surface can be accessed in the form of grb_tmp85.values.

  1. MetPy

3.1 About MetPy

Metpy is a project that has various weather related tools.

[Metpy Home Page](https://unidata.github.io/MetPy/latest/index.html “Metpy”)

May, R. M., Arms, S. C., Marsh, P., Bruning, E., Leeman, J. R., Goebbert, K., Thielen, J. E., and Bruick, Z., 2020: MetPy: A Python Package for Meteorological Data. Version 1.0.0rc1, Unidata, Accessed 14 January 2020. [Available online at https://github.com/Unidata/MetPy.] doi:10.5065/D6WW7G29.

3.2 Calculation of equivalent potential temperature, etc.

The ** equivalent potential temperature ** must be derived by calculation from the values of ** temperature ** and ** relative humidity ** obtained directly from GPV, but the following calculation library included in MetPy's calc is used. It can be calculated easily.

Calculate ** dew point temperature ** from dewpoint_rh ** temperature ** and ** relative humidity ** ʻEquivalent_potential_temperature` ** Equivalent potential temperature ** is calculated from ** dew point temperature **, ** atmospheric pressure **, and ** temperature **.

4. This and that of the map

4.1 Projection

Since the front position is learned from the breaking weather map, it is necessary to match the format and drawing range of the visualized image map with the breaking weather map.

Do I need to match? That may be an overstatement. That was necessary in my method. It may be possible to create machine learning that draws a proper front from a lot of data even if the range is different.

Since the earth is a sphere, you know that there are various methods for making a flat map, but if you look closely at the preliminary weather map, it is written narrower toward higher latitudes.

Breaking Weather Maps (SPAS) are based on polar stereographic projection rather than Mercator projection. The following technical information provided by the Japan Meteorological Agency includes ** "The map is projected using a polar stereographic projection based on latitude 60 degrees north and longitude 140 degrees east." ** There is a description that. [Technical Information on Distribution Materials (Weather Edition) No. 358](http://www.data.jma.go.jp/add/suishin/jyouhou/pdf/358.pdf "Technical Information on Distribution Materials (Weather Edition)" No. 358 ") This information will then be used when overlaying the data on the map using matplotlib's Basemap.

4.2 Drawing range

I had no choice but to read this from the breaking weather map. The latitude and longitude of the lower left and upper right are specified as the parameters of Basemap. I figured out the value specified by ** Trial and Error ** how it is actually imaged.

The result is as follows. The base point of polar stereo is specified by lat_0 and lon_0. The latitude and longitude of the lower left is (115 ° E, 9 ° N), and the latitude and longitude of the upper right is (178 ° E, 54 ° N).

python


Basemap(projection='stere', llcrnrlat=9, urcrnrlat=54, llcrnrlon=115, urcrnrlon=178, lat_0=60,  lon_0=140, resolution='i' )

Based on this, the surface pressure (sea level correction pressure) of UTC at 12:00 on December 2 was drawn. gsm_prs_srf_2019120212.v8.512.png The breaking weather map is below. SPAS_COLOR_201912021200.v8.512.png

Since GSM is originally global data, there is enough data to cover everything on the earth, but only this range is used. I feel a little wasteful. Although it is a visualized map, there are some places where the edges are a little more worrisome than the weather map, but this is okay.

5. Visualization with matplotlib

5.1 About visualization

I don't think you need to explain about matplotlib anymore.

Meteorological data is numerical data that is lined up (latitude, longitude) on the ground surface or on a high-rise atmospheric pressure isobaric surface. Visualize this so that CNN is easier to learn than it is easy for humans to see.

There are contour maps and isobar diagrams for visualizing two-dimensional data. In the weather forecast, the color range of the temperature is quietly changed between summer and winter, but this time, considering learning, we will keep it in the same range throughout the year.

value_range.py


levels_prs    = np.arange(930.0,1080.0,4.0) #Sea level correction pressure 930-1080hPa 4hPa interval
levels_tmp    = np.arange(210,316,2)        #temperature(Kelvin) 210-316K 2K interval
levels_tmps   = np.arange(-35,45,2)         #temperature(Celsius)-35 ° C to 45 ° C 2 ° C interval
levels_dp     = np.arange(0,80,10)          #Dew point temperature(Celsius)Not used for visualization
levels_dp2    = np.arange(0,3,1)            #Dew point depression(Celsius)0 ° C to 3 ° C 1 ° C interval
levels_vv     = np.arange(-5,5,0.5)         #Vertical speed(P/s)  -5P/s-5P/s 0.5P/s interval
levels_ept    = np.arange(200,400,3)        #Equivalent potential temperature(Kelvin) 200-400K 3K interval
levels_cld    = np.arange(-20,110,5)        #Cloud cover(%)        0-110
levels_rh     = np.arange(0.0,110.0,5)      #Relative humidity(%)     0-110 5%interval
levels_gh_300 = np.arange(7000,10000,40)    #Geopotential height 7000-10000m 40m interval
levels_gh_500 = np.arange(4500,6200,40)     #Geopotential height 4500-6200m 40m interval
levels_gh_850 = np.arange(1000,2000,40)     #Geopotential height 1000-2000m 40m interval
levels_gh_700 = np.arange(2000,4000,40)     #Geopotential height 2000-4000m 40m interval

5.2 Visualization of arrows, contours, and contour lines

The following types of CNN inputs are used this time.

  1. Ground surface ** Wind temperature Pressure **
  2. 850hPa surface ** Wind Temperature Atmospheric pressure ** (** Geopotential altitude **)
  3. 500hPa surface ** Wind Temperature Atmospheric pressure ** (** Geopotential altitude **) The wind expresses the wind speed and direction with an arrow feather diagram (using the barbs method of matplotlib). Overlay the contour diagram for atmospheric pressure, and the contour diagram and color contour for temperature. Atmospheric pressure is expressed in the sky by an element called geopotential height. In the meteorological world, high-rise meteorological elements are represented as a distribution of heights at a certain atmospheric pressure. Atmospheric pressure decreases exponentially as altitude increases. Depending on the high and low pressure, the height of the specified barometric pressure level will increase or decrease. This is called geopotential height. Candidates for ** fronts ** are areas where the temperature is changing rapidly and areas where the wind direction is changing rapidly. The source for drawing these three types of data on top of each other is shown below.

windmap



def windmap( u , v , values , levels , cmap , _save_filename , values2 , levels2 ):
        # u,v Wind speed east-west component, wind speed north-south component
        #values barometric pressure data
        #values2 Temperature data
        # levels,levels2 coloring range
        #cmap color map
        # _save_filename Save file name

        fig,ax = plt.subplots(figsize=(6,5.8)) #Create a diagram
        plt.subplots_adjust(left=0.01, right=0.98, top=0.99, bottom=0.01) #Adjust margins

        #Create a polar stereographic projection map with Basemap
        m = Basemap(projection='stere', llcrnrlat=9, urcrnrlat=54, llcrnrlon=115, urcrnrlon=178, lat_0=60,  lon_0=140, resolution='i' )
        m.drawparallels(np.arange(-80.,81.,10.))      #Draw latitude lines in 10 ° increments
        m.drawmeridians(np.arange(-180.,181.,10.))    #Draw the longitude line in 10 ° increments
        m.drawcoastlines()                            #Draw a coastline
        
        lons_s = lons[::5, ::5]   #Kazeyaha The drawing point is skipped by 5 elements.
        lats_s = lats[::5, ::5]   #Kazeyaha The drawing point is skipped by 5 elements.
        
        x , y    = m(lons, lats)     #Convert from latitude / longitude to Basemap drawing coordinates
        xs , ys  = m(lons_s, lats_s) #Convert from latitude / longitude to Basemap drawing coordinates
        us = u[::5, ::5]             #Wind data (east-west component) is skipped by 5 elements
        vs = v[::5, ::5]             #Wind data (north-south component) is skipped by 5 elements
        
        m.contour(  x , y , values  , levels=levels  , linewidths=0.7 , colors='k' )
        #Create contour lines for values
        m.contour(  x , y , values2 , levels=levels2 , linewidths=0.3 , colors='k' )
        #Create contour lines for values2
        m.contourf( x , y , values2 , levels2 , cmap=cmap )
        #Color contour map(values2)Create by overwriting
        m.barbs( xs , ys , us , vs  , length=4.5 )
        #Create an arrow feather figure by overwriting
        fig.savefig(_save_filename)

5.3 Visualization with contour map

  1. 850hPa surface ** Equivalent potential temperature ** First of all, there is an amount called ** potential temperature **, which is the temperature when the air of interest is brought up to 1000 hPa. When the air descends and adiabatically compresses, the temperature rises, and when it rises and adiabatic expands, the temperature decreases. The amount of such a concept is used because it is difficult to compare the thermal energy of the air unless it is compared at the same atmospheric pressure. In addition, if the air contains water vapor, it releases latent heat and rises in temperature as the temperature drops and condenses. Therefore, the amount that takes into consideration the condensation of water vapor is called the ** equivalent potential temperature **. An index that simultaneously evaluates "warmth and wetness" when you hear in the weather forecast, such as at the end of the rainy season, "warm and moist air will flow in from the south and it will rain very heavily to stimulate the front." is. Candidates for ** fronts **, but areas where the equivalent potential temperature changes suddenly are promising areas for fronts.

  2. 700hPa surface ** Dew point ** Dew point depression is the difference between air temperature and dew point temperature. Since the dew point temperature is the temperature at which water vapor condenses, the smaller this ** humidity number **, the easier it is for air to condense, that is, the amount of water vapor is close to the amount of saturated water vapor, indicating that the air is moist. In the high-rise meteorological map released by the Japan Meteorological Agency, the part where the dew point is 3 ° C or less is knitted and is designated as ** wet area **. In the vicinity of the center of the cyclone and ** in front of the warm front **, the air is often moist and rainy.

  3. 700hPa surface ** Vertical wind ** wind speed The vertical wind speed represents the vertical movement of air. It can rise when air gathers and there is nowhere to go, or when it hits a mountain slope. When it rises, the temperature drops, and when it reaches the dew point temperature, the water vapor contained in the air condenses. Since this is the beginning of precipitation activity, vertical winds are closely related to precipitation activity. In addition, ** the development of extratropical cyclones requires an increase in air along the warm front on the front and a decrease in air along the cold front on the rear **, so vertical winds are required for meteorological phenomena including fronts. Is greatly involved.

These are visualized by the following sources. Compared to the previous one, there is no Yaha map and another contour map.

drawmap


def drawmap( values , levels , cmap , _save_filename ) :
        fig,ax = plt.subplots(figsize=(6,5.8))
        plt.subplots_adjust(left=0.01, right=0.98, top=0.99, bottom=0.01)
        m = Basemap(projection='stere', llcrnrlat=9, urcrnrlat=54, llcrnrlon=115, urcrnrlon=178, lat_0=60,  lon_0=140, resolution='i' )
        
        m.drawparallels(np.arange(-80.,81.,10.))
        m.drawmeridians(np.arange(-180.,181.,10.))
        m.drawcoastlines()
        x , y = m(lons, lats)
        #
        m.contour(  x , y , values , levels=levels , linewidths=0.5 , colors='k' )
        m.contourf( x , y , values , levels , cmap=cmap )
        #
        fig.savefig(_save_filename)

5.4 GSM visualization data creation frequency

GSM makes initial values four times a day. The time is 0 o'clock, 6 o'clock, 12 o'clock and 18 o'clock in UTC. On the other hand, breaking weather maps are created every 3 hours except midnight. In other words, at the same time, the initial value and the weather map are aligned three times at 6:00, 12:00, and 18:00. I decided to make input and teacher data for 3 years.

Below is a video of January and August 2019. The data was downloaded from the GPV database published by the Research Institute for Sustainable Humanosphere, Kyoto University.

Research Institute for Sustainable Humanosphere, Kyoto University

I haven't changed the coloring range, so you can see the difference between summer and winter. Unlike a normal visualization diagram, it becomes a learning noise, so I have not added a legend.

Ground wind / atmospheric pressure / temperature January 2019 (red is warmer, blue is colder) ww_wndsrf01.gif Ground wind / atmospheric pressure / temperature August 2019 (red is warmer, blue is colder) ww_wndsrf08.gif 850hPa Wind / Atmospheric pressure / Temperature January 2019 (Red is warmer, blue is colder) ww_wnd8501.gif 850hPa Wind / Atmospheric pressure / Temperature August 2019 (Red is warmer, blue is colder) ww_wnd8508.gif 500hPa Wind / Atmospheric pressure / Temperature January 2019 (Red is warmer, blue is colder) ww_wnd5001.gif 500hPa Wind / Atmospheric pressure / Temperature August 2019 (Red is warmer, blue is colder) ww_wnd5008.gif Potential temperature equivalent to 850hPa January 2019 (redder is warmer and humider) ww_ept8501.gif 850hPa equivalent potential temperature August 2019 (redder is warmer and humider) ww_ept8508.gif 700hPa Dew Point January 2019 (Bluer, Dew Point Dew Point = Wet) ww_situ7001.gif 700hPa Dew point August 2019 (Bluer, lower dew point = wet) ww_situ7008.gif 700hPa Vertical wind January 2019 (red is upflow, blue is down) ww_vvl7001.gif 700hPa Vertical wind August 2019 (red is upflow, blue is down) ww_vvl7008.gif

Breaking weather map January 2019 ww201901.gif Breaking weather map August 2019 ww201908.gif

Summary

This time it has become very long, but I posted up to the visualization of meteorological data that is the input for machine learning. Next time, I will post about how to extract fronts from breaking weather maps, which are teacher data for machine learning.

[Next time: Let's draw a "weather map-like front" by machine learning based on weather data (3)](https://qiita.com/m-taque/items/4d5bb45e6b5dc42dc833 "Based on weather data," Let's draw a "weather map-like front" by machine learning (3) ")

Addendum

How to identify the parameterName from the GRIB2 file

It's a bit muddy, but it opens the GRIB2 file and lists the data it contains.

>>> import pygrib
>>> grbs=pygrib.open("Z__C_RJTD_20181209000000_GSM_GPV_Rgl_FD0000_grib2.bin")
>>> for grb in grbs:
...     grb
... 
1:Pressure reduced to MSL:Pa (instant):regular_ll:meanSea:level 0:fcst time 0 hrs:from 201812090000
2:Surface pressure:Pa (instant):regular_ll:surface:level 0:fcst time 0 hrs:from 201812090000
3:10 metre U wind component:m s**-1 (instant):regular_ll:heightAboveGround:level 10 m:fcst time 0 hrs:from 201812090000
4:10 metre V wind component:m s**-1 (instant):regular_ll:heightAboveGround:level 10 m:fcst time 0 hrs:from 201812090000
5:2 metre temperature:K (instant):regular_ll:heightAboveGround:level 2 m:fcst time 0 hrs:from 201812090000
6:2 metre relative humidity:% (instant):regular_ll:heightAboveGround:level 2 m:fcst time 0 hrs:from 201812090000
7:Low cloud cover:% (instant):regular_ll:surface:level 0:fcst time 0 hrs:from 201812090000
8:Medium cloud cover:% (instant):regular_ll:surface:level 0:fcst time 0 hrs:from 201812090000
9:High cloud cover:% (instant):regular_ll:surface:level 0:fcst time 0 hrs:from 201812090000
10:Total cloud cover:% (instant):regular_ll:surface:level 0:fcst time 0 hrs:from 201812090000
11:Geopotential Height:gpm (instant):regular_ll:isobaricInhPa:level 100000.0 Pa:fcst time 0 hrs:from 201812090000
12:U component of wind:m s**-1 (instant):regular_ll:isobaricInhPa:level 100000.0 Pa:fcst time 0 hrs:from 201812090000
13:V component of wind:m s**-1 (instant):regular_ll:isobaricInhPa:level 100000.0 Pa:fcst time 0 hrs:from 201812090000

(Omitted)

98:Vertical velocity:Pa s**-1 (instant):regular_ll:isobaricInhPa:level 2000.0 Pa:fcst time 0 hrs:from 201812090000
99:Geopotential Height:gpm (instant):regular_ll:isobaricInhPa:level 1000.0 Pa:fcst time 0 hrs:from 201812090000
100:U component of wind:m s**-1 (instant):regular_ll:isobaricInhPa:level 1000.0 Pa:fcst time 0 hrs:from 201812090000
101:V component of wind:m s**-1 (instant):regular_ll:isobaricInhPa:level 1000.0 Pa:fcst time 0 hrs:from 201812090000
102:Temperature:K (instant):regular_ll:isobaricInhPa:level 1000.0 Pa:fcst time 0 hrs:from 201812090000
103:Vertical velocity:Pa s**-1 (instant):regular_ll:isobaricInhPa:level 1000.0 Pa:fcst time 0 hrs:from 201812090000

Here, for example, to get the paramaterName of the 100th record (it seems to be messages in GRIB),

>>> f=grbs[100]
>>> f['parameterName']
'u-component of wind'

You can refer to it by specifying parameterName for the key.

pygrib documentation If you look at, the first field after listing is originally a parameter called name, so it looks like grb = grbs.select (name ='U component of wind') [0]. It seems to be used to take it out.

However, at one point, I encountered a message in which the name was not set, and as a result of various searches, I arrived at parameterName. I haven't encountered a message that doesn't have this set so far.

As an aside, the list of keys that each message has can be retrieved as follows.

>>> f.keys()
['globalDomain', 'GRIBEditionNumber', 'tablesVersionLatest', 'grib2divider', 'is_efas', 'angleSubdivisions', 'missingValue', 'ieeeFloats', 'isHindcast', 'section0Length', 'identifier', 'discipline', 'editionNumber', 'totalLength', 'sectionNumber', 'section1Length', 'numberOfSection', 'centre', 'centreDescription', 'subCentre', 'tablesVersion', 'masterDir', 'localTablesVersion', 'significanceOfReferenceTime', 'year', 'month', 'day', 'hour', 'minute', 'second', 'dataDate', 'julianDay', 'dataTime', 'productionStatusOfProcessedData', 'typeOfProcessedData', 'md5Section1', 'selectStepTemplateInterval', 'selectStepTemplateInstant', 'stepType', 'is_chemical', 'is_chemical_distfn', 'is_aerosol', 'is_aerosol_optical', 'setCalendarId', 'deleteCalendarId', 'is_uerra', 'sectionNumber', 'grib2LocalSectionPresent', 'deleteLocalDefinition', 'sectionNumber', 'gridDescriptionSectionPresent', 'section3Length', 'numberOfSection', 'sourceOfGridDefinition', 'numberOfDataPoints', 'numberOfOctectsForNumberOfPoints', 'interpretationOfNumberOfPoints', 'PLPresent', 'gridDefinitionTemplateNumber', 'gridDefinitionDescription', 'shapeOfTheEarth', 'scaleFactorOfRadiusOfSphericalEarth', 'scaledValueOfRadiusOfSphericalEarth', 'scaleFactorOfEarthMajorAxis', 'scaledValueOfEarthMajorAxis', 'scaleFactorOfEarthMinorAxis', 'scaledValueOfEarthMinorAxis', 'radius', 'Ni', 'Nj', 'basicAngleOfTheInitialProductionDomain', 'mBasicAngle', 'angleMultiplier', 'mAngleMultiplier', 'subdivisionsOfBasicAngle', 'angleDivisor', 'latitudeOfFirstGridPoint', 'longitudeOfFirstGridPoint', 'resolutionAndComponentFlags', 'resolutionAndComponentFlags1', 'resolutionAndComponentFlags2', 'iDirectionIncrementGiven', 'jDirectionIncrementGiven', 'uvRelativeToGrid', 'resolutionAndComponentFlags6', 'resolutionAndComponentFlags7', 'resolutionAndComponentFlags8', 'ijDirectionIncrementGiven', 'latitudeOfLastGridPoint', 'longitudeOfLastGridPoint', 'iDirectionIncrement', 'jDirectionIncrement', 'scanningMode', 'iScansNegatively', 'jScansPositively', 'jPointsAreConsecutive', 'alternativeRowScanning', 'iScansPositively', 'scanningMode5', 'scanningMode6', 'scanningMode7', 'scanningMode8', 'g2grid', 'latitudeOfFirstGridPointInDegrees', 'longitudeOfFirstGridPointInDegrees', 'latitudeOfLastGridPointInDegrees', 'longitudeOfLastGridPointInDegrees', 'iDirectionIncrementInDegrees', 'jDirectionIncrementInDegrees', 'latLonValues', 'latitudes', 'longitudes', 'distinctLatitudes', 'distinctLongitudes', 'gridType', 'md5Section3', 'sectionNumber', 'section4Length', 'numberOfSection', 'NV', 'neitherPresent', 'productDefinitionTemplateNumber', 'genVertHeightCoords', 'parameterCategory', 'parameterNumber', 'parameterUnits', 'parameterName', 'typeOfGeneratingProcess', 'backgroundProcess', 'generatingProcessIdentifier', 'hoursAfterDataCutoff', 'minutesAfterDataCutoff', 'indicatorOfUnitOfTimeRange', 'stepUnits', 'forecastTime', 'startStep', 'endStep', 'stepRange', 'stepTypeInternal', 'validityDate', 'validityTime', 'typeOfFirstFixedSurface', 'unitsOfFirstFixedSurface', 'nameOfFirstFixedSurface', 'scaleFactorOfFirstFixedSurface', 'scaledValueOfFirstFixedSurface', 'typeOfSecondFixedSurface', 'unitsOfSecondFixedSurface', 'nameOfSecondFixedSurface', 'scaleFactorOfSecondFixedSurface', 'scaledValueOfSecondFixedSurface', 'pressureUnits', 'typeOfLevel', 'level', 'bottomLevel', 'topLevel', 'tempPressureUnits', 'paramIdECMF', 'paramId', 'shortNameECMF', 'shortName', 'unitsECMF', 'units', 'nameECMF', 'name', 'cfNameECMF', 'cfName', 'cfVarNameECMF', 'cfVarName', 'modelName', 'ifsParam', 'PVPresent', 'deletePV', 'md5Section4', 'lengthOfHeaders', 'md5Headers', 'sectionNumber', 'section5Length', 'numberOfSection', 'numberOfValues', 'dataRepresentationTemplateNumber', 'packingType', 'referenceValue', 'referenceValueError', 'binaryScaleFactor', 'decimalScaleFactor', 'optimizeScaleFactor', 'bitsPerValue', 'typeOfOriginalFieldValues', 'md5Section5', 'sectionNumber', 'section6Length', 'numberOfSection', 'bitMapIndicator', 'bitmapPresent', 'md5Section6', 'sectionNumber', 'section7Length', 'numberOfSection', 'codedValues', 'values', 'packingError', 'unpackedError', 'maximum', 'minimum', 'average', 'numberOfMissing', 'standardDeviation', 'skewness', 'kurtosis', 'isConstant', 'changeDecimalPrecision', 'decimalPrecision', 'setBitsPerValue', 'getNumberOfValues', 'scaleValuesBy', 'offsetValuesBy', 'productType', 'md5Section7', 'section8Length', 'analDate', 'validDate']

Although it is not used in this front drawing, it is the parameterName used when visualizing MSM.

Specified parameter Contents
Pressure reduced to MSL Sea level correction pressure
Temperature temperature
Relative humidity Relative humidity
Vertical velocity [pressure] Vertical velocity (barometric pressure coordinates)
u-component of wind East-west component of wind speed
v-component of wind North-south component of wind speed
Geopotential height Geopotential height
Total precipitation Precipitation
Downward short-wave radiation flux Downward shortwave radiation
Low cloud cover Lower cloud cloud amount
Medium cloud cover Middle cloud cover
High cloud cover Upper cloud cloud amount
Total cloud cover Total cloud cover

Recommended Posts

Try to draw a "weather map-like front" by machine learning based on weather data (5)
Try to draw a "weather map-like front" by machine learning based on weather data (3)
Try to draw a "weather map-like front" by machine learning based on weather data (1)
Try to draw a "weather map-like front" by machine learning based on weather data (4)
Try to draw a "weather map-like front" by machine learning based on weather data (2)
Try to forecast power demand by machine learning
A story about data analysis by machine learning
Machine learning beginners try to make a decision tree
Try to draw a Bezier curve
How to collect machine learning data
Try to make a blackjack strategy by reinforcement learning ((1) Implementation of blackjack)
Search for technical blogs by machine learning focusing on "easiness to understand"
Try to predict the value of the water level gauge by machine learning using the open data of Data City Sabae
[Machine learning] Create a machine learning model by performing transfer learning with your own data set
Try to draw a life curve with python
Notes on machine learning (updated from time to time)
Try to create a new command on linux
Try to make a blackjack strategy by reinforcement learning (② Register the environment in gym)
Build a machine learning Python environment on Mac OS
Try to predict forex (FX) with non-deep machine learning
Time series data prediction by AutoML (automatic machine learning)
[Machine learning] Try to detect objects using Selective Search
xgboost: A valid machine learning model for table data
An introduction to machine learning from a simple perceptron
Build a machine learning environment natively on Windows 10 (x64)
How to interactively draw a machine learning pipeline with scikit-learn and save it in HTML
Data visualization with Python-It's too convenient to draw a graph by attribute with "Facet" at once
Try to make a blackjack strategy by reinforcement learning (③ Reinforcement learning in your own OpenAI Gym environment)
Introduction to machine learning
Build a python machine learning study environment on macOS sierra
Build a machine learning environment on mac (pyenv, deeplearning, opencv)
Try to build a deep learning / neural network with scratch
Try to evaluate the performance of machine learning / regression model
Collect machine learning data by scraping from bio-based public databases
Introduction to Machine Learning with scikit-learn-From data acquisition to parameter optimization
Made icrawler easier to use for machine learning data collection
Try to evaluate the performance of machine learning / classification model
Dockerfile for creating a data science environment based on pip3
Machine learning beginners try to reach out to Naive Bayes (2) --Implementation
Create AI to identify Zuckerberg's face by deep learning ③ (Data learning)
Try to predict if tweets will burn with machine learning
Machine learning environment settings based on Python 3 on Mac (coexistence with Python 2)
Machine learning beginners try to reach out to Naive Bayes (1) --Theory
Using open data from Data City Sabae to predict water level gauge values by machine learning Part 2
I was frustrated by Kaggle, so I tried to find a good rental property by scraping & machine learning
How to quickly create a machine learning environment using Jupyter Notebook on macOS Sierra with anaconda