Git Product home page Git Product logo

Comments (2)

mnlerman avatar mnlerman commented on June 20, 2024

Hello, I was able to run the code that you provided and I can see that rawValue.readScalarInt() throwing an UnsupportedOperationException is the expected behavior in this case. According to the docs:

readScalarInt throws UnsupportedOperationException - if not a scalar Variable or one-dimensional of length 1.

rawValue contains a one-dimensional array of length 2 [12, 12]. You can get an array with the data in rawValue by calling rawValue.read()

from netcdf-java.

JP95Git avatar JP95Git commented on June 20, 2024

Thanks for your help.

According to this tool
https://kunden.dwd.de/bufrviewer/
the BUFR file has 2 submessage, Wikipedia called them subsets.

I managed to read both submessages or subsets for some variables:

// For readScalarInt

Array arrayData = rawValue.read().reduce();
for (int i = 0; i <= arrayData.getRank(); i++) {
	log.debug("Value[{}]: {}", i, arrayData.getInt(i));
}

// For readScalarString

Array arrayData = rawValue.read().reduce();
DataType dataType = rawValue.getDataType();
if (dataType == DataType.STRING) {
	for (int i = 0; i < arrayData.getRank(); i++) {
		log.debug("Value[{}]: {}", i, arrayData.getObject(i));
	}
} else if (dataType == DataType.CHAR) {
	ArrayChar arrayDataChar = (ArrayChar) arrayData;
	for (int i = 0; i < arrayDataChar.getRank(); i++) {
		log.debug("Value[{}]: {}", i, arrayDataChar.getString(i));
	}
}

It's worth to note that some variables have more values than the others. E.g. I my BUFR files has 2 WMO_station_number but only 1 Solar_and_infrared_radiation_correction. So importing such a file will be not so easy.

It would be cool if I could open one BUFR file, iterate over the submessages and then read all variables of these submessage.

from netcdf-java.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.