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" begin ; List the months and years we want to plot in our time series year = (/"1990","1991","1992","1993","1994","1995","1996","1997","1998","1999","2000"/) numYEAR = dimsizes(year) ; Calculate how many points there will be in our time series (132 points) days = 365 ; Here we set up our netcdf file that we want to output. YEARS = stringtointeger(year) YEARS!0 = "Year" out = addfile("t2_precip_rtty_1990.nc","c") dim_names = (/"Year","Time"/) dim_sizes = (/-1,365/) dim_unlim = (/True,False/) filedimdef(out,dim_names,dim_sizes,dim_unlim) out->YEARS = YEARS DataNames = new(2,string) DataNames(0) = "T2MAX" DataNames(1) = "PREC" DimNames = (/"Year","Time"/) new_var_type = new ( 2 , string ) new_var_type = "float" filevardef(out, DataNames, new_var_type, DimNames ) ; Loop through the years so that we get each day of each year for our file. do i=0,numYEAR-1 time = new(days,string) ; Add the t2 maxmin daily file we just made a = addfile("data/t2_maxmin_daily_"+year(i)+"_rtty_1990.nc","r") c = addfile("data/precip_daily_"+year(i)+"_rtty_1990.nc","r") b = addfile("data/met_em.d01.2004-12-16_12:00:00.nc","r") ; Here we run the function wrf_user_ll_to_ij. We send in lat/lon and it returns the i,j ; grid box that we care about. llres = True llres@returnInt = True ; We want it to return an integer locij = wrf_user_ll_to_ij(b,-105.2705,40.0274,llres) ; Lat/lon for Boulder, CO locij = locij-1 locX = locij(0) locY = locij(1) ; Pull out the data for the grid box we care about. t2 = a->T2MAX(:,locY,locX) prec = c->PREC_DAY(:,locY,locX) ; Write out the data to the netcdf file out->T2MAX(i,:) = t2 out->PREC(i,:) = prec ; Here we want to get our dates in a good format to output to a text file. k = 1 do j=0,days-1 if(k.lt.10) then time(j) = year(i)+"00"+k else if(k.lt.100 .and. k.gt.9) then time(j) = year(i)+"0"+k else time(j) = year(i)+k end if end if k=k+1 end do time2 = stringtoint(time) time2@calendar = "365" date = tostring(yyyyddd_to_yyyymmdd(time2)) year2 = str_get_cols(date,0,3) mon = str_get_cols(date,4,5) day = str_get_cols(date,6,7) ; Here we are going to use the NCL function write_table to write out our data to a text file. if(i.eq.0) then write_table("t2_precip_rtty_1990.txt","w",[/year2,mon,day,t2,prec/],"%s %s %s %3.2f %3.2f") else write_table("t2_precip_rtty_1990.txt","a",[/year2,mon,day,t2,prec/],"%s %s %s %3.2f %3.2f") end if delete([/date,time,year2,mon,day,t2,prec,a,c/]) end do end