added plot script

pull/1/head
Simon Pirkelmann 2019-11-30 21:18:33 +01:00
parent 3096c57395
commit 86a3496cf3
21 changed files with 551 additions and 0 deletions

View File

@ -0,0 +1,3 @@
<component name="MarkdownNavigator.ProfileManager">
<settings default="" pdf-export="" plain-text-search-scope="!predefined.scope.project.files.name!" />
</component>

View File

@ -0,0 +1,87 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="MarkdownProjectSettings" wasCopied="true">
<PreviewSettings splitEditorLayout="SPLIT" splitEditorPreview="PREVIEW" useGrayscaleRendering="false" zoomFactor="1.0" maxImageWidth="0" showGitHubPageIfSynced="false" allowBrowsingInPreview="false" synchronizePreviewPosition="true" highlightPreviewType="NONE" highlightFadeOut="5" highlightOnTyping="true" synchronizeSourcePosition="true" verticallyAlignSourceAndPreviewSyncPosition="true" showSearchHighlightsInPreview="false" showSelectionInPreview="true" openRemoteLinks="true" replaceUnicodeEmoji="false" lastLayoutSetsDefault="false">
<PanelProvider>
<provider providerId="com.vladsch.idea.multimarkdown.editor.swing.html.panel" providerName="Default - Swing" />
</PanelProvider>
</PreviewSettings>
<ParserSettings gitHubSyntaxChange="false" emojiShortcuts="1" emojiImages="0">
<PegdownExtensions>
<option name="ABBREVIATIONS" value="false" />
<option name="ANCHORLINKS" value="true" />
<option name="ASIDE" value="false" />
<option name="ATXHEADERSPACE" value="true" />
<option name="AUTOLINKS" value="false" />
<option name="DEFINITIONS" value="false" />
<option name="DEFINITION_BREAK_DOUBLE_BLANK_LINE" value="false" />
<option name="FENCED_CODE_BLOCKS" value="true" />
<option name="FOOTNOTES" value="false" />
<option name="HARDWRAPS" value="false" />
<option name="HTML_DEEP_PARSER" value="false" />
<option name="INSERTED" value="false" />
<option name="QUOTES" value="false" />
<option name="RELAXEDHRULES" value="true" />
<option name="SMARTS" value="false" />
<option name="STRIKETHROUGH" value="true" />
<option name="SUBSCRIPT" value="false" />
<option name="SUPERSCRIPT" value="false" />
<option name="SUPPRESS_HTML_BLOCKS" value="false" />
<option name="SUPPRESS_INLINE_HTML" value="false" />
<option name="TABLES" value="true" />
<option name="TASKLISTITEMS" value="true" />
<option name="TOC" value="false" />
<option name="WIKILINKS" value="false" />
</PegdownExtensions>
<ParserOptions>
<option name="ADMONITION_EXT" value="false" />
<option name="ATTRIBUTES_EXT" value="false" />
<option name="COMMONMARK_LISTS" value="true" />
<option name="DUMMY" value="false" />
<option name="EMOJI_SHORTCUTS" value="true" />
<option name="ENUMERATED_REFERENCES_EXT" value="false" />
<option name="FLEXMARK_FRONT_MATTER" value="false" />
<option name="GFM_LOOSE_BLANK_LINE_AFTER_ITEM_PARA" value="false" />
<option name="GFM_TABLE_RENDERING" value="true" />
<option name="GITBOOK_URL_ENCODING" value="false" />
<option name="GITHUB_LISTS" value="false" />
<option name="GITHUB_WIKI_LINKS" value="false" />
<option name="GITLAB_EXT" value="false" />
<option name="GITLAB_MATH_EXT" value="false" />
<option name="GITLAB_MERMAID_EXT" value="false" />
<option name="HEADER_ID_NON_ASCII_TO_LOWERCASE" value="false" />
<option name="HEADER_ID_NO_DUPED_DASHES" value="false" />
<option name="JEKYLL_FRONT_MATTER" value="false" />
<option name="MACROS_EXT" value="false" />
<option name="NO_TEXT_ATTRIBUTES" value="false" />
<option name="PARSE_HTML_ANCHOR_ID" value="false" />
<option name="PLANTUML_FENCED_CODE" value="false" />
<option name="PUML_FENCED_CODE" value="false" />
<option name="SIM_TOC_BLANK_LINE_SPACER" value="true" />
</ParserOptions>
</ParserSettings>
<HtmlSettings headerTopEnabled="false" headerBottomEnabled="false" bodyTopEnabled="false" bodyBottomEnabled="false" embedUrlContent="false" addPageHeader="true" embedImages="false" embedHttpImages="false" imageUriSerials="false" addDocTypeHtml="true" noParaTags="false" plantUmlConversion="0" mathConversion="0">
<GeneratorProvider>
<provider providerId="com.vladsch.idea.multimarkdown.editor.swing.html.generator" providerName="Default Swing HTML Generator" />
</GeneratorProvider>
<headerTop />
<headerBottom />
<bodyTop />
<bodyBottom />
</HtmlSettings>
<CssSettings previewScheme="UI_SCHEME" cssUri="" isCssUriEnabled="false" isCssUriSerial="true" isCssTextEnabled="false" isDynamicPageWidth="true">
<StylesheetProvider>
<provider providerId="com.vladsch.idea.multimarkdown.editor.swing.html.css" providerName="Default Swing Stylesheet" />
</StylesheetProvider>
<ScriptProviders />
<cssText />
<cssUriHistory />
</CssSettings>
<AnnotatorSettings targetHasSpaces="true" linkCaseMismatch="true" wikiCaseMismatch="true" wikiLinkHasDashes="true" notUnderWikiHome="true" targetNotWikiPageExt="true" notUnderSourceWikiHome="true" targetNameHasAnchor="true" targetPathHasAnchor="true" wikiLinkHasSlash="true" wikiLinkHasSubdir="true" wikiLinkHasOnlyAnchor="true" linkTargetsWikiHasExt="true" linkTargetsWikiHasBadExt="true" notUnderSameRepo="true" targetNotUnderVcs="false" linkNeedsExt="true" linkHasBadExt="true" linkTargetNeedsExt="true" linkTargetHasBadExt="true" wikiLinkNotInWiki="true" imageTargetNotInRaw="true" repoRelativeAcrossVcsRoots="true" multipleWikiTargetsMatch="true" unresolvedLinkReference="true" linkIsIgnored="true" anchorIsIgnored="true" anchorIsUnresolved="true" anchorLineReferenceIsUnresolved="true" anchorLineReferenceFormat="true" anchorHasDuplicates="true" abbreviationDuplicates="true" abbreviationNotUsed="true" attributeIdDuplicateDefinition="true" attributeIdNotUsed="true" footnoteDuplicateDefinition="true" footnoteUnresolved="true" footnoteDuplicates="true" footnoteNotUsed="true" macroDuplicateDefinition="true" macroUnresolved="true" macroDuplicates="true" macroNotUsed="true" referenceDuplicateDefinition="true" referenceUnresolved="true" referenceDuplicates="true" referenceNotUsed="true" referenceUnresolvedNumericId="true" enumRefDuplicateDefinition="true" enumRefUnresolved="true" enumRefDuplicates="true" enumRefNotUsed="true" enumRefLinkUnresolved="true" enumRefLinkDuplicates="true" simTocUpdateNeeded="true" simTocTitleSpaceNeeded="true" />
<HtmlExportSettings updateOnSave="false" parentDir="" targetDir="" cssDir="css" scriptDir="js" plainHtml="false" imageDir="" copyLinkedImages="false" imageUniquifyType="0" targetPathType="2" targetExt="" useTargetExt="false" noCssNoScripts="false" useElementStyleAttribute="false" linkToExportedHtml="true" exportOnSettingsChange="true" regenerateOnProjectOpen="false" linkFormatType="HTTP_ABSOLUTE" />
<LinkMapSettings>
<textMaps />
</LinkMapSettings>
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 2.7.12 (/usr/bin/python2.7)" project-jdk-type="Python SDK" />
</project>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/plots.iml" filepath="$PROJECT_DIR$/.idea/plots.iml" />
</modules>
</component>
</project>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="TestRunnerService">
<option name="projectConfiguration" value="Nosetests" />
<option name="PROJECT_TEST_RUNNER" value="Nosetests" />
</component>
</module>

View File

@ -0,0 +1,248 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="7a4972e2-7a88-4336-a24f-0b70ac5a3df4" name="Default" comment="" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="TRACKING_ENABLED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="CoverageDataManager">
<SUITE FILE_PATH="coverage/plots$chirp.coverage" NAME="chirp Coverage Results" MODIFIED="1574788500854" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
</component>
<component name="FileEditorManager">
<leaf>
<file leaf-file-name="chirp.py" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/chirp.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="324">
<caret line="24" column="30" lean-forward="true" selection-start-line="24" selection-start-column="30" selection-end-line="24" selection-end-column="30" />
<folding>
<element signature="e#0#43#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="text.py" pinned="false" current-in-tab="false">
<entry file="file://$USER_HOME$/.local/lib/python2.7/site-packages/matplotlib/text.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="176">
<caret line="190" column="0" lean-forward="false" selection-start-line="190" selection-start-column="0" selection-end-line="190" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="spectral.py" pinned="false" current-in-tab="false">
<entry file="file://$USER_HOME$/.local/lib/python2.7/site-packages/scipy/signal/spectral.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1580">
<caret line="1572" column="0" lean-forward="false" selection-start-line="1572" selection-start-column="0" selection-end-line="1572" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="waveforms.py" pinned="false" current-in-tab="false">
<entry file="file://$USER_HOME$/.local/lib/python2.7/site-packages/scipy/signal/waveforms.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="176">
<caret line="443" column="0" lean-forward="false" selection-start-line="443" selection-start-column="0" selection-end-line="443" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/chirp.py" />
</list>
</option>
</component>
<component name="JsBuildToolGruntFileManager" detection-done="true" sorting="DEFINITION_ORDER" />
<component name="JsBuildToolPackageJson" detection-done="true" sorting="DEFINITION_ORDER" />
<component name="JsGulpfileManager">
<detection-done>true</detection-done>
<sorting>DEFINITION_ORDER</sorting>
</component>
<component name="ProjectFrameBounds" extendedState="4">
<option name="x" value="-1910" />
<option name="y" value="-1056" />
<option name="width" value="1141" />
<option name="height" value="1056" />
</component>
<component name="ProjectView">
<navigator currentView="ProjectPane" proportions="" version="1">
<flattenPackages />
<showMembers />
<showModules />
<showLibraryContents />
<hideEmptyPackages />
<abbreviatePackageNames />
<autoscrollToSource />
<autoscrollFromSource />
<sortByType />
<manualOrder />
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="Scope" />
<pane id="ProjectPane">
<subPane>
<expand>
<path>
<item name="plots" type="b2602c69:ProjectViewProjectNode" />
<item name="plots" type="462c0819:PsiDirectoryNode" />
</path>
</expand>
<select />
</subPane>
</pane>
<pane id="Scratches" />
</panes>
</component>
<component name="PropertiesComponent">
<property name="settings.editor.selected.configurable" value="com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable" />
<property name="last_opened_file_path" value="$USER_HOME$/firedrake/firedrake" />
<property name="WebServerToolWindowFactoryState" value="false" />
</component>
<component name="RunDashboard">
<option name="ruleStates">
<list>
<RuleState>
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
</RuleState>
<RuleState>
<option name="name" value="StatusDashboardGroupingRule" />
</RuleState>
</list>
</option>
</component>
<component name="RunManager" selected="Python.chirp">
<configuration name="chirp" type="PythonConfigurationType" factoryName="Python" temporary="true">
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<module name="plots" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/chirp.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
</configuration>
<recent_temporary>
<list size="1">
<item index="0" class="java.lang.String" itemvalue="Python.chirp" />
</list>
</recent_temporary>
</component>
<component name="ShelveChangesManager" show_recycled="false">
<option name="remove_strategy" value="false" />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="7a4972e2-7a88-4336-a24f-0b70ac5a3df4" name="Default" comment="" />
<created>1574774363804</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1574774363804</updated>
</task>
<servers />
</component>
<component name="ToolWindowManager">
<frame x="-1910" y="-1056" width="1141" height="1056" extended-state="4" />
<editor active="true" />
<layout>
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.20821919" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
<window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32938644" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="false" weight="0.33" sideWeight="0.5" order="10" side_tool="false" content_ui="tabs" />
<window_info id="Python Console" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="8" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="9" side_tool="false" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.39935413" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
<window_info id="Data View" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32932165" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
</layout>
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="1" />
</component>
<component name="VcsContentAnnotationSettings">
<option name="myLimit" value="2678400000" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
<breakpoints>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/chirp.py</url>
<line>192</line>
<option name="timeStamp" value="4" />
</line-breakpoint>
</breakpoints>
<breakpoints-dialog>
<breakpoints-dialog />
</breakpoints-dialog>
<option name="time" value="14" />
</breakpoint-manager>
<watches-manager />
</component>
<component name="editorHistoryManager">
<entry file="file://$USER_HOME$/.local/lib/python2.7/site-packages/scipy/signal/waveforms.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="176">
<caret line="443" column="0" lean-forward="false" selection-start-line="443" selection-start-column="0" selection-end-line="443" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$USER_HOME$/.local/lib/python2.7/site-packages/scipy/signal/spectral.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1580">
<caret line="1572" column="0" lean-forward="false" selection-start-line="1572" selection-start-column="0" selection-end-line="1572" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$USER_HOME$/.local/lib/python2.7/site-packages/matplotlib/text.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="176">
<caret line="190" column="0" lean-forward="false" selection-start-line="190" selection-start-column="0" selection-end-line="190" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/chirp.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="324">
<caret line="24" column="30" lean-forward="true" selection-start-line="24" selection-start-column="30" selection-end-line="24" selection-end-column="30" />
<folding>
<element signature="e#0#43#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</component>
</project>

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

193
presentation/plots/chirp.py Normal file
View File

@ -0,0 +1,193 @@
from scipy.signal import chirp, spectrogram
import numpy as np
import matplotlib.pyplot as plt
def amp_freq_mod():
# amplitude modulation
t = np.linspace(0, 20 * np.pi, 1000, endpoint=False)
t1 = t[0:200]
t2 = t[200:600]
t3 = t[600:800]
t4 = t[800:]
plt.figure(1)
signal_unmod = np.sin(t)
plt.plot(t, signal_unmod)
plt.title("Unmodulated signal")
plt.xlabel('time')
plt.ylabel('Amplitude')
plt.tight_layout()
plt.savefig('unmodulated.png')
plt.show()
plt.figure(2)
signal_ampmod = np.hstack((np.sin(t1), 0.2 * np.sin(t2), np.sin(t3), 0.2 * np.sin(t4)))
plt.plot(t, signal_ampmod)
plt.title("Amplitude modulation")
plt.xlabel('time')
plt.ylabel('Amplitude')
plt.tight_layout()
plt.savefig('amplitude_modulation.png')
plt.show()
# frequency modulation
plt.figure(3)
signal_ampmod = np.hstack((np.sin(t1), np.sin(0.5*t2), np.sin(t3), np.sin(0.5*t4)))
plt.plot(t, signal_ampmod)
plt.title("Frequency modulation")
plt.xlabel('time')
plt.ylabel('Amplitude')
plt.tight_layout()
plt.savefig('frequency_modulation.png')
plt.show()
def chirps():
# chirp example
fs = 8000
T = 10
t = np.linspace(0, T, T*fs, endpoint=False)
upchirp = chirp(t, f0=0, f1=5, t1=10, method='linear')
plt.figure(1)
plt.plot(t, upchirp)
plt.title("Chirp")
plt.xlabel('time')
plt.ylabel('Amplitude')
plt.tight_layout()
plt.savefig('chirp.png')
plt.show()
#######################################
# LoRa chirps
fs = 8000
T = 10
t = np.linspace(0, T, T*fs, endpoint=False)
upchirp = chirp(t, f0=250, f1=1750, t1=10, method='linear')
ff, tt, Sxx = spectrogram(upchirp, fs=fs, noverlap=256, nperseg=512,
nfft=2048)
# Chirp explanation
plt.figure(2)
plt.yticks([250, 1000, 1750], ['f_start', 'f_center', 'f_end'] )
plt.xticks([0,10], [0, 't_symb'])
plt.pcolormesh(tt, ff[:513], Sxx[:513])
plt.title("Chirp spectrogram")
plt.xlabel('time')
plt.ylabel('frequency')
plt.tight_layout()
plt.savefig('chirp_spectrogram.png')
plt.show()
# LoRa upchirp
plt.figure(3)
plt.yticks([250, 1000, 1750], ['868.1 MHz - 62.5 kHz', '868.1 MHz', '868.1 MHz + 62.5 kHz'] )
plt.xticks([0,10], [0, 't_symb'])
plt.pcolormesh(tt, ff[:513], Sxx[:513])
plt.title("LoRa Up-Chirp")
plt.xlabel('time')
plt.ylabel('frequency')
plt.tight_layout()
plt.savefig('lora_upchirp.png')
plt.show()
# downchirp
downchirp = chirp(t, f0=1750, f1=250, t1=10, method='linear')
ff, tt, Sxx = spectrogram(downchirp, fs=fs, noverlap=256, nperseg=512,
nfft=2048)
plt.figure(4)
plt.yticks([250, 1000, 1750], ['868.1 MHz - 62.5 kHz', '868.1 MHz', '868.1 MHz + 62.5 kHz'] )
plt.xticks([0,10], [0, 't_symb'])
plt.pcolormesh(tt, ff[:513], Sxx[:513])
plt.title("LoRa Down-Chirp")
plt.xlabel('time')
plt.ylabel('frequency')
plt.tight_layout()
plt.savefig('lora_downchirp.png')
plt.show()
def symbol():
# symbol example
fs = 8000
T = 10
t = np.linspace(0, T, T*fs, endpoint=False)
fracs = [0.7, 0.7, 0.99, 0.9, 0.8, 0.5]
for i in range(0,6):
frac = fracs[i]
t_jump = T * (1 - frac)
# 250, 500, 750, 1000, 1250, 1500, 1750
t1 = (frac)*T
symbol_p1 = chirp(t[0:int(frac*len(t))], f0=250, f1=1750, t1=T, method='linear')
symbol_p2 = chirp(t[int(frac*len(t)):], f0=250, f1=1750, t1=T, method='linear')
symbol = np.hstack((symbol_p2, symbol_p1))
ff, tt, Sxx = spectrogram(symbol, fs=fs, noverlap=256, nperseg=512,
nfft=2048)
#chirp = np.hstack((upchirp, upchirp))
#ff, tt, Sxx = spectrogram(chirp, fs=fs, noverlap=256, nperseg=512,
# nfft=2048)
plt.figure(5)
plt.yticks([250, 1000, 1750], ['868.1 MHz - 62.5 kHz', '868.1 MHz', '868.1 MHz + 62.5 kHz'] )
plt.pcolormesh(tt, ff[:513], Sxx[:513])
if i > 0:
plt.xticks([0, t_jump], [0, 't_jump'])
plt.plot([t_jump, t_jump], [0, 2000.0], 'r')
else:
plt.xticks([0, t_jump], [0, 't_jump'])
plt.gca().tick_params(axis='x', colors='white')
plt.title("LoRa Symbol")
plt.xlabel('time')
plt.ylabel('frequency')
plt.tight_layout()
plt.savefig('lora_symbols_{}.png'.format(i))
plt.show()
def spreading_factor():
fs = 8000
T = 400
t = np.linspace(0, T, T * fs, endpoint=False)
chirps = np.array([0])
for i in range(3,-1,-1):
t_final = len(t)/2**i
chirp1 = chirp(t[0:t_final], f0=250, f1=1750, t1=T/2**i, method='linear')
chirps = np.hstack((chirps, chirp1))
ff, tt, Sxx = spectrogram(chirps, fs=fs, noverlap=256, nperseg=512,
nfft=2048)
plt.figure(5)
plt.yticks([250, 1000, 1750], ['868.1 MHz - 62.5 kHz', '868.1 MHz', '868.1 MHz + 62.5 kHz'])
plt.pcolormesh(tt, ff[:513], Sxx[:513])
plt.title("LoRa Spreading Factors")
plt.xlabel('time')
plt.ylabel('frequency')
plt.xticks([], [])
plt.gca().set_aspect(0.28)
for i in range(0,4):
plt.text(tt[int(2.0**i/2.0**3 * len(tt)-1)], 1800.0, 'SF = {}'.format(i + 7), color='white', horizontalalignment='right')
plt.tight_layout()
plt.savefig('lora_spreading_factors.png', dpi=400.0)
plt.show()
pass
#symbol()
spreading_factor()
plt.show()

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB