Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to serialize a Tide to JSON #10

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open

Add ability to serialize a Tide to JSON #10

wants to merge 15 commits into from

Conversation

fawkesley
Copy link

  • add json_encoding.py module providing PytidesJson{Encoder,Decoder}
  • add serialize and deserialize methods to BaseConstituent and
    Tide classes

Note that a constituent can be fully reconstructed from its name alone,
so we don't need to serialize derivative member methods like
coefficients.

For a Tide, we reconstruct the model (a numpy object) which comprises
triples of Constituent, Amplitude, Phase.

Paul M Furley added 15 commits June 10, 2014 15:24
Add a test runner script which runs any units tests using nosetests
(there currently aren't any) and will eventually run PEP8 tests.

This will run on Travis CI after visiting https://travis-ci.org/profile and
enabling it for the repo.

In Travis CI, we need to use system site packages for numpy and scipy,
see:
http://danielnouri.org/notes/2012/11/23/use-apt-get-to-install-python-dependencies-for-travis-ci/

For Travis to try to install the right packages (not numpy/scipy),
create two requirements files: `requirements/_common.txt` and
`requirements/_numpy_and_scipy.txt`.

As a developer, you can install `./requirements.txt`. As Travis, you can
install `./requirements_for_travis.txt`

In the `.travis.yml` file we also use the environment variables for
ATLAS, BLAS etc as suggested by Sam in the README:

```
export LAPACK=/usr/lib/liblapack.so
export ATLAS=/usr/lib/libatlas.so
export BLAS=/usr/lib/libblas.so
```
- tide.py
- constituents.py
- astro.py
- nodal_corrections.py

http://legacy.python.org/dev/peps/pep-0008/
The purpose of these classes is to make a convenient way to load observation
data (datetime, height) from a source such as CSV, and handle any
wrangling to ie numpy when required.

- `Observations` is an abstract-base-class defining a basic interface
  which all subclasses must adhere to.
- `CsvObservations` reads observations from an arbitrary-sized CSV with
  UTC dates. Note that it tries to avoid reading the file into memory.
- Tests for CsvObservations which capture its behaviour.

Included is an example data set from the NOAA with hourly observations
for the year of 2013.
This is a regression test to pin the behaviour of pytides doing a full
analysis for `example_observations_2.csv`

Note that it depends on the new `CsvObservations` class.
They are helper functions, not class methods. Simplify the class.
Previously:

   BaseConstituent
          |
 CompoundConstituent

But `CompoundConstituent` does *not* have an "is-a" relationship with
BaseConstituent (although it has common features).

This commit renames `BaseConstituent` to `Constituent` and introduces a
new `BaseConstituent` which provides any common functionality, and
dictates what functionality must be provided by the subclass.

      BaseConstituent  (new)
        |       |
Constituent   CompoundConstituent
Split out BaseConstituent, Constituent and CompoundConstituent as they
are functionality quite different.

Move the actual constituent defintions into a new file
`constituent_factory` which will soon have factory methods for creating
a constituent [set] from a name.
- `get_constituent(name)` - get a constituent object based on a name
  (allows aliasing constituents for different naming conventions)
- `get_constituent_set(name` - get a set of constituents, ie NOAA
- add `json_encoding.py` module providing PytidesJson{Encoder,Decoder}
- add `serialize` and `deserialize` methods to `BaseConstituent` and
  `Tide` classes

Note that a constituent can be fully reconstructed from its name alone,
so we don't need to serialize derivative member methods like
coefficients.

For a Tide, we reconstruct the model (a numpy object) which comprises
triples of Constituent, Amplitude, Phase.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant