[MITgcm-support] Reading data

Martin Losch Martin.Losch at awi.de
Wed Feb 10 10:27:02 EST 2016


Alejandro,

I am not familiar with Mathematica and I am not sure, if it is a useful tool for reading large data sets.

the *.data files contain binary ieee-big endian unblocked values (one after another, without any header, line breaks etc.) In the *.meta files you'll find the size of the fields and the bit-precisition (32 for single, 64 for double precision). You should be able to use that information to read a *.data file into any probgram that can read ieee-big endian data. In matlab it would someithing like this:
fid=fopen(“myfile”,”r”,”b”)
v=fread(fid,inf,”real*4”);
close(fid)
% and then use reshape(v,nx,ny) or whatever the dimensions are

### in python:
import numpy as np
fid=open(“myfile”,”r”)
v=np.fromfile(fid,”float32”)
fid.close()
v.reshape((ny,nx)) # or similar, you might have to use v.byteswap(True) if you work on a little-endian computer.

Martin

> On 10 Feb 2016, at 11:35, Alejandro Jiménez Rico <paulexca at hotmail.com> wrote:
> 
> Hello, my name is Alejandro. I am studying Physics in UAB (Barcelona, Spain) and I am learning how to manage with MITgcm.
> 
> I would like to ask for some help. I am working out exp2 and I want to read the .data output using Mathematica, but I don't know how to do it.
> 
> Thank you,
> Alejandro
> _______________________________________________
> MITgcm-support mailing list
> MITgcm-support at mitgcm.org
> http://mitgcm.org/mailman/listinfo/mitgcm-support




More information about the MITgcm-support mailing list