PythonSampleApp/sample_app.py
2024-03-29 10:57:24 +01:00

28 lines
999 B
Python

# -----------------
# Copyright © 2022 ACK Cyfronet AGH, Poland.
# -----------------
#
# Sample function created for demonstration of creating custom applications functionality
# See also https://docs.cyfronet.pl/display/ISDOC/Creating+Custom+Applications
from numpy import genfromtxt
import matplotlib.pyplot as plt
def main(numbers_file, multiplier):
"""
Example Python application that reads the given numbers_file and multiplies
the content (numbers) by the supplied multiplier
Arguments:
numbers_file: path to input file of type 'text_data'
multiplier: number by which the array of numbers is multiplied
Returns:
A file named 'multiplied_numbers_plot.png' containing a plot of multiplied
numbers.
"""
numbers = genfromtxt(numbers_file, comments="#", delimiter=",", unpack=False)[:,:-1]
multiplied_numbers = numbers * multiplier
plt.figure()
plt.plot(multiplied_numbers)
plt.savefig('multiplied_numbers_plot.png')