4

I am very new to Python, and I have managed to read in some variables from NetCDF in to Python and plot them, but the size of the variables isn't correct.

My dataset is 144 x 90 (lon x lat) but when I call in the variables, it seems to miss a large section of data.

Do I need to specify the size of the dataset I'm reading in? Is that what I'm doing wrong here?

Here is the code I am using:

    import netCDF4
    from netCDF4 import Dataset
    from pylab import *

    ncfile = Dataset('DEC3499.aijE03Ccek11p5A.nc','r')

    temp = ncfile.variables['tsurf']
    prec = ncfile.variables['prec']

    subplot(2,1,1)
    pcolor(temp)

    subplot(2,1,2)
    pcolor(prec)

    savefig('DEC3499.png',optimize=True,quality=85)

    quit()

Just to clarify, here is an image showing the output. There should be data right to the far right hand side of the box.

(http://img163.imageshack.us/img163/6900/screenshot20130520at112.png)

1 Answer 1

5

I figured it out.

For those interested, I just needed to amend the following lines to pull in the variables properly:

temp = ncfile.variables['tsurf'][:,:]
prec = ncfile.variables['prec'][:,:]

Thanks!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.