diff --git a/lib/step.rb b/lib/step.rb index fd5f41e..96ed145 100644 --- a/lib/step.rb +++ b/lib/step.rb @@ -1,3 +1,4 @@ +# coding: iso-8859-1 require 'fileutils' module CMORizer @@ -186,6 +187,13 @@ def file_commands end end + class FLIP_SIGN < IndividualBaseStep + def file_commands + cmds = [] + cmds << CDO_MULC_cmd.new(-1) + cmds + end + end class AUTO_CONVERT_UNIT < IndividualBaseStep def self.auto_convert_unit_possible?(from_unit, to_unit) @@ -214,6 +222,29 @@ def self.convert_unit_commands(from_unit, to_unit) cmds << CDO_MULC_cmd.new(100) when ["K", "degC"] cmds << CDO_SUBC_cmd.new(-273.15) + when ["mmolC/m2/d", "kg m-2 s-1"] + # notes on how this factor was derived (by chrisdane "Christopher Danek") + # e.g. recom variable: CO2f => CMIP6_Omon.json: fgco2 + # 1) mmolC -> molC: /1e3 + # 2) molC -> gC: *12.0107 + # 3) gC -> kgC: /1e3 + # 4) d-1 -> s-1: /86400 + # -> mult_factor = 1/1e3*12.0107/1e3/86400 # = 1.390127e-10 + # In the CMIP6_Omon.json:fgco2 case, an additional sign change is necessary: + # >0: into ocean -> >0: into atm: *-1 + # -> mult_factor = mult_factor*-1 + # COMMENT: For sign change use flip_sign function + cmds << CDO_MULC_cmd.new(1.390127e-10) + when ["uatm", "Pa"] + # notes on how this factor was derived (by chrisdane "Christopher Danek") + # e.g. recom variable: pCO2s => CMIP6_Omon.json: spco2 + # 1) µatm -> atm: /1e6 + # 2) atm -> Pa: *1.01325e5 (1 atm = 1.01325e5 Pa) + # -> mult_factor = 1/1e6*1.01325e5 # = 0.101325 + # + # these notes are available on the following link + # https://notes.desy.de/F8hTyk3PRielZrVdZRtyaQ?view#Seamore-missing-features-FESOM1-and-2 + cmds << CDO_MULC_cmd.new(0.101325) else raise "can not automatically convert unit from '#{from_unit}' to '#{to_unit}'" end