From 0051f29ee9d77f828c1fc3f5c19f161600c7a509 Mon Sep 17 00:00:00 2001 From: peterdudfield Date: Tue, 12 Mar 2024 15:50:10 +0000 Subject: [PATCH] add lat and lon limits --- src/nwp_page.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/nwp_page.py b/src/nwp_page.py index 923e147..116f626 100644 --- a/src/nwp_page.py +++ b/src/nwp_page.py @@ -160,6 +160,18 @@ def nwp_page(): else: print("Average over latitude and longitude") + + # reduce by lat lon + lon = st.text_input("Longitude Limits", "73,79") + lat = st.text_input("Latitude Limits", "24,28") + lon = lon.split(",") + lat = lat.split(",") + + # swap lat limits round if wrong way + if d_one_channel.latitude.values[0] > d_one_channel.latitude.values[-1]: + lat = lat[::-1] + d_one_channel = d_one_channel.sel({'latitude':slice(lat[0], lat[1]), 'longitude':slice(lon[0], lon[1])}) + if "latitude" in d_one_channel.dims and "longitude" in d_one_channel.dims: df = d_one_channel.mean(dim=["latitude", "longitude"]) else: