You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR adds a weather infographic which includes the following list of the following data:
{
'severity': severity code ([0-3], int),
'severity_hebrew': severity hebrew name (str),
'amount_of_accidents_caused_by_rain': ammount of accidents (of this severity) which their rain rate is above our threshold and therefore counted as "caused by rain" (int),
'accidents_caused_by_rain_percentage': the percentage of the accidents (of this severity) caused by rain out of all of the accidents (of this severity) (int),
}
This allows to show infographic that shows amount of accidents caused by rain (and their percentage) by severity
Notes:
This PR marked as don't merge since we currently don't have a token that enable us to get data from the IMS (Israel meteorological service) API, for now there just random function there (get_weather_at_station function in weather_interpolator.py)
Accident is counted as caused by rain when its rain_rate is above the ACCIDENT_RAIN_RATE_THRESHOLD which is defined in infographics_utils.py
This PR added call to the ensure_accidents_weather_data function after every import of new accidents from the cbs.
Basically backfill will happen automatically the next time we'll get update from the cbs (the function ensures all db records, not just new ones)
But if we don't want to wait we can do it manually, it can be done by running: python main.py process weather-data
Running it on the whole history is pretty heavy, so we can separate it to several batches by using the start_date filter, e.g. python main.py process weather-data --start_date 01-01-2019
After the backfill everytime new accidents are inserted from new data from the cbs the ensure_accidents_weather_data function will be triggered which will fill weather data for the new accidents
@idosavion
It was marked as draft in the beginning
But since 99% of the logic is in, I wanted to move on and start with the review <-> fix cycles, therefore marked it as ready for review (but left the [don't merge] in the title)
@Hedingber can you please split this one to a few logically separated commits?
It's a bit hard to review a 2000 line change without missing anything :)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a weather infographic which includes the following list of the following data:
This allows to show infographic that shows amount of accidents caused by rain (and their percentage) by severity
Notes:
get_weather_at_stationfunction inweather_interpolator.py)rain_rateis above theACCIDENT_RAIN_RATE_THRESHOLDwhich is defined ininfographics_utils.pyensure_accidents_weather_datafunction after every import of new accidents from the cbs.Basically backfill will happen automatically the next time we'll get update from the cbs (the function ensures all db records, not just new ones)
But if we don't want to wait we can do it manually, it can be done by running:
python main.py process weather-dataRunning it on the whole history is pretty heavy, so we can separate it to several batches by using the
start_datefilter, e.g.python main.py process weather-data --start_date 01-01-2019After the backfill everytime new accidents are inserted from new data from the cbs the
ensure_accidents_weather_datafunction will be triggered which will fill weather data for the new accidents