Skip to content

Commit

Permalink
Scan meteosat satellite name and channel information. refs: #268
Browse files Browse the repository at this point in the history
  • Loading branch information
spanezz committed Jun 4, 2021
1 parent 290d0f5 commit 5cfef94
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 4 deletions.
37 changes: 37 additions & 0 deletions conf/scan/grib2.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,29 @@
import datetime


METEOSAT_NAMES = {
55: "MSG1",
56: "MSG2",
57: "MSG3",
70: "MSG4",
}

METEOSAT_CHAN_NAMES = {
6: "VIS006",
8: "VIS008",
16: "IR016",
39: "IR039",
62: "WV062",
73: "WV073",
87: "IR087",
97: "IR907",
108: "IR108",
120: "IR120",
134: "IR134",
7: "HRV",
}


def scan_grib2(grib, md):
# Reference time
md["reftime"] = {
Expand Down Expand Up @@ -190,6 +213,20 @@ def scan_grib2(grib, md):
grib["scaledValueOfUpperLimit"],
)

if grib["satelliteSeries"] == 333:
# Meteosat satellites
sat_name = METEOSAT_NAMES.get(grib["satelliteNumber"])
if sat_name is not None:
proddef["sat"] = sat_name

if grib["instrumentType"] == 207:
# Data from the SEVIRI instrument
ch_name = METEOSAT_CHAN_NAMES.get(
int(round(10 * 1.0 / (grib["scaledValueOfCentralWaveNumber"] * 0.000001)))
)
if ch_name is not None:
proddef["ch"] = ch_name

md["proddef"] = {
"style": "GRIB",
"value": proddef,
Expand Down
8 changes: 4 additions & 4 deletions python/tests/test_scan_grib.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ def test_meteosat(self):
self.assertEqual(md["level"], "GRIB2S( -, -, -)")
self.assertNotIn("timerange", md)
self.assertEqual(md["area"], "GRIB(tn=90)")
self.assertEqual(md["proddef"], "GRIB(tod=0,sat=MSG4,ch=IR016)")
self.assertEqual(md["proddef"], "GRIB(ch=IR016, sat=MSG4, tod=0)")
self.assertEqual(md["reftime"], "2020-02-23T11:00:00Z")
self.assertEqual(md["run"], "MINUTE(11:00)")

Expand All @@ -423,7 +423,7 @@ def test_meteosat(self):
self.assertEqual(md["level"], "GRIB2S( -, -, -)")
self.assertNotIn("timerange", md)
self.assertEqual(md["area"], "GRIB(tn=90)")
self.assertEqual(md["proddef"], "GRIB(tod=0,sat=MSG4,ch=IR039)")
self.assertEqual(md["proddef"], "GRIB(ch=IR039, sat=MSG4, tod=0)")
self.assertEqual(md["reftime"], "2020-02-23T11:00:00Z")
self.assertEqual(md["run"], "MINUTE(11:00)")

Expand All @@ -435,7 +435,7 @@ def test_meteosat(self):
self.assertEqual(md["level"], "GRIB2S( -, -, -)")
self.assertNotIn("timerange", md)
self.assertEqual(md["area"], "GRIB(tn=90)")
self.assertEqual(md["proddef"], "GRIB(tod=0,sat=MSG4,ch=VIS006)")
self.assertEqual(md["proddef"], "GRIB(ch=VIS006, sat=MSG4, tod=0)")
self.assertEqual(md["reftime"], "2020-02-23T11:00:00Z")
self.assertEqual(md["run"], "MINUTE(11:00)")

Expand All @@ -447,6 +447,6 @@ def test_meteosat(self):
self.assertEqual(md["level"], "GRIB2S( -, -, -)")
self.assertNotIn("timerange", md)
self.assertEqual(md["area"], "GRIB(tn=90)")
self.assertEqual(md["proddef"], "GRIB(tod=0,sat=MSG4,ch=WV062)")
self.assertEqual(md["proddef"], "GRIB(ch=WV062, sat=MSG4, tod=0)")
self.assertEqual(md["reftime"], "2020-02-23T11:00:00Z")
self.assertEqual(md["run"], "MINUTE(11:00)")

0 comments on commit 5cfef94

Please sign in to comment.