spidru / jgribx Goto Github PK
View Code? Open in Web Editor NEWJava GRIB-1/GRIB-2 decoder
License: MIT License
Java GRIB-1/GRIB-2 decoder
License: MIT License
Hi
I tried to add this library in my android app to read the Grib file.
0.5.0 have to jar files so i download the 0.4 version jar file and add it to my libs folder.
GribFile gribFile = new GribFile("filename.grb"); // typically .grb or .grb2 extension
gives error and there is nothing to import.
How to use this library on my app, Thanks
Binu
Lambert Conformal (Can be Secant, Tangent, Conical, or Bipolar) is the now the U.S. National standard. It would be quite helpful to be able to decode that grid template.
https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/grib2_temp3-30.shtml
Are there any plans to support this format?
Currently this library supports only "Grid Point Data - Complex Packing and Spatial Differencing". It would be useful to support more than this one to enable reading GRIB2 files from e.g. NOMAD which use "Grid Point Data - Simple Packing".
Documentation can be found: https://www.yumpu.com/en/document/view/11723135/guide-to-wmo-table-driven-code-forms
The "Grid Point Data - Simple Packing" is rather simple. "Grid Point Data - Complex Packing" is more complex but as it is a base for the already implemented "Grid Point Data - Complex Packing and Spatial Differencing" this should also be feasable.
Hello.
I currently pull my grib2 data from https://tgftp.nws.noaa.gov/SL.us008001/ST.opnl/MT.gfs_CY.00/RD.20220705/PT.grid_DF.gr2/. When I put this data into a GribFile, I get the NoValidGribException. I am using the current version of the JGribX.jar. After downloading one of these records from this url, I also checked using java -jar JGribX.jar -i grib2.grb and I get the same NoValidGribException. Can you please tell me what is wrong with this data?
Thank you.
Exception in thread "main" java.lang.NullPointerException
at mt.edu.um.cf2.jgribx.grib1.Grib1RecordBDS.getValue(Grib1RecordBDS.java:276)
at mt.edu.um.cf2.jgribx.grib1.Grib1Record.getValue(Grib1Record.java:296)
Hi.
I downloaded the actual source code (commit 0e5b8c3 and try to build it with gradle on Intellij. When doing it, all two thirdof the tests failed due to NoValidGribException
. Here is the compilation output on Intellij console :
15:52:50: Executing task 'build'...
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:jar UP-TO-DATE
:assemble UP-TO-DATE
:compileTestJava UP-TO-DATE
:processTestResources UP-TO-DATE
:testClasses UP-TO-DATE
:test
mt.edu.um.cf2.jgribx.GribTest > testVersion STARTED
mt.edu.um.cf2.jgribx.GribTest > testVersion PASSED
mt.edu.um.cf2.jgribx.GribTest > testGrib1Gfs3 STARTED
mt.edu.um.cf2.jgribx.GribTest > testGrib1Gfs3 FAILED
mt.edu.um.cf2.jgribx.NoValidGribException at GribTest.java:58
mt.edu.um.cf2.jgribx.GribTest > testGrib2Gfs3 STARTED
mt.edu.um.cf2.jgribx.GribTest > testGrib2Gfs3 FAILED
mt.edu.um.cf2.jgribx.NoValidGribException at GribTest.java:163
3 tests completed, 2 failed
:test FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':test'.
> There were failing tests. See the report at: file:///C:/Users/amerat/Downloads/JGribX-master/JGribX-master/build/reports/tests/test/index.html
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 2s
6 actionable tasks: 1 executed, 5 up-to-date
15:52:54: Task execution finished 'build'.
I thought it was due to corrupted GRIB files in your repository, but when I try with my own and with the JAR I built from the actual code (not your release), it fails too giving me this error :
mt.edu.um.cf2.jgribx.NoValidGribException: No valid GRIB records found.
at mt.edu.um.cf2.jgribx.GribFile.<init>(GribFile.java:138)
at mt.edu.um.cf2.jgribx.GribFile.<init>(GribFile.java:80)
at mt.edu.um.cf2.jgribx.GribFile.<init>(GribFile.java:63)
The GRIB2 file I use is not corrupted, I can open it in Nasa's Panoply GUI Software without any error. Reading your GribFile.java:138, it looks like the code is seeing an empty record whereas it is not.
In my GRIB2 file, there's only one data Temperature_height_above_ground
at only one timestamp 2021-10-12 14:00+0000
and height 2.00000 m
, thus I wrote the code below.
Please note that the GRIB2 data is first acquired by a client API so that's why it's first held by a variable bytes
which type is Array[Byte]
. Before using your library I write the GRIB2 data to a file and then pass it's path to the GribFile
constructor. This part of the code works fine, I can open the created file in Nasa's Panoply.
import mt.edu.um.cf2.jgribx._
import java.util.Calendar
import java.util.GregorianCalendar
val path: String = "mf-data.grb2"
val file: File = new File(path)
FileUtils.writeByteArrayToFile(file, bytes)
val gribFile: GribFile = new GribFile(path)
val date: Calendar = new GregorianCalendar(2021, Calendar.OCTOBER, 12, 14, 0, 0)
val parameter: String = "TMP"
val ltvid: String = "TGL:2" // TGL = "specified height level above ground" & 2 = 2 meters
val lat: Double = 50.7
val lon: Double = 362.29
val record: GribRecord = gribFile.getRecord(date, parameter, ltvid)
val value: Double = record.getValue(lat, lon)
println("Value at (" + lat + ", " + lon + ") : " + value + "\n")
Thanks.
When I try to read a grab file, I get "Records successfully read: 1 of 195". What does "RecordsSkipped" mean?
I have GRB1 file with SFC level, but without level value.
if (matcher.find())
is falserecord.getLevelValues()[0]
is NaNException in thread "main" java.lang.NumberFormatException: null at java.lang.Integer.parseInt(Integer.java:542) at java.lang.Integer.parseInt(Integer.java:615) at mt.edu.um.cf2.jgribx.GribFile.getRecord(GribFile.java:364)
Hello.
You have recently updated the jgribx.jar to handle the following data: https://tgftp.nws.noaa.gov/SL.us008001/ST.opnl/MT.gfs_CY.00/RD.20220705/PT.grid_DF.gr2/.
Now I am having issues with NAM and RAP data:
https://tgftp.nws.noaa.gov/SL.us008001/ST.opnl/MT.rap_CY.06/RD.20220725/PT.grid_DF.gr2/ - for RAP and https://tgftp.nws.noaa.gov/SL.us008001/ST.opnl/MT.nam_AR.ak_CY.06/RD.20220725/PT.grid_DF.gr2/ for NAM
For the RD.20220725 above- please update to the current date to see data for that day.
When I put this data into a GribFile, I get the NoValidGribException. I am using the current version of the JGribX.jar. After downloading one of these records from this url, I also checked using java -jar JGribX.jar -i grib2.grb and I get the same NoValidGribException. Can you please tell me what is wrong with this data?
Thank you so much for helping with decoding GFS - hopefully it will not be a big issue for RAP and NAM.
Christine
Otherwise every use should compile it by himself.
See https://docs.gradle.org/current/userguide/publishing_maven.html
https://maven.apache.org/repository/guide-central-repository-upload.html
It means create "java" folder under "main"
Otherwise gradle build creates empty jar
I am trying to load an GFS grib2 file with this library. Unfortunately I get a NullPointerException while calling
GribFile gribFile = new GribFile(gribPath);
as following:
java.lang.NullPointerException at mt.edu.um.cf2.jgribx.grib2.Grib2RecordPDS.getLevelCode(Grib2RecordPDS.java:313) at mt.edu.um.cf2.jgribx.grib2.Grib2Record.getLevelCode(Grib2Record.java:121) at mt.edu.um.cf2.jgribx.GribFile.<init>(GribFile.java:127) at mt.edu.um.cf2.jgribx.GribFile.<init>(GribFile.java:80) at mt.edu.um.cf2.jgribx.GribFile.<init>(GribFile.java:63)
I've downloaded various files from NOAA GFS to test the import, but still the same exception.
I would appreciate any help, thanks in advance.
Hi i cant read this grib file. Can you please check it
https://github.com/spidru/JGribX/files/8329778/global-wind-wave.zip
Here is the grib record output.
GRIB record:
IS section:
Grib Edition 1
length: 209505 bytes
PDS header:
center: 0
subcenter: 0
table: 255
grid_id: 255
time: 22.3.2022 0:0 (dd.mm.yyyy hh:mm)
Type: missing
Description: missing parameter
Unit:
table version: 255
Level description:
parameter id: 1
name: ground or water surface
description: ground or water surface
units:
short descr: SFC
increasing up?: true
single layer?: true
value1: NaN
value2: NaN
dec.scale: 0
GDS exists
BMS exists
GDS section:
LatLon Grid (366x367)
lon: 61.2 to 97.7 (dx 0.1)
lat: -7.7 to 28.9 (dy 0.1)
BMS section:
bitmap length: 134322
BDS section:
min/max value: -1.6407833 1.4991093
ref. value: -1.6407833
is a constant: false
bin. scale: -14
num bits: 16
Can you please make a new release JAR with new commits since 2019. I need the new improvements made since then.
Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.