;This script unpacks netCDF data that has "scale_factor" and "add_offset" ;attributes and writes it to a new file. ;Author: Sara Rauscher ;Date: 10.22.02 load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl" begin ;open file to write variable to out = addfile("csm.8.5k.ocn.S.ann.nc","c") ;open data file f = addfile("csm.8.5k.ocn.ST.ann50_99.nc","r") ;get necessary variables S = f->S(0,0,:,:) ;create new variable snew = new((/116,102/),float) ;unpack data ;get these values by doing a ncdump -h on the file ;they are listed under the variable ;example: ; float S(time, z_t, lat_t, lon_t) ; ; S:long_name = "Salinity" ; ; S:units = "psu" ; ; S:time_rep = "averaged" ; ; S:missing_value = 1.e+30f ; ; S:_FillValue = 1.e+30f ; ; S:scale_factor = 1000.f ; ; S:add_offset = 35.f ; ; sf = 1000. ao = 35. snew = (S*sf) + ao ;copy var coordinates from orig var copy_VarCoords(f->S(0,0,:,:),snew) ;write out var out->S = snew end