예제 #1
0
def get_aqi(o3_8h: float = None, no2_1h: float = None, so2_24h: float = None,
            co_8h: float = None, pm25_24h: float = None, pm10_24h: float = None, with_level: bool = False) -> (int, {}):
    """
    Calculates Singapore PSI (Maximum from individual indexes)

    :param o3_8h: O3 average (8h), ppm
    :param no2_1h: NO2 average (1h), ppm
    :param so2_24h: SO2 average (24h), ppm
    :param co_8h: CO average (8h), ppm
    :param pm25_24h: PM2.5 average (24h), μg/m3
    :param pm10_24h: PM10 average (24h), μg/m3
    :param with_level: Boolean distinguishing whether to print AQI level such as 'good' or 'hazardous'
    :return: Singapore PSI, dict with tuples (Individual PSI, General message, Risk message)
            keys are: o3_8h, no2_1h, so2_24h, co_8h, pm25_24h, pm10_24h
             -1 means AQI is not available
    """
    aqi_data = {}
    if o3_8h:
        aqi_data['o3_8h'] = get_psi_o3_8h(o3_8h)
    if no2_1h and bool(__round_down(no2_1h, 3)):
        aqi_data['no2_1h'] = get_psi_no2_1h(no2_1h)
    if so2_24h:
        aqi_data['so2_24h'] = get_psi_so2_24h(so2_24h)
    if co_8h:
        aqi_data['co_8h'] = get_psi_co_8h(co_8h)
    if pm25_24h:
        aqi_data['pm25_24h'] = get_psi_pm25_24h(pm25_24h)
    if pm10_24h:
        aqi_data['pm10_24h'] = get_psi_pm10_24h(pm10_24h)
    if len(aqi_data) == 0:
        return AQI_NOT_AVAILABLE, aqi_data
    value = max(list(map(lambda x: x[0], aqi_data.values())))
    if not with_level:
        return value, aqi_data
    return value, {'level': __get_aqi_level(value, SG_PSI, SG_PSI_LEVELS)}
예제 #2
0
파일: daqi_uk.py 프로젝트: atmotube/aqipy
def get_aqi_pm25_24h(pm25_24h: float) -> (int, str, str):
    """
    Calculates PM2.5 (24h) UK DAQI

    :param pm25_24h: PM2.5 average (24h), μg/m3
    :return: PM2.5 UK DAQI, Effect message, Caution message
    """
    cp = __round_down(pm25_24h)
    return __get_daqi(cp, UK_PM25_24H)
예제 #3
0
파일: daqi_uk.py 프로젝트: atmotube/aqipy
def get_daqi_so2_15m(so2_15m: float) -> (int, str, str):
    """
    Calculates SO2 (15m) UK DAQI

    :param so2_15m: SO2 average (15m), ppm
    :return: SO2 UK DAQI, Effect message, Caution message
    """
    cp = __round_down(so2_15m * 1000)
    return __get_daqi(cp, UK_NO2_1H)
예제 #4
0
def get_caqi_pm25_1h(pm25_1h: float) -> float:
    """
    Calculates PM2.5 (1h) CAQI Europe

    :param pm25_1h: PM2.5 (1h), µg/m3
    :return: PM2.5 CAQI Europe
    """
    cp = __round_down(pm25_1h)
    return __get_aqi_general_formula(cp, EU_PM25_1H, EU_CAQI)
예제 #5
0
파일: daqi_uk.py 프로젝트: atmotube/aqipy
def get_daqi_o3_1h(o3_1h: float) -> (int, str, str):
    """
    Calculates O3 (1h) UK DAQI

    :param o3_1h: O3 average (1h), ppm
    :return: O3 UK DAQI, Effect message, Caution message
    """
    cp = __round_down(o3_1h * 1000)
    return __get_daqi(cp, UK_O3_1H)
