API Documentation#
snowday_calculator package.
This module provides functions and classes to predict the chance of a snow day based on zipcode, snow days, and school type.
- class snowday_calculator.Prediction#
Bases:
objectClass to hold and retrieve snow day prediction chances.
- chance(day)#
Retrieve the prediction chance for a specified day.
- Parameters:
day (datetime.datetime) – The day for which to retrieve the chance.
- Returns:
The chance value if available; otherwise, None.
- Return type:
float or None
- chance_tmrw()#
Retrieve the prediction chance for tomorrow.
- Returns:
Tomorrow’s chance value if available; otherwise, None.
- Return type:
float or None
- chance_today()#
Retrieve the prediction chance for today.
- Returns:
Today’s chance value if available; otherwise, None.
- Return type:
float or None
- class snowday_calculator.SchoolType#
Bases:
objectConstants representing different school types for prediction calculations.
- BOARDING = 1#
- PRIVATE = -0.4#
- PUBLIC = 0#
- RURAL_PUBLIC = -0.4#
- URBAN_PUBLIC = 0.4#
- snowday_calculator.datetime_to_daycode(day)#
Convert a datetime object to a daycode string in the format YYYYMMDD.
- Parameters:
day (datetime.datetime) – The datetime object to convert.
- Returns:
The daycode in the format “YYYYMMDD”.
- Return type:
str
- snowday_calculator.predict(zipcode, snowdays=0, schooltype=0)#
Predict the chance of a snow day.
Makes an HTTP request to the snow day prediction service and parses the JavaScript response to extract prediction chances.
- Parameters:
zipcode (str) – The zipcode for which to predict.
snowdays (int, optional) – Number of snow days to consider. Defaults to 0.
schooltype (int, optional) – School type constant from SchoolType. Defaults to SchoolType.PUBLIC.
- Returns:
An instance of Prediction containing the parsed chances.
- Return type: