<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style>
<!--
@font-face
        {font-family:"Cambria Math"}
@font-face
        {font-family:Calibri}
@font-face
        {font-family:Tahoma}
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif"}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;
        text-decoration:underline}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif"}
span.EstiloCorreo17
        {font-family:"Calibri","sans-serif";
        color:#1F497D}
span.TextodegloboCar
        {font-family:"Tahoma","sans-serif"}
.MsoChpDefault
        {font-family:"Calibri","sans-serif"}
@page WordSection1
        {margin:70.85pt 3.0cm 70.85pt 3.0cm}
div.WordSection1
        {}
-->
</style>
</head>
<body lang="ES-CL" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt; font-family:"Calibri","sans-serif"; color:#1F497D">Dear users,</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt; font-family:"Calibri","sans-serif"; color:#1F497D"> </span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt; font-family:"Calibri","sans-serif"; color:#1F497D">Chilean authorities provide 1x1 km WRF simulations for regulatory dispersion modelling purposes with Calpuff. Initially this is a great idea
but in practice, in several occasions, the model performance for sea breeze circulations and slope valley circulations is very poor. This together with the fact that the authority doesn’t accept using CALMET/WRF (under any circumstances) is turning regulatory
dispersion modelling into a headache. </span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt; font-family:"Calibri","sans-serif"; color:#1F497D"> </span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt; font-family:"Calibri","sans-serif"; color:#1F497D">I wonder if you have any recommended configuration to solve sea breeze circulations and slope valley circulations at 1 x 1 km resolution.</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt; font-family:"Calibri","sans-serif"; color:#1F497D">Would be WRF obs -nudging a good option?</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt; font-family:"Calibri","sans-serif"; color:#1F497D"> </span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt; font-family:"Calibri","sans-serif"; color:#1F497D">Other problem I guess, is that probably with the recommended configurations the time run for 1 year of should increase considerably.</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt; font-family:"Calibri","sans-serif"; color:#1F497D"> </span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt; font-family:"Calibri","sans-serif"; color:#1F497D"> </span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt; font-family:"Calibri","sans-serif"; color:#1F497D">Many thanks</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt; font-family:"Calibri","sans-serif"; color:#1F497D"> </span></p>
<p class="MsoNormal"><b><span style="font-size:9.0pt; font-family:"Arial","sans-serif"; color:#0079A2">Julio Castro M.</span></b><span style="font-size:9.0pt; font-family:"Arial","sans-serif"; color:#555555"> </span><span style="font-size:9.0pt; font-family:"Arial","sans-serif"; color:#333333">|
Especialista Senior en Calidad de Aire | </span><span style="font-size:10.0pt; font-family:"Arial","sans-serif"; color:#333333"><a href="mailto:julio.castro@arcadis.cl"><span style="font-family:"Times New Roman","serif"">julio.castro@arcadis.cl</span></a></span><span style="font-size:11.0pt; font-family:"Calibri","sans-serif"; color:#1F497D"></span></p>
<p class="MsoNormal" style="margin-top:6.0pt; line-height:120%"><span style="font-size:9.0pt; line-height:120%; font-family:"Arial","sans-serif"; color:#0079A2">ARCADIS Chile</span><span style="font-size:9.0pt; line-height:120%; font-family:"Arial","sans-serif"; color:#333333">
| Antonio Varas #621| Providencia</span><span style="font-size:11.0pt; line-height:120%; font-family:"Calibri","sans-serif"; color:#1F497D"></span></p>
<p class="MsoNormal" style="line-height:120%"><span style="font-size:9.0pt; line-height:120%; font-family:"Arial","sans-serif"; color:#333333">CP 7500655 | Santiago | Chile</span><span style="font-size:11.0pt; line-height:120%; font-family:"Calibri","sans-serif"; color:#1F497D"></span></p>
<p class="MsoNormal" style="line-height:120%"><span lang="EN-US" style="font-size:9.0pt; line-height:120%; font-family:"Arial","sans-serif"; color:#333333">T. + 56 2 2 3816248 | F. + 56 2 2 3816001</span><span lang="EN-US" style="font-size:11.0pt; line-height:120%; font-family:"Calibri","sans-serif"; color:#1F497D"></span></p>
<p class="MsoNormal" style="line-height:120%"><span lang="EN-US" style="font-size:9.0pt; line-height:120%; font-family:"Arial","sans-serif"; color:#333333"><a href="http://www.arcadis.cl/"><span style="font-family:"Times New Roman","serif"">www.arcadis.cl</span></a></span><span lang="EN-US" style="font-size:11.0pt; line-height:120%; font-family:"Calibri","sans-serif"; color:#1F497D"></span></p>
<p class="MsoNormal" style="line-height:120%"><span lang="EN-US" style="font-size:9.0pt; line-height:120%; font-family:"Arial","sans-serif"; color:#333333"> </span><span lang="EN-US" style="font-size:11.0pt; line-height:120%; font-family:"Calibri","sans-serif"; color:#1F497D"></span></p>
<p class="MsoNormal" style="line-height:120%"><span lang="EN-US" style="font-size:9.0pt; line-height:120%; font-family:"Arial","sans-serif"; color:#333333">ARCADIS, Imagine the result</span><span lang="EN-US" style="font-size:11.0pt; line-height:120%; font-family:"Calibri","sans-serif"; color:#1F497D"></span></p>
<p class="MsoNormal" style="margin-top:14.0pt; line-height:110%"><b><span style="font-size:7.0pt; line-height:110%; font-family:"Arial","sans-serif"; color:#009A00">Antes de imprimir este correo piense bien si es necesario. ARCADIS por un mundo sustentable.</span></b><span style="font-size:11.0pt; line-height:110%; font-family:"Calibri","sans-serif"; color:#1F497D"></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt; font-family:"Calibri","sans-serif"; color:#1F497D"> </span></p>
<p class="MsoNormal"><b><span lang="ES" style="font-size:10.0pt; font-family:"Tahoma","sans-serif"">De:</span></b><span lang="ES" style="font-size:10.0pt; font-family:"Tahoma","sans-serif""> wrf-users-bounces@ucar.edu [mailto:wrf-users-bounces@ucar.edu]
<b>En nombre de </b>Sara Fenech<br>
<b>Enviado el:</b> miércoles, 02 de julio de 2014 19:21<br>
<b>Para:</b> wrf-users@ucar.edu<br>
<b>Asunto:</b> [Wrf-users] Fwd: Data analysis using NCL</span></p>
<p class="MsoNormal"> </p>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"> </p>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">---------- Forwarded message ----------<br>
From: <b>Sara Fenech</b> <<a href="mailto:sarafenech@gmail.com">sarafenech@gmail.com</a>><br>
Date: Wed, Jul 2, 2014 at 12:44 PM<br>
Subject: Re: [Wrf-users] Data analysis using NCL<br>
To: Li Xianxiang <<a href="mailto:lixx@smart.mit.edu">lixx@smart.mit.edu</a>><br>
Cc: "<a href="mailto:wrf-users@ucar.edu">wrf-users@ucar.edu</a>" <<a href="mailto:wrf-users@ucar.edu">wrf-users@ucar.edu</a>><br>
<br>
</p>
<div>
<p class="MsoNormal">Hi Li </p>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">First of all thanks for your reply. I have altered my script (shown below) and it seems to work fine when opening the wrfout file for domain 1 (48km). When I tried running the script for wrfout file of domain 2 (9,6km nest) I got very unrealistic
huge values (billions m/s).</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">Do you have any idea what the problem could be?</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">Kind Regards</p>
</div>
<div>
<p class="MsoNormal">Sara</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<div>
<p class="MsoNormal">;---------------LOAD FUNCTIONS AND PROCEDURES ----------------</p>
</div>
<div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"</p>
</div>
<div>
<p class="MsoNormal">load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"</p>
</div>
<div>
<p class="MsoNormal">load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"</p>
</div>
<div>
<p class="MsoNormal">load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">; -------------- BEGINING OF NCL SCRIPT ----------------</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">begin</p>
</div>
<div>
<p class="MsoNormal">;********************************************************</p>
</div>
<div>
<p class="MsoNormal">; read in netCDF file and make a loop for all time steps</p>
</div>
<div>
<p class="MsoNormal">;********************************************************</p>
</div>
</div>
<div>
<p class="MsoNormal"> in = addfile("/home/wrf/OUTPUT/run_PBL2winter/<a href="http://wrfout_d01_2010-12-01.nc" target="_blank">wrfout_d01_2010-12-01.nc</a>","r")</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">;********************************************************</p>
</div>
<div>
<p class="MsoNormal">; Process all the time steps</p>
</div>
<div>
<p class="MsoNormal">;********************************************************</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">times = wrf_user_list_times(in) ; get times in the file </p>
</div>
<div>
<div>
<p class="MsoNormal">ntimes = dimsizes(times) ; number of times in the file </p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
</div>
<div>
<p class="MsoNormal">;T100 = new(ntimes,float) ; creation of a T vector at each time step</p>
</div>
<div>
<p class="MsoNormal">;P98 = new(ntimes,float) ; creation of a P vector at each time step</p>
</div>
<div>
<p class="MsoNormal">;Q = new(ntimes,float) ; creation of a Q vector at each time step</p>
</div>
<div>
<p class="MsoNormal">;rh100 = new(ntimes,float) ; creation of a RH vector at each time step</p>
</div>
<div>
<p class="MsoNormal">windspd100 = new(ntimes,float) ; creation of a Windspeed vector at each time step</p>
</div>
<div>
<div>
<p class="MsoNormal">;print(ntimes)</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">do it = 0,ntimes-1 ;Loop for the time: it= starting time</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
</div>
<div>
<div>
<p class="MsoNormal">time = it</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">;************************************************</p>
</div>
<div>
<p class="MsoNormal">; - Select lon & lat of the point of interest - </p>
</div>
<div>
<p class="MsoNormal">;************************************************</p>
</div>
</div>
<div>
<p class="MsoNormal">; - The function wrf_user_ll_to_ij find the nearest grid point for a specific lat and lon</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">Latitude = 35.99725</p>
</div>
<div>
<p class="MsoNormal">Longitude = 14.36775</p>
</div>
<div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">res = True </p>
</div>
<div>
<p class="MsoNormal">res@returnInt = True ; False : return real values, True: return interger values</p>
</div>
</div>
<div>
<p class="MsoNormal">point = wrf_user_ll_to_ij(in,Longitude,Latitude,res) ; wrf_user_ll_to_ij(nc_file,lon,lat,opt)</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> x = point(0)</p>
</div>
<div>
<p class="MsoNormal"> y = point(1)</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> ;print("X location is: " + x) ; print the value of X at the screen</p>
</div>
<div>
<div>
<p class="MsoNormal"> ;print("Y location is: " + y) ; print the value of Y at the screen</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
</div>
<div>
<p class="MsoNormal">;*************************************************************************************</p>
</div>
<div>
<p class="MsoNormal">; - extract wind, Temperature, Pressure, relative humidity and height coordinates- *</p>
</div>
<div>
<p class="MsoNormal">;*************************************************************************************</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">; Wind and Height</p>
</div>
<div>
<p class="MsoNormal"> u = wrf_user_getvar(in,"ua",time) ; u averaged to mass points</p>
</div>
<div>
<p class="MsoNormal"> v = wrf_user_getvar(in,"va",time) ; v averaged to mass points</p>
</div>
<div>
<p class="MsoNormal"> height = wrf_user_getvar(in, "z",time) ; height is our vertical coordinate</p>
</div>
<div>
<p class="MsoNormal"> ;ter = wrf_user_getvar(in, "ter",time) ; model terrain height (HGT_M, HGT_U, HGT_V)</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">; Conform data to Terrain Height </p>
</div>
<div>
<p class="MsoNormal"> ;nheight = conform(height,ter,(/1,2/)) ; assuming height is a 3d array and ter is a 2d array</p>
</div>
<div>
<p class="MsoNormal"> ;height = height - nheight</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">; Temperature</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> ;T_in = wrf_user_getvar(in, "tc", time) ; Extract sea level pressure (°C)</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">; Surface Pressure</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> ;P_in = wrf_user_getvar(in, "pressure", time) ; Extract sea level pressure (Pa)</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">; Relative humidity</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> ;rh_in = wrf_user_getvar(in, "rh", time) ; Extract relative humidity (%)</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">;print(rh_in) </p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">;*******************************************************************************</p>
</div>
<div>
<p class="MsoNormal">; - Interpolate wind speed and wind direction at 100m height - * </p>
</div>
<div>
<p class="MsoNormal">;*******************************************************************************</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> ; Interpolate U,V to 100 Meters</p>
</div>
<div>
<p class="MsoNormal"> u_plane = wrf_user_intrp3d( u,height,"h", 100,0.,False)</p>
</div>
<div>
<p class="MsoNormal"> v_plane = wrf_user_intrp3d( v,height,"h", 100,0.,False)</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> ; Calculate Wind Speed from Vectors</p>
</div>
<div>
<p class="MsoNormal"> spd = (u_plane*u_plane + v_plane*v_plane)^(0.5)</p>
</div>
<div>
<p class="MsoNormal"> windspd100(it)=spd(x,y)</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> ; Wind direction at 100 Meters</p>
</div>
<div>
<p class="MsoNormal"> ; r2d = 45.0/atan(1.0) ; conversion factor (radians to degrees)</p>
</div>
<div>
<p class="MsoNormal"> ; dir = atan2(u_plane,v_plane) * r2d + 180</p>
</div>
<div>
<p class="MsoNormal"> ; dir100 = dir(x,y)</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> ; Wind Speed </p>
</div>
<div>
<p class="MsoNormal"> spd@description = "Wind Speed"</p>
</div>
<div>
<p class="MsoNormal"> spd@units = "m/s"</p>
</div>
<div>
<p class="MsoNormal"> u_plane@units = "m/s"</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">;************************************************************</p>
</div>
<div>
<p class="MsoNormal">; - Interpolate temperature at 100m height - * </p>
</div>
<div>
<p class="MsoNormal">;************************************************************</p>
</div>
<div>
<p class="MsoNormal"> ; T_plane = wrf_user_intrp3d( T_in,height,"h", 98,0.,False)</p>
</div>
<div>
<p class="MsoNormal"> ; T100(it)=T_plane(x,y)</p>
</div>
<div>
<p class="MsoNormal">;************************************************************</p>
</div>
<div>
<p class="MsoNormal">; - Interpolate P at 98m height - * </p>
</div>
<div>
<p class="MsoNormal">;************************************************************</p>
</div>
<div>
<p class="MsoNormal"> ; P_plane = wrf_user_intrp3d( P_in,height,"h", 98,0.,False)</p>
</div>
<div>
<p class="MsoNormal"> ; P98(it)=P_plane(x,y)</p>
</div>
<div>
<p class="MsoNormal">;************************************************************</p>
</div>
<div>
<p class="MsoNormal">; - Interpolate rh at 98m height - * </p>
</div>
<div>
<p class="MsoNormal">;************************************************************</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> ; rh_plane = wrf_user_intrp3d( rh_in,height,"h", 98,0.,False)</p>
</div>
<div>
<p class="MsoNormal"> ; rh100(it)=rh_plane(x,y)</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">end do</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">;************************************************************</p>
</div>
<div>
<p class="MsoNormal">; - Print the variables at the screen - * </p>
</div>
<div>
<p class="MsoNormal">;************************************************************</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">print(" Time Wind_speed_100m ") </p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">do it = 0,ntimes-1</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> print (sprintf("%5.0f",it) +" " \</p>
</div>
<div>
<p class="MsoNormal"> +sprintf("%23.2f", windspd100(it)) +" " )</p>
</div>
<div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">end do ; end of time loop</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
</div>
<div>
<p class="MsoNormal">;************************************************************</p>
</div>
<div>
<p class="MsoNormal">; - Print the variables at the screen - *</p>
</div>
<div>
<p class="MsoNormal">;************************************************************</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> ;print(windspd100(it))</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> line = new(721,string) ; new(ntimes+1,string) ; declare a string array</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> ; print headers</p>
</div>
<div>
<p class="MsoNormal"> line(0) = " Time Wind_speed "</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> do it = 0,ntimes-1</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> line(it+1) = sprintf("%5.0f",it) +" " \</p>
</div>
<div>
<p class="MsoNormal"> +sprintf("%23.2f", windspd100(it)) +" " </p>
</div>
<div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> end do ; end of time loop</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
</div>
<div>
<p class="MsoNormal"> print(""+line) ; print output to console</p>
</div>
<div>
<p class="MsoNormal"> asciiwrite("PBL2AhraxDec.txt",line) ; write output to file</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">end</p>
</div>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
</div>
<div>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"> </p>
<div>
<p class="MsoNormal">On Mon, Jun 30, 2014 at 5:59 PM, Li Xianxiang <<a href="mailto:lixx@smart.mit.edu" target="_blank">lixx@smart.mit.edu</a>> wrote:</p>
<div>
<div>
<p class="MsoNormal">Hi Sara,</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">Basically your error is to interpolate with a single value (rather than an array). Here</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">ua = ua_in(0:0,y,x)</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">is just a scalar rather than an array. It should be</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">ua = us_in(:, y,x)</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">The same applies to other variables. You can use printVarSummary to check the dimension of a variable.</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">Other thoughts:</p>
</div>
<div>
<p class="MsoNormal">1. wrf_ll_to_ij returns the index of the point in the domain, starting from 1. But in ncl index of an array starts from 0. So usually we should subtract 1 from the i and j. However, I may be wrong here. You'd better check.</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">2. I remember wrf_user_getvar(nc_file, "ua", time) returns the unstaggered u. You can check.</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">Xianxiang</p>
</div>
<div>
<div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
On 30 Jun, 2014, at 11:38 PM, "Sara Fenech" <<a href="mailto:sarafenech@gmail.com" target="_blank">sarafenech@gmail.com</a>> wrote:</p>
</div>
<blockquote style="margin-top:5.0pt; margin-bottom:5.0pt">
<div>
<div>
<p class="MsoNormal">Hi all</p>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">I am very new to NCL and I've been trying to write a simple script but I'm having some problems. Well I have done 7 runs using wrf having hourly data for 3 months. Now I would like to extract the wind speed for each time step:</p>
</div>
<div>
<p class="MsoNormal">1) at a particular Lat and Lon (I managed this)</p>
</div>
<div>
<p class="MsoNormal">2) at a predefined height (in m)</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">Now I have managed to plot the wind speed for all my domain at a particular and I have managed to get wind speeds for a particular lat and lon but I cannot manage to obtain both at once. </p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">Thus to sum it up I would like one value for wind speed for each time step (where lat lon and lev are predefined.)</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">The last thing I would like to ask is how I can save the extracted data into a file. </p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">Thanks a lot for all you help. I'm attaching the script which is not working maybe you can spot what's wrong (Something to do with dimensions) together with the error message at the bottom. </p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">Thanks Again</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">Sara </p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<div>
<div>
<p class="MsoNormal">;******************************************************************************</p>
</div>
<div>
<p class="MsoNormal">;*NCL script to generate netCDF file containing wind speed at specific location *</p>
</div>
<div>
<p class="MsoNormal">;* Example for <a href="http://wrfout_d01_2010-12-01.nc" target="_blank">
wrfout_d01_2010-12-01.nc</a> *</p>
</div>
<div>
<p class="MsoNormal">;* *</p>
</div>
<div>
<p class="MsoNormal">;************************************************************************************</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">; -------------- LOAD FUNCTIONS AND PROCEDURES ----------------</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"</p>
</div>
<div>
<p class="MsoNormal">load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"</p>
</div>
<div>
<p class="MsoNormal">load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"</p>
</div>
<div>
<p class="MsoNormal">load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">; -------------- BEGINING OF NCL SCRIPT ----------------</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">begin</p>
</div>
<div>
<p class="MsoNormal">;********************************************************</p>
</div>
<div>
<p class="MsoNormal">; read in netCDF file and make a loop for all time steps</p>
</div>
<div>
<p class="MsoNormal">;********************************************************</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> a = addfile("/home/wrf/OUTPUT/run_PBL2winter/<a href="http://wrfout_d01_2010-12-01.nc" target="_blank">wrfout_d01_2010-12-01.nc</a>","r")</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">times = wrf_user_list_times(a) ; get times in the file </p>
</div>
<div>
<p class="MsoNormal">ntimes = dimsizes(times) ; number of times in the file </p>
</div>
<div>
<p class="MsoNormal">wind_speed = new(ntimes,float) ; creation of a windspeed vector at each time step</p>
</div>
<div>
<p class="MsoNormal">;print(ntimes)</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">do it = 0,ntimes-1 ;Loop for the time: it= starting time</p>
</div>
<div>
<p class="MsoNormal">print("Working on time " + it )</p>
</div>
<div>
<p class="MsoNormal">time = it</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">;************************************************</p>
</div>
<div>
<p class="MsoNormal">; - Select lon & lat of the point of interest - </p>
</div>
<div>
<p class="MsoNormal">;************************************************</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> res = True </p>
</div>
<div>
<p class="MsoNormal"> res@returnInt = True ; False : return real values, True: return interger values</p>
</div>
<div>
<p class="MsoNormal"> lat = 42.47 ; Latitude of the point of interest</p>
</div>
<div>
<p class="MsoNormal"> lon = 12.98 ; Longitude of the point of interest</p>
</div>
<div>
<p class="MsoNormal"> point = wrf_user_ll_to_ij(a,lon,lat,res) ; wrf_user_ll_to_ij(nc_file,lon,lat,opt)</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> x = point(1)</p>
</div>
<div>
<p class="MsoNormal"> y = point(0)</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> print("X location is: " + x) ; print the value of X at the screen</p>
</div>
<div>
<p class="MsoNormal"> print("Y location is: " + y) ; print the value of Y at the screen</p>
</div>
<div>
<p class="MsoNormal">;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</p>
</div>
<div>
<p class="MsoNormal">; The specific height levels that we want the data interpolated to.</p>
</div>
<div>
<p class="MsoNormal"> height_levels = (/ 1039./) ; height levels to plot - in meter</p>
</div>
<div>
<p class="MsoNormal"> nlevels = 1 ; number of height levels</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">;************************************************</p>
</div>
<div>
<p class="MsoNormal">; - extract wind components and unstagger them - </p>
</div>
<div>
<p class="MsoNormal">;************************************************</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">; ----- Hence U and V are staggered, we need to average them to get the point on the mass grid using wrf_user_unstagger</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> U = wrf_user_getvar(a, "U", time)</p>
</div>
<div>
<p class="MsoNormal"> ua_in = wrf_user_unstagger(U,U@stagger)</p>
</div>
<div>
<p class="MsoNormal"> ua = ua_in(0:0,y,x) ;ua(bottom_up,grid_lon,grid_lat)</p>
</div>
<div>
<p class="MsoNormal"> V = wrf_user_getvar(a, "V", time)</p>
</div>
<div>
<p class="MsoNormal"> va_in = wrf_user_unstagger(V,V@stagger) </p>
</div>
<div>
<p class="MsoNormal"> va = va_in(0:0,y,x) ;va(bottom_up,grid_lon,grid_lat)</p>
</div>
<div>
<p class="MsoNormal"> W = wrf_user_getvar(a, "W", time)</p>
</div>
<div>
<p class="MsoNormal"> z_in = wrf_user_unstagger(W,W@stagger)</p>
</div>
<div>
<p class="MsoNormal"> z = z_in(0:0,x,y) ;z(bottom_up,grid_lon,grid_lat)</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> wind_speed(it) = sqrt(ua^2+va^2)</p>
</div>
<div>
<p class="MsoNormal"> ;copy_VarCoords(ua,wind_speed(it)) ; copy coord vars to speed</p>
</div>
<div>
<p class="MsoNormal"> ;print(wind_speed(it))</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</p>
</div>
<div>
<p class="MsoNormal">;Interpolating to the requested height</p>
</div>
<div>
<p class="MsoNormal">;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</p>
</div>
<div>
<p class="MsoNormal"> u_plane = wrf_user_intrp4d( ua,z,"h",height_levels,0.,False)</p>
</div>
<div>
<p class="MsoNormal"> v_plane = wrf_user_intrp3d( va,z,"h",height_Levels,0.,False)</p>
</div>
<div>
<p class="MsoNormal"> spd_plane =wrf_user_intrp3d (wind_speed(it),z,"h",height_Levels,0.,False) ; speed in m/sec</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> print(spd_plane(it))</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">end do ; end of time loop</p>
</div>
<div>
<p class="MsoNormal">;************************************************</p>
</div>
<div>
<p class="MsoNormal">; - Write wind speed in ascii file - </p>
</div>
<div>
<p class="MsoNormal">;************************************************</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> ; XLAT = lat ; (nlat)</p>
</div>
<div>
<p class="MsoNormal"> ; YLON = lon ; (mlon)</p>
</div>
<div>
<p class="MsoNormal"> ;windspeed = wind_speed ; (ntim,nlat,mlon)</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> ;dimwindspeed = dimsizes(windspeed)</p>
</div>
<div>
<p class="MsoNormal"> ;ntim = dimwindspeed(0)</p>
</div>
<div>
<p class="MsoNormal"> ;nXLAT = dimwindspeed(1)</p>
</div>
<div>
<p class="MsoNormal"> ;mYLON = dimwindspeed(2)</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> ;npts = nXLAT*mYLON ; total number of grid points</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> ;fName = "foo.txt"</p>
</div>
<div>
<p class="MsoNormal"> ;data = new( npts, "string")</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> ;npt = -1</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> ;do nl=0,nXLAT-1 </p>
</div>
<div>
<p class="MsoNormal"> ; do ml=0,mYLON-1</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> ; npt = npt + 1 </p>
</div>
<div>
<p class="MsoNormal"> ; data(npt) = sprinti("%0.5i", (npt+1) ) </p>
</div>
<div>
<p class="MsoNormal"> ; data(npt) = data(npt) + sprintf("%7.1f ",XLAT(nl))</p>
</div>
<div>
<p class="MsoNormal"> ;data(npt) = data(npt) + sprintf("%7.1f ",YLON(ml))</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> ;do nt=0,ntim-1</p>
</div>
<div>
<p class="MsoNormal"> ; data(npt) = data(npt) + sprintf("%10.3f ", windspeed(nt,nl,ml))</p>
</div>
<div>
<p class="MsoNormal"> ;end do</p>
</div>
<div>
<p class="MsoNormal"> ;end do</p>
</div>
<div>
<p class="MsoNormal"> ;end do</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> ;asciiwrite (fName , data)</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">; -------------- END OF NCL SCRIPT ----------------</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">end</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"><b><u>Error Message</u></b></p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<div>
<p class="MsoNormal">fatal:Subscript out of range, error in subscript #0</p>
</div>
<div>
<p class="MsoNormal">fatal:An error occurred reading dims</p>
</div>
<div>
<p class="MsoNormal">fatal:["Execute.c":8567]:Execute: Error occurred at or near line 223 in file $NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl</p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal">fatal:["Execute.c":8567]:Execute: Error occurred at or near line 84 in file SpLev.ncl</p>
</div>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
<div>
<p class="MsoNormal"> </p>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
</div>
<blockquote style="margin-top:5.0pt; margin-bottom:5.0pt">
<div>
<p class="MsoNormal">_______________________________________________<br>
Wrf-users mailing list<br>
<a href="mailto:Wrf-users@ucar.edu" target="_blank">Wrf-users@ucar.edu</a><br>
<a href="http://mailman.ucar.edu/mailman/listinfo/wrf-users" target="_blank">http://mailman.ucar.edu/mailman/listinfo/wrf-users</a></p>
</div>
</blockquote>
</div>
</div>
<p class="MsoNormal"> </p>
</div>
</div>
</div>
</div>
<p class="MsoNormal"> </p>
</div>
</div>
<br>
<hr>
<font face="Arial" color="Black" size="2">Este correo electrónico es confidencial. Está destinado para su uso sólo por parte del destinatario.
<br>
Si usted no es el destinatario previsto, le solicitamos notificarlo al emisor y borrar este correo electrónico, y cualquier otro adjunto(s), sin copiarlo, reenviarlo, divulgarlo o usarlo de cualquier otra forma.<br>
<br>
This e-mail is confidential and may also be privileged. It is intended for use by the addressee only.<br>
If you are not the intended addressee, we request that you notify us immediately and delete this e-mail, and any attachment(s), without copying, forwarding, disclosing or using it in any other way.
<br>
</font>
</body>
</html>