<div dir="ltr">Hello:<div><br></div><div>A most important step is to do a printVarSummary of the variables you with to write to the table and to see (compare) if you are referencing them correctly (which it appears you are not).</div><div><br></div><div>Barry</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jan 16, 2020 at 2:27 PM Borja Sas González via ncl-talk <<a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Hi everyone. I am trying to put in a CSV file the wind speed and direction for level 1 of the out file of the WRF output. I have reviewed the script a thousand times, but I can't find where the error is. The answer that prints me is:</div><div><br></div><div><p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">(0)<span style="white-space:pre-wrap"> </span>wind_speed: dimension size mismatch</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">(0)<span style="white-space:pre-wrap"> </span> u: 1000</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">(1)<span style="white-space:pre-wrap"> </span> u: 27</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">(2)<span style="white-space:pre-wrap"> </span> u: 81</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">(3)<span style="white-space:pre-wrap"> </span> u: 82</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">(0)<span style="white-space:pre-wrap"> </span> v: 1000</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">(1)<span style="white-space:pre-wrap"> </span> v: 27</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">(2)<span style="white-space:pre-wrap"> </span> v: 82</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">(3)<span style="white-space:pre-wrap"> </span> v: 81</span></p></div><div><br></div><div>The script is:</div><div><br></div><div><p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">begin</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41);min-height:16px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">; Abrir archivos</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">files = systemfunc("ls /home/ssd/begur/WRF/test/em_real/wrfout_d03_*") + ".nc"</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">a = addfiles(files,"r")</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41);min-height:16px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">; Definir latitud y longitud</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">lat = 41.935165</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">lon = 3.158911</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41);min-height:16px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">; Opciones del encabezado</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">csv_filename = "wind_levels.csv"</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">system("rm -f " + csv_filename)</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">fields = (/"TIME","WIND SPEED (m/s)","WIND DIRECTION (º)"/)</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41);min-height:16px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">; Crear encabezado</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">dq = str_get_dq()</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">fields = dq + fields + dq</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">header = [/str_join(fields,",")/]</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41);min-height:16px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">; Formato de escritura de las variables</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">format = "%s,%g,%g,%g,%g" ; Para escribir sin espacios</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41);min-height:16px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">; Crea el archivo con el encabezado</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">write_table(csv_filename,"w",header,"%s")</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41);min-height:16px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">; Para leer archivo por archivo</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">nfiles = dimsizes(files)</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41);min-height:16px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">; Bucle archivo por archivo</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">do nf = 0,nfiles-1</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41);min-height:16px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">; Localización del punto más próximo</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">opt = True ; Devuelve la coordenada entera</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">loc := wrf_user_ll_to_xy(a[nf],lon,lat,opt) ; Pasa lon/lat a xy más próximo</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41);min-height:16px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">; Coordenadas para las variables</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">lat2 = loc(1) ; Latitud para las variables</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">lon2 = loc(0) ; Longitud para las variables</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41);min-height:16px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">; Velocidad del viento a los niveles establecidos</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">u := wrf_user_getvar(a[nf],"U",-1)</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">v := wrf_user_getvar(a[nf],"V",-1)</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">wspd := wind_speed(u,v)</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">wspd = decimalPlaces(wspd,2,True)</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41);min-height:16px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">; Dirección del viento a los niveles establecidos</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">wdir := wind_direction(u,v,0)</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41);min-height:16px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">; Loop temporal</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">times := wrf_user_getvar(a[nf],"times",-1)</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">ntimes = dimsizes(times)</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41);min-height:16px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">; Bucle temporal</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">do it = 0,ntimes-1</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41);min-height:16px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">; Crea el archivo CSV con las variables</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">alist = [/times(it),wspd(it,0,lat2,lon2),wdir(it,0,lat2,lon2)/]</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">write_table(csv_filename,"a",alist,format)</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41);min-height:16px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">end do</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41);min-height:16px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">end do</span></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41);min-height:16px"><span style="font-variant-ligatures:no-common-ligatures"></span><br></p>
<p style="margin:0px;font-stretch:normal;font-size:12px;line-height:normal;font-family:Monaco;color:rgb(255,255,255);background-color:rgb(30,31,41)"><span style="font-variant-ligatures:no-common-ligatures">end</span></p></div><div><br></div><div>If anyone can help me I appreciate it.</div><div><br></div>-- <br><div dir="ltr">Borja Sas González</div></div></div></div></div>
_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a></blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr">Barry H. Lynn, Ph.D<div><div>Senior Associate Scientist, Lecturer,</div><div><div><span style="color:rgb(136,136,136)">The Institute of the Earth Science, </span><br style="color:rgb(136,136,136)"><span style="color:rgb(136,136,136)">The Hebrew University of Jerusalem, </span><br style="color:rgb(136,136,136)"><span style="color:rgb(136,136,136)">Givat Ram, Jerusalem 91904, Israel </span><br style="color:rgb(136,136,136)"></div><span style="color:rgb(136,136,136)">Tel: 972 547 231 170</span><br style="color:rgb(136,136,136)"><span style="color:rgb(136,136,136)">Fax: (972)-25662581</span></div></div><div><span style="color:rgb(136,136,136)"><br></span></div><div>C.E.O, Weather It Is, LTD<br>Weather and Climate Focus<br><a href="http://weather-it-is.com" target="_blank">http://weather-it-is.com</a><br>Jerusalem, Israel<br>Local: 02 930 9525<br>Cell: 054 7 231 170<br>Int-IS: x972 2 930 9525<br><br></div></div></div></div></div>