예제 #6
0
def get_caqi_so2_1h(so2_max_1h: float) -> float:
    """
    Calculates SO2 (max in 1h) CAQI Europe

    :param so2_max_1h: SO2 (1h), ppm
    :return: SO2 CAQI Europe
    """
    cp = __round_down(so2_max_1h * 1000)
    return __get_aqi_general_formula(cp, EU_SO2_1H, EU_CAQI)
예제 #7
0
def get_caqi_o3_1h(o3_max_1h: float) -> float:
    """
    Calculates O3 (max in 1h) CAQI Europe

    :param o3_max_1h: O3 (1h), ppm
    :return: O3 CAQI Europe
    """
    cp = __round_down(o3_max_1h * 1000)
    return __get_aqi_general_formula(cp, EU_O3_1H, EU_CAQI)
예제 #8
0
파일: aqi_au.py 프로젝트: atmotube/aqipy
def get_aqi_no2_1h(no2_1h: float) -> (int, str, str):
    """
    Calculates NO2 (1h) AU AQI

    :param no2_1h: NO2 average (1h), ppm
    :return: NO2 AU AQI, General message, Risk message
    """
    cp = __round_down(no2_1h, 2)
    return __get_aqi(cp, AU_NO2_NEPM_STANDARD_1H)
예제 #9
0
파일: aqi_au.py 프로젝트: atmotube/aqipy
def get_aqi_so2_24h(so2_24h: float) -> (int, str, str):
    """
    Calculates SO2 (24h) AU AQI

    :param so2_24h: SO2 average (1h), ppm
    :return: SO2 AU AQI, General message, Risk message
    """
    cp = __round_down(so2_24h, 2)
    return __get_aqi(cp, AU_SO2_NEPM_STANDARD_24H)
예제 #10
0
파일: aqi_au.py 프로젝트: atmotube/aqipy
def get_aqi_o3_4h(o3_4h: float) -> (int, str, str):
    """
    Calculates O3 (4h) AU AQI

    :param o3_4h: O3 average (4h), ppm
    :return: O3 AU AQI, General message, Risk message
    """
    cp = __round_down(o3_4h, 2)
    return __get_aqi(cp, AU_O3_NEPM_STANDARD_4H)
예제 #11
0
파일: aqi_au.py 프로젝트: atmotube/aqipy
def get_aqi_co_8h(co_8h: float) -> (int, str, str):
    """
    Calculates CO (8h) AU AQI

    :param co_8h: CO average (8h), ppm
    :return: CO AU AQI, General message, Risk message
    """
    cp = __round_down(co_8h, 1)
    return __get_aqi(cp, AU_CO_NEPM_STANDARD_8H)
예제 #12
0
파일: aqi_au.py 프로젝트: atmotube/aqipy
def get_aqi_pm10_24h(pm10_24h: float) -> (int, str, str):
    """
    Calculates PM10 (24h) AU AQI

    :param pm10_24h: PM10 average (24h), μg/m3
    :return: PM10 AU AQI, General message, Risk message
    """
    cp = __round_down(pm10_24h)
    return __get_aqi(cp, AU_PM10_NEPM_STANDARD_24H)
예제 #13
0
def get_caqi_co_1h(co_8h: float) -> float:
    """
    Calculates CO (8h) CAQI Europe

    :param co_8h: CO (8h), ppm
    :return: CO CAQI Europe
    """
    cp = __round_down(co_8h, 1)
    return __get_aqi_general_formula(cp, EU_CO_8H, EU_CAQI)
예제 #14
0
파일: daqi_uk.py 프로젝트: atmotube/aqipy
def get_daqi_no2_1h(no2_1h: float) -> (int, str, str):
    """
    Calculates NO2 (1h) UK DAQI

    :param no2_1h: NO2 average (1h), ppm
    :return: NO2 UK DAQI, Effect message, Caution message
    """
    cp = __round_down(no2_1h * 1000)
    return __get_daqi(cp, UK_NO2_1H)
