Skip to main content

No project description provided

Project description

Resourcecode library

Installation

To install the library, you may first of all, create a dedicated virtual environment:

$ cd /your/work/directory
$ python3 -m venv env-resourcecode

then, you activate it:

$ source env-resourcecode/bin/activate
(env-resourcecode)$

In this virtual environment, you can now install the library. The library is not available on PyPI yet, therefore you have to download the archive (here for instance), and then install it:

(env-resourcecode)$ python -m pip install /your/downloads/directory/resourcecode-branch-default.zip
[…]

To test whether the install has been successful, you can run:

(env-resourcecode)$ python -c "import resourcecode ; print(resourcecode.__version__)"
0.1.0

which should print the current locally installed version of resourcecode.

Configuration

The library needs a configuration file to work properly. This file contains in particular the URL of the Cassendra API.

The library will look for the configuration at the following location (in the order) :

  • in the file described by the RESOURCECODE_CONFIG_FILEPATH environment variable.
  • in a file named resourcecode.ini in the current directory.
  • in a file located in $HOME/.config/resourcecode.ini.
  • in a file located in /usr/local/etc/resourcecode/config.ini

The search stops at the first file found.

The default configuration file can be found here. You may download it and move it to this location: $HOME/.config/resourcecode.ini.

You may need to update the Cassandra URL.

Example of use

Once the library is installed and the configuration is done, you can use the library.

The first thing to do, is a create a Client. The client will query the cassandra database for you, and return a pandas dataframe of your selection.

See the following example:

>>> import resourcecode
>>> client = resourcecode.Client()
>>> data = client.get_dataframe_from_criteria(
"""
{
    "node": 0,
    "start": 1483228400,
    "end": 1489903600,
    "parameter": ["fp", "hs"]
}
""")
>>> data
                        fp     hs
2017-01-01 00:00:00  0.074  0.296
2017-01-01 01:00:00  0.072  0.400
2017-01-01 02:00:00  0.071  0.356
2017-01-01 03:00:00  0.071  0.350
2017-01-01 04:00:00  0.074  0.256
...                    ...    ...
2017-01-31 19:00:00  0.096  0.250
2017-01-31 20:00:00  0.096  0.332
2017-01-31 21:00:00  0.096  0.480
2017-01-31 22:00:00  0.096  0.612
2017-01-31 23:00:00  0.097  0.756

[744 rows x 2 columns]
>>> data.describe()
               fp          hs
count  744.000000  744.000000
mean     0.088046    0.537551
std      0.011400    0.192594
min      0.058000    0.160000
25%      0.081000    0.370000
50%      0.087000    0.533000
75%      0.095000    0.688500
max      0.120000    0.948000

>>> # if you have malptolib installed, you can do the following
>>> ax = data.plot()
>>> ax.figure.savefig('fp_hs.png')

which will generate the following plot:

plot_hs_fp

Acknowledgments

The ResourceCode Python module was developed by Logilab based on various scientific codes written by the partners of the ResourceCode Projet: EMEC, CentraleNantes, Ocean Data Lab, Smart Bay Ireland, University College Dublin, INNOSEA, Ifremer, University of Edinburgh. More information at http://resourcecode.info.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

resourcecode-0.5.2.tar.gz (11.3 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

resourcecode-0.5.2-py3-none-any.whl (11.3 MB view details)

Uploaded Python 3

File details

Details for the file resourcecode-0.5.2.tar.gz.

File metadata

  • Download URL: resourcecode-0.5.2.tar.gz
  • Upload date:
  • Size: 11.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.9

File hashes

Hashes for resourcecode-0.5.2.tar.gz
Algorithm Hash digest
SHA256 a341256a8b60974978556bf4c593fd48cba1751c8630d867bd2bf18bea1b879c
MD5 735571d26fc67421fc83d58c450dd1db
BLAKE2b-256 650ee14ee721810da815616a980f6a3b1753a8ad31d9520edd2a859ac53df760

See more details on using hashes here.

File details

Details for the file resourcecode-0.5.2-py3-none-any.whl.

File metadata

  • Download URL: resourcecode-0.5.2-py3-none-any.whl
  • Upload date:
  • Size: 11.3 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.9

File hashes

Hashes for resourcecode-0.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0f3d88bbe35e371c3a38a2d0bcdbb744ed1228a1368a22aba592d3bfee0bbb6b
MD5 0d1689da9a22dfeb494d211cced64314
BLAKE2b-256 24b46e6050870043b2332f0993a50a9244e55c8aa7a8c80fe86c9e9d53195fcb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page