shell code+ nearest point question [message #84677] |
Thu, 14 June 2012 06:18 |
anil
Messages: 34 Registered: August 2009
|
Member |
|
|
Hi
I do have a single data file namely 'lonlat.dat' , which contains
longitude,latitude and filename data, like:
( longitude latitude filename)
30.4000 42.2900 2002252.s04d1pfv50-sst.hdf
30.5300 42.3300 2002260.s04d1pfv50-sst.hdf
and so on... I do have some hdf files which are named just like in
column 3 of this lonlat.dat file.
What i want to do is to open every file listed in this 3rd column. and
for this file, i want to find the closest /nearest point to my
longitude and latitude (column1&2) and read the corresponding value of
my desired variable(sst, sea surface temperature for this case.) I can
read hdf data files like this :
files=findfile('*.hdf',count=numfiles)
for k=0,numfiles-1 do begin
file=hdf_sd_start(files(k))
indexa=hdf_sd_nametoindex(file,'lon')
indexb=hdf_sd_nametoindex(file,'lat')
indexc=hdf_sd_nametoindex(file,'sst')
varida=hdf_sd_select(file,indexa)
varidb=hdf_sd_select(file,indexb)
varidc=hdf_sd_select(file,indexc)
hdf_sd_getdata,varida,loni
hdf_sd_getdata,varidb,lati
hdf_sd_getdata,varidc,ssti
hdf_sd_endaccess,varida
hdf_sd_endaccess,varidb
hdf_sd_endaccess,varidc
hdf_sd_end,file
endfor
I could not read the 'lonlat.dat' file into idl as variables, so i
wanted to write a short shell script to read in this 'lonlat.dat' file
and run idl within this script. below is this script. it may be wrong,
but here is what i do. i just could not figure out, how to read these
variables into IDL. I have to read in the 3rd column and assign it as
the filenames of the files to be opened and read. 1st and 2nd columns
as the desired longitudes and latitudes.
while read line
do
lon=`echo $line |awk '{print $1}'`
lat=`echo $line |awk '{print $2}'`
filename=`echo $line |awk '{print $3}'`
echo $lon $lat $filename
idl <<EOF
.r nearest.pro $filename $lon $lat
exit
EOF
done <lonlat.dat
So i should somehow read this $filename into idl and use it to read
the files.
And use the $lon and $lat to find the closest point to them within
that hdf file and read the corresponding sst.
My 2nd question is how to find the closest point to my lat and lon?
I hope it is clear. need help ,urgently
|
|
|