Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

General Information

...

Analog outputs are then connected to the T7:
U - channel 1 - AIN0
V - channel 2 - AIN1
W - channel 3 - AIN2
sonic speed - channel 4 - AIN3

Sample Dataset taken over 10 min:

image.png

And zoomed in to ~half a second of data taking:

image.png

...

Code for taking data

Note: this will take data for 10 minutes. It also takes data at a rate of 1 kHz, which is unecessary, as the anemometer takes data at 32 Hz.

Code Block
languagepy
# -*- coding: utf-8 -*-
"""
Created on TueFri NovOct 3015 0213:1155:0610 2021
@author: brodi, elanaku
"""
# saves anemometer data
from datetime import datetime, timedelta
import pandas as pd
from labjack import ljm
from sqlalchemy import create_engine
import def load_pd(db_fi: str, table: str) -> pd.DataFrame:
    """
    loads pandas df from db given table name
    """
    engine = create_engine(db_fi, echo = False)
    with engine.connect() as sqlite_connection:
        df = pd.read_sql(table, sqlite_connectiontime

DEVICE = None
PIN_VX = "AIN0"
PIN_VY = "AIN1"
PIN_VZ = "AIN2"
PIN_VSONIC = "AIN3"

sample_time = .001


db_fi = 'sqlite:///anemometer.db'

start = datetime.now()
end = start + timedelta(seconds=60*10)

def readout(PIN_VX, PIN_VY, PIN_VZ, PIN_VSONIC):
    vx = ljm.eReadName(handle, PIN_VX)
    vy = ljm.eReadName(handle, PIN_VY)
    vz = ljm.eReadName(handle, PIN_VZ)
    vsonic = ljm.eReadName(handle, PIN_VSONIC)
     return df

If database file is named anemometer, for instance, you can load it into a dataframe and then convert the relevant voltage measurements into wind speed and temperature with:

Code Block
languagepy
# Load datafile into pandas data frame
db_fi = r"sqlite:///anemometer.db"
df = load_pd(df_fi, "anem")

# Add columns in correct units
# because the units are +/- 5 m/s, 0 to 5 V
df['vx_ms'] = (df.vx - 2.5) * 2
df['vy_ms'] = (df.vy - 2.5) * 2
df['vz_ms'] = (df.vz - 2.5) * 2

# because sonic temperature is measured on a scale of 0 to 5 V
# from -40 to 70 C
df['tsonic'] = -40 + df.vsonic/5 * 110

#Plot data
plt.plot(df.t, df.vx_ms, label = 'Vx')
plt.plot(df.t, df.vy_ms, label = 'Vy')
plt.plot(df.t, df.vz_ms, label = 'Vz')
# plt.plot(df.t, df.tsonic/8 - np.mean(df.tsonic/8), label = 'Temp')

plt.legend()
plt.xlabel('Time')
plt.ylabel('Wind Speed (m/s)')
plt.show()

plt.plot(df.t, df.tsonic)
plt.xlabel('Time')
plt.ylabel(r'Sonic Temperature ($^o$C)')
plt.show()

...

(datetime.now(), vx, vy, vz, vsonic)

try:
    handle = ljm.openS("Any","Any","Any")
    engine = create_engine(db_fi, echo = False)
    sqlite_connection = engine.connect()
    options = {"index": False, "if_exists": "append"}



    while datetime.now() < end:
        it = 200
        i = 0
        res = []
        while i < it:
            res.append(readout(PIN_VX, PIN_VY, PIN_VZ, PIN_VSONIC))
            time.sleep(sample_time)
            i += 1

        anem = pd.DataFrame(res, columns = ["t", "vx", "vy", "vz", "vsonic"])

        anem.to_sql("anemometer", sqlite_connection, **options)



finally:
    ljm.close(handle)
    sqlite_connection.close()

Relevant code for analyzing binary datafile

Code Block
languagepy
# -*- coding: utf-8 -*-
"""
Created on Tue Nov 30 02:11:06 2021
​
@author: brodi
"""
​
import pandas as pd
from sqlalchemy import create_engine
​
def load_pd(db_fi: str, table: str) -> pd.DataFrame:
    """
    loads pandas df from db given table name
    """
    engine = create_engine(db_fi, echo = False)
    with engine.connect() as sqlite_connection:
        df = pd.read_sql(table, sqlite_connection)
        
    return df


If database file is named anemometer, for instance, you can load it into a dataframe and then convert the relevant voltage measurements into wind speed and temperature with:

Code Block
languagepy
# Load datafile into pandas data frame
db_fi = r"sqlite:///anemometer.db"
df = load_pd(df_fi, "anem")

# Add columns in correct units
# because the units are +/- 5 m/s, 0 to 5 V
df['vx_ms'] = (df.vx - 2.5) * 2
df['vy_ms'] = (df.vy - 2.5) * 2
df['vz_ms'] = (df.vz - 2.5) * 2

# because sonic temperature is measured on a scale of 0 to 5 V
# from -40 to 70 C
df['tsonic'] = -40 + df.vsonic/5 * 110

#Plot data
plt.plot(df.t, df.vx_ms, label = 'Vx')
plt.plot(df.t, df.vy_ms, label = 'Vy')
plt.plot(df.t, df.vz_ms, label = 'Vz')
# plt.plot(df.t, df.tsonic/8 - np.mean(df.tsonic/8), label = 'Temp')

plt.legend()
plt.xlabel('Time')
plt.ylabel('Wind Speed (m/s)')
plt.show()

plt.plot(df.t, df.tsonic)
plt.xlabel('Time')
plt.ylabel(r'Sonic Temperature ($^o$C)')
plt.show()

Which gives the first plots in the previous section.

Troubleshooting: Corrupted Data File

If for some reason the anemometer database file becomes corrupted so you can't open it or analyze the data, you can dump the data from that file into a new, uncorrupted file with the command:

$ sqlite3 old_file.db .recover | sqlite3 new_file.db

Relevant pin connections (all of which are copied from the manual)

Output pins from the anemometer (p. 15 of manual):

Image Modified


To change the analog output settings, connect a RS 432 serial port to a windows computer and to the anemometer outputs. 

RS 432 serial port pin connections (p.32 of manual):

Image Modified

For the serial connector we were using, pin 2 was white, pin 3 was yellow, pin 5 was orange, but apparently this isn't necessarily generically true.

The windows computer should have WIND software downloaded on it. Follow p. 46 of the manual.


Mounting plate

Image Modified



Image Modified

Image Modified

Image Modified

through bolts are McMaster Carr 


Super-cheap hot-wire anemometer for airflow in the dome: 

...