2022-10-18 15:33:39 +02:00
|
|
|
# -----------------
|
|
|
|
# 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
|
|
|
|
|
2024-03-29 11:13:59 +01:00
|
|
|
import numpy as np
|
2022-10-18 15:33:39 +02:00
|
|
|
import matplotlib.pyplot as plt
|
2022-10-18 15:22:27 +02:00
|
|
|
|
|
|
|
def main(numbers_file, multiplier):
|
|
|
|
"""
|
2022-10-18 15:33:39 +02:00
|
|
|
Example Python application that reads the given numbers_file and multiplies
|
|
|
|
the content (numbers) by the supplied multiplier
|
2022-10-18 15:22:27 +02:00
|
|
|
Arguments:
|
|
|
|
numbers_file: path to input file of type 'text_data'
|
2022-10-18 15:33:39 +02:00
|
|
|
multiplier: number by which the array of numbers is multiplied
|
2022-10-18 15:22:27 +02:00
|
|
|
Returns:
|
2022-10-18 15:33:39 +02:00
|
|
|
A file named 'multiplied_numbers_plot.png' containing a plot of multiplied
|
|
|
|
numbers.
|
2022-10-18 15:22:27 +02:00
|
|
|
"""
|
|
|
|
|
2024-03-29 11:13:59 +01:00
|
|
|
numbers = np.genfromtxt(numbers_file, comments="#", delimiter=",", unpack=False)
|
|
|
|
numbers = numbers[~np.isnan(numbers)]
|
|
|
|
numbers = np.array(numbers).flatten()
|
2022-10-18 15:33:39 +02:00
|
|
|
multiplied_numbers = numbers * multiplier
|
|
|
|
plt.figure()
|
|
|
|
plt.plot(multiplied_numbers)
|
|
|
|
plt.savefig('multiplied_numbers_plot.png')
|