Announcements

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
shuchi
Level 2
Level 2
25 sign-ins 5 replies posted 5 likes given
import numpy as np
from ifxAvian import Avian
import csv


print("Radar SDK Version: " + Avian.get_version())
with Avian.Device() as device:
    # set device config
    config = device.get_config_defaults()
    device.set_config(config)
    
    # A loop for fetching a finite number of frames comes next..
    with open('radar.csv', 'w+') as file:
        f_radar= csv.writer(file)
        for frame_number in range(10):
            frame = device.get_next_frame()
            num_rx = np.shape(frame)[0]
            print (np.shape(frame))
    
    ## initialize empty list to hold reshaped slices
        reshaped_slices= []

    #loop through each slice along the first index
        for i in range(frame.shape[0]):
            current_slice= frame[i, :, :]
            print(current_slice)

        
        # Do some processing with the obtained frame.
        # In this example we just dump it into the console
        print ("Got frame " + format(frame_number) + ", num_antennas={}".format(num_rx))

        for iAnt in range(num_rx):
            mat = frame[0, :, :]
            print("Antenna", iAnt, "\n", mat)

Hello,

Thank you for your available Python wrapper example code. I am able to get all the frame data. However, I wish to write each antenna data into .csv file and analyse for which i modified a little in the code but not able to see any data in the file that i am saving. can you kindly help in this? Thnaks again.

import numpy as np
from ifxAvian import Avian
import csv


print("Radar SDK Version: " + Avian.get_version())


# open device: The device will be closed at the end of the block. Instead of
# the with-block you can also use:
#   device = Device()
# However, the with block gives you better control when the device is closed.
with Avian.Device() as device:
    # set device config
    config = device.get_config_defaults()
    device.set_config(config)
    
    
    # A loop for fetching a finite number of frames comes next..
    with open('radar.csv', 'w+') as file:
        f_radar= csv.writer(file)
        for frame_number in range(10):
            frame = device.get_next_frame()
            num_rx = np.shape(frame)[0]
            print (np.shape(frame))
    
    ## initialize empty list to hold reshaped slices
        reshaped_slices= []

    #loop through each slice along the first index
        for i in range(frame.shape[0]):
            current_slice= frame[i, :, :]
            print(current_slice)

        
        # Do some processing with the obtained frame.
        # In this example we just dump it into the console
        print ("Got frame " + format(frame_number) + ", num_antennas={}".format(num_rx))

        for iAnt in range(num_rx):
            mat = frame[0, :, :]
            print("Antenna", iAnt, "\n", mat)
0 Likes
1 Solution
Siddharth_H
Moderator
Moderator
Moderator
100 solutions authored 50 likes received First question asked

Hey Suchi!

Looks like you had posted the thread in a different forum page, so we missed it. Apologies for that.

So, Below is a little piece of Python code that you can use to save the data to CSV file.

import numpy as np
from ifxAvian import Avian
import csv
import pandas as pd 

with Avian.Device() as device:
    config = device.get_config_defaults()
    device.set_config(config)
    
    for frame_number in range(10):
        frame = device.get_next_frame()
        num_rx = np.shape(frame)[0]

    for iAnt in range(num_rx):
        mat = frame[0, :, :]
        print("Antenna", iAnt, "\n", mat)
        pd.DataFrame(mat).to_csv('rawData.csv')

 

Hope this helps : )

Thank you,

Siddharth.

View solution in original post

2 Replies
Siddharth_H
Moderator
Moderator
Moderator
100 solutions authored 50 likes received First question asked

Hey Suchi!

Looks like you had posted the thread in a different forum page, so we missed it. Apologies for that.

So, Below is a little piece of Python code that you can use to save the data to CSV file.

import numpy as np
from ifxAvian import Avian
import csv
import pandas as pd 

with Avian.Device() as device:
    config = device.get_config_defaults()
    device.set_config(config)
    
    for frame_number in range(10):
        frame = device.get_next_frame()
        num_rx = np.shape(frame)[0]

    for iAnt in range(num_rx):
        mat = frame[0, :, :]
        print("Antenna", iAnt, "\n", mat)
        pd.DataFrame(mat).to_csv('rawData.csv')

 

Hope this helps : )

Thank you,

Siddharth.

Thank you Siddharth 🙂

0 Likes