[ncl-talk] wind_speed: dimension size mismatch

Barry Lynn barry.h.lynn at gmail.com
Thu Jan 16 08:00:59 MST 2020


Hi:

You should compare what you see in the printVarSummary with how you are
indexing your csv table write.  For instanc,e there are three dimensions in
wspd.  Do they match what you are writing?

On Thu, Jan 16, 2020 at 3:01 PM Borja Sas González <saszalez at gmail.com>
wrote:

> printVarSummary prints:
>
> Variable: wspd
> Type: float
> Total Size: 20601540 bytes
>             5150385 values
> Number of Dimensions: 3
> Dimensions and sizes: [Time | 785] x [south_north | 81] x [west_east | 81]
> Coordinates:
> Number Of Attributes: 2
>   units : m s-1
>   long_name : wind speed
>
> El jue., 16 ene. 2020 a las 12:41, Barry Lynn (<barry.h.lynn at gmail.com>)
> escribió:
>
>> Hello:
>>
>> 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).
>>
>> Barry
>>
>> On Thu, Jan 16, 2020 at 2:27 PM Borja Sas González via ncl-talk <
>> ncl-talk at ucar.edu> wrote:
>>
>>> 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:
>>>
>>> (0) wind_speed: dimension size mismatch
>>>
>>> (0)         u: 1000
>>>
>>> (1)         u: 27
>>>
>>> (2)         u: 81
>>>
>>> (3)         u: 82
>>>
>>> (0)         v: 1000
>>>
>>> (1)         v: 27
>>>
>>> (2)         v: 82
>>>
>>> (3)         v: 81
>>>
>>> The script is:
>>>
>>> begin
>>>
>>>
>>> ; Abrir archivos
>>>
>>> files = systemfunc("ls /home/ssd/begur/WRF/test/em_real/wrfout_d03_*") +
>>> ".nc"
>>>
>>> a = addfiles(files,"r")
>>>
>>>
>>> ; Definir latitud y longitud
>>>
>>> lat = 41.935165
>>>
>>> lon = 3.158911
>>>
>>>
>>> ; Opciones del encabezado
>>>
>>> csv_filename = "wind_levels.csv"
>>>
>>> system("rm -f " + csv_filename)
>>>
>>> fields = (/"TIME","WIND SPEED (m/s)","WIND DIRECTION (º)"/)
>>>
>>>
>>> ; Crear encabezado
>>>
>>> dq = str_get_dq()
>>>
>>> fields = dq + fields + dq
>>>
>>> header = [/str_join(fields,",")/]
>>>
>>>
>>> ; Formato de escritura de las variables
>>>
>>> format = "%s,%g,%g,%g,%g" ; Para escribir sin espacios
>>>
>>>
>>> ; Crea el archivo con el encabezado
>>>
>>> write_table(csv_filename,"w",header,"%s")
>>>
>>>
>>> ; Para leer archivo por archivo
>>>
>>> nfiles = dimsizes(files)
>>>
>>>
>>> ; Bucle archivo por archivo
>>>
>>> do nf = 0,nfiles-1
>>>
>>>
>>> ; Localización del punto más próximo
>>>
>>> opt = True ; Devuelve la coordenada entera
>>>
>>> loc := wrf_user_ll_to_xy(a[nf],lon,lat,opt) ; Pasa lon/lat a xy más
>>> próximo
>>>
>>>
>>> ; Coordenadas para las variables
>>>
>>> lat2 = loc(1) ; Latitud para las variables
>>>
>>> lon2 = loc(0) ; Longitud para las variables
>>>
>>>
>>> ; Velocidad del viento a los niveles establecidos
>>>
>>> u := wrf_user_getvar(a[nf],"U",-1)
>>>
>>> v := wrf_user_getvar(a[nf],"V",-1)
>>>
>>> wspd := wind_speed(u,v)
>>>
>>> wspd = decimalPlaces(wspd,2,True)
>>>
>>>
>>> ; Dirección del viento a los niveles establecidos
>>>
>>> wdir := wind_direction(u,v,0)
>>>
>>>
>>> ; Loop temporal
>>>
>>> times := wrf_user_getvar(a[nf],"times",-1)
>>>
>>> ntimes = dimsizes(times)
>>>
>>>
>>> ; Bucle temporal
>>>
>>> do it = 0,ntimes-1
>>>
>>>
>>> ; Crea el archivo CSV con las variables
>>>
>>> alist = [/times(it),wspd(it,0,lat2,lon2),wdir(it,0,lat2,lon2)/]
>>>
>>> write_table(csv_filename,"a",alist,format)
>>>
>>>
>>> end do
>>>
>>>
>>> end do
>>>
>>>
>>> end
>>>
>>> If anyone can help me I appreciate it.
>>>
>>> --
>>> Borja Sas González
>>> _______________________________________________
>>> ncl-talk mailing list
>>> ncl-talk at ucar.edu
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>>
>> --
>> Barry H. Lynn, Ph.D
>> Senior Associate Scientist, Lecturer,
>> The Institute of the Earth Science,
>> The Hebrew University of Jerusalem,
>> Givat Ram, Jerusalem 91904, Israel
>> Tel: 972 547 231 170
>> Fax: (972)-25662581
>>
>> C.E.O, Weather It Is, LTD
>> Weather and Climate Focus
>> http://weather-it-is.com
>> Jerusalem, Israel
>> Local: 02 930 9525
>> Cell: 054 7 231 170
>> Int-IS: x972 2 930 9525
>>
>>
>
> --
> Borja Sas González
>


-- 
Barry H. Lynn, Ph.D
Senior Associate Scientist, Lecturer,
The Institute of the Earth Science,
The Hebrew University of Jerusalem,
Givat Ram, Jerusalem 91904, Israel
Tel: 972 547 231 170
Fax: (972)-25662581

C.E.O, Weather It Is, LTD
Weather and Climate Focus
http://weather-it-is.com
Jerusalem, Israel
Local: 02 930 9525
Cell: 054 7 231 170
Int-IS: x972 2 930 9525
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20200116/d7d4fbd2/attachment.html>


More information about the ncl-talk mailing list