pro cdf_help, fn ;Hi Leslie, ; ;I've attached two sample NetCDF files (*.nc) and a PNG image. ; ;1) mola72x36.nc -- a Mars GCM topography file; plot the 'topogy' ;variable (the result should look similar to the mola*.png image, attached) ; ;2) Russell*.nc -- Mars mesoscale model output over Russell Crater (this ;file has 144 temporal snapshots, 20 Mars-minutes apart. The variable ;'ustar' (turbulent friction velocity) is a good one to try. ; ;Have fun! ; ;~~ Tim ;NCDF_OPEN: Open an existing netCDF file. ;NCDF_INQUIRE: Call this function to find the format of the netCDF file. ;NCDF_ATTNAME: Optionally, retrieve attribute names. ;NCDF_ATTINQ: Optionally, retrieve the types and lengths of attributes. ;NCDF_ATTGET: Optionally, retrieve the attributes. ;NCDF_DIMINQ: Retrieve the names and sizes of dimensions in the file. ;NCDF_VARINQ: Retrieve the names, types, and sizes of variables in the file. ;NCDF_VARGET: Read the data from the variables. ;NCDF_CLOSE: Close the file. print, 'OPENING THE FILE '+fn+' AND INQUIRING ABOUT ENTIRE FILE --------------------' cdfid = NCDF_OPEN( fn ) ; netCDF ID inq = NCDF_INQUIRE(Cdfid) ; Ndims The number of dimensions defined for this netCDF file. ; Nvars The number of variables defined for this netCDF file. ; Ngatts The number of global attributes defined for this netCDF file. ; RecDim The ID of the unlimited dimension, if there is one, for this netCDF file. If there is no unlimited dimension, RecDim is set to -1. help, inq, /str ;** Structure <1f1fc64>, 4 tags, length=16, data length=16, refs=1: ; NDIMS LONG 3 ; NVARS LONG 6 ; NGATTS LONG 4 ; RECDIM LONG 2 print, 'INVESTIGATING THE GLOBAL ATTRIBUTES --------------------' ;NCDF_ATTNAME: Optionally, retrieve attribute names. ;NCDF_ATTINQ: Optionally, retrieve the types and lengths of attributes. ;NCDF_ATTGET: Optionally, retrieve the attributes. for attnum = 0, inq.ngatts-1 do begin name = NCDF_ATTNAME( Cdfid, Attnum, /GLOBAL) attinq = NCDF_ATTINQ( Cdfid, Name, /GLOBAL) NCDF_ATTGET, Cdfid, Name, Value, /GLOBAL ; if attinq.datatype print, attnum, name, attinq.datatype, attinq.length, string(value),$ for='(I3, A20, A10, I6, " ",A-30)' end print, 'INVESTIGATING THE DIMENTIONS --------------------' for dimid = 0, inq.ndims -1 do begin NCDF_DIMINQ, Cdfid, Dimid, Name, Size print, dimid, name, size,for='(I3, A20, I6)' end print, 'INVESTIGATING THE VARIABLES --------------------' for varid = 0, inq.nvars -1 do begin varinq = ncdf_varinq(cdfid, varid) ;{ NAME:"", DATATYPE:"", NDIMS:0L, NATTS:0L, DIM:LONARR(NDIMS) } ; Name The name of the variable. ; DataType A string describing the data type of the variable. The string will be one of the following: 'BYTE', 'CHAR', 'INT', 'LONG', 'FLOAT', or 'DOUBLE'. ; Ndims The number of dimensions. ; Natts The number of attributes assigned to this variable. ; Dim A vector of the dimension IDs for the variable dimensions. print, varid, varinq.name, varinq.datatype,$ varinq.ndims, varinq.natts, varinq.dim, $ for='(I3, A10, A10, 2I6," ",3I6)' for attnum = 0, varinq.natts-1 do begin name = NCDF_ATTNAME( Cdfid, varid, Attnum) attinq = NCDF_ATTINQ( Cdfid, varid, Name) NCDF_ATTGET, Cdfid, varid, Name, Value print, attnum, name, attinq.datatype, attinq.length, string(value),$ for='(" ATT", I3, A20, A10, I6, " ",A-30)' end NCDF_VARGET, Cdfid, Varid, Value help, value end print, 'CLOSING THE FILE --------------------' NCDF_CLOSE, cdfid end