Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
mathleur committed Feb 4, 2025
1 parent 1014abc commit a222d15
Showing 1 changed file with 37 additions and 37 deletions.
74 changes: 37 additions & 37 deletions tests/test_icon_grid_unstructured_fdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# import os
import time

import geopandas as gpd
import matplotlib.pyplot as plt
# import geopandas as gpd
# import matplotlib.pyplot as plt
import pandas as pd
import pytest
import xarray as xr
Expand Down Expand Up @@ -86,38 +86,38 @@ def test_quad_tree_slicer_extract(self):
print(time1 - time0)
result.pprint()

lats = []
lons = []
eccodes_lats = []
eccodes_lons = []
# tol = 1e-8
leaves = result.leaves
for i in range(len(leaves)):
cubepath = leaves[i].flatten()
lat = cubepath["latitude"][0]
lon = cubepath["longitude"][0]
lats.append(lat)
lons.append(lon)

# # each variable in the netcdf file is a cube
# # cubes = iris.load('../../Downloads/votemper_ORAS5_1m_197902_grid_T_02.nc')
# # iris.save(cubes, '../../Downloads/votemper_ORAS5_1m_197902_grid_T_02.grib2')
# nearest_points = find_nearest_latlon(
# "../../Downloads/icon-d2_germany_icosahedral_single-level_2025011000_024_2d_t_2m.grib2", lat, lon)
# eccodes_lat = nearest_points[0][0]["lat"]
# eccodes_lon = nearest_points[0][0]["lon"] - 360
# eccodes_lats.append(eccodes_lat)
# eccodes_lons.append(eccodes_lon)
# assert eccodes_lat - tol <= lat
# assert lat <= eccodes_lat + tol
# assert eccodes_lon - tol <= lon
# assert lon <= eccodes_lon + tol

worldmap = gpd.read_file(gpd.datasets.get_path("naturalearth_lowres"))
fig, ax = plt.subplots(figsize=(12, 6))
worldmap.plot(color="darkgrey", ax=ax)

plt.scatter(lons, lats, s=18, c="red", cmap="YlOrRd")
plt.scatter(eccodes_lons, eccodes_lats, s=6, c="green")
plt.colorbar(label="Temperature")
plt.show()
# lats = []
# lons = []
# eccodes_lats = []
# eccodes_lons = []
# # tol = 1e-8
# leaves = result.leaves
# for i in range(len(leaves)):
# cubepath = leaves[i].flatten()
# lat = cubepath["latitude"][0]
# lon = cubepath["longitude"][0]
# lats.append(lat)
# lons.append(lon)

# # # each variable in the netcdf file is a cube
# # # cubes = iris.load('../../Downloads/votemper_ORAS5_1m_197902_grid_T_02.nc')
# # # iris.save(cubes, '../../Downloads/votemper_ORAS5_1m_197902_grid_T_02.grib2')
# # nearest_points = find_nearest_latlon(
# # "../../Downloads/icon-d2_germany_icosahedral_single-level_2025011000_024_2d_t_2m.grib2", lat, lon)
# # eccodes_lat = nearest_points[0][0]["lat"]
# # eccodes_lon = nearest_points[0][0]["lon"] - 360
# # eccodes_lats.append(eccodes_lat)
# # eccodes_lons.append(eccodes_lon)
# # assert eccodes_lat - tol <= lat
# # assert lat <= eccodes_lat + tol
# # assert eccodes_lon - tol <= lon
# # assert lon <= eccodes_lon + tol

# worldmap = gpd.read_file(gpd.datasets.get_path("naturalearth_lowres"))
# fig, ax = plt.subplots(figsize=(12, 6))
# worldmap.plot(color="darkgrey", ax=ax)

# plt.scatter(lons, lats, s=18, c="red", cmap="YlOrRd")
# plt.scatter(eccodes_lons, eccodes_lats, s=6, c="green")
# plt.colorbar(label="Temperature")
# plt.show()

0 comments on commit a222d15

Please sign in to comment.