Skip to content

Commit

Permalink
Merge pull request #3 from ctarver/devleop
Browse files Browse the repository at this point in the history
Devleop
  • Loading branch information
ctarver committed Sep 26, 2019
2 parents 10f0a3e + 1eeb46d commit c876180
Show file tree
Hide file tree
Showing 21 changed files with 223 additions and 47 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE.md
@@ -1,4 +1,4 @@
* phypy version:
* PhyPy version:
* Python version:
* Operating System:

Expand Down
16 changes: 14 additions & 2 deletions .travis.yml
@@ -1,8 +1,20 @@
# Config file for automatic testing at travis-ci.org

language: python
python:
- 3.6
- 3.7
- 3.6

# Command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors
install: pip install -U tox-travis

# Command to run tests, e.g. python setup.py test
script: tox

# Assuming you have installed the travis-ci CLI tool, after you
# create the Github repo and add it to Travis, run the
# following command to finish PyPI deployment setup:
# $ travis encrypt --add deploy.password
deploy:
provider: pypi
distributions: sdist bdist_wheel
Expand All @@ -12,4 +24,4 @@ deploy:
on:
tags: true
repo: ctarver/phypy
python: 3.6
python: 3.7
12 changes: 6 additions & 6 deletions CONTRIBUTING.rst
Expand Up @@ -38,8 +38,8 @@ and "help wanted" is open to whoever wants to implement it.
Write Documentation
~~~~~~~~~~~~~~~~~~~

phypy could always use more documentation, whether as part of the
official phypy docs, in docstrings, or even on the web in blog posts,
PhyPy could always use more documentation, whether as part of the
official PhyPy docs, in docstrings, or even on the web in blog posts,
articles, and such.

Submit Feedback
Expand Down Expand Up @@ -80,7 +80,7 @@ Ready to contribute? Here's how to set up `phypy` for local development.
tests, including testing other Python versions with tox::

$ flake8 phypy tests
$ python setup.py test or py.test
$ python setup.py test or pytest
$ tox

To get flake8 and tox, just pip install them into your virtualenv.
Expand All @@ -102,7 +102,7 @@ Before you submit a pull request, check that it meets these guidelines:
2. If the pull request adds functionality, the docs should be updated. Put
your new functionality into a function with a docstring, and add the
feature to the list in README.rst.
3. The pull request should work for Python 2.7, 3.4, 3.5 and 3.6, and for PyPy. Check
3. The pull request should work for Python 3.6 and 3.7, and for PyPy. Check
https://travis-ci.org/ctarver/phypy/pull_requests
and make sure that the tests pass for all supported Python versions.

Expand All @@ -111,7 +111,7 @@ Tips

To run a subset of tests::

$ py.test tests.test_phypy
$ pytest tests.test_phypy


Deploying
Expand All @@ -121,7 +121,7 @@ A reminder for the maintainers on how to deploy.
Make sure all your changes are committed (including an entry in HISTORY.rst).
Then run::

$ bumpversion patch # possible: major / minor / patch
$ bump2version patch # possible: major / minor / patch
$ git push
$ git push --tags

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -54,7 +54,7 @@ lint: ## check style with flake8
flake8 phypy tests

test: ## run tests quickly with the default Python
py.test
pytest

test-all: ## run tests on every Python version with tox
tox
Expand Down
11 changes: 7 additions & 4 deletions README.rst
@@ -1,19 +1,23 @@
=====
phypy
PhyPy
=====


.. image:: https://img.shields.io/pypi/v/phypy.svg
:target: https://pypi.python.org/pypi/phypy

.. image:: https://travis-ci.org/ctarver/phypy.svg?branch=master
.. image:: https://img.shields.io/travis/ctarver/phypy.svg
:target: https://travis-ci.org/ctarver/phypy

.. image:: https://readthedocs.org/projects/phypy/badge/?version=latest
:target: https://phypy.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status


.. image:: https://pyup.io/repos/github/ctarver/phypy/shield.svg
:target: https://pyup.io/repos/github/ctarver/phypy/
:alt: Updates



Library of tools for wireless, physical layer research, simulations, and testing.
Expand All @@ -26,8 +30,7 @@ Library of tools for wireless, physical layer research, simulations, and testing
Features
--------

* A power amplifier model with realistic coefficients extracted from a WARPv3 board PA.

* TODO

Credits
-------
Expand Down
10 changes: 5 additions & 5 deletions docs/conf.py
Expand Up @@ -32,7 +32,7 @@

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode', 'sphinx.ext.napoleon', 'sphinx.ext.todo']
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode']

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
Expand All @@ -47,7 +47,7 @@
master_doc = 'index'

# General information about the project.
project = u'phypy'
project = u'PhyPy'
copyright = u"2019, Chance Tarver"
author = u"Chance Tarver"

Expand Down Expand Up @@ -129,7 +129,7 @@
# [howto, manual, or own class]).
latex_documents = [
(master_doc, 'phypy.tex',
u'phypy Documentation',
u'PhyPy Documentation',
u'Chance Tarver', 'manual'),
]

Expand All @@ -140,7 +140,7 @@
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'phypy',
u'phypy Documentation',
u'PhyPy Documentation',
[author], 1)
]

Expand All @@ -152,7 +152,7 @@
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'phypy',
u'phypy Documentation',
u'PhyPy Documentation',
author,
'phypy',
'One line description of project.',
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
@@ -1,4 +1,4 @@
Welcome to phypy's documentation!
Welcome to PhyPy's documentation!
======================================

.. toctree::
Expand Down
8 changes: 4 additions & 4 deletions docs/installation.rst
Expand Up @@ -8,13 +8,13 @@ Installation
Stable release
--------------

To install phypy, run this command in your terminal:
To install PhyPy, run this command in your terminal:

.. code-block:: console
$ pip install phypy
This is the preferred method to install phypy, as it will always install the most recent stable release.
This is the preferred method to install PhyPy, as it will always install the most recent stable release.

If you don't have `pip`_ installed, this `Python installation guide`_ can guide
you through the process.
Expand All @@ -26,7 +26,7 @@ you through the process.
From sources
------------

The sources for phypy can be downloaded from the `Github repo`_.
The sources for PhyPy can be downloaded from the `Github repo`_.

You can either clone the public repository:

Expand All @@ -38,7 +38,7 @@ Or download the `tarball`_:

.. code-block:: console
$ curl -OL https://github.com/ctarver/phypy/tarball/master
$ curl -OJL https://github.com/ctarver/phypy/tarball/master
Once you have a copy of the source, you can install it with:

Expand Down
2 changes: 1 addition & 1 deletion docs/usage.rst
Expand Up @@ -2,6 +2,6 @@
Usage
=====

To use phypy in a project::
To use PhyPy in a project::

import phypy
2 changes: 1 addition & 1 deletion phypy/__init__.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

"""Top-level package for phypy."""
"""Top-level package for PhyPy."""

__author__ = """Chance Tarver"""
__email__ = 'tarver.chance@gmail.com'
Expand Down
18 changes: 18 additions & 0 deletions phypy/cli.py
@@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-

"""Console script for phypy."""
import sys
import click


@click.command()
def main(args=None):
"""Console script for phypy."""
click.echo("Replace this message by putting your code into "
"phypy.cli.main")
click.echo("See click documentation at https://click.palletsprojects.com/")
return 0


if __name__ == "__main__":
sys.exit(main()) # pragma: no cover
6 changes: 6 additions & 0 deletions phypy/mimo/__init__.py
@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-

"""MIMO Module for PhyPy"""

__author__ = """Chance Tarver"""
__email__ = 'tarver.chance@gmail.com'
Empty file added phypy/mimo/channels.py
Empty file.
95 changes: 95 additions & 0 deletions phypy/mimo/mimo.py
@@ -0,0 +1,95 @@
import numpy as np
import simpy


class MimoTransmitter:
""" Class that represents an entire MIMO Transmitter Array. Includes channel and precoder."""

def __init__(self,
n_antennas: int = 64,
n_users: int = 4,
precoder: str = 'zero_forcing',
update_precoder_frequency: int = 7):
self.n_antennas = n_antennas
self.n_users = n_users
self.channel_matrix = None # Will store the channel matrix when we get it.
self.precoder = ZeroForcing(self.channel_matrix, update_precoder_frequency)

def update_channel(self, channel):
""" The channel object exists in its own object. Periodically, our transmitter will get new CSI/channel.
This method updates the classes copy of the channel"""

def transmit(self, symbols):
pass


class LinearPrecoder:
def __init__(self):
pass

def precode(self, symbols):
out = np.dot(self.precoding_matrix, symbols)
return out

def precode_update_process(self, env):
env.timeout(
0.001
) # Small delay so that we always update based on a new channel
while True:
print(f'Current Symbol = {env.now}. Updating precoder')
self.create_precoder_matrix(self.precoding_matrix)
yield env.timeout(self.update_rate)


class ZeroForcing(LinearPrecoder):
def __init__(self, channel_matrix, update_rate):
self.precoding_matrix = None # Will be set by create_precoder_matrix method
self.create_precoder_matrix(channel_matrix)
self.update_rate = update_rate

def create_precoder_matrix(self, channel_matrix):
self.precoding_matrix = channel_matrix


class MIMO_Channel:
def channel_update_process(self, env):
while True:
print(f'Current Symbol = {env.now}. Updating channel')
self.update_channel()
yield env.timeout(self.update_rate)


class MimoAwgn(MIMO_Channel):
def __init__(self, n_users: int = 8, n_antennas: int = 64, n_subcarriers=1200, update_rate: int = 7):
self.n_users = n_users
self.n_antennas = n_antennas
self.n_subcarriers = n_subcarriers
self.update_rate = update_rate
self.matrix = 1

def update_channel(self):
new_channel = 0.9*old_channel + guassian
pass


if __name__ == "__main__":
env = simpy.Environment()
update_channel_frequency = 1 # Every 2 symbols, make new MIMO channel
update_precoder_frequency = 7
n_users = 4
n_antennas = 64
n_subcarriers = 1200
n_symbols = 64

channel = MimoAwgn(n_users=n_users, n_antennas=n_antennas, n_subcarriers=n_subcarriers)
tx = MimoTransmitter(n_users=n_users, n_antennas=n_antennas,
update_precoder_frequency=update_precoder_frequency)
env.process(channel.channel_update_process(env))
env.process(tx.precoder.precode_update_process(env))
env.run(until=n_symbols)

print(tx.n_antennas)
print(tx.n_users)
print(tx.precoder)


Empty file added phypy/mimo/precoders.py
Empty file.
26 changes: 12 additions & 14 deletions requirements.txt
@@ -1,16 +1,14 @@
pip==18.1
bumpversion==0.5.3
wheel==0.32.1
pip==19.2.3
bump2version==0.5.11
wheel==0.33.6
watchdog==0.9.0
flake8==3.5.0
tox==3.5.2
coverage==4.5.1
Sphinx==1.8.1
twine==1.12.1

pytest==3.8.2
pytest-runner==4.2
mypy

flake8==3.7.8
tox==3.14.0
coverage==4.5.4
Sphinx==1.8.5
twine==1.14.0
Click==7.0
pytest==4.6.5
pytest-runner==5.1
numpy
matplotlib
simpy
1 change: 1 addition & 0 deletions setup.cfg
Expand Up @@ -18,6 +18,7 @@ universal = 1
exclude = docs

[aliases]
# Define setup.py command aliases here
test = pytest

[tool:pytest]
Expand Down

0 comments on commit c876180

Please sign in to comment.