Ejemplo n.º 1
0
    def execute(self):
        mutableID = self.mutableID()
        newTerrainDbId = self.findDatabase("EditTopo_NewTerrain")
        if mutableID != newTerrainDbId:
            DisplayMessageDialog.openError(
                "Invalid Mutable Database",
                "You must be using the NewTerrain GFE configuration to run this procedure.\n"
                "Please restart CAVE and select the NewTerrain GFE configuration."
            )
            return

        allTimes = TimeRange.allTimes()
        baseTerrainDbId = self.findDatabase("EditTopo_BaseTerrain")
        gtopoParm = self.getParm(baseTerrainDbId, "GTOPO", "SFC")
        gtopoGrid = self.getTerrainGrid("gtopo30")
        gtopoParm.setMutable(True)
        self.createGrid(baseTerrainDbId, "GTOPO", "SCALAR", gtopoGrid,
                        allTimes)
        gtopoParm.saveParameter(True)
        gtopoParm.setMutable(False)

        stdTopoDbId = self.findDatabase("D2D_StdTerrain")
        stdTopoGrid = self.getGrids(stdTopoDbId,
                                    "DISTsurface",
                                    "SFC",
                                    allTimes,
                                    mode="First")
        stdTopoGrid /= 0.3048  # convert meters to feet

        stdTopoParm = self.getParm(baseTerrainDbId, "StdTopo", "SFC")
        stdTopoParm.setMutable(True)
        self.createGrid(baseTerrainDbId, "StdTopo", "SCALAR", stdTopoGrid,
                        allTimes)
        stdTopoParm.saveParameter(True)
        stdTopoParm.setMutable(False)

        newTopoParm = self.getParm(newTerrainDbId, "NewTopo", "SFC")
        inventory = newTopoParm.getGridInventory()
        doIt = True
        if len(inventory) > 0:
            doIt = DisplayMessageDialog.openQuestion(
                "NewTopo Grid exists!",
                "Do you wish to re-initialize the NewTopo Grid discarding any edits?"
            )

        if doIt:
            self.createGrid(newTerrainDbId, "NewTopo", "SCALAR", stdTopoGrid,
                            allTimes)
            newTopoParm.saveParameter(True)

        self.setActiveElement(newTerrainDbId, "NewTopo", "SFC", allTimes)
Ejemplo n.º 2
0
    def execute(self, timeRange):
        mutableID = self.mutableID()
        newTerrainDbId = self.findDatabase("EditTopo_NewTerrain")
        if mutableID != newTerrainDbId:
            DisplayMessageDialog.openError("Invalid Mutable Database", 
            "You must be using the NewTerrain GFE configuration to run this procedure.\n"
            "Please restart CAVE and select the NewTerrain GFE configuration.")
            return

        newTopo = self.getGrids(newTerrainDbId, "NewTopo", "SFC", timeRange, mode="First")
        
        baseTerrainDbId = self.findDatabase("EditTopo_BaseTerrain")
        stdTopo = self.getGrids(baseTerrainDbId, "StdTopo", "SFC", timeRange, mode="First")
        gtopo = self.getGrids(baseTerrainDbId, "GTOPO", "SFC", timeRange, mode="First")

        topoDbId = self.findDatabase("EditTopo_Topo")
        topo = self.getGrids(topoDbId, "Topo", "SFC", timeRange, mode="First")

        self.unloadWEs(newTerrainDbId, 
                       [("newTopoMinusTopo", "SFC"),
                        ("StdMinusGTOPO", "SFC"),
                        ("newEdits", "SFC"),
                        ("currentEdits", "SFC")])

        delta = newTopo - topo
        maxVal = numpy.nanmax(delta)
        minVal = numpy.nanmin(delta)
        maxDelta = max(1.0, abs(maxVal), abs(minVal))
        self.createGrid(newTerrainDbId, "newTopoMinusTopo", "SCALAR", delta, TimeRange.allTimes(), 
                        "NewTopo - Topo", (0,60,60), 1, -maxDelta, maxDelta, "ft", defaultColorTable="GFE/Delta")

        delta = stdTopo - gtopo
        maxVal = numpy.nanmax(delta)
        minVal = numpy.nanmin(delta)
        maxDelta = max(1.0, abs(maxVal), abs(minVal))
        self.createGrid(newTerrainDbId, "StdMinusGTOPO", "SCALAR", delta, TimeRange.allTimes(), 
                        "StdTopo - GTOPO", (0,60,60), 1, -maxDelta, maxDelta, "ft", defaultColorTable="GFE/Delta")

        delta = newTopo - stdTopo
        maxVal = numpy.nanmax(delta)
        minVal = numpy.nanmin(delta)
        maxDelta = max(1.0, abs(maxVal), abs(minVal))
        self.createGrid(newTerrainDbId, "newEdits", "SCALAR", delta, TimeRange.allTimes(), 
                        "NewTopo - StdTopo", (0,60,60), 1, -maxDelta, maxDelta, "ft", defaultColorTable="GFE/Delta")

        delta = topo - gtopo
        maxVal = numpy.nanmax(delta)
        minVal = numpy.nanmin(delta)
        maxDelta = max(1.0, abs(maxVal), abs(minVal))
        self.createGrid(newTerrainDbId, "currentEdits", "SCALAR", delta, TimeRange.allTimes(), 
                        "Topo - GTOPO", (0,60,60), 1, -maxDelta, maxDelta, "ft", defaultColorTable="GFE/Delta")