예제 #15
0
def get_psi_pm10_24h(pm10_24h: float) -> (int, str, str):
    """
    Calculates PM10 (24h) Singapore PSI

    :param pm10_24h: PM10 average (24h), μg/m3
    :return: PM10 Singapore PSI,  General message, Risk message
    """
    cp = __round_down(pm10_24h)
    return __get_aqi_general_formula_texts(cp, SG_PM10_24H, SG_AQI_GENERAL, SG_AQI_RISK, SG_PSI)
예제 #16
0
def get_psi_co_8h(co_8h: float) -> (int, str, str):
    """
    Calculates CO (8h) Singapore PSI

    :param co_8h: CO average (8h), ppm
    :return: Singapore PSI, General message, Risk message
    """
    cp = __round_down(co_8h, 1)
    return __get_aqi_general_formula_texts(cp, SG_CO_8H, SG_AQI_GENERAL, SG_AQI_RISK, SG_PSI)
예제 #17
0
def get_caqi_pm10_24h(pm10_24h: float) -> float:
    """
    Calculates PM10 (24h) CAQI Europe

    :param pm10_24h: PM10 (24h), µg/m3
    :return: PM10 CAQI Europe
    """
    cp = __round_down(pm10_24h)
    return __get_aqi_general_formula(cp, EU_PM10_24H, EU_CAQI)
예제 #18
0
def get_psi_no2_1h(no2_1h: float) -> (int, str, str):
    """
    Calculates NO2 (1h) Singapore PSI

    :param no2_1h: NO2 average (1h), ppm
    :return: Singapore PSI, General message, Risk message
    """
    cp = __round_down(no2_1h * 1000)
    return __get_aqi_general_formula_texts(cp, SG_NO2_1H, SG_AQI_GENERAL, SG_AQI_RISK, SG_PSI)
예제 #19
0
def get_psi_so2_24h(so2_24h: float) -> (int, str, str):
    """
    Calculates SO2 (24h) Singapore PSI

    :param so2_24h: SO2 average (24h), ppm
    :return: Singapore PSI, General message, Risk message
    """
    cp = __round_down(so2_24h * 1000)
    return __get_aqi_general_formula_texts(cp, SG_SO2_24H, SG_AQI_GENERAL, SG_AQI_RISK, SG_PSI)
예제 #20
0
def get_psi_o3_8h(o3_8h: float) -> (int, str, str):
    """
    Calculates O3 (8h) Singapore PSI

    :param o3_8h: O3 average (8h), ppm
    :return: Singapore PSI, General message, Risk message
    """
    cp = __round_down(o3_8h * 1000)
    return __get_aqi_general_formula_texts(cp, SG_O3_8H, SG_AQI_GENERAL, SG_AQI_RISK, SG_PSI)
예제 #21
0
def get_aqi_so2_24h(so2_24h: float) -> (int, str, str):
    """
    Calculates SO2 (24h) India AQI

    :param so2_24h: SO2 average (24h), ppm
    :return: SO2 India AQI, Effect message, Caution message
    """
    cp = __round_down(so2_24h * 1000)
    return __get_aqi_general_formula_texts(cp, IN_SO2_24H, IN_AQI_EFFECTS,
                                           IN_AQI_EFFECTS, IN_AQI)
예제 #22
0
파일: aqi_us.py 프로젝트: atmotube/aqipy
def get_aqi_pm25_24h(pm25_24h: float) -> (int, str, str):
    """
    Calculates PM2.5 (24h) US AQI

    :param pm25_24h: PM2.5 average (24h), μg/m3
    :return: PM2.5 US AQI, Effect message, Caution message
    """
    cp = __round_down(pm25_24h, 1)
    return __get_aqi_general_formula_texts(cp, US_PM25_24H, US_PM_EFFECTS,
                                           US_PM_CAUTIONS, US_AQI)
