Skip to content
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

Possible bug trying to save 2D variables #175

Closed
dmeoli opened this issue May 10, 2022 · 2 comments
Closed

Possible bug trying to save 2D variables #175

dmeoli opened this issue May 10, 2022 · 2 comments

Comments

@dmeoli
Copy link

dmeoli commented May 10, 2022

Hello, I have the following code:

image

and I obtain this:

image

Can anyone explain to me why the 2D variables are stored transposed wrt the shape defined in input?

Thx.

@visr
Copy link
Contributor

visr commented May 10, 2022

This is because julia is column major, and the storage order is row major. To be able to deal with this difference efficiently, the order of the dimensions is flipped. See also:

https://en.wikipedia.org/wiki/Row-_and_column-major_order
JuliaIO/Zarr.jl#78 (comment)

@Alexander-Barth
Copy link
Owner

I clarified this in the docs:

 Dimension ordering
  ====================

  The data is stored in the NetCDF file in the same order as they are stored in memory. As julia uses the Column-major ordering
  (https://en.wikipedia.org/wiki/Row-_and_column-major_order) for arrays, the order of dimensions will appear reversed when the data is loaded in languages or
  programs using Row-major ordering (https://en.wikipedia.org/wiki/Row-_and_column-major_order) such as C/C++, Python/NumPy or the tools ncdump/ncgen (NetCDF CDL
  (https://web.archive.org/web/20220513091844/https://docs.unidata.ucar.edu/nug/current/_c_d_l.html)). NumPy can also use Column-major ordering but Row-major order
  is the default. For the column-major interpretation of the dimensions (as in Julia), the CF Convention recommends
  (https://web.archive.org/web/20220328110810/http://cfconventions.org/Data/cf-conventions/cf-conventions-1.7/cf-conventions.html#dimensions) the order "longitude"
  (X), "latitude" (Y), "height or depth" (Z) and "date or time" (T) (if applicable). All other dimensions should, whenever possible, be placed to the right of the
  spatiotemporal dimensions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants