;;;;;;;;;;****************************************************************************************** FUNCTION READ_ABI_NETCDF_01, inputfiles, outputfile=outfile, xx=xx, yy=yy, nvars=nvars, lineele=lineele, vars=vars, ii=ii if not keyword_set(dprint ) then dprint = 0 if not keyword_set( outputfile ) then outputfile='' ;; west_east=2654 & south_north=1222 zz=N_ELEMENTS(inputfiles) ;; IF (katr EQ 1) THEN BEGIN ;; west_east=753 ;; south_north=685 ;; ENDIF ;;vars= the variable index to read. ;;nvars=the number of variables to create. dname1='x' & dname2='y' if not keyword_set( xx ) then dname1='west_east' if not keyword_set( yy ) then dname2='south_north' IF (inputfiles(0) NE '')THEN BEGIN ncdfid= NCDF_OPEN(inputfiles(0)) fileinfo= NCDF_INQUIRE(ncdfid) WE = NCDF_DIMID( ncdfid, dname1) SE = NCDF_DIMID( ncdfid, dname2) NCDF_DIMINQ, ncdfid, WE, Name1, Size1 NCDF_DIMINQ, ncdfid, SE, Name2, Size2 ngatts=fileinfo.ngatts nvars=fileinfo.nvars gattrnames=STRARR(ngatts) gatts={name:'',value:''} gats=REPLICATE(gatts,ngatts) rep=1 IF (lineele EQ 1) THEN BEGIN rep=2 & size2=1 ENDIF ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;; added to cap the sizes for 1km bands (01, 02, 03,05) ; ;;;;; IF ((ii EQ 1 OR ii EQ 2 OR ii EQ 3 OR ii EQ 5) AND lineele EQ 0) THEN BEGIN Size1=5310 & Size2=2444 ENDIF varnames=STRARR(nvars) avarset={data:FLTARR(Size1, Size2),var:'', attr:STRARR(8), attrval:STRARR(8),nvars:nvars, nvarsatt:0, ngatts:ngatts} dataset=REPLICATE(avarset,rep) ; nvars) newoutdata= {gats:gats,dataset:dataset} ;newoutdata=outdata ;REPLICATE(outdata, zz) ;nvars) NCDF_CLOSE, ncdfid ;;ENDIF FOR ww=0, zz-1 DO BEGIN ncdfid= NCDF_OPEN(inputfiles(0)) fileinfo= NCDF_INQUIRE(ncdfid) ngatts=fileinfo.ngatts ;nvars=fileinfo.nvars gattrnames=STRARR(ngatts) FOR i=0L, ngatts -1L DO BEGIN gattrnames[i]= NCDF_ATTNAME(ncdfid,i, /global) NCDF_ATTGET,ncdfid, gattrnames[i], gattvalue, /global gats(i).name=gattrnames[i] gats(i).value=string(gattvalue) IF (dprint EQ 1) THEN printf, 1, gats(i) ;print, 'gats' ,gats(i) ENDFOR IF (lineele EQ 0) THEN BEGIN FOR j=vars, vars DO BEGIN varinfo=NCDF_VARINQ(ncdfid,j) dataset(0).var=varinfo.name print, dataset(0).var varid=NCDF_VARID(ncdfid, varinfo.name) NCDF_VARGET,ncdfid, varid, temp_data dataset(0).data = temp_data(0:Size1-1, 0:Size2-1) kkk= where (temp_data GE -997) & lll=SIZE(KKK) IF (dprint EQ 1) THEN printf,1 ,dataset(0).data natts=varinfo.natts dataset.nvarsatt=natts FOR k=0L, natts- 1L DO BEGIN dataset(0).attr(k)=NCDF_ATTNAME(ncdfid,varid, k) NCDF_ATTGET, ncdfid, varid, dataset(0).attr(k), attvalue IF ((j LE 1) AND (k EQ 2) AND nvars GE 3) THEN BEGIN dataset(0).attrval(k)= string(attvalue(0)) ENDIF ELSE BEGIN dataset(0).attrval(k)= string(attvalue) ;;crashes when reading "-90, 90" or "-180 180" ENDELSE ENDFOR newoutdata.gats=gats newoutdata.dataset(0)= dataset(0) ENDFOR ENDIF ELSE BEGIN aa=1 & bb=0 IF (ii EQ 1 OR ii EQ 2 OR ii EQ 3 OR ii EQ 5) THEN aa=2 IF (ii NE 1 OR ii NE 2 OR ii NE 3 OR ii NE 5) THEN nvars=4 ; IF (ii EQ 2) THEN nvars=5 FOR j=aa, nvars-1 DO BEGIN varinfo=NCDF_VARINQ(ncdfid,j) dataset(bb).var=varinfo.name print, dataset(bb).var varid=NCDF_VARID(ncdfid, varinfo.name) NCDF_VARGET,ncdfid, varid, temp_data dataset(bb).data = temp_data kkk= where (temp_data GE -997) & lll=SIZE(KKK) IF (dprint EQ 1) THEN printf,1 ,dataset(bb).data natts=varinfo.natts dataset.nvarsatt=natts FOR k=0L, natts- 1L DO BEGIN dataset(bb).attr(k)=NCDF_ATTNAME(ncdfid,varid, k) NCDF_ATTGET, ncdfid, varid, dataset(bb).attr(k), attvalue IF ((bb LE 1) AND (k EQ 2) AND nvars GE 3) THEN BEGIN dataset(bb).attrval(k)= string(attvalue(0)) ENDIF ELSE BEGIN dataset(bb).attrval(k)= string(attvalue) ;;crashes when reading "-90, 90" or "-180 180" ENDELSE ENDFOR newoutdata.gats=gats newoutdata.dataset(bb)= dataset(bb) bb=bb+1 ; j=j+1 & IF (ii GT 5 OR ii EQ 4 ) THEN J=J+1 ;IF (ii GT 5 OR ii EQ 4 OR ii EQ 2) THEN J=J+1 ENDFOR ENDELSE NCDF_CLOSE, ncdfid CLOSE, /ALL ENDFOR ENDIF ELSE BEGIN newoutdata='' ENDELSE RETURN, newoutdata END ;;;;***********************************************************************************************