[MITgcm-support] Read NetCDF data (Internal Waves)
Alejandro Jiménez Rico
paulexca at hotmail.com
Tue May 10 10:25:00 EDT 2016
I am using python.
Look, I wrote this:
from matplotlib import pyplot as plt
import pandas as pd
import numpy as np
import netCDF4
fp='toread.nc'
nc = netCDF4.Dataset(fp)
print "Stationary or animated? (Say 'st' or 'a')"
q1 = raw_input()
print "Filled contours or an image? (Say 'fc' or 'image')"
q2 = raw_input()
print(nc['Temp'].shape)
t = 1
y = 0
if q1 == 'a':
while t< 10000:
if q2 == 'image':
plt.imshow(nc['Temp'][t,:,y,:])
if q2 == 'fc':
a=nc['Temp'][t,:,y,:]
b=np.flipup(a)
plt.contourf(nc['Temp'][t,:,y,:])
plt.pause(.001)
t=t+1
plt.draw()
if q1 == 'st':
if q2 == 'image':
plt.imshow(nc['Temp'][t,:,y,:])
if q2 == 'fc':
a=nc['Temp'][t,:,y,:]
b=np.flipup(a)
plt.contourf(nc['Temp'][t,:,y,:])
plt.show()But now I would like to not just looking the data, I want to touch it a bit.
I assume that you know that the position coordinates are no centralized; well, I would like to centralize it so then I will can calculate more interesting things like (for example) the kinetic energy of the fluid particles and plot it.
How could I do it? Do that things is what - essentially - I am trying to learn about.
Again, really thank you for your help;Alejandro
From: jklymak at uvic.ca
Date: Mon, 2 May 2016 08:53:40 -0700
To: mitgcm-support at mitgcm.org
Subject: Re: [MITgcm-support] Read NetCDF data (Internal Waves)
What package are you using to do the analysis? Matlab and python are the most common, and they both have excellent netcdf libraries.
Cheers, Jody
On May 2, 2016, at 2:59 AM, Alejandro Jiménez Rico <paulexca at hotmail.com> wrote:
From: paulexca at hotmail.com
To: mitgcm-support at mitgcm.org
Subject: RE: [MITgcm-support] Read NetCDF data (Internal Waves)
Date: Mon, 2 May 2016 09:59:24 +0000
Hello Roland,
Thank you for answering me. Actually I am trying to completely understand the Internal Waves model to carry out my own simulations using it.
First of all I would like to get the full matrix data of the .nc output of this model; so I'll can read it in a different ways and more personalized than using ncview (for example, I would like to see the time evolution of velocity in a precise point of the space, like field experiments).
Moreover, I'm trying to get the scale of this model (miles, kilometers, seconds, etc.) and all the information I can find about the performance of the model.
I hope you can help me and - again - really thank you for your help.
Alejandro
From: Roland.Young at physics.ox.ac.uk
To: mitgcm-support at mitgcm.org
Date: Wed, 20 Apr 2016 11:30:55 +0000
Subject: Re: [MITgcm-support] Read NetCDF data (Internal Waves)
Hi Alejandro,
I’m not entirely sure what you are trying to do; ncdump is useful for looking inside a NetCDF file but not for manipulating its contents, which is what I think you are trying to do.
If you want to view the fields themselves I suggest using ncview, which is very useful for doing this quickly. There are other programs that can read in NetCDF files for viewing, such as xconv and Panoply (the second of which is very powerful).
ncdump -c $file should print the values of all the grid variables in the .nc file, typically X, Y, Z, T for longitude, latitude, pressure/height, time.
ncdump -h $file will just print the headers (i.e. a list of variables in the file).
ncdump -v <variable> $file will print the complete record for a single variable to the screen. For example, ncdump -v U $file will print the entire zonal velocity field in the .nc file to the screen. This is not particularly useful if you want to manipulate the data, however.
You can manipulate NetCDF files directly using the NCO library: http://nco.sourceforge.net
However, most useful for manipulating the data itself rather than just view it using ncview is an interpreter such as IDL, Matlab, or Python. Each of these have libraries to read NetCDF files, after which you can do what you like with the data.
Don’t forget that if you are running a parallel model run you will need to stitch the tiles together using gluemncbig, otherwise each .nc file only contains one tile’s worth of data.
Hope that helps,
Roland
On 20 Apr 2016, at 11:52, Alejandro Jiménez Rico <paulexca at hotmail.com> wrote:Hello, I am trying to figure out how to read all the netcdf data using ncdump. I did $ ndump -c filetoread.nc
But I would want to organize all this data a little bit. How do I do this? I don't find information about the dimensions or the variables of this NetCDF in the mitgcm documentation.
Thank you,Alejandro_______________________________________________
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_______________________________________________MITgcm-support mailing listMITgcm-support at mitgcm.orghttp://mitgcm.org/mailman/listinfo/mitgcm-support
_______________________________________________
MITgcm-support mailing list
MITgcm-support at mitgcm.org
http://mitgcm.org/mailman/listinfo/mitgcm-support
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mitgcm.org/pipermail/mitgcm-support/attachments/20160510/6ca3deb8/attachment-0001.htm>
More information about the MITgcm-support
mailing list