[ncl-talk] fatal:Dimension sizes of left hand side and right hand side of assignment do not match
Borja Sas González
saszalez at gmail.com
Mon Sep 30 10:43:47 MDT 2019
In the following script, the"slp" variable is extracted from several WRF
out files and the values are written to the CSV file. The variables are
read file by file due to a memory problem. The problem comes when the
amount of time steps of the out files are different. In this case, all the
files have 1000 time steps, minus one, which has 700. If I run the script
taking into account the 700 time step file, the script prints the following
error:
fatal:Dimension sizes of left hand side and right hand side of assignment
do not match
fatal:["Execute.c":8637]:Execute: Error occurred at or near line 41 in file
slp.ncl
If I omit the 700 time step file, the script works successfully. How can I
fix the script so that it does not print error when the time steps are not
the same?
begin
; Abrir archivo
files = systemfunc("ls /home/ssd/chile/WRF/test/em_real/wrfout_d03_*") +
".nc"
a = addfiles(files,"r")
; Definir latitud y longitud
lat = -22.056923
lon = -68.573862
; Localización del punto más próximo
opt = True ; Devuelve la coordenada entera
loc = wrf_user_ll_to_xy(a,lon,lat,opt) ; Pasa lon/lat a xy más próximo
lat2 = loc(1) ; Latitud para las variables
lon2 = loc(0) ; Longitud para las variables
; Opciones del encabezado
csv_filename = "slp.csv"
system("rm -f " + csv_filename)
fields = (/"TIME, PRESSURE (hPa)"/)
; 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)
do nf = 0,nfiles-1
; Presión en superficie
psfc = wrf_user_getvar(a[nf],"slp",-1)
psfc = decimalPlaces(psfc,2,True)
; Loop temporal
times = wrf_user_getvar(a[nf],"times",-1)
ntimes = dimsizes(times)
do it = 0,ntimes-1
; Crea el archivo con las variables
alist = [/times(it),psfc(it,lat2,lon2)/]
write_table(csv_filename, "a", alist, format)
end do
end do
end
--
Borja Sas González
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190930/3d571c56/attachment.html>
More information about the ncl-talk
mailing list