function check_date,yr,mon,dom ;this has not been tested with data prior to 2000 if (yr gt 1900 and yr lt 2100 and $ mon ge 1 and mon le 12 and $ dom ge 1 and dom le 31) then return,1 return,0 end ;****I* idl/idl.read_sat_winds ; NAME ; read_sat_winds ; PURPOSE ; To read in and return satellite winds. ; USAGE ; INPUT ; Cloud drift wind filename ; OUTPUT ; prs - pressure level of wind observation (mb) ; lat - latitude of wind obs. (deg) ; lon - longitde of wind obs. (deg) ; dir - wind direction (degrees east of North) ; spd - wind speed (m/s) ; Optional Keywords ; u = u-component of wind (north-south) (m/s) ; v = v-component of sind (east-west) (m/s) ; RESULT ; EXAMPLE ; read_sat_winds,'GOESE.WVAPWIND.J2006137.T2300Z',prs,lat,lon,dir,spd,u=u,v=v ; NOTES ; * This is based on the clouddriftwinds.pro ; TODO ; BUGS ; AUTHOR ; Ken Knapp, NOAA/NCDC/RSAD ; CREATION DATE ; Mon Aug 27 09:44:19 EDT 2007 ; HISTORY ; SOURCE pro read_sat_winds,file,prs,lat,lon,dir,spd,u=u,v=v ;*** finfo = file_info(file) n = finfo.size / 200. d=lonarr(50,n) openr,1,file;,/swap_endian readu,1,d close,1 year = d(0)/10000l mon = d(0)/100l mod 100l dom = d(0) mod 100l ; if the date is wrong, then try byte swapping the data if (check_date(year,mon,dom) eq 0) then begin openr,1,file,/swap_endian readu,1,d close,1 year = d(0)/10000l mon = d(0)/100l mod 100l dom = d(0) mod 100l endif ;if the date is still wrong, then stop with an error if (check_date(year,mon,dom) eq 0) then begin print,'ERROR: Problem reading data' stop endif prs = d(4,*) / 10. ;Pressure level (mb) lat = d(6,*) / 100. ;latitude (deg) lon = -d(7,*) / 100. ;longitude (deg) dir = d(8,*) ;Wind direction (0=North) spd = d(9,*) / 10. ;meters per second u = -spd*sin(dir*!pi/180.) ;u-component of wind v = -spd*cos(dir*!pi/180.) ;v-component of wind end