예제 #23
0
파일: aqi_us.py 프로젝트: atmotube/aqipy
def get_aqi_co_8h(co_8h: float) -> (int, str, str):
    """
    Calculates CO (8h) US AQI

    :param co_8h: CO average (8h), ppm
    :return: CO US AQI, Effect message, Caution message
    """
    cp = __round_down(co_8h, 1)
    return __get_aqi_general_formula_texts(cp, US_CO_8H, US_CO_EFFECTS,
                                           US_CO_CAUTIONS, US_AQI)
예제 #24
0
def get_aqi_pb_24h(pb_24h: float) -> (int, str, str):
    """
    Calculates Pb (24h) India AQI

    :param pb_24h: Pb average (24h), ppm
    :return: Pb India AQI, Effect message, Caution message
    """
    cp = __round_down(pb_24h * 1000, 3)
    return __get_aqi_general_formula_texts(cp, IN_PB_24H, IN_AQI_EFFECTS,
                                           IN_AQI_EFFECTS, IN_AQI)
예제 #25
0
def get_cai_no2_1h(no2_1h: float) -> (int, str, str):
    """
    Calculates NO2 (1h) South Korea CAI

    :param no2_1h: NO2 average (1h), ppm
    :return: NO2 South Korea CAI, General message, Risk message
    """
    cp = __round_down(no2_1h, 3)
    return __get_aqi_general_formula_texts(cp, KR_NO2_1H, KR_AQI_GENERAL,
                                           KR_AQI_GENERAL, KR_CAI)
예제 #26
0
def get_cai_o3_1h(o3_1h: float) -> (int, str, str):
    """
    Calculates O3 (1h) South Korea CAI

    :param o3_1h: O3 average (1h), ppm
    :return: O3 South Korea CAI, General message, Risk message
    """
    cp = __round_down(o3_1h, 3)
    return __get_aqi_general_formula_texts(cp, KR_O3_1H, KR_AQI_GENERAL,
                                           KR_AQI_GENERAL, KR_CAI)
예제 #27
0
def get_cai_co_1h(co_1h: float) -> (int, str, str):
    """
    Calculates CO (1h) South Korea CAI

    :param co_1h: CO average (1h), ppm
    :return: CO South Korea CAI, General message, Risk message
    """
    cp = __round_down(co_1h, 2)
    return __get_aqi_general_formula_texts(cp, KR_CO_1H, KR_AQI_GENERAL,
                                           KR_AQI_GENERAL, KR_CAI)
예제 #28
0
파일: aqi_us.py 프로젝트: atmotube/aqipy
def get_aqi_o3_1h(o3_1h: float) -> (int, str, str):
    """
    Calculates O3 US AQI

    :param o3_1h: O3 average (1h), ppm
    :return: O3 US AQI, Effect message, Caution message
    """
    cp = __round_down(o3_1h, 3)
    return __get_aqi_general_formula_texts(cp, US_OZONE_1H, US_OZONE_EFFECTS,
                                           US_OZONE_CAUTIONS, US_AQI)
예제 #29
0
def get_cai_pm10_24h(pm10_24h: float) -> (int, str, str):
    """
    Calculates PM10 (24h) South Korea CAI

    :param pm10_24h: PM10 average (24h), μg/m3
    :return: PM10 South Korea CAI, General message, Risk message
    """
    cp = __round_down(pm10_24h)
    return __get_aqi_general_formula_texts(cp, KR_PM10_24H, KR_AQI_GENERAL,
                                           KR_AQI_GENERAL, KR_CAI)
예제 #30
0
def get_aqi_nh3_24h(nh3_24h: float) -> (int, str, str):
    """
    Calculates NH3 (24h) India AQI

    :param nh3_24h: NH3 average (24h), ppm
    :return: NH3 India AQI, Effect message, Caution message
    """
    cp = __round_down(nh3_24h * 1000)
    return __get_aqi_general_formula_texts(cp, IN_NH3_24H, IN_AQI_EFFECTS,
                                           IN_AQI_EFFECTS, IN_AQI)