azinke / coloradar

API for loading the Coloradar dataset.
MIT License
20 stars 0 forks source link

questions on frequency / phase calibration and DC bias cut #5

Open eshibusawa opened 1 month ago

eshibusawa commented 1 month ago

Hi, Thank you for publishing very interesting repository. I have some questions about ADC data processing.

1) the reference channel in frequency / phase calibration The coloradar ADC data has same layout to mmawve-repack and its shape [tx][rx][doppler][range]. The API uses index 0 in frequency and phase calibration matrix computation, so I think the reference channel is not master device but third slave device. I think both calibrations are channel to channel calibration and any channel can be selected for the reference. Is my understanding is correct?

2) DC bias removing The API uses numpy's mean for removing DC component, however, this operation averages all element of the passed array. Following to the numpy reference, I think axis=3 argument is required for computing DC component in range-dimension. https://numpy.org/doc/stable/reference/generated/numpy.mean.html

azinke commented 1 month ago

Hi @eshibusawa !

  1. Index 0 is indeed not the master. It's the first device (DEV 4) where the transmission/reception started The device order is something like the following for the MMW-CAS Board
[DEV 4] [DEV 1] [DEV 3] [DEV 2]
  1. Very good point. You mean this line here, right? It would actually make sense to only average on the sample's axis https://github.com/azinke/coloradar/blob/000626e644f34fbb067bfe33097dfc37482e6191/core/radar.py#L431

Have you tried to fix it and check the result already?!

-- Edit -- I just checked again and the adc_samples variable I've quoted above is a 1D array containing the complex recorded samples. So, the mean there should be fine. Where you referring to the use of the mean somewhere else?!

eshibusawa commented 1 month ago

Thank you for your reply!

1) the reference channel in frequency / phase calibration I understood the index 0 is not master device. Your description seems consistent to Fig. 1 of the following document. https://e2e.ti.com/cfs-file/__key/communityserver-discussions-components-files/1023/signalPrcesssing_5F00_userguide_5F00_4chipCascade.pdf image

2) DC bias removing I used the following test code. Both adc data of single chip and cascade seem a complex-valued 4D array.

assert_eps = 1E-7
cl = Coloradar()
rr = cl.getRecord('outdoor0', 0)
rr.load('scradar')
## rr.scradar.showPointcloudFromRaw()
# check single chip raw adc
adc_samples_sc = rr.scradar.raw
dc_sc = np.mean(adc_samples_sc)
dc3_sc = np.mean(adc_samples_sc, axis=3)
print(adc_samples_sc.shape)
print(dc_sc.shape)
print(dc3_sc.shape)
adc_dccut_sc = adc_samples_sc - dc_sc # scalar is broadcasted to ALL dimension
adc_dccut3_sc = adc_samples_sc - dc3_sc[:,:,:,np.newaxis] # newaxis is added for broadcasting range-dimension
print(np.max(np.abs(adc_dccut_sc - adc_dccut3_sc)) < assert_eps) # both results are not equal

rr.load('ccradar')
## rr.ccradar.showPointcloudFromRaw() # not officialy supported?
# check cascade raw adc
adc_samples_cc = rr.ccradar.raw
dc_cc = np.mean(adc_samples_cc)
dc3_cc = np.mean(adc_samples_cc, axis=3)
print(adc_samples_cc.shape)
print(dc_cc.shape)
print(dc3_cc.shape)
adc_dccut_cc = adc_samples_cc - dc_cc # scalar is broadcasted to ALL dimension
adc_dccut3_cc = adc_samples_cc - dc3_cc[:,:,:,np.newaxis] # newaxis is added for broadcasting range-dimension
print(np.max(np.abs(adc_dccut_cc - adc_dccut3_cc)) < assert_eps) # both results are not equal