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

Extraction of subset of binary MITgcm data #297

Open
SOFIADAL opened this issue Jan 19, 2022 · 3 comments
Open

Extraction of subset of binary MITgcm data #297

SOFIADAL opened this issue Jan 19, 2022 · 3 comments

Comments

@SOFIADAL
Copy link

SOFIADAL commented Jan 19, 2022

Hello,

I am a new MITgcm file user and I was wondering whether it is possible to extract specific longitude/latitude subregions from a binary file, the same way it is done in Netcdf files. I would like to also save the extracted file into a new binary file. Is this possible with xmitgcm?

Thank you in advance for your help,

@rabernat
Copy link
Member

Yes. If the MITgcm data uses a lat lon grid, xmitgcm.open_mdsdataset will return an Xarray Dataset. You can use that dataset to do label-based data selection. E.g.

from xmitgcm import open_mdsdataset
ds = open_mdsdataset(<YOUR OPTIONS GO HERE>)
ds.sel(lon=slice(30, 40), lat=slice(50, 60))

@rabernat
Copy link
Member

I would like to also save the extracted file into a new binary file.

You can export your data to netCDF from xarray, e.g. ds.to_netcdf.

It is possible write MDS data with xmitgcm as well, but this is not very well supported: https://xmitgcm.readthedocs.io/en/latest/demo_writing_binary_file.html

@SOFIADAL
Copy link
Author

ok @rabernat thanks a lot for the quick answer. It is very helpful.

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

2 participants