diff --git a/README.md b/README.md index e873d62fc0f29ae08ed91cf1131273e856e1c5fe..913a1fc2064473e4c9e5d8d3e21ca5ca19b36dc7 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,99 @@ -# plot_ID_python +# PlotID for Python This is the python PlotID project. +PlotID is a program connected to Research Data Management (RDM). It has two main functionalities: +1. Tag your plot with an identifier. +2. Export the resulting file to a specified directory along the corresponding research data, the plot is based on. Additionally, the script that created the plot will also be copied to the directory. -To run the program python version 3.10 is required. \ No newline at end of file +**Note:** To run PlotID python version ≥ 3.10 is required. + +## Installation +Currently there are two options to run PlotID. Either install it via pip from the Python Package Index (PyPi) or install PlotID from the source code. + +### From PyPi with pip +1. *Optional* Create a virtual environment and activate it: +`pip install venv` +`mkdir venv` +`python3 -m venv` +`source venv/bin/activate` +2. Install PlotID +`pip install --upgrade --index-url https://test.pypi.org/simple/ example-package-plotid-test` + +### From source +1. Download the source code from [Gitlab](https://git.rwth-aachen.de/plotid/plotid_python): +`git clone https://git.rwth-aachen.de/plotid/plotid_python.git` +`cd plotid_python` +2. [Optional] Create a virtual environment: +`pip install venv` +`mkdir venv` +`python3 -m venv` +`source venv/bin/activate` +3. Install dependencies +`pip install -r requirements.txt` +4. Install PlotID +`pip install .` + +## Usage +PlotID has two main functionalities: +1. Tag your plot with an identifier. +2. Export the resulting file to a specified directory along the corresponding research data, the plot is based on. Additionally, the script that created the plot will also be copied to the directory. + +### tagplot() +Tag your figure/plot with an ID. +`tagplot(figures, plot_engine)` +The variable "figures" can be a single figure or a list of multiple figures. +The argument "plot_engine" defines which plot engine was used to create the figures. It also determines which plot engine PlotID uses to place the ID on the plot. Currently supported plot engines are: +- 'matplotlib' + +tagplot returns a list that contains two lists each with as many entries as figures were given. The first list contains the tagged figures. The second list contains the corresponding IDs as strings + +Optional parameters can be used to customize the tag process. +- prefix : str, optional + Will be added as prefix to the ID. +- id_method : str, optional + id_method for creating the ID. Create an ID by Unix time is referenced as 'time', create a random ID with id_method='random'. The default is 'time'. +- location : string, optional + Location for ID to be displayed on the plot. Default is 'east'. + +Example: + FIG1 = plt.figure() + FIG2 = plt.figure() + FIGS_AS_LIST = [FIG1, FIG2] + [TAGGED_FIGS, ID] = tagplot(FIGS_AS_LIST, 'matplotlib', prefix='XY23_', id_method='random', location='west') + + +### publish() +Save plot, data and measuring script. +`publish(src_datapath, dst_path, figure, plot_name)` + +- "src_datapath" specifies the path to (raw) data that should be published. +- "dst_path" is the path to the destination directory, where all the data should be copied/exported to. +- "figure" expects the figure that was tagged and now should be saved as picture. +- "plot_name" will be the file name for the exported plot. + +Optional parameters can be used to customize the publish process. +- data_storage: str, optional + Method how the data should be stored. Available options: + - centralized: The raw data will copied only once. All other plots will reference this data via sym link. + - individual: The complete raw data will be copied to a folder for every plot, respectively. +Example: +`publish('/home/user/Documents/research_data', '/home/user/Documents/exported_data', FIG1, 'Energy_over_time') + +## Build +If you want to build PlotID yourself, follow these steps: +1. Download the source code from [Gitlab](https://git.rwth-aachen.de/plotid/plotid_python): +`git clone https://git.rwth-aachen.de/plotid/plotid_python.git` +`cd plotid_python` +2. [Optional] Create a virtual environment: +`pip install venv` +`mkdir venv` +`python3 -m venv` +`source venv/bin/activate` +3. [Optional] Run unittests and coverage: +`python3 tests/runner_tests.py` +4. Build the package +`python3 -m build` + +## Documentation +If you have more questions about PlotID, please have a look at the [documentation](link-to-docs). +Also have a look at the example.py that is shipped with PlotID. \ No newline at end of file diff --git a/plotid/publish.py b/plotid/publish.py index 46924af7196c40b32d85f0de30b2eb3088448418..c5c53dd58da59cca6e3adb56149b3ca9e071726b 100644 --- a/plotid/publish.py +++ b/plotid/publish.py @@ -18,7 +18,8 @@ import warnings from plotid.save_plot import save_plot -def publish(src_datapath, dst_path, figure, plot_name, data_storage): +def publish(src_datapath, dst_path, figure, plot_name, + data_storage='individual'): """ Save plot, data and measuring script. @@ -37,7 +38,7 @@ def publish(src_datapath, dst_path, figure, plot_name, data_storage): centralized: The raw data will copied only once. All other plots will reference this data via sym link. individual: The complete raw data will be copied to a folder for - every plot, respectively. + every plot, respectively. This is the default value. Returns ------- diff --git a/plotid/tagplot.py b/plotid/tagplot.py index 695d2b143d12ba3c47eafc592d836806d3559d22..ba660b153fdfbd6fc6b17d02d9a5d156710a67bf 100644 --- a/plotid/tagplot.py +++ b/plotid/tagplot.py @@ -30,9 +30,10 @@ def tagplot(figs, engine, prefix='', id_method='time', location='east'): Plot engine which should be used to tag the plot. prefix : string Will be added as prefix to the ID. - id_method : int, optional + id_method : string, optional id_method for creating the ID. Create an ID by Unix time is referenced - as 1, create a random ID with id_method=2. The default is 1. + as 'time', create a random ID with id_method='random'. + The default is 'time'. location : string, optional Location for ID to be displayed on the plot. Default is 'east'. diff --git a/setup.cfg b/setup.cfg index a6cf4d39f556c4dc0ccde3181d3153c876ad29e2..bd426a9d240cc9e3cfdc61f0682b9c19ecf749d1 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,18 +1,20 @@ [metadata] name = example-package-plotid-test -version = 0.0.5 +version = 0.0.6 author = Example Author author_email = author@example.com description = A small example package long_description = file: README.md long_description_content_type = text/markdown -url = https://github.com/pypa/sampleproject +url = https://git.rwth-aachen.de/plotid/plotid_python project_urls = - Bug Tracker = https://github.com/pypa/sampleproject/issues + Bug Tracker = https://git.rwth-aachen.de/plotid/plotid_python/-/issues classifiers = - Programming Language :: Python :: 3 + Programming Language :: Python :: 3.10 License :: OSI Approved :: Apache Software License Operating System :: OS Independent + Development Status :: 2 - Pre-Alpha + Intended Audience :: Science/Research [options] packages = plotid