-
Notifications
You must be signed in to change notification settings - Fork 66
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
Unable to open binary data with xm.open_mdsdataset #296
Comments
Thanks for sharing @SOFIADAL! Can you post the raw contents of Was this file generated by MITgcm or some other process? |
Thanks for answering @rabernat .
So the files were generated based on an MITgcm model, but it was a reprocessing of basic model data from an individual. So I guess that the final writing of the files were not properly done maybe? Also this data are from a regional model, so not global. These files open without problem in matlab (according to the generator) using some commands similar to the low level utilities mds.rdmds. However the command I showed above in python fails.
I uploaded the file in my dropbox if you have time to have a look at it ( can you let me know if you have access to it?) |
I think I might have found the problem. So an additional "," in the dimList of the meta file is what created the Assertion Error. I manually modified the file, added a few parameters and now I have this:
However, I now have another issue which I suspect has to do with the way these files were created. When I try to open it again it gives me the following error:
I suspect this means that the file has different dimensions from the grid files xmitgcm reads automatically, right? |
I'm glad you were able to make progress. You're correct that the meta file was not formatted the way xmitgcm expects. We could imagine trying to update our code to be more flexible. In the meantime, you found a workaround by manually correcting the meta file formatting.
This is also my interpretation. If you look at your meta file:
and compare it to Do you have any idea why they are different sizes? One workaround would be to bypass xmitgcm's automatic inference of grid shape and explicitly specify the shape you want. Something like this data_dir = '/home/sofi/Documents/POSTDOC_ATHENS/PROGRAMS/MLHB_DATA',
datatot= xm.open_mdsdataset(
data_dir,
prefix=['TT_in_R'],
iters=[7730880],
read_grid=False,
nx=1999,
ny=1999,
delta_t=90,
ref_date='1979-01-15 00:00'
) If you want to merge this with any of the rest of your outputs (with nx=2000), you will need to manually extend or pad the data. |
Thanks for the help! What do you mean that I have to manually "pad" the data? |
Hello,
I have recently tried to open (MITgcm) binary data using xmitgcm package in ipython. However I am getting an Assertion Error which I have no idea where it is coming from. An example of a data file of temperature is named like this:
TT_in_R.0007730880.data
TT_in_R.0007730880.meta
and when I use low-level utilities to have a look on the files inside (using ipython) I get the following:
Similarly for the .meta file:
However, when I try to open the same file with the xm.open_mdsdataset I get the following error:
I suspect that this AssertionError has something to do with the prefix definition, as I have tried to run the command just by specifying data_dir and prefix.
In addition I also tried to include a “.” inside the filename in prefix and I got the following:
It seems that it is reading all the grid files but finds no variable to read.
Anyone any ideas? Does anyone know if I can add the missing attributes in a mitgcm file using python?
Thank you in advance for your time and help,
Sofi
The text was updated successfully, but these errors were encountered: