;---------;---------;---------;---------;---------;---------;---------;--------: ;File/Program ScanPlotFixed ;2006/04/25 WCC ;This program reads RICO RHI data and produces GIF images of a 3D visualization ; of corrected velocity and reflectivity using Object Graphics. ; ;---------;---------;---------;---------;---------;---------;---------;--------: PRO ScanPlotFixed ;---------;---------;---------;---------;---------;---------;---------;--------: ;Define the colors and device characteristics COMMON COLORS, R_orig, G_orig, B_orig, R_mod, G_mod, B_mod LOADCT,13 ;load the rainbow color table into the COMMON COLORS ;rgb_table = BYTARR(3,256) R_mod = R_orig[*] G_mod = G_orig[*] B_mod = B_orig[*] R_mod[255] = 255 & G_mod[255] = 255 & B_mod[255] = 255 ;make top of color table white DEVICE, DECOMPOSED = 0 ;used for TrueColor displays R = 6378.0*10^3 ;radius of earth in meters Xmax = 20000 ;these values are based on the range of the radar which was Ymax = 16000 ; fixed for this experiment ;---------;---------;---------;---------;---------;---------;---------;--------: ;Get the files to process files = DIALOG_PICKFILE(/MULTIPLE_FILES,GET_PATH=path,FILTER='*.met.rc.nc', $ TITLE='Please Select Files to Process') type = SIZE(files) IF type[0] EQ 0 THEN BEGIN PRINT, 'no files found' RETURN ENDIF ;---------;---------;---------;---------;---------;---------;---------;--------: ;Scan the files to determine extremes of lat, long and altitude latMin = 90 latMax = 0 lonMin = 180 lonMax = -180 zMin = 100000 zMax = 0 FOR j = 0, N_ELEMENTS(files)-1 DO BEGIN fileId = NCDF_OPEN(files[j], /NOWRITE) NCDF_ATTGET, fileId, /GLOBAL, "P3_mode", P3_mode ;get the processing mode ;Skip processing if not a mode 170 (covariance) file IF P3_mode NE 170 THEN BEGIN PRINT, files[i] + ' has mode ', P3_mode, '. Skipping ...' CONTINUE ENDIF ;Get various variables from the netCDF file ;nRec gets the number of records in the file timeId = NCDF_DIMID(fileId, 'Time') NCDF_DIMINQ, fileId, timeId, name, nRec ;nCells gets the number of range cells in the file cellId = NCDF_DIMID(fileId, 'maxCells') NCDF_DIMINQ, fileId, cellId, name, nCells NCDF_VARGET, fileId, "lat", lati ;latitude of range cells by beam and range cell NCDF_VARGET, fileId, "lon", lon NCDF_VARGET, fileId, "altm", altm latMinFile = MIN(lati[*,*]) IF latMinFile LT 90 THEN latMin = MIN([latMin,latMinFile]) latMaxFile = MAX(lati[*,*]) IF latMaxFile LT 90 THEN latMax = MAX([latMax,latMaxFile]) lonMinFile = MIN(lon[*,*]) IF lonMinFile LE 180 THEN lonMin = MIN([lonMin,lonMinFile]) lonMaxFile = MAX(lon[*,*]) IF lonMaxFile LE 180 THEN lonMax = MAX([lonMax,lonMaxFile]) zMinFile = MIN(altm[*,*]) IF zMinFile LE 100000 THEN zMin = MIN([zMin,zMinFile]) zMaxFile = MAX(altm[*,*]) IF zMaxFile LE 100000 THEN zMax = MAX([zMax,zMaxFile]) NCDF_CLOSE, fileId ENDFOR ;---------;---------;---------;---------;---------;---------;---------;--------: delLat = 2*(latMax - latMin) delLon = 2*(lonMax - lonMin) delZ = 2*(zMax - zMin) xcoord_conv = [-lonMin/delLon,1.0/delLon] ycoord_conv = [-latMin/delLat,1.0/delLat] zcoord_conv = [-zMin/delZ, 1.0/delZ] ;---------;---------;---------;---------;---------;---------;---------;--------: ;Create the window, scene, view and model for the corrected velocity plot oWindow = OBJ_NEW('IDLgrWindow',TITLE='NOAA/K Radar') oWindow->SetProperty,DIMENSIONS=[512,1024] oPalette = OBJ_NEW('IDLgrPalette',R_mod,G_mod,B_mod);create the color palette oWindow->SetProperty,PALETTE=oPalette ;load color table into window oScene = OBJ_NEW('IDLgrScene') ;scene object contains the view objects ; Create the view and the model for the corrected velocity Plot oViewP = OBJ_NEW('IDLgrView', VIEWPLANE_RECT=[-0.15,-0.15,1,1], $ LOCATION=[0.0,0.60],DIMENSIONS=[1.0,0.40],UNITS=3) oScene->Add, oViewP oModelP = OBJ_NEW('IDLgrModel') oViewP->Add, oModelP ;add the model to the view ; Create the view and the model for the velocity Colorbar oViewC = OBJ_NEW('IDLgrView', VIEWPLANE_RECT=[-0.05,0,1,1],$ LOCATION=[0.1,0.55],DIMENSIONS=[0.8,0.07],UNITS=3) oScene->Add, oViewC oModelC = OBJ_NEW('IDLgrModel') oViewC->Add, oModelC ;add the model to the view ; Create the view and the model for the reflectivity Plot oViewR = OBJ_NEW('IDLgrView', VIEWPLANE_RECT=[-0.15,-0.15,1,1], $ LOCATION=[0.0,0.10],DIMENSIONS=[1.0,0.40],UNITS=3) oScene->Add, oViewR oModelR = OBJ_NEW('IDLgrModel') oViewR->Add, oModelR ;add the model to the view ; Create the view and the model for the reflectivity Colorbar oViewCR = OBJ_NEW('IDLgrView', VIEWPLANE_RECT=[-0.05,0,1,1],$ LOCATION=[0.1,0.05],DIMENSIONS=[0.8,0.07],UNITS=3) oScene->Add, oViewCR oModelCR = OBJ_NEW('IDLgrModel') oViewCR->Add, oModelCR ;add the model to the view ; Create the view and the model for the Annotation oViewA = OBJ_NEW('IDLgrView', VIEWPLANE_RECT=[0,0,1,1],$ LOCATION=[0.0,0.0],DIMENSIONS=[1.0,0.05],UNITS=3) oScene->Add, oViewA oModelA = OBJ_NEW('IDLgrModel') oViewA->Add, oModelA ;add the model to the view ; Create a text object and add it to the Annotation model ;oText = OBJ_NEW('IDLgrText','NOAA/ESRL',ALIGNMENT=0.8) ;oModelA->Add, oText ; Create the axes and add them to the velocity plot model oXaxisTitleV = OBJ_NEW('IDLgrText', 'Longitude') oXaxis = OBJ_NEW('IDLgrAxis', 0, RANGE=[lonMin,lonMax], $ XCOORD_CONV=xcoord_conv, TICKLEN=0.02, TITLE=oXaxisTitleV) oYaxis = OBJ_NEW('IDLgrAxis', 1, RANGE=[latMin,latMax], $ YCOORD_CONV=ycoord_conv, TICKLEN=0.02) oZaxis = OBJ_NEW('IDLgrAxis', 2, RANGE=[zMin,zMax], $ ZCOORD_CONV=zcoord_conv, TICKLEN=0.02) oModelP->Add, oXaxis oModelP->Add, oYaxis oModelP->Add, oZaxis ; Rotate the model to achieve an isometric view oModelP->Rotate,[1,0,0], -90 ;put the y-axis going into the screen oModelP->Rotate,[0,1,0], -90 oModelP->Rotate,[0,1,0], -45 ;make isometric, step 1 oModelP->Rotate,[1,0,0], -35.3 ;make isometric, step 2 oModelP->Rotate,[0,1,0], 180 oModelP->Translate,0.3,0,0 ; Create the axes and add them to the reflectivity plot model oXaxisTitleR = OBJ_NEW('IDLgrText', 'Longitude') oXaxisR = OBJ_NEW('IDLgrAxis', 0, RANGE=[lonMin,lonMax], $ XCOORD_CONV=xcoord_conv, TICKLEN=0.02, TITLE=oXaxisTitleR) oYaxisR = OBJ_NEW('IDLgrAxis', 1, RANGE=[latMin,latMax], $ YCOORD_CONV=ycoord_conv, TICKLEN=0.02) oZaxisR = OBJ_NEW('IDLgrAxis', 2, RANGE=[zMin,zMax], $ ZCOORD_CONV=zcoord_conv, TICKLEN=0.02) oModelR->Add, oXaxisR oModelR->Add, oYaxisR oModelR->Add, oZaxisR ; Rotate the model to achieve an isometric view oModelR->Rotate,[1,0,0], -90 ;put the y-axis going into the screen oModelR->Rotate,[0,1,0], -90 oModelR->Rotate,[0,1,0], -45 ;make isometric, step 1 oModelR->Rotate,[1,0,0], -35.3 ;make isometric, step 2 oModelR->Rotate,[0,1,0], 180 oModelR->Translate,0.3,0,0 ; Create the velocity colorbar dataRange = [-12,12] oTitle = OBJ_NEW('IDLgrText', 'Corrected Velocity in m/s') oColorbar = OBJ_NEW('IDLgrColorbar',R_mod,G_mod,B_mod,TITLE=oTitle, $ DIMENSIONS=[.9,.15],/SHOW_AXIS,/SHOW_OUTLINE) ; oColorbar->SetProperty,MAJOR=7 ;this is ignored oColorbar->GetProperty,TICKVALUES=ticks nticks = N_ELEMENTS(ticks) myTicks = FINDGEN(nTicks)/(nTicks-1) * (dataRange[1]-dataRange[0]) + dataRange[0] myTickString = STRING(myTicks,FORMAT='(F5.1)') myTickString = STRTRIM(myTickString,2) oTicktext = OBJ_NEW('IDLgrText', mytickString) oColorbar->SetProperty,TICKTEXT=oTicktext oModelC->Add, oColorbar ;oModelC->Translate,0,5000,0 ; Create the reflectivity colorbar dataRange = [-40,30] oTitleR = OBJ_NEW('IDLgrText', 'Reflectivity in dBZ') oColorbarR = OBJ_NEW('IDLgrColorbar',R_mod,G_mod,B_mod,TITLE=oTitleR, $ DIMENSIONS=[.9,.15],/SHOW_AXIS,/SHOW_OUTLINE) oColorbarR->GetProperty,TICKVALUES=ticks nticks = N_ELEMENTS(ticks) myTicks = FINDGEN(nTicks)/(nTicks-1) * (dataRange[1]-dataRange[0]) + dataRange[0] myTickString = STRING(myTicks,FORMAT='(F5.1)') myTickString = STRTRIM(myTickString,2) oTicktextR = OBJ_NEW('IDLgrText', mytickString) oColorbarR->SetProperty,TICKTEXT=oTicktextR oModelCR->Add, oColorbarR ;---------;---------;---------;---------;---------;---------;---------;--------: ;Main file processing loop. A file contains a complete sweep. FOR j = 0, N_ELEMENTS(files)-1 DO BEGIN fileId = NCDF_OPEN(files[j], /NOWRITE) NCDF_ATTGET, fileId, /GLOBAL, "P3_mode", P3_mode ;get the processing mode ;Skip processing if not a mode 170 (covariance) file IF P3_mode NE 170 THEN BEGIN PRINT, files[i] + ' has mode ', P3_mode, '. Skipping ...' CONTINUE ENDIF ; PRINT, 'processing ' + files[j] ;Get various variables from the netCDF file ;nRec gets the number of records in the file timeId = NCDF_DIMID(fileId, 'Time') NCDF_DIMINQ, fileId, timeId, name, nRec ;nCells gets the number of range cells in the file cellId = NCDF_DIMID(fileId, 'maxCells') NCDF_DIMINQ, fileId, cellId, name, nCells ;define a data structure for field data dummy = {Fields, ve:FLTARR(nCells), c0:FLTARR(nCells), p0:FLTARR(nCells), $ z0:FLTARR(nCells), cve:FLTARR(nCells)} NCDF_VARGET, fileId, "base_time", baseTime timeString = unixTimetoString(baseTime) NCDF_VARGET, fileId, "lat", lati ;latitude of range cells by beam and range cell NCDF_VARGET, fileId, "lon", lon NCDF_VARGET, fileId, "altm", altm NCDF_VARGET, fileId, "Latitude", Latitude ;Latitude of radar by beam NCDF_VARGET, fileId, "Longitude", Longitude NCDF_VARGET, fileId, "Altitude", Altitude data = REPLICATE({Fields}, nRec) ;data will get all of the field data readAllData, fileId, data ;read all of the field data into data ;---------;---------;---------;---------;---------;---------;---------;--------: ;Filter the z0, ve and cve fields based on the p0 field and the c0 field mask = BYTARR(nRec,nCells) FOR i = 0, nRec-1 DO BEGIN badData = WHERE(data[i].p0[*] LT -104,count) ;discard data where p0 < -104 dBm IF count EQ 0 THEN CONTINUE data[i].z0[badData] = -9999 data[i].ve[badData] = -9999 data[i].cve[badData] = -9999 ENDFOR FOR i = 0, nRec-1 DO BEGIN badData = WHERE(data[i].c0[*] LT 0.3,count) ;discard data where c0 < 0.3 IF count EQ 0 THEN CONTINUE data[i].z0[badData] = -10000 data[i].ve[badData] = -10000 data[i].cve[badData] = -10000 ENDFOR ;---------;---------;---------;---------;---------;---------;---------;--------: lati = TRANSPOSE(lati) lon = TRANSPOSE(lon) altm = TRANSPOSE(altm) ;---------;---------;---------;---------;---------;---------;---------;--------: ; Create the time/location string and add it to the model idString1 = timestring + ' Latitude:'+STRING(Latitude[0],FORMAT='(F9.4)')+ $ ', Longitude:'+STRING(Longitude[0],FORMAT='(F9.4)') idString2 = 'NOAA/ESRL' oText = OBJ_NEW('IDLgrText',[idString1,idString2],ALIGNMENT=0.0, $ LOCATIONS=[[0.0,0.03],[0.0,0.5]]) oModelA->Add, oText ;---------;---------;---------;---------;---------;---------;---------;--------: ;Plot corrected velocity using Object Graphics Color = BYTSCL(data[*].cve[*],MIN=-12,MAX=12,TOP=254) badData = WHERE(Color[*] EQ 0,count) IF count GT 0 THEN Color[badData] = 255 Colors = TRANSPOSE(Color) ; Create a surface and add it to the model oPlot = OBJ_NEW('IDLgrSurface',altm,lon,lati,$ VERT_COLORS=colors[*] ,XCOORD_CONV=xcoord_conv, $ YCOORD_CONV=ycoord_conv, ZCOORD_CONV=zcoord_conv) oModelP->Add, oPlot ;add the plot to the model ;---------;---------;---------;---------;---------;---------;---------;--------: ;Plot reflectivity Color = BYTSCL(data[*].z0[*],MIN=-40,MAX=30,TOP=254) badData = WHERE(Color[*] EQ 0,count) IF count GT 0 THEN Color[badData] = 255 Colors = TRANSPOSE(Color) ; Create a surface and add it to the model oPlotR = OBJ_NEW('IDLgrSurface',altm,lon,lati,$ VERT_COLORS=colors[*],XCOORD_CONV=xcoord_conv, $ YCOORD_CONV=ycoord_conv, ZCOORD_CONV=zcoord_conv) oModelR->Add, oPlotR ;add the plot to the model oWindow->Draw, oScene ;redraw the scene ;---------;---------;---------;---------;---------;---------;---------;--------: ; Produce a GIF image of the window outFile = path + '/NOAA-K-' + STRMID(timestring,0,4) + $ STRMID(timestring,5,2) + STRMID(timestring,8,2) + '.2Df.' + $ STRING(j+1,FORMAT='(I04)') + '.gif' ;build path name exportWindowToGif,oWindow,outFile ;export the GIF file OBJ_DESTROY,oPlot ;destroy the plots and annotation OBJ_DESTROY,oPlotR OBJ_DESTROY,oText ;---------;---------;---------;---------;---------;---------;---------;--------: NCDF_CLOSE, fileId ENDFOR ;End of Main File Processing Loop ;---------;---------;---------;---------;---------;---------;---------;--------: theEnd: END ;---------;---------;---------;---------;---------;---------;---------;--------: ;---------;---------;---------;---------;---------;---------;---------;--------: