Borrar filtros
Borrar filtros

Problem with scale_factor and off_set with opening netCDF file

13 visualizaciones (últimos 30 días)
Michelle Bachrach
Michelle Bachrach el 1 de Feb. de 2023
Comentada: Michelle Bachrach el 20 de Feb. de 2023
I downloaded netcdf data and opened it in matlab, when I have done this in previous times the scale_factor =1 and add_offset=0 and the data is int32
In this new file I downloaded I get the following (the code is exactly the same):
scale_factor = 1.298e-05
add_offset = 0.50271
The values should be between 0 and 1 and instead I get really high and low numbers
I am not really sure what to do in order to get the scale factor and offset to the right values again, also the data is int16

Respuestas (1)

Shushant
Shushant el 16 de Feb. de 2023
My understanding of your problem is that when you previously read a netcdf data file you got the “scale_factor” as 1 and “add_offset” as 0 and datatype was int32. But when you downloaded a new file having datatype as int16 and ran the same code again you got a different value for “scale_factor” and “add_offset”. And that you are getting a really high and low numbers which I assume is the value of your data inside the netcdf file and not the “scale_factor/add_offset” as they are already in the range of 0 and 1. The main aim of your problem is getting correct values of “scale_factor” and “add_offset” again.
When reading NetCDF data in MATLAB using the “ncread” the MATLAB automatically finds the best match for the data file and applies both the “scale_factor” and “add_offset”. So, the change in the datatype of the file is reflected on the values of “scale_factor” and “add_offset”. This is the reason you might be getting different values as the file format is different (int32 and int16). Check out this documentation (vardata – variable and More About section).
You can always normalize the data after reading it from the file by scaling and setting offset based on your requirements.
  1 comentario
Michelle Bachrach
Michelle Bachrach el 20 de Feb. de 2023
Thank you very much :) I was able to figure out that indeed my problem was that I didn’t adjust the data with the given scale factor and offset

Iniciar sesión para comentar.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by