Exemple #1
0
    def graph_station(self, packageName, stationName, varsub=True):
        """
        produces graph of given station in/outflows
        """
        if self._ignores(packageName, station=stationName):
            if self.verbose: print("ignoring s: " + packageName + "/" + stationName)
            return
        else:
            if self.verbose: print("graphing "+packageName+"/"+stationName+"...")
            cfgfile = CFGFileReader(
                path_helper.cfg_path(packageName, stationName),
                verbose=(self.verbocity > 1)
            )
            cfgfile.set_varsub(varsub)

            self._add_node(stationName, NodeType.STATION, cfgfile, package=packageName)

            # connect inflow product to station
            for inflow in cfgfile.get_inflows():
                if self.verbose: print(inflow, "=>", stationName)
                self._add_node(inflow, NodeType.PRODUCT, cfgfile)
                self._add_edge(inflow, stationName)

            # connect station to outflow products
            for outflow in cfgfile.get_outflows():
                if self.verbose: print(stationName, "=>", outflow)
                self._add_node(outflow, NodeType.PRODUCT, cfgfile)
                self._add_edge(stationName, outflow)

        self._finalize()  # NOTE: would be more efficient (but messier) to do this once
    def test_var_sub_on_crefl(self):
        """h2g modis_tcolor-2 w/ undefined product_group"""
        cfg = CFGFileReader(path_helper.cfg_path("h2g", "modis_tcolor-2"),
                            verbose=True)
        cfg.set_varsub(True)
        actual = cfg.get_inflows()
        expected = ['imars.getProductType().modis.?product_group?.filtered']

        self.assertEqual(expected, actual)
    def test_graph_modisl1db_l0l1aqua_inflows_w_formatter(self):
        """
        modisl1db l0l1aqua inflows = ['drl.aqua.modis.pds']
        """
        cfg = CFGFileReader(path_helper.cfg_path("modisl1db", "l0l1aqua"))
        cfg.set_varsub(True)
        actual = cfg.get_inflows()
        expected = ['drl.aqua.modis.pds']

        self.assertEqual(expected, actual)
    def test_oc_png_has_no_None_inflows_w_formatter(self):
        """
        imars oc_png inflows should not include "None" values
        """
        cfg = CFGFileReader(path_helper.cfg_path("imars", "oc_png"),
                            verbose=True)
        cfg.set_varsub(True)
        actual = cfg.get_inflows()
        expected = ['imars.getProductType().modis.oc.mapped']

        self.assertEqual(expected, actual)
    def test_brackets_in_varnames(self):
        """ test using CVIIRS/CVIIRS which has brackets in varnames """
        cfg = CFGFileReader(path_helper.cfg_path("CVIIRS", "CVIIRS"),
                            verbose=True)
        cfg.set_varsub(True)
        actual = cfg.get_inflows()
        expected = [
            'drl.npp.viirs.svm03',
            'drl.npp.viirs.svm04 drl.npp.viirs.svm05 drl.npp.viirs.svm07 '
            'drl.npp.viirs.svm08 drl.npp.viirs.svm10 drl.npp.viirs.svm11 '
            'drl.npp.viirs.svi01 drl.npp.viirs.svi02 drl.npp.viirs.svi03 '
            'drl.npp.viirs.gmtco'
        ]

        self.assertEqual(expected, actual)