Update sample_app.py

This commit is contained in:
parent 767ef26e47
commit 9323387d24

View File

@ -1,15 +1,29 @@
# This function was automatically generated. When modifying its signature, take care to apply
# modifications also to the descriptor files in the repository.
# -----------------
# Copyright © 2025 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
import numpy as np
import matplotlib.pyplot as plt
def main(numbers_file, multiplier):
"""
Main function for application: PYTHONSAMPLEAPPENV
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: parameter of type 'INTEGER'
multiplier: number by which the array of numbers is multiplied
Returns:
File(s) named 'multiplied_numbers_plot.png' of type 'image_data' and format 'PNG' from working directory
A file named 'multiplied_numbers_plot.png' containing a plot of multiplied
numbers.
"""
# TODO: Put your application code here
numbers = np.genfromtxt(numbers_file, comments="#", delimiter=",", unpack=False)
numbers = numbers[~np.isnan(numbers)]
numbers = np.array(numbers).flatten()
multiplied_numbers = numbers * multiplier
plt.figure()
plt.plot(multiplied_numbers)
plt.savefig('multiplied_numbers_plot.png')