from java.util import SimpleTimeZone # Now I must plot grib data, point data and wish myself luck! currentDir = os.getenv("HOME")+"/data/derecho/20120629/NEARCAST/" dataSelection = DataSelection() # make the data source from the 12Z run nc12ds = makeDataSource(currentDir+"20120629.12z.ECON.grib2", 'netcdf.grid') nc12data = getData(currentDir+"20120629.12z.ECON.grib2") dataChoice1 = nc12ds.findDataChoice("Pseudo-adiabatic_potential_temperature @ pressure") # find out how many times are in this data source runTimes = nc12ds.getAllDateTimes() plotMe=[] # The times pulled from getAllDateTimes() are missing seconds. This is not # compatible with makeSingleTimeFromFlatField called within makeTimeFieldFromFlatFields # need to reformat reformatTimes = [] tz = SimpleTimeZone(0,"UTC") # create a loop of each forecast time for indexOfTimes, modelTimes in enumerate(runTimes): times = ArrayList() times.add(Integer(indexOfTimes)) dataSelection.setTimes(times) dataSelection.setLevel(Integer(0)) flatField1 = nc12ds.getData(dataChoice1,None,dataSelection,None) # find out level of data myGeoGrid1 = flatField1.getSample(0) domainSet1 = myGeoGrid1.getDomainSet() print 'Level of first flat field is ', domainSet1.HiZ, domainSet1.LowZ dataSelection.setLevel(Integer(1)) flatField2 = nc12ds.getData(dataChoice1,None,dataSelection,None) # find out level of data myGeoGrid2 = flatField2.getSample(0) domainSet2 = myGeoGrid2.getDomainSet() print 'Level of second flat field is ', domainSet2.HiZ, domainSet2.LowZ plotMe.append(nearcast(myGeoGrid1, myGeoGrid2)) reformatTimes.append(modelTimes.formattedString("yyyy-MM-dd HH:mm:ss", tz)) timeSeq=makeTimeFieldFromFlatFields(plotMe,reformatTimes) panels = buildWindow() # I don't care what size the default display window is, the full screen size matters panels[0].setFullScreenSize(1280,960) panel0instance = panels[0].getJavaInstance() # Eject to full screen (when working interactively this is nice) panel0instance.toggleFullScreen() layer12Z = panels[0].createLayer('Image Display', timeSeq) layer12Z.setEnhancementTable('NEARCAST layer diff LI (Invert)') # Seems quite silly, but when I want to zoom my layer, I zoom the panel. I assume that # this is done so that all layers zoom together. panels[0].setScaleFactor(1.5) # Add the Color Bar at the Top of the Image layer12Z.setColorScale(placement='top', font='SansSerif', size=18.0, color='black') # Change the colorbar range dataRange = GridUtil.fieldMinMax(plotMe[0]) dataRange[0].min = -20 dataRange[0].max = 30 layer12Z.setRange(dataRange[0]) # Adjust the map layer bGroundMaps = (panel0instance.getControls())[0] bGroundMapState = bGroundMaps.getMapStates() # can't figure out how to point to exact map names that are needed. This is a cludgy # buggy "solution." for index,currentMap in enumerate(bGroundMapState): if (index == 1) or (index == 2): currentMap.setVisible(True) currentMap.setLineWidth(2.0) else: currentMap.setVisible(False) # Turn off the range and wireframe ## JMF Can't find where this is done. # Plot the point data from the file... currentDir = os.getenv("HOME")+"/data/derecho/20120629/" windsDataSource = makeDataSource(currentDir+"120629_full_wind.txt", 'FILE.POINTTRACKTEXT') windsDataSet = getData(currentDir+"120629_full_winds.txt") pointChoice = windsDataSource.findDataChoice("Text Point Data") observedWinds = windsDataSource.getData(pointChoice,None,None,None) layerObsWinds = panels[0].createLayer('Point Data Plot', observedWinds) pointLayer = layerObsWinds.getJavaInstance() layoutModel = "Position" stationModel = pointLayer.setStationModelName(layoutModel) currentModel = pointLayer.getStationModel() pointLayer.setLayoutModel(layoutModel, currentModel)