[MITgcm-support] Python3 and netCDFfile (smaeilpour)

Karina Ramos Musalem anakarinarm at gmail.com
Thu Mar 30 13:52:00 EDT 2017


Message: 3

> Date: Thu, 30 Mar 2017 01:23:56 +0000 (UTC)
> From: smaeilpour <saeid_gal at yahoo.com>
> To: <mitgcm-support at mitgcm.org>
> Subject: [MITgcm-support] Python3 and netCDFfile
> Message-ID: <1333983629.29763.1490837036892 at mail.yahoo.com>
> Content-Type: text/plain; charset=UTF-8
>
> Hi everyone,
> I have a nc file (netCDF file) that is output of the internal_wave created
> by MITgcm Model. I would be appreciate if somebody send me a program
> (commands for it) in python for reading and plotting that. in view of the
> fact that i have python3 on my system.
>
> cheers,
> Saeid
>
>
>
>
Hi Saeid,

I don't know if there is anything special about the internal_wave output,
but I use the xarray and library to read nc data. It is used like this:

# import library
import xarray as xr

# open data set forn file 'filename'
dset = xr.open_dataset(filename)

# extract variable (V) and optionally, a subset of the variable
sub_selection = dset.V.isel(X=310, T=6, Y=slice(0,40))

The you can plot sub_selection using matplotlib.

There is a short tutorial here
<https://nbviewer.jupyter.org/github/bmooremaley/software-workouts/blob/master/tutorials/NetcdfAndXarray.ipynb>

Cheers,
Karina



Karina Ramos Musalem
PhD Candidate (Phys.Ocgy.)
Earth, Ocean and Atmospheric Sciences
University of British Columbia
kramosmu at eoas.ubc.ca
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mitgcm.org/pipermail/mitgcm-support/attachments/20170330/17cdc327/attachment.htm>


More information about the MITgcm-support mailing list