cambecc / grib2json

converts GRIB2 files to JSON
MIT License
357 stars 154 forks source link

Not a valid CDM file #33

Open gustavost26 opened 5 years ago

gustavost26 commented 5 years ago

I downloaded the following gfs.t00z.pgrb2.1p00.f000 config file shown in github.

But when executing the following command: sh grib2json -d -n -o current-wind-surface-level-gfs-1.0.json gfs.t00z.pgrb2.1p00.f000

And presenting the following error:

java.io.IOException: java.io.IOException: Cant read gfs.t00z.pgrb2.1p00.f000: not a valid CDM file. at ucar.nc2.NetcdfFile.open(NetcdfFile.java:425) at ucar.nc2.NetcdfFile.open(NetcdfFile.java:392) at ucar.nc2.NetcdfFile.open(NetcdfFile.java:379) at ucar.nc2.NetcdfFile.open(NetcdfFile.java:367) at net.nullschool.grib2json.Grib2Json.write(Grib2Json.java:114) at net.nullschool.grib2json.Launcher.main(Launcher.java:75) Caused by: java.io.IOException: Cant read gfs.t00z.pgrb2.1p00.f000: not a valid CDM file. at ucar.nc2.NetcdfFile.open(NetcdfFile.java:803) at ucar.nc2.NetcdfFile.open(NetcdfFile.java:422) ... 5 more

I noticed that the file I downloaded according to the github tutorial does not have the extension .grb2

How do I download a file with this extension for possible conversion to json?

Sources: https://github.com/cambecc/earth https://github.com/cambecc/grib2json

gustavost26 commented 5 years ago

I downloaded the correct file to convert to json through this page: https://nomads.ncep.noaa.gov/cgi-bin/filter_gfs_1p00.pl http://nomads.ncep.noaa.gov/cgi-bin/filter_gfs_1p00.pl?dir=%2Fgfs.2018122700

DeZhao-Zhang commented 5 years ago

have you solve this problem?I have the same problem

gustavost26 commented 5 years ago

@Rhettydl If you are having this error, it is quite possible that you are trying to convert an invalid file.

Download a valid file through this site: https://nomads.ncep.noaa.gov/cgi-bin/filter_gfs_1p00.pl

denx-b commented 5 years ago

The error "Not a valid CDM file" occurs when a square is selected incorrectly. You can get the minimal possible and correct square as follows:

lon = 54.941036
lat = 20.153401

if (lon < 0):
    lon += 360

leftLongitude = round(lon / 0.5) * 0.5
rightLongitude = leftLongitude + 0.25
topLatitude = round(lat / 0.5) * 0.5
bottomLatitude = topLatitude - 0.25

print(leftLongitude, rightLongitude)
print(topLatitude, bottomLatitude)