Skip to content

Commit

Permalink
pre-commit clean-up
Browse files Browse the repository at this point in the history
  • Loading branch information
mpvginde committed Sep 16, 2024
1 parent 7cd6457 commit 828b908
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

from collections import defaultdict

import numpy as np
from earthkit.data.indexing.fieldlist import FieldArray
from earthkit.meteo import thermo

Expand Down Expand Up @@ -49,4 +48,4 @@ def execute(context, input, t, rh, q="q"):
q_pl = thermo.specific_humidity_from_relative_humidity(t_pl, rh_pl, pressure)
result.append(NewDataField(values[rh], q_pl, q))

return result
return result
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

from collections import defaultdict

import numpy as np
from earthkit.data.indexing.fieldlist import FieldArray
from earthkit.meteo import thermo

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

from earthkit.data.indexing.fieldlist import FieldArray
from earthkit.meteo import thermo

from single_level_specific_humidity_to_relative_humidity import NewDataField


def execute(context, input, t, td, rh="d"):
"""Convert relative humidity on single levels to dewpoint"""
result = FieldArray()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

from earthkit.data.indexing.fieldlist import FieldArray
from earthkit.meteo import thermo

from single_level_specific_humidity_to_relative_humidity import NewDataField

EPS = 1.0e-4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
import numpy as np
from earthkit.data.indexing.fieldlist import FieldArray
from earthkit.meteo import thermo

from anemoi.datasets.create.functions.filters.single_level_specific_humidity_to_relative_humidity import AutoDict
from anemoi.datasets.create.functions.filters.single_level_specific_humidity_to_relative_humidity import NewDataField
from anemoi.datasets.create.functions.filters.single_level_specific_humidity_to_relative_humidity import pressure_at_height_level
from anemoi.datasets.create.functions.filters.single_level_specific_humidity_to_relative_humidity import \
pressure_at_height_level


def execute(context, input, height, t, rh, sp, new_name="2q", **kwargs):
Expand Down Expand Up @@ -50,7 +52,7 @@ def execute(context, input, height, t, rh, sp, new_name="2q", **kwargs):

needed_fields[key][levtype][param] = f
if param == rh:
if kwargs.get("keep_rh",False):
if kwargs.get("keep_rh", False):
result.append(f)
else:
result.append(f)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def to_numpy(self, *args, **kwargs):
def metadata(self, key=None, **kwargs):
if key is None:
return self.field.metadata(**kwargs)

value = self.field.metadata(key, **kwargs)
if key == "param":
return self.new_name
Expand Down Expand Up @@ -259,7 +259,7 @@ def execute(context, input, height, t, q, sp, new_name="2r", **kwargs):

needed_fields[key][levtype][param] = f
if param == q:
if kwargs.get("keep_q",False):
if kwargs.get("keep_q", False):
result.append(f)
else:
result.append(f)
Expand Down Expand Up @@ -315,12 +315,13 @@ def execute(context, input, height, t, q, sp, new_name="2r", **kwargs):
# See https://github.com/ecmwf/earthkit-meteo/issues/15
p_sl = pressure_at_height_level(height, q_ml, t_ml, sp_sl, np.array(kwargs["A"]), np.array(kwargs["B"]))
td_sl = thermo.dewpoint_from_specific_humidity(q=q_sl, p=p_sl)
rh_sl = thermo.relative_humidity_from_dewpoint(t=t_sl, td=td_sl)
rh_sl = thermo.relative_humidity_from_dewpoint(t=t_sl, td=td_sl)

result.append(NewDataField(values["sfc"][q], rh_sl, new_name))

return result


def test():
from earthkit.data import from_source
from earthkit.data.readers.grib.index import GribFieldList
Expand Down Expand Up @@ -376,7 +377,8 @@ def test():
print(f"Median difference in dewpoint temperature: {np.median(np.abs(newdew - dewpoint)):02f} degC")
print(f"Maximum difference in dewpoint temperature: {np.abs(newdew - dewpoint).max():02f} degC")

#source.save("source.grib")
# source.save("source.grib")


if __name__ == "__main__":
test()
test()
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def to_numpy(self, *args, **kwargs):
def metadata(self, key=None, **kwargs):
if key is None:
return self.field.metadata(**kwargs)

value = self.field.metadata(key, **kwargs)
if key == "param":
return self.new_name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
import numpy as np
from earthkit.data.indexing.fieldlist import FieldArray
from earthkit.meteo.wind.array import xy_to_polar

from anemoi.datasets.create.functions.filters.speeddir_to_uv import NewDataField


def execute(context, input, u_component, v_component, wind_speed, wind_dir, in_radians=False):
result = FieldArray()

Expand Down

0 comments on commit 828b908

Please sign in to comment.