Mean Sea Level Pressure & Wind Speed at 850 hPa

Note: this notebook is lightly modified from an existing ECMWF notebook. See the original ECMWF notebook example.

Retrieve Data

This product takes in input 3 parameters :

In this example, we will use:

  • cdsapi Client to download the data

  • ecmwf.data library to read and process the data

  • magpye to plot the result


Load required libraries

import cdsapi
import ecmwf.data as ecdata
from magpye import GeoMap

[OPTIONAL] Specify URL and Atmosphere Data Store key

This step is optional as we have already downloaded the data for you.

URL='https://ads.atmosphere.copernicus.eu/api/v2'
KEY='######################################'

CAMS global atmospheric composition forecasts

[OPTIONAL] Retrieve CAMS global atmospheric composition forecasts from the Atmosphere Data Store

This step is optional as we have already downloaded the data for you. The following two code blocks have been commented out as a result.

Link: https://ads.atmosphere.copernicus.eu/cdsapp#!/dataset/cams-global-atmospheric-composition-forecasts?tab=overview

Variables: Mean sea level pressure, 10m u-component of wind, 10m v-component of wind
Type: Forecasts
Resolution: 0.4 deg x 0.4 deg

'''
c = cdsapi.Client(url=URL, key=KEY)

c.retrieve(
    'cams-global-atmospheric-composition-forecasts',
    {
        'date': '2021-08-05/2021-08-05',
        'type': 'forecast',
        'format': 'grib',
        'time': '00:00',
        'variable': [
            'u_component_of_wind', 'v_component_of_wind',
        ],
        'leadtime_hour': '12',
        'pressure_level': '850',
    },
    './20210805_cams_forecast_wind850.grib')
'''
'''
c.retrieve(
    'cams-global-atmospheric-composition-forecasts',
    {
        'date': '2021-08-05/2021-08-05',
        'type': 'forecast',
        'format': 'grib',
        'time': '00:00',
        'variable': 'mean_sea_level_pressure',
        'leadtime_hour': '12',
    },
    './20210805_cams_forecast_mslp.grib')
'''
pl_filename = '../data/cams/2021/20210805_cams_forecast_wind850.grib'
sfc_filename = '../data/cams/2021/20210805_cams_forecast_mslp.grib'

Reading and processing the data

Now we can use ecmwf.data to read the files.

wind850 = ecdata.read(pl_filename)
msl = ecdata.read(sfc_filename)

The describe() function will give us the overview of the dataset.

wind850.describe()
parametertypeOfLevelleveldatetimestepparamIdclassstreamtypeexperimentVersionNumber
uisobaricInhPa85020210805012131mcoperfc0001
visobaricInhPa85020210805012132mcoperfc0001

And an overview of one parameter, where we can see more information, such as units or type of level.

msl.describe('msl')
shortNamemsl
nameMean sea level pressure
paramId151
unitsPa
typeOfLevelsurface
level0
date20210805
time0
step12
classmc
streamoper
typefc
experimentVersionNumber0001

We can use ls() function to list all the fields in the file we downloaded.

wind850.ls()
centre shortName typeOfLevel level dataDate dataTime stepRange dataType gridType
Message
0 ecmf u isobaricInhPa 850 20210805 0 12 fc regular_ll
1 ecmf v isobaricInhPa 850 20210805 0 12 fc regular_ll

In order to calculate the speed, we need to filter out u and v component and use the speed() function for the calculation.

u = wind850.select(shortName ='u')
v = wind850.select(shortName ='v')
speed = ecdata.speed(u,v)
speed.describe()
parametertypeOfLevelleveldatetimestepparamIdclassstreamtypeexperimentVersionNumber
wsisobaricInhPa8502021080501210mcoperfc0001

Mean sea level pressure data has unites Pa, but we want to plot it in hPa, therefore we need to convert it.

msl /= 100

Plotting the data

And finally, we can plot the data on the map.

fig = GeoMap(area_name='europe')

fig.coastlines(land_colour="cream",resolution="medium")

fig.contour_shaded(speed, style="green_speed")
fig.contour_lines(msl, style="black_i5")

fig.coastlines(resolution="medium")
fig.gridlines()

fig.title(["Mean sea level pressure and wind speed at 850 hPa", 
           "START TIME: <grib_info key='base-date' format='%a %d %B %Y %H' where='shortName=msl'/> ",
           "VALID TIME: <grib_info key='valid-date' format='%a %d %B %Y %H' where='shortName=msl'/>, STEP: <grib_info key='step' where='shortName=msl' />"])
fig.legend()
fig.footer("© European Centre for Medium-Range Weather Forecasts (ECMWF) Source: www.ecmwf.int Licence: CC-BY-4.0 and ECMWF Terms of Use (https://apps.ecmwf.int/datasets/licences/general/)", logo='ecmwf')
fig.show()
../_images/figure6_CAMS_mslp_wind850_31_0.png

References

Return to the case study

Assessing pre-fire risk with next-generation satellites: Mediterranean Fires Case Study
Mean sea level pressure and wind speed at 850 hPa