-
Notifications
You must be signed in to change notification settings - Fork 264
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
In Memory netcdf subdatasets do not persist order when buffer is closed #1388
Comments
I don't know how gdal chooses how to order to variables - maybe alphabetical? Don't believe this is a bug in netcdf4-python. |
Looks like the order of the variables does change when the memory buffer is written out and re-read (ncdump shows the same thing as gdal). I don't know if the order should be preserved - perhaps @DennisHeimbigner would know. |
Thanks for the quick look, |
just curious - why does the order matter for your use case? |
To be in compliance with previous version of the product we are working on. A more specific usage would be if someone opens two netcdfs of the same product and try to compare the subdataset by indices. |
netcdf-c keeps track of creation order, and preserves that order when a dataset is written to disk. Since you are bypassing the c library when writing the memory buffer to disk directly, my guess is that the logic that preserves creation order is also bypassed. Unfortunately, I don't see any way to tell the C library to write the memory buffer to disk preserving the creation order. |
Just to clarify the use-case, we want to use in-memory feature combining with writing the IO.buffer result directly to S3. |
Apparently, it seems netcdf gdal driver does not support writing a file directly on s3 (/vsis3). |
To report a non-security related issue, please provide:
the version of the software with which you are encountering an issue
netcdf4 1.7.1 nompi_py311hae66bec_102 conda-forge
environmental information (i.e. Operating System, compiler info, java version, python version, etc.)
OS: Almalinux-9.3, python: 3.11
a description of the issue with the steps needed to reproduce it:
When writing subdatasets to a netcdf in-memory, the subdatasets change index order when the buffer is written as a netcdf file at the end. Following a minimal example:
In print(ds) we still have ordered subdatasets:
printing gdal.Info after dumping the nc file:
The text was updated successfully, but these errors were encountered: