Created
October 28, 2022 12:15
-
-
Save aloncohen1/4a8451c9abcebbdb7d5ff4a172f82d69 to your computer and use it in GitHub Desktop.
generate_static_signals.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 8, | |
"metadata": { | |
"id": "EeklA-LMk5zo" | |
}, | |
"outputs": [], | |
"source": [ | |
"def generate_static_signals(lat, lng, start_time, end_time, sampling_rate=600):\n", | |
"\n", | |
" signals_list = []\n", | |
" signal_time = start_time + timedelta(seconds=int(np.random.choice([5,10,15]))) # start smaple couple of second after visits start\n", | |
"\n", | |
" noise_list = np.linspace(0.9999997, 1.000003) # noise factor\n", | |
"\n", | |
" while end_time > signal_time:\n", | |
" signals_list.append({'lat': lat*np.random.choice(noise_list), \n", | |
" 'lng': lng*np.random.choice(noise_list),\n", | |
" 'timestamp': signal_time})\n", | |
" signal_time += timedelta(seconds=sampling_rate - \n", | |
" int(np.random.choice(range(0,59))))\n", | |
" \n", | |
" return pd.DataFrame(signals_list).sort_values('timestamp')" | |
] | |
} | |
], | |
"metadata": { | |
"colab": { | |
"collapsed_sections": [], | |
"provenance": [] | |
}, | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.8.6" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment