コード例 #1
0
ファイル: html.py プロジェクト: Mark-Zwaving/WeatherStatsNL
def table_hellmann(days, entity='TG'):
    html = ''
    total = np.size(days, axis=0)
    if total > 0:
        # HTML table header
        html += f'''
                <table class="popup">
                    <thead>
                        <tr>
                            <th>date</th>
                            <th>tg</th>
                            <th>val</th>
                            <th>sum</th>
                            <th>cnt</th>
                        </tr>
                    </thead>
                    <tbody>
                '''

        # Prepare values
        l, sum, cnt = list(), 0.0, 1
        ndx_ent  = daydata.ndx_ent(entity) # Index of value
        for day in days:
            ymd  = int(day[daydata.YYYYMMDD]) # Get data int format
            symd = utils.ymd_to_txt( ymd ) # Get date string format
            raw  = day[daydata.TG]
            hman = abs(raw)
            sum += hman
            l.append( f'''
                        <tr>
                            <td title="{symd}">{ymd}</td>
                            <td>{fix.ent(raw,  entity)}</td>
                            <td>{fix.rounding(hman, entity)}</td>
                            <td>{fix.rounding(sum,  entity)}</td>
                            <td>{cnt}</td>
                        </tr>
                    ''' )
            cnt += 1

        l.reverse() # Reverse list
        # Put to html until max
        cnt, max = 1, cfg.html_popup_table_val_10
        if max == -1: max = total
        for el in l:
            html += el
            if cnt == max:
                break
            else:
                cnt += 1

        html += '''
                </tbody>
            </table>
                '''
    return html
コード例 #2
0
ファイル: html.py プロジェクト: Mark-Zwaving/WeatherStatsNL
def table_days(days, entity, time_ent=''):
    html = ''
    total = np.size(days, axis=0)
    if total > 0:
        # Time th cell yess or no
        b_time_cell  = True if time_ent != '' else False
        th_time_cell = '<th>time</th>' if b_time_cell else ''
        time_ndx = daydata.ndx_ent(time_ent) if b_time_cell else -1
        val_ndx  = daydata.ndx_ent(entity) # Index of value

        # HTML table header
        html += f'''
                <table class="popup">
                    <thead>
                        <tr>
                            <th>pos</th>
                            <th>date</th>
                            <th>val</th>
                            {th_time_cell}
                        </tr>
                    </thead>
                    <tbody>
                '''

        pos, max = 1, cfg.html_popup_table_val_10
        if max == -1:
            max = total

        for day in days:
            ymd  = int(day[daydata.YYYYMMDD]) # Get data int format
            symd = utils.ymd_to_txt( ymd ) # Get date string format
            val = fix.ent( day[val_ndx], entity )  # Get value with right output

            # Get a time value or not
            time_val = f'<td>{fix.ent(day[time_ndx], time_ent)}</td>' if b_time_cell else ''

            html += f'''
                        <tr>
                            <td>{pos}</td>
                            <td title="{symd}">{ymd}</td>
                            <td>{val}</td>
                            {time_val}
                        </tr>
                    '''
            if pos == max:
                break
            else:
                pos += 1

        html += '''
                </tbody>
            </table>
                '''
    return html
コード例 #3
0
ファイル: html.py プロジェクト: Mark-Zwaving/WeatherStatsNL
def table_days_count(days, entity, time_ent=''):
    html = ''
    total = np.size(days, axis=0)
    if total > 0:
        # Time th cell yess or no
        b_time_cell  = True if time_ent != '' else False
        th_time_cell = '<th>time</th>' if b_time_cell else ''
        time_ndx = daydata.ndx_ent( time_ent ) if b_time_cell else -1
        val_ndx  = daydata.ndx_ent( entity )  # Index of value

        html += f'''
                <table class="popup">
                    <thead>
                        <tr>
                            <th>date</th>
                            <th>val</th>
                            {th_time_cell}
                            <th>cnt</th>
                        </tr>
                    </thead>
                    <tbody>
                '''

        pos, max = 1, cfg.html_popup_table_cnt_rows
        if max == -1:
            max = total

        days = np.flip(days, axis=0) # Reverse the matrix. Last day first
        for day in days:
            ymd  = int(day[daydata.YYYYMMDD])
            symd = utils.ymd_to_txt( ymd )
            val  = fix.ent( day[val_ndx], entity )
            tme  = f'<td>{fix.ent(day[time_ndx],time_ent)}</td>' if b_time_cell else ''
            html += f'''
                        <tr>
                            <td title="{symd}">{ymd}</td>
                            <td>{val}</td>
                            {tme}
                            <td>{total}</td>
                        </tr>
                    '''
            if pos == max:
                break
            else:
                total, pos = total - 1, pos + 1

        html += '''
                    </tbody>
                </table>
                '''

    return html
コード例 #4
0
ファイル: html.py プロジェクト: Mark-Zwaving/WeatherStatsNL
def table_frost_sum( days, entity='TN' ):
    html = ''
    total = np.size(days, axis=0)
    if total > 0:
        # HTML table header
        html += f'''
                <table class="popup">
                    <thead>
                        <tr>
                            <th>date</th>
                            <th>tx</th>
                            <th>txh</th>
                            <th>tn</th>
                            <th>tnh</th>
                            <th>val</th>
                            <th>sum</th>
                            <th>cnt</th>
                        </tr>
                    </thead>
                    <tbody>
                '''

        # Prepare values
        l, tot, cnt = list(), 0.0, 1
        for day in days:
            ymd  = int(day[daydata.YYYYMMDD]) # Get data int format
            symd = utils.ymd_to_txt( ymd ) # Get date string format
            tx   = day[daydata.TX]
            txh  = day[daydata.TXH]
            tn   = day[daydata.TN]
            tnh  = day[daydata.TNH]

            # Calculate frost sum
            dsum = 0.0
            if tx < 0: dsum += abs(tx)
            if tn < 0: dsum += abs(tn)
            tot += dsum

            l.append( f'''
                        <tr>
                            <td title="{symd}">{ymd}</td>
                            <td>{fix.ent(tx,  entity)}</td>
                            <td>{fix.ent(txh, 'TXH')}</td>
                            <td>{fix.ent(tn,  entity)}</td>
                            <td>{fix.ent(tnh, 'TNH')}</td>
                            <td>{fix.rounding(dsum, entity)}</td>
                            <td>{fix.rounding(tot,  entity)}</td>
                            <td>{cnt}</td>
                        </tr>
                    ''' )
            cnt += 1

        l.reverse() # Reverse list
        # Put to html until max
        cnt, max = 1, cfg.html_popup_table_val_10
        if max == -1: max = total
        for el in l:
            html += el
            if cnt == max:
                break
            else:
                cnt += 1

        html += '''
                </tbody>
            </table>
                '''
    return html