Happy new year 2013 for you all!
I have a netcdf file with temperature fields, T(time,lat,lon), and would like to have lat x lon netcdf files each one with a single timeseries (one for location).
I need to do this for different grids, so I cannot assume that lat,lon values are known. If lat,lon were always the same and known, it would be easy to write a shell script using ncks to extract those locations. However, as the lat,lon values depend on the filed to be read, they need to be read in some way from the netcdf file itself and passed to a shell variable to be then used in the script. I have tried "ncks -H" and "ncap2 print" to read lat and lon variables to a shell variable but without success. For instance, I tried
lon=`ncap -s 'print(lon,"%3.2f,")' $file` and got "Segmentation fault"
ncks -H -v lon $file and got
but I want just the values 0, 2.5, 5 … and not the "lon=" chain.
Perhaps I will eventually use this piped with "cut" but would prefer a more elegant solution.
Any ideas how to achieve this?
I am trying to compute teleconnections, that is, correlations between T in one location and the T in the other points of the field for every location in the field.
Perhaps there is a completely different way to compute teleconnections or point correaltions that avoids extracting locations. Please let me know if you know about such an algorithm.
Thanks a lot in advance for your time and insight on this.
you want to use ncap2 not ncap.
the distinction between the two is in the manual.
always use ncap2 if possible.
lon=`ncap2 -s 'print(lon,"%3.2f,")' $file`
as does this:
ncks -H -s '%3.2f, ' -v lon $file
Log in to post a comment.