Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/add dewpoint temperature #342

Merged
merged 3 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Atlite can process the following weather data fields and can convert them into f
.. * Surface roughness
.. * Height maps
.. * Soil temperature
.. * Dewpoint temperature


.. * Wind power generation for a given turbine type
Expand Down
15 changes: 15 additions & 0 deletions atlite/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,21 @@ def soil_temperature(cutout, **params):
return cutout.convert_and_aggregate(convert_func=convert_soil_temperature, **params)


# dewpoint temperature
def convert_dewpoint_temperature(ds):
"""
Return dewpoint temperature.
"""
# Temperature is in Kelvin
return ds["dewpoint temperature"] - 273.15


def dewpoint_temperature(cutout, **params):
return cutout.convert_and_aggregate(
convert_func=convert_dewpoint_temperature, **params
)


def convert_coefficient_of_performance(ds, source, sink_T, c0, c1, c2):
assert source in ["air", "soil"], NotImplementedError(
"'source' must be one of ['air', 'soil']"
Expand Down
3 changes: 3 additions & 0 deletions atlite/cutout.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
coefficient_of_performance,
convert_and_aggregate,
csp,
dewpoint_temperature,
heat_demand,
hydro,
irradiation,
Expand Down Expand Up @@ -681,6 +682,8 @@ def layout_from_capacity_list(self, data, col="Capacity"):

soil_temperature = soil_temperature

dewpoint_temperature = dewpoint_temperature

coefficient_of_performance = coefficient_of_performance

solar_thermal = solar_thermal
Expand Down
17 changes: 14 additions & 3 deletions atlite/datasets/era5.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def nullcontext():
"solar_altitude",
"solar_azimuth",
],
"temperature": ["temperature", "soil temperature"],
"temperature": ["temperature", "soil temperature", "dewpoint temperature"],
"runoff": ["runoff"],
}

Expand Down Expand Up @@ -199,11 +199,22 @@ def get_data_temperature(retrieval_params):
Get wind temperature for given retrieval parameters.
"""
ds = retrieve_data(
variable=["2m_temperature", "soil_temperature_level_4"], **retrieval_params
variable=[
"2m_temperature",
"soil_temperature_level_4",
"2m_dewpoint_temperature",
],
**retrieval_params,
)

ds = _rename_and_clean_coords(ds)
ds = ds.rename({"t2m": "temperature", "stl4": "soil temperature"})
ds = ds.rename(
{
"t2m": "temperature",
"stl4": "soil temperature",
"d2m": "dewpoint temperature",
}
)

return ds

Expand Down
14 changes: 14 additions & 0 deletions test/test_preparation_and_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,16 @@ def soil_temperature_test(cutout):
assert demand.sum() > 0


def dewpoint_temperature_test(cutout):
"""
Test the atlite.Cutout.dewpoint_temperature function with different
settings.
"""
demand = cutout.dewpoint_temperature()
assert demand.notnull().all()
assert demand.sum() > 0


def wind_test(cutout):
"""
Test the atlite.Cutout.wind function with two different layouts.
Expand Down Expand Up @@ -684,6 +694,10 @@ def test_heat_demand_era5(cutout_era5):
def test_soil_temperature_era5(cutout_era5):
return soil_temperature_test(cutout_era5)

@staticmethod
def test_dewpoint_temperature_era5(cutout_era5):
return dewpoint_temperature_test(cutout_era5)

@staticmethod
def test_line_rating_era5(cutout_era5):
return line_rating_test(cutout_era5)
Expand Down