Пример #1
0
    def get_json_explorer(self):

        if (self.explorer is None):
            db = self.__open_db()

            with dballe.Explorer() as explorer:
                with explorer.rebuild() as updater:
                    with db.transaction() as tr:
                        updater.add_db(tr)
                return explorer.to_json()
        else:
            with dballe.Explorer(self.explorer) as explorer:
                return explorer.to_json()
Пример #2
0
    def query_summary(self, rec):
        """Query summary.

        .. warning::

            Get data from dballe explorer
        """

        with dballe.Explorer(self.explorer) as explorer:

            for cur in explorer.query_summary(rec):
                data={}
                data["ident"]=cur["ident"]
                data["report"]=cur["report"]
                data["lat"]=cur.enqi("lat")
                data["lon"]=cur.enqi("lon")
                data["datemin"]=cur["datetimemin"]
                data["datemax"]=cur["datetimemax"]
                data["leveltype1"]= cur["leveltype1"]
                data["l1"]=cur["l1"]
                data["leveltype2"]=cur["leveltype2"]
                data["l2"]=cur["l2"]
                data["pindicator"]=cur["pindicator"]
                data["p1"]=cur["p1"]
                data["p2"]=cur["p2"]
                data["var"]=cur["var"]
                #print ("dballe query summary: ",data)
                yield data
Пример #3
0
    def query_summary(self, rec):

        with dballe.Explorer() as explorer:
            with explorer.update() as updater:
                for db in self.dbs:
                    #jsexp=db.get_json_explorer()
                    #print (jsexp)
                    #updater.add_json(jsexp)
                    updater.add_json(db.get_json_explorer())

            explorer.set_filter(rec)
            for cur in explorer.query_summary(rec):
                data = {}
                data["ident"] = cur["ident"]
                data["report"] = cur["report"]
                data["lat"] = cur.enqi("lat")
                data["lon"] = cur.enqi("lon")
                data["datemin"] = cur["datetimemin"]
                data["datemax"] = cur["datetimemax"]
                data["leveltype1"] = cur["leveltype1"]
                data["l1"] = cur["l1"]
                data["leveltype2"] = cur["leveltype2"]
                data["l2"] = cur["l2"]
                data["pindicator"] = cur["pindicator"]
                data["p1"] = cur["p1"]
                data["p2"] = cur["p2"]
                data["var"] = cur["var"]
                #print ("dballe query summary: ",data)
                yield data
Пример #4
0
    def query_stations_explorer(self, rec):

        with dballe.Explorer(self.explorer) as explorer:
            for staz in explorer.stations:
                #print(staz.ident,staz.lat,staz.lon,staz.report)

                data = {}
                data["ident"] = staz.ident
                data["report"] = staz.report
                data["lat"] = staz.lat * 100000
                data["lon"] = staz.lon * 100000
                #print ("dballe query station: ",data)
                yield data
Пример #5
0
    def query_stations(self, rec):

        with dballe.Explorer() as explorer:
            with explorer.update() as updater:
                for db in self.dbs:
                    updater.add_json(db.get_json_explorer())
            explorer.set_filter(rec)
            for staz in explorer.stations:
                #print(staz.ident,staz.lat,staz.lon,staz.report)
                data = {}
                data["ident"] = staz.ident
                data["report"] = staz.report
                data["lat"] = staz.lat * 100000
                data["lon"] = staz.lon * 100000
                #print ("dballe query station: ",data)
                yield data
Пример #6
0
 def _make_explorer(self, name, *args, **kw):
     return dballe.Explorer(name, *args, **kw)
Пример #7
0
 def test_issue235(self):
     with dballe.Explorer(test_pathname("json/issue235.json")) as explorer:
         for cur in explorer.query_summary({"var": "B12101"}):
             cur["datetimemax"]
Пример #8
0
 def _explorer(self, *args, **kw):
     return dballe.Explorer(*args, **kw)
Пример #9
0
 def _explorer(self):
     return dballe.Explorer()
Пример #10
0
    def get_json_explorer(self):

        with dballe.Explorer(self.explorer) as explorer:
            return explorer.to_json()