From b08959e189b82286c717ee83a3c57d614ec0802b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=85smund=20Bakketun?= Date: Fri, 20 Sep 2024 08:35:23 +0000 Subject: [PATCH] add diff converter. Returns field1 - field2 --- pysurfex/read.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pysurfex/read.py b/pysurfex/read.py index f7cb3e9..b5a18c9 100644 --- a/pysurfex/read.py +++ b/pysurfex/read.py @@ -162,6 +162,9 @@ def __init__(self, name, initial_time, defs, conf, fileformat): if self.name == "none" or self.name == "analysis": self.var = self.create_variable(fileformat, defs, conf[self.name]) + elif name == "diff": + self.field1 = self.create_variable(fileformat, defs, conf[self.name]["field1"]) + self.field2 = self.create_variable(fileformat, defs, conf[self.name]["field2"]) elif name == "rh2q": self.r_h = self.create_variable(fileformat, defs, conf[self.name]["rh"]) self.temp = self.create_variable(fileformat, defs, conf[self.name]["t"]) @@ -316,6 +319,9 @@ def read_time_step(self, geo, validtime, cache): # Specific reading for each converter if self.name == "none" or self.name == "analysis": field = self.var.read_variable(geo, validtime, cache) + elif self.name == "diff": + field = self.field1.read_variable(geo, validtime, cache) \ + - self.field2.read_variable(geo, validtime, cache) elif self.name == "windspeed" or self.name == "winddir": field_x = self.x_wind.read_variable(geo, validtime, cache) field_y = self.y_wind.read_variable(geo, validtime, cache)