Ejemplo n.º 3
0
    def execute(self, timeRange):
        mutableID = self.mutableID()
        topoDbId = self.findDatabase("EditTopo_Topo")
        if mutableID != topoDbId:
            DisplayMessageDialog.openError("Invalid Mutable Database", 
            "You must be using the EditTopo GFE configuration to run this procedure.\n"
            "Please restart CAVE and select the EditTopo GFE configuration.")
            return
        
        # check for existence of PrevTopo grid
        baseTerrainDbId = self.findDatabase("EditTopo_BaseTerrain")
        prevTopoParm = self.getParm(baseTerrainDbId, "PrevTopo", "SFC")
        inventory = prevTopoParm.getGridInventory()
        if len(inventory) == 0:
            DisplayMessageDialog.openError("No PrevTopo grid exists!", 
                "It appears you have not yet run CopyFromNewTopo so you have\n"
                "no backup copy to restore.")

        doIt = DisplayMessageDialog.openQuestion("RevertTopo",
               "You are about to revert your GFE Topo data to the last saved state.\n\n"
               "Do you wish to continue?")
        
        if not doIt:
            return
        
        # Replace the current Topo grid with PrevTopo
        prevTopo = self.getGrids(baseTerrainDbId, "PrevTopo", "SFC", timeRange, mode="First")
        topoParm = self.getParm(topoDbId, "Topo", "SFC")
        self.createGrid(topoDbId, "Topo", "SCALAR", prevTopo, TimeRange.allTimes())
        topoParm.saveParameter(True)

        DisplayMessageDialog.openInformation("Success!", "Topo successfully restored!")
Ejemplo n.º 4
0
    def execute(self, timeRange):
        mutableID = self.mutableID()
        topoDbId = self.findDatabase("EditTopo_Topo")
        if mutableID != topoDbId:
            DisplayMessageDialog.openError("Invalid Mutable Database", 
            "You must be using the EditTopo GFE configuration to run this procedure.\n"
            "Please restart CAVE and select the EditTopo GFE configuration.")
            return
        
        # check for existence of NewTopo grid
        newTerrainDbId = self.findDatabase("EditTopo_NewTerrain")
        newTopoParm = self.getParm(newTerrainDbId, "NewTopo", "SFC")
        inventory = newTopoParm.getGridInventory()
        if len(inventory) == 0:
            DisplayMessage.openError("No NewTopo grid exists!",
            "You must initialize and edit the NewTopo grid as desired.\n" 
            "You should run this procedure only when your edits are final.")
            return

        doIt = DisplayMessageDialog.openQuestion("WARNING!", 
           "You are about to replace your GFE Topo data with the NewTopo data.\n"
           "You should only do this after you have completed all edits and have\n"
           "resolved any border differences with your neighboring sites.\n\n"
           "Do you wish to continue?")
            
        if not doIt:
            return;
        
        baseTerrainDbId = self.findDatabase("EditTopo_BaseTerrain")
        prevTopoParm = self.getParm(baseTerrainDbId, "PrevTopo", "SFC")
        inventory = prevTopoParm.getGridInventory()
        doIt = True
        if len(inventory) > 0:
            doIt = DisplayMessageDialog.openQuestion("WARNING PrevTopo exists!", 
                   "It appears that you have previously run CopyFromNewTopo and a\n"
                   "backup copy of your original GFE Topo grid already exists.\n\n"
                   "Do you want to overwrite the backup copy with your current GFE Topo grid?")
        if doIt:
            # Save the current Topo grid to PrevTopo
            topo = self.getGrids(topoDbId, "Topo", "SFC", timeRange, mode="First")
            prevTopoParm.setMutable(True)
            self.createGrid(baseTerrainDbId, "PrevTopo", "SCALAR", topo, TimeRange.allTimes())
            prevTopoParm.saveParameter(True)
            prevTopoParm.setMutable(False)

        # Copy the NewTopo data to Topo
        newTopo = self.getGrids(newTerrainDbId, "NewTopo", "SFC", timeRange, mode="First")

        topoParm = self.getParm(topoDbId, "Topo", "SFC")
        self.createGrid(topoDbId, "Topo", "SCALAR", newTopo, TimeRange.allTimes())
        topoParm.saveParameter(True)

        DisplayMessageDialog.openInformation("Topo Successfully Updated!", 
        "To revert to the previous version, run the RevertTopo procedure.")