[MITgcm-support] open source software for creating binary files from NetCDF

Jonny Williams Jonny.Williams at bristol.ac.uk
Wed Apr 22 10:00:18 EDT 2015


Hi Oliver

Thank you very much indeed for that. I will have a go using your
suggestions!

Much appreciated as always!

Jonny

On 22 April 2015 at 15:52, Oliver Jahn <jahn at mit.edu> wrote:

> Hi Jonny,
>
> if you want to read the files into MITgcm, you have to make sure they
> are big-endian, e.g.,
>
> a.astype('>f8').tofile('foo')
>
> or replace '>f8' by '>f4' if you use readBinaryPrec=32.
>
> For reading, you can use
>
> a = np.fromfile('foo', '>f8').reshape((3, 3))
>
> (for a 3x3 array).  If the files are MITgcm output and you have meta
> files, you can also use rdmds from the MITgcmutils package in
> MITgcm/utils/python which will set shape and precision automatically.
>
> Oliver
>
>
> On 2015-04-22 09:40, Jonny Williams wrote:
> > It seems that something along these lines in Python may be able to do
> > the trick...
> >
> >>>> import numpy as np
> >>>> a = np.array([1, 2, 3], dtype='float64')
> >>>> a.tofile('foo')
> >
> > Jonny
> >
> >
> > On 22 April 2015 at 14:43, Jonny Williams <Jonny.Williams at bristol.ac.uk
> > <mailto:Jonny.Williams at bristol.ac.uk>> wrote:
> >
> >     Hi everyone
> >
> >     Just a quick question if I may.
> >
> >     I've successfully used the readbin.m and writebin.m MATLAB scripts
> >     bundled with the MITgcm code base to make binary files from NetCDF
> >     files and vice versa.
> >
> >     Is there an open source way of doing this using, say, CDO or R, etc?
> >
> >     Thanks!
> >
> >     Jonny
> >
> >     --
> >     Dr Jonny Williams
> >     School of Geographical Sciences
> >     Cabot Institute
> >     University of Bristol
> >     BS8 1SS
> >
> >     +44 (0)117 3318352 <tel:%2B44%20%280%29117%203318352>
> >     jonny.williams at bristol.ac.uk <mailto:jonny.williams at bristol.ac.uk>
> >     http://www.bristol.ac.uk/geography/people/jonny-h-williams
> >     <http://bit.ly/jonnywilliams>
> >
> >
> >
> >
> > --
> > Dr Jonny Williams
> > School of Geographical Sciences
> > Cabot Institute
> > University of Bristol
> > BS8 1SS
> >
> > +44 (0)117 3318352
> > jonny.williams at bristol.ac.uk <mailto:jonny.williams at bristol.ac.uk>
> > http://www.bristol.ac.uk/geography/people/jonny-h-williams
> > <http://bit.ly/jonnywilliams>
> >
> >
> > _______________________________________________
> > MITgcm-support mailing list
> > MITgcm-support at mitgcm.org
> > http://mitgcm.org/mailman/listinfo/mitgcm-support
> >
>
> _______________________________________________
> MITgcm-support mailing list
> MITgcm-support at mitgcm.org
> http://mitgcm.org/mailman/listinfo/mitgcm-support
>



-- 
Dr Jonny Williams
School of Geographical Sciences
Cabot Institute
University of Bristol
BS8 1SS

+44 (0)117 3318352
jonny.williams at bristol.ac.uk
http://www.bristol.ac.uk/geography/people/jonny-h-williams
<http://bit.ly/jonnywilliams>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mitgcm.org/pipermail/mitgcm-support/attachments/20150422/d6d52a86/attachment-0001.htm>


More information about the MITgcm-support mailing list