<jupyter_start><jupyter_text>Federal University of Rio Grande do Sul (UFRGS)   Postgraduate Program in Civil Engineering (PPGEC)   Laboratório de Aerodinâmica das Construções (LAC) OHFPI - Object Oriented High Frequency Pressure Integration _A Python Class for Wind Tunnel Data Processing_---_Prof. <NAME>, Dr.techn._ [(ORCID)](https://orcid.org/0000-0001-5640-1020)  _Prof. <NAME>._ (ORCID)_Porto Alegre, RS, Brazil_   Table of contents   1. [Introduction and basic concepts](section_1)  2. [Pressure data input](section_2)  &nbsp;&nbsp;&nbsp;[2.1. The _Master Table_](section_21)   &nbsp;&nbsp;&nbsp;[2.2. The _Batch Table_](section_22)   &nbsp;&nbsp;&nbsp;[2.3. The _AllCases_ table](section_23)   &nbsp;&nbsp;&nbsp;[2.4. Pressure data pre-processing](section_24)   &nbsp;&nbsp;&nbsp;[2.5. Structural data input](section_25)   &nbsp;&nbsp;&nbsp;[2.6. Examples of complete data input](section_26)   3. [Basic usage of pressure data](section_3)<jupyter_code># Importing Python modules required for this notebook
# (this cell must be executed with "shift+enter" before any other Python cell)

import numpy as np 
import pandas as pd
import matplotlib.pyplot as plt

# Module for multivariate random processes methods
import MRPy 

# Class definitions for High Frequency Pressure Integration
from   OHFPI import *  
#print(AllCases)<jupyter_output><empty_output><jupyter_text>1. Introduction and basic conceptsThis Jupyter Notebook presents the use of ``OHFPI`` class module for processing the large amount of data from wind tunnel tests and from the building structural design, coupling the two datasets together for estimating the building dynamic response to wind action.The wind tunnel provides a directory with a set of raw files, one file per wind direction. The so-called _Master Table_ connects the pressure channels in each file to the corresponding pressure taps in the model. The _Master Table_ also provides further information for pressure integration over building surface, such as tap coordinates, tap normal direction and corresponding surface areas.On the other hand, the building designer provides information on the numerical model used for structural analysis. Nodal coordinates, nodal masses, natural frequencies of vibration and the respective modal shapes can be used to calculate the building response through modal superposition. The link between the wind tunnel pressure records and the structural model are the _modal forces_, which are calculated by projecting the aerodynamic forces on modal space. The modal responses are combined to yield the total structural response, from which static equivalent forces may be specified and provided back to building designer for accomplishing the structural design. The two examples used in this notebook are the CAARC standard tall building (E01, 180m height)and a concrete bell tower with a square cross section (E24, 130m height):                CAARC    Bell Tower  These two examples are taken from the LAC/UFRGS database, with more than 30 buildingsanalysed with the HFPI technique. The figures above shows that the Python scripts must be able to deal with arbitrary definitions for the wind direction references.   2. Data organization 2.1 The _Master Table_Each wind tunnel bulding test provides a set of pressure (ASCII) files, each file associated with a wind direction. The tests make use of a rigid model instrumented with hundreds of pressure taps. The tunnel is configured according to a specified setup for both close field neighborhood and far field terrain roughness. The setup defines the wind turbulence reaching the model. A single building model may be tested for more than one setup.The pressure files must be pre-processed to become associated with model taps. The files give the instantaneous pressure at each channel in the data acquisition system. To link the channels to pressure taps a _Master Table_ must provide the complete mapping. The _Master Table_ has one line for each tap, plus two lines for the reference pressures $A_1$ and $A_2$ (related to the instantaneous velocity in the tunnel). The table columns bring all required tap information, as described bellow.The format above provides the possibility of assign not only one, but two channels to each pressure tap, what can be used to build a _virtual tap_, defined as the mean value between two adjacent taps. When this feature is not required (as it is usually the case) the information in columns (2) and (3) are simply repeated.The reference pressures $A_1$ and $A_2$ are identified by setting $-1$ and $-2$ in column (6), respectivelly. For these two channels, further columns are not used and may be filled with zeros.The measurement phase in column (7) is required whenever tap pressures are not to be simultaneously recorded. In this case, data assembling is performed by combining two or more pressure file sets. This is seldomly required for buildings, but may be necessary when testing, for instance, a large stadium roofing for mean pressurecoefficients. Most commonly, column (7) is simply filled with 1's.  2.2 The _Batch Table_Each pressure acquisition is carried out with a given setup and results in a ASCII datafile, which must be associated to a set of experimental parameters. This association is informed in the _Batch Table_, also provided as an ASCII file with one line per pressure acquisition. The columns in this table contains information as described bellow.A wind tunnel test (set of pressure acquisitions) may have more than one _Master Table_ if, for instance, tap connections had to be changed between acquisitions. The terrain roughness category may be a decimal number, what implies that wind profile will be interpolated accordingly. The terrain category may change with the wind direction. It is used to define the (prototype scale) dynamic pressure at building top.A further parameter associated with each acquisition is the reference pressure:$$\Delta P_{\rm a} = \beta k_0 \left(A_1 - A_2 \right) $$where $\beta$ is the blockage factor and $k_0$ is a wind tunnel calibration constant associated to  the building model height and the imposed far field turbulence.This reference pressure, $\Delta P_{\rm a}$, is internally calculated and appended to each line in the _Batch Table_, so that it is readly available for calculatingthe non dimensional pressure coefficients.  2.3 The _AllCases Table_The _AllCases Table_ is ``.xlsx`` spreadsheet to be read with ``pandas`` module,containing general information about the complete dataset (all wind direction), withone building dataset per line.The table brings general information such as the model length scale, the overall building dimensions and some ocasionally required coordinates offset.The availability of this table was motivated by the eventual need of iterating overall wind tunnel data bank, for the purpose of research on general aerodynamic properties.The coordinates offset to be applied to structural models are quite often required, foronly seldomly the building designer provides numerical model information matching thereference system adopted in the wind tunnel.  2.4. Pressure data pre-processingBoth the _Master Table_ and the _Batch Table_ must be provided for processing each pressure dataset, what is handled by the module function ``scanivalve_process()``. The general function usage is:    batch = scanivalve_process(path, prefix, dwnd=0, avg=1, per=64*32)where ``path`` is a string with the relative path to the building data directory, ``prefix`` is a string with a code for the building test setup, to be used for completing the path to the dataset directory. This two parts addressing organizes the data in case the building is tested for several setups (what is usually the case).The parameter ``dwnd`` is used to specify whether the wind direction is depicted coincident with the positive or negative $x$ axis direction in the coordinatesreference system. The ``avg`` and ``per`` are acquisition parameters used in theScanivalve system available at the LAC/UFRGS wind tunnel.The function ``scanivalve_process()`` is called internally by the ``OHFPI`` classconstructor along with with the methods for structural data input, as described inthe next section.  2.5. Structural data input  2.6. Examples of complete data input Once all datafiles and guiding tables are made available, the data input is fully abstracted in the ``OHFPI`` class constructor. This is demonstrated below for the two datasets used as examples in this notebook.<jupyter_code># CAARC Standard Tall Building
path   = 'data/E01/'  # path to building data
prefix = 'E01_IS023'  # setup code, subpath to dataset

E01    =  OHFPI(path, prefix, stype='3dof')

# Reinforced concrete bell tower
path   = 'data/E24/'
prefix = 'E24_Conf1' 

E24    =  OHFPI(path, prefix, stype='TQS')<jupyter_output><empty_output><jupyter_text>A very important feature of ``OHFPI`` instances is the method ``batchIter()``,which iterates over all wind directions available in the dataset, as exemplified below:<jupyter_code>for kb, b, master, Cp in E24.batchIter():

    if (b['swnd'] != '000'): continue  # choose which wind direction is to be displayed
    else:
        print('Direction: {0}'.format(b['swnd']))
        print('Category:  {0:3.1f}'.format(b['categ']))
        print('WT speed:  {0:3.2f}m/s'.format(b['Vm']))
        print('dPa:       {0:3.2f}Pa'.format(b['dPa']))
        print('Td:        {0:3.2f}s'.format(b['Td']),'\n')<jupyter_output>Direction: 000
Category:  4.0
WT speed:  24.75m/s
dPa:       36.97Pa
Td:        16.78s<jupyter_text>It is shown above that the iterator returns:* item order ``kb``, * the batch table entry ``b`` (with the reference pressure, $\Delta P_{\rm a}$,   and the test duration, $T_{\rm d}$, appended)* the corresponding _Master Table_ (which may be changed for some wind directions), and* a matrix, ``Cp``, with the pressure readings, one column for each tap, one row for  each time step.In the example above, the item property ``swnd`` is used as a selection criteriato display some data for a chosen wind direction only.After all the data input and pressure pre-processing, the dataset is ready to be iteratedand used for structural loading and response calculations.  3. Basic usage of pressure data<jupyter_code>Cx, Cy, Ct, Cm, Cs = E01.aerocoeffs()

wnd = np.array(E01.batch.swnd.astype('int'))

plt.figure(1, figsize=(12,4))

plt.subplot(1,3,1); plt.plot(wnd,Cm[0]); plt.grid(True); plt.axis([0, 360, -1.5, 1.5])
plt.subplot(1,3,2); plt.plot(wnd,Cm[1]); plt.grid(True); plt.axis([0, 360, -1.5, 1.5])
plt.subplot(1,3,3); plt.plot(wnd,Cm[2]); plt.grid(True); plt.axis([0, 360, -0.2, 0.2])

Cx, Cy, Ct, Cm, Cs = E24.aerocoeffs()

wnd = np.array(E24.batch.swnd.astype('int'))

plt.figure(1, figsize=(12,4))

plt.subplot(1,3,1); plt.plot(wnd,Cm[0]); plt.grid(True); plt.axis([0, 360, -1.5, 1.5])
plt.subplot(1,3,2); plt.plot(wnd,Cm[1]); plt.grid(True); plt.axis([0, 360, -1.5, 1.5])
plt.subplot(1,3,3); plt.plot(wnd,Cm[2]); plt.grid(True); plt.axis([0, 360, -0.2, 0.2])<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.07737503389677303, 'fraction_numerical': 0.021241977763716894, 'mean_word_length': 4.913415285943346, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 18, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '270544', 'license': 'MIT', 'n_tokens_mistral': 3082, 'n_tokens_neox': 2908, 'n_words': 1483, 'path': 'HFPI_Notebook.ipynb', 'repo_name': 'mmaiarocha/OHFPI', 'size': '11087'}