NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.

To learn about what's going on, see About the Archive Site.

Re: [netcdf-java] scalefactors from grib-files in NetCDF for Java 4.6.3

  • To: Ben Caradoc-Davies <ben@xxxxxxxxxxxx>
  • Subject: Re: [netcdf-java] scalefactors from grib-files in NetCDF for Java 4.6.3
  • From: Christian Ward-Garrison <cwardgar@xxxxxxxx>
  • Date: Mon, 25 Apr 2016 20:52:33 -0600
Hi Robert,

I disagree with the statement that the VariableDS 'knows' its data came
from a grib1 file. It'll likely have some attributes attached that mention
grib parameters, but the details of the underlying file format are
purposefully abstracted away. So, given just a VariableDS, I don't believe
it's possible to retrieve the decimalScaleFactor of the underlying grib
record.

However, if you're willing to work at a lower level in the stack, there are
some options. Here [1] is some test code where we open a grib1 record as a
RandomAccessFile and retrieve its GribData.Info. Once you have that object,
you can just read its decimalScaleFactor field.

Hopefully that'll get you started,
Christian

[1]
https://github.com/Unidata/thredds/blob/master/cdm-test/src/test/java/ucar/nc2/writer/TestGribSize.java#L125

On Mon, Apr 25, 2016 at 2:42 PM, Ben Caradoc-Davies <ben@xxxxxxxxxxxx>
wrote:

> Robert,
>
> why do you want these scale factors? The purpose of the readers is to
> apply these scale factors to the data and present the scaled data via the
> CDM API just as is done for a NetCDF file. No further scaling should be
> required.
>
> If I needed to get these raw scale factors I would instantiate a new
> ucar.unidata.io.RandomAccessFile and use it to create a
> Grib1Record/Grib2Record and get the scale factors from that object. I do
> not think it is possible to get this information via the CDM API.
>
> Kind regards,
> Ben.
>
> On 25/04/16 19:08, Robert Leander wrote:
>
>> Sirs, madams,
>>
>>
>>
>> Not being certain whether or not I sent my question to this list already,
>> I humbly apologize if this was the case.
>>
>> My question concerns the following.
>>
>>
>>
>> Currently, I am using the netcdf 4.6.3 java library to read data from
>> grib1 and grib2 files. I was able to open the file, which gives me at a
>> certain point a "VariableDS" object. This object 'knows' its data came from
>> a grib1 file. Now I am trying to get the decimalScalefactor of the original
>> gribdata through the getBinaryDataInfo of the grib1Record class, but for
>> this I need a grib1Record. How can I search this record in my dataset or is
>> there another way to get to the decimal- and binaryScalefactor ? I have
>> searched the manual and javadocs, but hitherto failed to find a solution.
>> If anyone could point me in the right direction, I would greatly appreciate
>> that.
>>
>>
>>
>> Thx for your answer!
>>
>>
>>
>>
>> Robert Leander
>>
>> E
>>
>> robert.leander@xxxxxxxxxxx
>>
>>
>>
>>
>> [Logo]<http://www.deltares.com/>
>>
>>   www.deltares.com<http://www.deltares.com/>
>>
>> Postbus 177
>> 2600 MH Delft
>>
>> [Deltares Twitter]
>> <http://www.twitter.com/deltares>
>>
>> [Deltares LinkedIn]<http://www.linkedin.com/company/217430>
>>
>> [Deltares Facebook]<
>> https://www.facebook.com/pages/Deltares/154189334634001>
>>
>>
>>
>> [Think before printing]Please consider the environment before printing
>> this email
>> DISCLAIMER: This message is intended exclusively for the addressee(s) and
>> may contain confidential and privileged information. If you are not the
>> intended recipient please notify the sender immediately and destroy this
>> message. Unauthorized use, disclosure or copying of this message is
>> strictly prohibited. The foundation 'Stichting Deltares', which has its
>> seat at Delft, The Netherlands, Commercial Registration Number 41146461, is
>> not liable in any way whatsoever for consequences and/or damages resulting
>> from the improper, incomplete and untimely dispatch, receipt and/or content
>> of this e-mail .
>>
>>
>>
>> _______________________________________________
>> netcdf-java mailing list
>> netcdf-java@xxxxxxxxxxxxxxxx
>> For list information or to unsubscribe, visit:
>> http://www.unidata.ucar.edu/mailing_lists/
>>
>>
> --
> Ben Caradoc-Davies <ben@xxxxxxxxxxxx>
> Director
> Transient Software Limited <http://transient.nz/>
> New Zealand
>
> _______________________________________________
> netcdf-java mailing list
> netcdf-java@xxxxxxxxxxxxxxxx
> For list information or to unsubscribe, visit:
> http://www.unidata.ucar.edu/mailing_lists/
  • 2016 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdf-java archives: