From 33fc3e61379240ee690f3a8c7dab942c496d225e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=85smund=20Bakketun?= Date: Tue, 6 Aug 2024 11:15:40 +0000 Subject: [PATCH 1/2] handle case where diskless_write is not in kwargs (e.g. from pysurfex-experiment) --- pysurfex/forcing.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/pysurfex/forcing.py b/pysurfex/forcing.py index 84b90ad..39dc724 100644 --- a/pysurfex/forcing.py +++ b/pysurfex/forcing.py @@ -1,4 +1,5 @@ """Forcing.""" + import abc import copy import json @@ -310,9 +311,9 @@ def _define_forcing(self, geo, att_objs, att_time, cache): "Number_of_points", ), ) - self.forcing_file[ - "DIR_SWdown" - ].longname = "Surface_Incident_Downwelling_Shortwave_Radiation" + self.forcing_file["DIR_SWdown"].longname = ( + "Surface_Incident_Downwelling_Shortwave_Radiation" + ) self.forcing_file["DIR_SWdown"].units = "W/m2" elif this_var == "SCA_SW": self.forcing_file["SCA_SWdown"] = self.file_handler.createVariable( @@ -323,9 +324,9 @@ def _define_forcing(self, geo, att_objs, att_time, cache): "Number_of_points", ), ) - self.forcing_file[ - "SCA_SWdown" - ].longname = "Surface_Incident_Diffuse_Shortwave_Radiation" + self.forcing_file["SCA_SWdown"].longname = ( + "Surface_Incident_Diffuse_Shortwave_Radiation" + ) self.forcing_file["SCA_SWdown"].units = "W/m2" elif this_var == "LW": self.forcing_file["LWdown"] = self.file_handler.createVariable( @@ -336,9 +337,9 @@ def _define_forcing(self, geo, att_objs, att_time, cache): "Number_of_points", ), ) - self.forcing_file[ - "LWdown" - ].longname = "Surface_Incident_Diffuse_Longwave_Radiation" + self.forcing_file["LWdown"].longname = ( + "Surface_Incident_Diffuse_Longwave_Radiation" + ) self.forcing_file["LWdown"].units = "W/m2" elif this_var == "RAIN": self.forcing_file["Rainf"] = self.file_handler.createVariable( @@ -764,6 +765,7 @@ def set_forcing_config(**kwargs): co2 = "default" co2_converter = "none" + diskless_write = False analysis = False interpolation = None try: @@ -772,7 +774,6 @@ def set_forcing_config(**kwargs): input_format = kwargs["input_format"] output_format = kwargs["output_format"] outfile = kwargs["of"] - diskless_write = kwargs["diskless_write"] zref = kwargs["zref"] uref = kwargs["uref"] config = kwargs["config"] @@ -848,6 +849,8 @@ def set_forcing_config(**kwargs): co2 = kwargs["co2"] if "co2_converter" in kwargs: co2_converter = kwargs["co2_converter"] + if "diskless_write" in kwargs: + diskless_write = kwargs["diskless_write"] except ValueError: raise Exception("Needed input is missing") from ValueError From 69d1a5a61266ba4d4851799e0a548fc032fcbe29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=85smund=20Bakketun?= Date: Tue, 6 Aug 2024 11:32:30 +0000 Subject: [PATCH 2/2] format with the proper black --- pysurfex/forcing.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pysurfex/forcing.py b/pysurfex/forcing.py index 39dc724..b9d48ba 100644 --- a/pysurfex/forcing.py +++ b/pysurfex/forcing.py @@ -311,9 +311,9 @@ def _define_forcing(self, geo, att_objs, att_time, cache): "Number_of_points", ), ) - self.forcing_file["DIR_SWdown"].longname = ( - "Surface_Incident_Downwelling_Shortwave_Radiation" - ) + self.forcing_file[ + "DIR_SWdown" + ].longname = "Surface_Incident_Downwelling_Shortwave_Radiation" self.forcing_file["DIR_SWdown"].units = "W/m2" elif this_var == "SCA_SW": self.forcing_file["SCA_SWdown"] = self.file_handler.createVariable( @@ -324,9 +324,9 @@ def _define_forcing(self, geo, att_objs, att_time, cache): "Number_of_points", ), ) - self.forcing_file["SCA_SWdown"].longname = ( - "Surface_Incident_Diffuse_Shortwave_Radiation" - ) + self.forcing_file[ + "SCA_SWdown" + ].longname = "Surface_Incident_Diffuse_Shortwave_Radiation" self.forcing_file["SCA_SWdown"].units = "W/m2" elif this_var == "LW": self.forcing_file["LWdown"] = self.file_handler.createVariable( @@ -337,9 +337,9 @@ def _define_forcing(self, geo, att_objs, att_time, cache): "Number_of_points", ), ) - self.forcing_file["LWdown"].longname = ( - "Surface_Incident_Diffuse_Longwave_Radiation" - ) + self.forcing_file[ + "LWdown" + ].longname = "Surface_Incident_Diffuse_Longwave_Radiation" self.forcing_file["LWdown"].units = "W/m2" elif this_var == "RAIN": self.forcing_file["Rainf"] = self.file_handler.createVariable(