Datasets:
Download data_process_example/process2.py from RS2002/WiCount: direct link, hf CLI and curl.
- Browser
- Download file 1.64 kB
-
https://huggingface.co/datasets/RS2002/WiCount/resolve/main/data_process_example/process2.py
- Command line
-
hf download hf://datasets/RS2002/WiCount/data_process_example/process2.py
-
curl -L -o process2.py https://huggingface.co/datasets/RS2002/WiCount/resolve/main/data_process_example/process2.py
1.64 kB
| import numpy as np | |
| import pickle | |
| result=[] | |
| pad=[-1000]*52 | |
| loacl_gap=10000 | |
| with open("./csi_data.pkl", 'rb') as f: | |
| csi = pickle.load(f) | |
| for data in csi: | |
| csi_time=data['csi_time'] | |
| local_time=data['csi_local_time'] | |
| magnitude=data['magnitude'] | |
| phase=data['phase'] | |
| people_num=data['people_num'] | |
| last_local=None | |
| current_magnitude=[] | |
| current_phase=[] | |
| current_timestamp=[] | |
| for i in range(len(csi_time)): | |
| if last_local is None: | |
| last_local=local_time[i] | |
| current_magnitude.append(magnitude[i]) | |
| current_phase.append(phase[i]) | |
| current_timestamp.append(local_time[i]) | |
| else: | |
| local = local_time[i] | |
| num=round((local-last_local-loacl_gap)/loacl_gap) | |
| if num>0: | |
| delta=(local-last_local)/(num+1) | |
| for j in range(num): | |
| current_magnitude.append(pad) | |
| current_phase.append(pad) | |
| current_timestamp.append(current_timestamp[-1] + delta) | |
| current_magnitude.append(magnitude[i]) | |
| current_phase.append(phase[i]) | |
| current_timestamp.append(local_time[i]) | |
| last_local=local | |
| print(len(current_magnitude)) | |
| result.append({ | |
| 'time': np.array(current_timestamp), | |
| 'action': people_num, | |
| 'people': people_num, | |
| 'magnitude': np.array(current_magnitude), | |
| 'phase': np.array(current_phase) | |
| }) | |
| output_file = './data_sequence.pkl' | |
| with open(output_file, 'wb') as f: | |
| pickle.dump(result, f) | |