def guardarPrediccionRep(estacion, fecha, Valor,contaminant,tipo):
    """
    function to save the prediction in the database

    :param estacion: name the station
    :type estacion: string
    :param fecha: current date
    :type fecha: date
    :param valor: prediction value
    :type valor: float32
    """
    if estacion == 'SFE':
        fecha = fecha + timedelta(days = 1)
        fecha1 = fecha + timedelta(hours = 6)
        fechaActual = str(fecha1.year) + '-' + str(fecha1.month) + '-' + str(fecha1.day)+' '+str(fecha1.hour)+':00:00'
        fd.saveData(estacion, fechaActual, Valor, findT(contaminant),tipo)
    elif estacion == 'NEZ':
        fecha = fecha + timedelta(days=1)
        fecha = fecha + timedelta(hours = 11)
        fechaActual = str(fecha.year) + '-' + str(fecha.month) + '-' + str(fecha.day)+' '+str(fecha.hour)+':00:00'
        fd.saveData(estacion, fechaActual, Valor, findT(contaminant),tipo)
    elif estacion == 'TAH':
        fecha = fecha + timedelta(days=1)
        fecha = fecha + timedelta(hours=15)
        fechaActual = str(fecha.year) + '-' + str(fecha.month) + '-' + str(fecha.day)+' '+str(fecha.hour)+':00:00'
        fd.saveData(estacion, fechaActual, Valor, findT(contaminant),tipo)
    elif estacion == 'UAX':
        fecha = fecha + timedelta(days=1)
        fecha = fecha + timedelta(hours=13)
        fechaActual = str(fecha.year) + '-' + str(fecha.month) + '-' + str(fecha.day)+' '+str(fecha.hour)+':00:00'
        fd.saveData(estacion, fechaActual, Valor, findT(contaminant),tipo)
    else:
        fecha = fecha + timedelta(days=1)
        fechaActual = str(fecha.year) + '-' + str(fecha.month) + '-' + str(fecha.day)+' '+str(fecha.hour)+':00:00'
        fd.saveData(estacion, fechaActual, Valor, findT(contaminant),tipo)
Пример #2
0
def savePrediccion1(estacion, dataPrediccion, contaminant, fechas):
    """
    function to save the prediction in the database

    :param estacion: name the station
    :type estacion: string
    :param fecha: current date
    :type fecha: date
    :param valor: prediction value
    :type valor: float32
    """
    print(findT(contaminant))
    size = len(dataPrediccion)
    for i in range(size):
        fecha = fechas.iloc[i]
        print(fecha)
        Valor = dataPrediccion[i]
        #fecha =  datetime.strptime(fecha, '%Y-%m-%d %H:%M:%S')
        if estacion == 'TAH':
            fecha = fecha + timedelta(hours =15)
        else:
            fecha = fecha + timedelta(days=1)
        fechaActual = str(fecha.year) + '-' + str(fecha.month) + '-' + str(fecha.day)+' '+str(fecha.hour)+':00:00'
        print(Valor);
        fd.saveData(estacion, fechaActual,[Valor], findT(contaminant),3)
Пример #3
0
def guardarPrediccion(estacion, fecha, Valor,contaminant,tipo):
    """
    function to save the prediction in the database

    :param estacion: name the station
    :type estacion: string
    :param fecha: current date
    :type fecha: date
    :param valor: prediction value
    :type valor: float32
    """
    if estacion == 'TAH':
        fecha = fecha + timedelta(days = 1)
        fecha1 = fecha + timedelta(hours = 15)
        fechaActual = str(fecha1.year) + '-' + str(fecha1.month) + '-' + str(fecha1.day)+' '+str(fecha1.hour)+':00:00'
        rept = fd.rev_data(estacion,fechaActual,findT(contaminant),tipo)
        print(fechaActual)
        if rept == 0:
            fd.saveData(estacion, fechaActual, Valor, findT(contaminant),tipo)
        else:
            print('valor repetido')
    else:
        fecha = fecha + timedelta(days=2)
        fechaActual = str(fecha.year) + '-' + numString(fecha.month)+ '-' + numString(fecha.day)+' '+numString(fecha.hour)+':00:00'
        rept = fd.rev_data(estacion,fechaActual,findT(contaminant),tipo)
        print(fechaActual)
        if rept == 0:
            fd.saveData(estacion, fechaActual, Valor, findT(contaminant),tipo)
        else:
            print('valor repetido')
def guardarPrediccion(estacion, fecha, Valor,contaminant,tipo):
    """
    function to save the prediction in the database

    :param estacion: name the station
    :type estacion: string
    :param fecha: current date
    :type fecha: date
    :param valor: prediction value
    :type valor: float32
    """
    if math.isnan(Valor[0]):
        print('no valor')
        return 0
    fecha = datetime.strptime(fecha, '%Y-%m-%d %H:%M:%S')
    if estacion == 'SFE':
        fecha = fecha + timedelta(days = 1)
        fecha1 = fecha + timedelta(hours = 6)
        fechaActual = str(fecha1.year) + '-' + numString(fecha1.month) + '-' + numString(fecha1.day)+' '+numString(fecha1.hour)+':00:00'
        rept = fd.rev_data(estacion,fechaActual,findT(contaminant),tipo)
        if rept == 0:
            fd.saveData(estacion, fechaActual, Valor, findT(contaminant),tipo)
        else:
            print('valor repetido')
    elif estacion == 'NEZ':
        fecha = fecha + timedelta(days=1)
        fecha = fecha + timedelta(hours = 11)
        fechaActual = str(fecha.year) + '-' + numString(fecha.month) + '-' + numString(fecha.day)+' '+numString(fecha.hour)+':00:00'
        rept = fd.rev_data(estacion,fechaActual,findT(contaminant),tipo)
        if rept == 0:
            fd.saveData(estacion, fechaActual, Valor, findT(contaminant),tipo)
        else:
            print('valor repetido')
    elif estacion == 'TAH':
        fecha = fecha + timedelta(days=1)
        fecha = fecha + timedelta(hours=15)
        fechaActual = str(fecha.year) + '-' + numString(fecha.month) + '-' + numString(fecha.day)+' '+numString(fecha.hour)+':00:00'
        rept = fd.rev_data(estacion,fechaActual,findT(contaminant),tipo)
        if rept == 0:
            fd.saveData(estacion, fechaActual, Valor, findT(contaminant),tipo)
        else:
            print('valor repetido')
    elif estacion == 'UAX':
        fecha = fecha + timedelta(days=1)
        fecha = fecha + timedelta(hours=13)
        fechaActual = str(fecha.year) + '-' + numString(fecha.month) + '-' + numString(fecha.day)+' '+numString(fecha.hour)+':00:00'
        rept = fd.rev_data(estacion,fechaActual,findT(contaminant),tipo)
        if rept == 0:
            fd.saveData(estacion, fechaActual, Valor, findT(contaminant),tipo)
        else:
            print('valor repetido')
    else:
        fecha = fecha + timedelta(days=1)
        fechaActual = str(fecha.year) + '-' + numString(fecha.month) + '-' + numString(fecha.day)+' '+numString(fecha.hour)+':00:00'
        rept = fd.rev_data(estacion,fechaActual,findT(contaminant),tipo)
        if rept == 0:
            fd.saveData(estacion, fechaActual, Valor, findT(contaminant),tipo)
        else:
            print('valor repetido')