; load libraries, twice for good measure 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/wrf/WRFUserARW.ncl" load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/wind_rose.ncl" ;load "/home/torn/ncl/wrf_map_info.ncl" ;load "/home/torn/ncl/array_stat.ncl" ;load "/home/torn/ncl/image_conv.ncl" 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/wrf/WRFUserARW.ncl" ;load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/wind_rose.ncl" ;load "/home/torn/ncl/wrf_map_info.ncl" ;load "/home/torn/ncl/array_stat.ncl" ;load "/home/torn/ncl/image_conv.ncl" ;load "wrf_dart_util.ncl" begin ; read in station metadata meta = asciiread("station.txt", -1, "string") print(" ") print("Attempting "+meta(1)) print(" ") ; define files, previously scp'ed and cat'ed datafile = "stationdata" ;---Read in files as array of strings so we can parse each line tnew = asciiread(datafile,-1,"string") delim = "," ; define variables sitename = str_get_field(tnew,1,delim) datetime = str_get_field(tnew,2,delim) precip = tofloat(str_get_field(tnew,12,delim)) pres = tofloat(str_get_field(tnew,14,delim)) temp = tofloat(str_get_field(tnew,9,delim)) relh = tofloat(str_get_field(tnew,11,delim)) temp9m = tofloat(str_get_field(tnew,10,delim)) solar = tofloat(str_get_field(tnew,13,delim)) windspeed = tofloat(str_get_field(tnew,7,delim)) winddir = tofloat(str_get_field(tnew,6,delim)) windmax = tofloat(str_get_field(tnew,8,delim)) windspeedp = tofloat(str_get_field(tnew,4,delim)) winddirp = tofloat(str_get_field(tnew,3,delim)) windmaxp = tofloat(str_get_field(tnew,5,delim)) windspeed = where(windspeed.eq.-999.0,windspeed,windspeed*2.23694) windmax = where(windmax.eq.-999.0,windmax,windmax*2.23694) windspeedp = where(windspeedp.eq.-999.0,windspeedp,windspeedp*2.23694) windmaxp = where(windmaxp.eq.-999.0,windmaxp,windmaxp*2.23694) temp = where(temp.eq.-999.0,temp,temp*9/5 + 32) temp9m = where(temp9m.eq.-999.0,temp9m,temp9m*9/5 + 32) pres = where(pres.eq.-999.0,pres,pres/100) solar = where(solar.eq.-999.0,solar,solar) precip = where(precip.eq.-999.0,precip,precip*.0393701) value = -999.0 relh@_FillValue = value pres@_FillValue = value precip@_FillValue = value solar@_FillValue = value winddir@_FillValue = value winddirp@_FillValue = value winds = new((/2,dimsizes(temp)/), float) winds(0,:) = windmax ;winds(1,:) = windprop ; if this gets used, must change dimension of winds array winds(1,:) = windspeed winds@_FillValue = value windsprop = new((/2,dimsizes(temp)/), float) windsprop(0,:) = windmaxp windsprop(1,:) = windspeedp windsprop@_FillValue = value ;----------- The below section checks for NaNs and replaces them, and swaps bad sonic data for good prop data ------- windtext = "Sonic Wind & Gust (Blue, Brown)" windround = round(winds(1,:),3) windcolor = new((/11,dimsizes(windround)/),float) windcolor@_FillValue = -999.0 if (all(ismissing(winds(1,:)))) winds = windsprop winddir = winddirp windround = round(windspeedp,3) delete(windcolor) windcolor = new((/11,dimsizes(windround)/),float) windcolor@_FillValue = -999.0 windtext = "Prop Wind & Gust (Blue, Brown)" end if if (any(ismissing(winds(0,:)))) winds(0,:)=where(ismissing(winds(0,:)),windsprop(0,:),winds(0,:)) winds@_FillValue = value windtext = "Sonic/Prop Wind & Gust (Blue, Brown)" end if winddir=where(ismissing(winddir),winddirp,winddir) if (any(ismissing(winds(1,:)))) winds(1,:)=where(ismissing(winds(1,:)),windsprop(1,:),winds(1,:)) winds@_FillValue = value windtext = "Sonic/Prop Wind & Gust (Blue, Brown)" windround = round(winds(1,:),3) end if xx=dimsizes(windmax) ; set to length of time period you want quote = inttochar(34) if .not.all(ismissing(winds(0,:))) gustmax = max(winds(0,(xx-290):(xx-1))) if max(windmaxp((xx-290):(xx-1))).gt.gustmax gustmax=max(windmaxp((xx-290):(xx-1))) end if info = (/stringtofloat(meta(2)),stringtofloat(meta(3)),gustmax/) asciiwrite(meta(1)+".txt",info) relative = ""+tofloat(meta(2))+","+tofloat(meta(3))+","+gustmax system("echo "+quote+relative(0)+quote+" >> currentdata.dat") end if end