Skip to content

Commit

Permalink
Fall back to generic GRIB2 template. Fixes #39.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexamici committed Jan 1, 2019
1 parent 10c2b14 commit 90c8106
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions cfgrib/xarray_to_grib.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright 2017-2018 European Centre for Medium-Range Weather Forecasts (ECMWF).
# Copyright 2017-2019 European Centre for Medium-Range Weather Forecasts (ECMWF).
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -133,7 +133,8 @@ def detect_sample_name(grib_keys, sample_name_template='{geography}_{vertical}_g
if grib_keys['gridType'] in GRID_TYPES:
geography = grib_keys['gridType']
else:
raise NotImplementedError("Unsupported 'gridType': %r" % grib_keys['gridType'])
LOGGER.info("unknown 'gridType': %r. Using GRIB2 template", grib_keys['gridType'])
return 'GRIB2'

if grib_keys['typeOfLevel'] in TYPE_OF_LEVELS_PL:
vertical = 'pl'
Expand All @@ -142,7 +143,8 @@ def detect_sample_name(grib_keys, sample_name_template='{geography}_{vertical}_g
elif grib_keys['typeOfLevel'] in TYPE_OF_LEVELS_ML:
vertical = 'ml'
else:
raise NotImplementedError("Unsupported 'typeOfLevel': %r" % grib_keys['typeOfLevel'])
LOGGER.info("unknown 'typeOfLevel': %r. Using GRIB2 template", grib_keys['typeOfLevel'])
return 'GRIB2'

sample_name = sample_name_template.format(**locals())
return sample_name
Expand Down

0 comments on commit 90c8106

Please sign in to comment.