Files

23 lines
884 B
Python
Raw Permalink Normal View History

2026-04-07 11:40:42 +02:00
import numpy as np
import matplotlib.pyplot as plt
2026-04-07 11:33:11 +02:00
def main(numbers_files, multiplier):
"""
2026-04-07 11:40:42 +02:00
Example Python application that reads the given numbers_files and multiplies
the content (numbers) by the supplied multiplier
2026-04-07 11:33:11 +02:00
Arguments:
2026-04-07 11:40:42 +02:00
numbers_files: list of paths to input files of type 'text_data'
multiplier: number by which the arrays of numbers are multiplied
2026-04-07 11:33:11 +02:00
Returns:
2026-04-07 11:40:42 +02:00
A file named 'multiplied_numbers_plot.png' containing a plot of multiplied
numbers.
2026-04-07 11:33:11 +02:00
"""
2026-04-07 11:40:42 +02:00
plt.figure()
for numbers_file in numbers_files:
numbers = np.genfromtxt(numbers_file, comments="#", delimiter=",", unpack=False)
numbers = numbers[~np.isnan(numbers)]
numbers = np.array(numbers).flatten()
multiplied_numbers = numbers * multiplier
plt.plot(multiplied_numbers)
plt.savefig('multiplied_numbers_plot.png')