3
$\begingroup$

While reading the SMAP data (grib format) using xarray with cfgrib as engine, the variable is shown as unknown and the longitude of the data has a value of around 539 which shouldn't be possible. I assume the variable being identified as `Unknown may be due to the missing grib table for the SMAP data. Summary of data read using xarray is given below:

<xarray.Dataset>
Dimensions:     (latitude: 1920, longitude: 2560)

Coordinates:
    time        datetime64[ns] ...
    step        timedelta64[ns] ...
    level       float64 ...
  * latitude    (latitude) float64 -89.95 -89.86 -89.77 ... 89.77 89.86 89.95
  * longitude   (longitude) float64 -179.9 -179.8 -179.6 ... 179.6 179.8 539.9
    valid_time  datetime64[ns] ...
Data variables:
    unknown     (latitude, longitude) float32 ...
Attributes:
    GRIB_edition:            2
    GRIB_centre:             consensus
    GRIB_centreDescription:  Consensus
    GRIB_subCentre:          65535
    Conventions:             CF-1.7
    institution:             Consensus
    history:                 2023-01-17T14:45 GRIB to CDM+CF via cfgrib-0.9.1...

The output of wgrib2 is given below:

** WARNING input Code Table 4.3 = 255 (undefined) for 20150402_20150404_anom1.grb2 **
1:0:d=1970010100:var discipline=1 master_table=2 parmcat=255 parm=255:reserved:anl:
$\endgroup$

1 Answer 1

3
$\begingroup$

It seems like the GRIB format is being used to distribute the data (probably for storage, ease of processing?), while satellite SMAP doesn't fit under the GRIB standard (see available parameters supported in the GRIB standard here). This is why the input code is 255 (i.e. "missing").

I downloaded the file 20150402_20150404_anom1.grb2 and opened in Python using xarray 0.18.2 with cfgrib 0.9.10.1. I cannot see the anomalous longitude.

<xarray.Dataset>
Dimensions:     (latitude: 1920, longitude: 2560)
Coordinates:
    time        datetime64[ns] 1970-01-01
    step        timedelta64[ns] 00:00:00
    level       float64 0.0
  * latitude    (latitude) float64 -89.95 -89.86 -89.77 ... 89.77 89.86 89.95
  * longitude   (longitude) float64 -179.9 -179.8 -179.6 ... 179.6 179.8 179.9
    valid_time  datetime64[ns] 1970-01-01
Data variables:
    unknown     (latitude, longitude) float32 nan nan nan nan ... nan nan nan
Attributes:
    GRIB_edition:            2
    GRIB_centre:             consensus
    GRIB_centreDescription:  Consensus
    GRIB_subCentre:          65535
    Conventions:             CF-1.7
    institution:             Consensus
    history:                 2023-01-17T15:53 GRIB to CDM+CF via cfgrib-0.9.1...

You can read and process the data in Python in any case using 'unknown' as the variable name:

ds = xr.open_dataset(...)
smap = ds.variables['unknown']
lon = ds.variables['longitude']
lat = ds.variables['latitude']

2

$\endgroup$
3
  • $\begingroup$ My xarray version is 2022.12.0 where the anomalous longitude value appears. The problem disappears when downgraded to 0.18.2. $\endgroup$
    – irok94
    Jan 18, 2023 at 9:04
  • $\begingroup$ Notice that time stamps are incorrect in xarray and wgrib outputs. Is there anyway fix the time issue? $\endgroup$
    – irok94
    Jan 19, 2023 at 8:41
  • $\begingroup$ Data in the grib files contain 3-day composites with start and end dates provided in the filename. Which is probably why the timestamp in the grib is 'incorrect', as there is only one 2D array. I would use cdo if you really wanted to change the timestamp in the file:cdo settaxis,2015-04-02,00:00,1day 20150402_20150404_anom1.grb2 out.grb2 $\endgroup$ Jan 19, 2023 at 15:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.