示例#1
0
 def test_load_old(self):
     # Load from an old session
     ecmwf_prod_orig_dir = os.path.join(self.tmpdir.name, "products", "20141109-00-ECMWF-IDD")
     ecmwf_prod_edit_dir = os.path.join(self.tmpdir.name, "products_edited", "20141109-00-ECMWF-IDD")
     os.makedirs(ecmwf_prod_orig_dir)
     os.makedirs(ecmwf_prod_edit_dir)
     prod = CSVProduct("test_grib_out/20141109-00-ECMWF-IDD/t2m+36.staz.csv")
     with open(os.path.join(ecmwf_prod_orig_dir, "t2m+36.staz.csv"), "wt") as out:
         prod.copy(out)
     with open(os.path.join(ecmwf_prod_edit_dir, "t2m+36.staz.csv"), "wt") as out:
         def amend(row):
             # Do not clobber macroarea indicators
             if row["Variable"] == "B01192": return
             if round(float(row["Latitude"]) * 100000) == 4407000 and \
                 round(float(row["Longitude"]) * 100000) == 1257000:
                 row["Value"] = "242.123456"
         prod.copy(out, amend)
     ep = EditedValues.from_old_session(self.today, self.sel_runs, self.tmpdir.name)
     # Test
     self.assertEquals(ep.values, { (0, 12, "t2m"): { ("staz", 44.07, 12.57): ("242.123456", "manual") } })
     # Convert to json and read it back
     data = ep.to_jsonable()
     ep = EditedValues.from_json(data)
     # Test again
     self.assertEquals(ep.values, { (0, 12, "t2m"): { ("staz", 44.07, 12.57): ("242.123456", "manual") } })
     # Clone and test again
     ep = ep.clone()
     self.assertEquals(ep.values, { (0, 12, "t2m"): { ("staz", 44.07, 12.57): ("242.123456", "manual") } })
示例#2
0
 def test_load_old_empty(self):
     # Load from an empty old session
     ep = EditedValues.from_old_session(self.today, self.sel_runs, self.tmpdir.name)