Skip to content
Snippets Groups Projects
Commit ff87ac8e authored by Tor-Einar Skog's avatar Tor-Einar Skog
Browse files

Fix: Handle wrong period

parent d7e44f80
No related branches found
No related tags found
No related merge requests found
......@@ -16,7 +16,6 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
from datetime import datetime
from _datetime import date
from shapely import wkb
from shapely.geometry import Point
......
......@@ -7,14 +7,14 @@ from models import WeatherData
def filter_period(weather_data, time_start, time_end):
# Get the start and end index
#print(time_start)
start_index = weather_data.get_index_from_epoch_seconds(WeatherData.to_epoch_seconds(time_start))
start_index = max(0,weather_data.get_index_from_epoch_seconds(WeatherData.to_epoch_seconds(time_start)))
#print(start_index)
end_index = weather_data.get_index_from_epoch_seconds(WeatherData.to_epoch_seconds(time_end))
end_index = min(weather_data.get_index_from_epoch_seconds(weather_data.timeEnd), weather_data.get_index_from_epoch_seconds(WeatherData.to_epoch_seconds(time_end)))
for lwd in weather_data.locationWeatherData:
lwd.data = lwd.data[start_index:end_index]
# Adjust timeStart and timeEnd
weather_data.timeStart = WeatherData.to_epoch_seconds(time_start)
weather_data.timeEnd = WeatherData.to_epoch_seconds(time_end)
weather_data.timeStart = weather_data.timeStart + (start_index * weather_data.interval)
weather_data.timeEnd = weather_data.timeStart + (end_index * weather_data.interval)
return weather_data
def filter_params(weather_data, params):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment