; ; CENTER FOR OCEAN-ATMOSPHERIC PREDICTION STUDIES, ; THE FLORIDA STATE UNIVERSITY ; ; DIRECT ALL QUESTIONS TO: nscat-anim@coaps.fsu.edu ;**************************************************** ; Function: readncdf_vort ; Date: June 2, 2008 ; Version : 1.0 ; Author : Jiangyi Hu, COAPS ; Description: Modified from readncdf.pro. Now the function reads ; one more variable - vort. ;**************************************************** ; ; Parameters: ; ; input Name of the NetCDF file you wish to read ; u the variable you would like the u wind component saved to ; v the variable you would like the v wind component saved to ; vort the variable you would like the vorticity saved to ; lat the latitude values stored in an array ; lon the longitude values stored in an array ; missing the value you would like all missing values set to ; ; Example: Prints all the u and v component values and the vorticity ; value to the screen with their respective latitude and ; longitude values. ;----------- ; @readncdf.pro ; ; file = "QSACT_Inidan_200812000.nc" ; missing = 9999.0 ; ; readncdf, file, u, v, vort, lat, lon, missing ; ; dims = SIZE(lat) ; latdim = dims[1] ; dims = SIZE(lon) ; londim = dims[1] ; ; FOR i = 0, latdim - 1 DO BEGIN ; FOR j = 0, londim - 1 DO BEGIN ; print, FORMAT="(F6.2,A2,F7.2,A4,F8.2,A2,F8.2,A2,F8.2,A1)", lat[i], $ ; ', ', lon[j], ' = (', u[j,i], ', ', v[j,i],', ', vort[j,i], ')' ; ENDFOR ; ENDFOR ; ; END ;----------- PRO readncdf_vort, input, u, v, vort, lat, lon, missing ; Opens NetCDF for reading. ncid = NCDF_OPEN(input, /NOWRITE) ; Gets the u, v and vorticity values from the opened file, plus their scale ; factors. lat_id = NCDF_VARID(ncid, 'lat') lon_id = NCDF_VARID(ncid, 'lon') NCDF_VARGET, ncid, lat_id, lat NCDF_VARGET, ncid, lon_id, lon u_id = NCDF_VARID(ncid, 'u') v_id = NCDF_VARID(ncid, 'v') vort_id = NCDF_VARID(ncid, 'vort') NCDF_VARGET, ncid, u_id, u NCDF_VARGET, ncid, v_id, v NCDF_VARGET, ncid, vort_id, vort NCDF_ATTGET, ncid, u_id, 'scale_factor', usf NCDF_ATTGET, ncid, v_id, 'scale_factor', vsf NCDF_ATTGET, ncid, u_id, 'missing_value', u_miss NCDF_ATTGET, ncid, v_id, 'missing_value', v_miss NCDF_ATTGET, ncid, vort_id, 'missing_value', vort_miss ; Multiplies by the scale factor. u_bad = where( u EQ u_miss ) v_bad = where( v EQ v_miss ) vort_bad = where( vort EQ vort_miss ) u = u * usf v = v * vsf u( u_bad ) = missing v( v_bad ) = missing vort( vort_bad) = missing ; Closes *.nc file. NCDF_CLOSE, ncid END