Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python

NetCDF to ascii file

 

 

Python python RSS feed   Index | Next | Previous | View Threaded


arnaud.sig at gmail

Nov 12, 2009, 4:25 AM

Post #1 of 1 (124 views)
Permalink
NetCDF to ascii file

Hi all,

I would like to know if it's possible to read data from a netcdf file and
export it into an ASCII file.
I'm trying to get the latitude, longitude and a determinate value of a
netcdf file. But I don't know exactly how to do it.
I succeed to open and read a netcdf file but i don't know how to export the
data.
Here is my simple script :

import Scientific.IO.NetCDF as nc
from Numeric import *
import sys

try :
ncFile = nc.NetCDFFile("tos_O1_2001-2002.nc","r")
except :
print "can't open the file"
sys.exit(1)

try :
print "################# Dimensions #################"
print ncFile.dimensions.keys()

print "################# Variables #################"
print ncFile.variables.keys()
#return [.'time_bnds', 'lat_bnds', 'lon', 'lon_bnds', 'time', 'lat',
'tos'

print "################# Var Dim #################"
tos = ncFile.variables["tos"]
print tos.dimensions
#return : ('time', 'lat', 'lon')


tosValue = tos.getValue()

except :
ncFile.close()



Do you know how I can get for each tos feature the lat, lon and time values.

Best regards

Arnaud

Python python RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.