Esempio n. 1
0
    def makeModDialog(self, varnames):
        datahandlers = []
        for name in varnames:
            dh = dataHandler(self.data, str(name))
            datahandlers.append(dh)

        moddialog = modifyDialog(datahandlers, self)
        moddialog.setWindowTitle("Modify netCDF data")
        moddialog.show()
Esempio n. 2
0
    def makeHumCreatorDialog(self, varnames):
        datahandlers = []

        # read in temperature and specific humidity from forcing file
        temperature = self.data.variables["t"][0, :]
        spechum = self.data.variables["q"][0, :]

        varnames = list(set().union(varnames, ["q", "t"]))
        print varnames
        nlvl = 0
        for name in varnames:
            dh = dataHandler(self.data, str(name))
            datahandlers.append(dh)
            nlvl = dh.nlvl

        if "vct_a" in self.data.variables.keys() and "vct_b" in self.data.variables.keys():
            print "vct_a", self.data.variables["vct_a"][:].shape
            hyam = self.data.variables["vct_a"][:]
            hybm = self.data.variables["vct_b"][:]
            print "vct_a taken from file:"
            print hyam
            print "vct_b taken from file:"
            print hybm
        if nlvl == 31:
            hyam = hyam31
            hybm = hybm31
        elif nlvl == 47:
            hyam = hyam47
            hybm = hybm47
        else:
            print "cannot handle those modellevels:", self.data.nlev
            return

        if "aps" in self.data.variables.keys():
            aps = self.data.variables["aps"][0]
            print "aps taken from file: aps = %s" % (aps)
        else:
            aps = 100000

        mlev = hyam + hybm * aps
        # interpolate interface pressure to midlvl pressures to much T and q
        # this can be done more carefully, but it doesn't really matter for the
        # application, so it may be improved some time later.
        if len(mlev) % 2 == 0:
            i = np.arange(len(mlev) - 1)
            mlev = (mlev[i] + mlev[i + 1]) / 2.0
        humConverter = HumidityConverter(mlev, temperature, spechum)

        moddialog = modifyDialog(datahandlers, self, humConverter)
        moddialog.setWindowTitle("Modify netCDF data")
        moddialog.show()
        print "finished showing moddialog"