-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When importing ECMWF / Copernicus NetCDF files MDAL seems not to be applying scaling factors and offsets. #107
Comments
Hi, these data are just taken from GDAL, see https://github.com/lutraconsulting/MDAL/blob/master/mdal/frmts/mdal_gdal.cpp#L333 can you load the file as raster layer and check in QGIS if the scale factor is applied there? |
ad R: #42 |
Just had a look at some of the pages in the GDAL API and found some notes in the GetOffset and GetScale sections of the page for GDALRasterBand GetOffset
GetScale
My C++ skills are pretty minimal but quickly scanned through that .cpp you gave a link to and the other one that looked potentially relevant for this type of file.
I didn't spot any obvious calls to GetOffset or GetScale. So at a guess, hopefully all that might be needed for a fairly generic fix might be a few extra lines to which for each band would use those functions to get and thne apply any offset and scale values in the data files (or the default 0 and 1 for formats that don't use them). |
For reference - this is where it's done in the qgs raster data provider: https://github.com/qgis/QGIS/blob/master/src/providers/gdal/qgsgdalprovider.cpp#L665 (also similar for the various raster stats methods) |
fix #107 apply scale and offset for GDAL data
Sorry not to follow up on this till now. Many thanks for sorting out a fix so quickly. After a bit of fiddling around I eventually managed to get a 3.7 development version of QGIS building on my Windows machine with the new MDAL code. I gave it a quick test by importing the same ECMWF mean sea level pressure field and this time the range of values reported for the mesh version looks much better (as shown below). I see from some of the posts today that the patch might even make it into the QGIS 3.6.2 release. If so that'll be great. Once it's available, all I'll need to do is tell the colleague working with some of these ECMWF datasets to update their QGIS installation. cheers Clint |
Thanks, merged the fix to 3.6.2 so you will get it tomorrow :) |
Hi,
I've just been helping a colleague use R to download and work with some reanalysis datasets from ECMWF and Copernicus. I thought I'd also try using the MDAL import option to load them into QGIS 3.6 on Windows. I was able to successfully load in new MDAL layers within which there were 10 metre wind groups. The displayed magitudes and vector arrows showed the expected sort of patterns. However, when I checkd the ranges of values the magnitudes were up in the 1000s of metres per second :-(
In case something was wrong with the files I'd downloaded, I switched to the example ECMWF_ERA-40_subset.nc files mentioned in this blog post: https://www.lutraconsulting.co.uk/blog/2018/10/18/mdal/. Again the 10m windspeeds ranged way up into the 10,000s of metres per second. I tested the same file in UniData's IDV and it generated displays indicating much more reasonable ranges of a few 10s of metres per second.
I did a bit of digging and it looks like the values that the MDAL layer is showing are probably just the raw short integers from the NetCDF files. Any associated scaling factors and offsets necessary to convert those back into the original floating point values currently don't seem to be getting picked up from the NetCDF flies and applied to the integer numbers.
This extract from running the ncdump utility on the ECMWF_ERA-40_subset.nc file shows the scale_factors and offsets for the two variables used to store the 10m u and v wind components:
Hopefullly either I've just missed something or this will just be quite a quick fix. Happy to supply more info if needed as having MDAL in QGIS is potentially very useful for a few of us in my Unit.
cheers
Clint
The text was updated successfully, but these errors were encountered: