;+NAME/ONE LINE DESCRIPTION OF ROUTINE: ; READL3BIN reads a specific product from a seawifs bin file ; ; NAME: ; readl3bin ; ; PURPOSE: ; Simplifies the reading of SeaWiFS standard L3 bin file. Returns mean ; bin values for a specified product, and corresponding lon/lat. ; ; CALLING SEQUENCE: ; data = readl3hdf(filename,prodname,lon,lat) ; ; INPUT: ; filename - L2 filename string. ; prodname - L2 SDS product name string. If this ends in '_', all SDS ; products of name prodname_nnn (where nnn is wavelength) ; will be returned. ; ; OUTPUT: ; data - 1-dimensional array containing the requested product. ; lon - 1-demensional array of bin longitude positions ; lat - 1-demensional array of bin latitude positions ; ; SUBROUTINES CALLED: ; get_vds_in_vg ; bin2ll ; ; WRITTEN BY: ; J. Gales, Futuretech Corp.. ; B. A. Franz, SAIC General Sciences Corp.. ; February 2000. ; ; HISTORY: ; ; Tue Oct 29 15:47:19 2002, Joel Gales ; ; ; ;- function readl3bin,file,prod,lon,lat,bins,nobs,wts,nscenes,sum,sum2, $ beg=beg,extent=extent,nrows=nrows,quiet=quiet fileid = HDF_OPEN(file, /READ) vref = HDF_VD_FIND(fileid,'BinIndex') vdata_id = HDF_VD_ATTACH(fileid, vref) HDF_VD_GET, vdata_id, count=nrows nrec = HDF_VD_READ(vdata_id,beg,fields='begin') nrec = HDF_VD_READ(vdata_id,extent,fields='extent') HDF_VD_DETACH,vdata_id vref = HDF_VD_FIND(fileid,'BinList') vdata_id = HDF_VD_ATTACH(fileid, vref) nrec = HDF_VD_READ(vdata_id,bins,fields='bin_num') nrec = HDF_VD_READ(vdata_id,nobs,fields='nobs') nrec = HDF_VD_READ(vdata_id,wts,fields='weights') nrec = HDF_VD_READ(vdata_id,nscenes,fields='nscenes') HDF_VD_DETACH,vdata_id n = LONG(total(nobs ne 0)) if (not keyword_set(quiet)) then print,'# of non-zero bins:', n if (prod eq '') then begin data = -1 goto, skip endif vd = get_vds_in_vg(file,'Level-3 Binned Data','DataSubordinate') s = where(vd eq prod) if (s(0) eq -1) then begin print,'Product ',prod,' not found in ',file return,-1 endif vref = HDF_VD_FIND(fileid, prod) vdata_id = HDF_VD_ATTACH(fileid, vref, /READ) nrec = HDF_VD_READ(vdata_id,sum,fields=prod+"_sum") nrec = HDF_VD_READ(vdata_id,sum2,fields=prod+"_sum_sq") data = sum/wts HDF_VD_DETACH,vdata_id HDF_CLOSE,fileid skip: bin2ll,nrows,bins,lat,lon return, data end