comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Saving to netCDF
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Saving to netCDF [message #7761] Thu, 16 January 1997 00:00 Go to next message
mal3p is currently offline  mal3p
Messages: 13
Registered: June 1994
Junior Member
This is probably a no-brainer, but I don't have time right
now to figure how to do this: I'd like to be able to save variables-
including arrays and arrays of structures, to one of the public
domain scientific formats. Ideally, I would like to be able to "save"
the session's current variables to such a file.

Michael Lefsky



--
Re: Saving to netCDF [message #7885 is a reply to message #7761] Sat, 18 January 1997 00:00 Go to previous message
R. Bauer is currently offline  R. Bauer
Messages: 137
Registered: November 1996
Senior Member
if you want to share your netCDF data with others you should probably
look first at the conventions of the netCDF data format.

more information by
http://www.unidata.ucar.edu/packages/netcdf/index.html


R.Bauer
Re: Saving to netCDF [message #7888 is a reply to message #7761] Fri, 17 January 1997 00:00 Go to previous message
agraps is currently offline  agraps
Messages: 35
Registered: September 1994
Member
mal3p@faraday.clas.Virginia.EDU (Michael A. Lefsky) writes:

> This is probably a no-brainer, but I don't have time right
> now to figure how to do this: I'd like to be able to save variables-
> including arrays and arrays of structures, to one of the public
> domain scientific formats. Ideally, I would like to be able to "save"
> the session's current variables to such a file.


Actually I thought netCDF was a really nonintuitive format, so I
wouldn't call it a no-brainer. It seems unneccessarily complicated to
me. I spent a day or so trying to understand how reading and writing
in netCDF works.

I cannibalized one of my programs to give you this netCDF example. It
should work, but I haven't tested these code fragments, so no
guarantees. Here it goes.

Amara

-----------------------------------------------------------
Say you have a volume of data: call it "freqcube" dimensions float(x,y,f).
And say that you have a long string that describes the data, say "header"
And say that you want to create a netCDF file called "freq.nc"

;-----------------------
;Write out netCDF data
;-----------------------

;Create file
cd,'/tmp20/amara/'
newfile = 'freq.nc'

id_main = NCDF_CREATE(newfile,/CLOBBER)
IF (id_main eq -1) THEN BEGIN
PRINT, 'Unable to create file ', newfile
RETURN
END

;I will write out one attribute of "header" and one of "data".

;------------------
;Header Definition
;------------------

hsize = N_ELEMENTS(header)
dimheader = NCDF_DIMDEF(id_main, 'dimheader', /unlimited)
id_header = NCDF_VARDEF(id_main, 'header', dimheader, /char)

;---------------
;Data Definition
;---------------

sz = SIZE(freqcube)
xdim = sz(1)
ydim = sz(2)
zdim = sz(3)
xid = NCDF_DIMDEF(id_main,'x',xdim)
yid = NCDF_DIMDEF(id_main,'y',ydim)
zid = NCDF_DIMDEF(id_main,'z',zdim)
id_freq = NCDF_VARDEF(id_main,'freqcube',[xid,yid,zid],/FLOAT)

;End Definition
NCDF_CONTROL, id_main, /endef

print, ' '
print, 'Writing Variable Information..'
print, ' '

;------------
;Header Write
;------------

;Write header line into the one netCDF 'header' variable.

NCDF_VARPUT, id_main, id_header, header

;----------
;Data Write
;----------

print, ' '
print, 'Writing Variable Data..'
print, ' '
NCDF_VARPUT, id_main, id_freq, freqcube


NCDF_CLOSE, id_main

-----------------------------------------------------------
--

************************************************************ *************
Amara Graps email: agraps@netcom.com
Computational Physics vita: finger agraps@best.com
Multiplex Answers URL: http://www.amara.com/
************************************************************ *************
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Recordable CD's for Sale
Next Topic: Re: gotcha: indexing into a scalor

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Thu Oct 09 06:40:35 PDT 2025

Total time taken to generate the page: 0.96204 seconds