Skip to content
Snippets Groups Projects
Commit 7f638418 authored by Xia, Ning's avatar Xia, Ning :penguin:
Browse files

updated docstring in utility

parent 3c83d7c6
No related branches found
No related tags found
No related merge requests found
......@@ -12,23 +12,39 @@ def plot_temp_over_time(
y_label: str,
is_save: bool = False,
file_name: str = "image.svg",
x_log: bool = False,
y_log: bool = False,
) -> None:
"""Plotting The temperature data obtained from any number of temperature sensors over time. The data should be stored in a list, with each element of the list representing the data collected by one sensor. The data from each sensor must include uncertainty, so each element of the list should be an numpy.ndarray of size (2,n), with n meaning the number of data collected by that sensor.
"""Plots temperature data over time with error bars for multiple datasets.
This function creates a plot representing temperature data against time
for multiple sensors or datasets. Each dataset's standard deviation is visualized
with error bars.
Args:
data (List[np.ndarray]): A list of numpy arrays where each array represents
the temperature data (with standard deviation).
Each array should have a shape of (2, n), with n
representing the number of data points.
time (List[np.ndarray]): A list of numpy arrays with the time data corresponding
to each dataset in `data`.
legend (List[str]): A list of strings that label each dataset in the legend.
x_label (str): The label for the x-axis (time).
y_label (str): The label for the y-axis (temperature).
is_save (bool, optional): If set to True, the plot will be saved to the path specified by
`file_name`. Defaults to False.
file_name (str, optional): The path and filename where the plot image will be saved if
`is_save` is True. Defaults to "image.svg".
Args:
data (list[np.ndarray]): temprature data, each element of the list must be a numpy.ndarray with size (2,n), n means number of data.
time (list[np.ndarray]): time step.
legend (list[str]): label of sensors
x_label (str): label of x axis.
y_label (str): label of y axis.
is_save (bool, optional): if the plot should be saved. Defaults to False.
file_name (str, optional): name of the image file be saved. Defaults to "image.svg".
x_log (bool, optional): Turn on x-axis logarithmic.
y_log (bool, optional): Turn on y-axis logarithmic.
"""
pass
# TODO:
# This line of code throws an exception. This is just to make sure you can see
# all the code you need to refine. If you already know how to implement the program
# or have done so, then you can safely delete the three lines of code below, as well
# as this comment.
raise NotImplementedError(
"Delete these 3 lines if you have finished the code or want to test it.".upper()
)
## DONE ##
def get_plot_data_from_dataset(
......@@ -43,47 +59,69 @@ def get_plot_data_from_dataset(
Returns:
tuple[np.ndarray, np.ndarray, np.ndarray]: Data for plot in a tuple (temperature, time step, label of data).
"""
pass
def cal_total_uncertainty(
stat_uncert: Union[np.ndarray, float], syst_uncert: Union[np.ndarray, float]
) -> Union[np.ndarray, float]:
"""Total uncertainty combines systematic uncertainty and statistical uncertainty.
Args:
stat_uncert (Union[np.ndarray, float]): statistical uncertainty
syst_uncert (Union[np.ndarray, float]): systematic uncertainty
# TODO:
# This line of code throws an exception. This is just to make sure you can see
# all the code you need to refine. If you already know how to implement the program
# or have done so, then you can safely delete the three lines of code below, as well
# as this comment.
raise NotImplementedError(
"Delete these 3 lines if you have finished the code or want to test it.".upper()
)
Returns:
Union[np.ndarray, float]: total uncertainty
"""
pass
## DONE ##
def cal_uncertainty(data: np.ndarray, sys_uncert: float) -> np.ndarray:
"""Calculating mean and uncertainty for raw data.
def cal_main_and_standard_deviation(data: np.ndarray) -> np.ndarray:
"""Calculating mean and standard_deviation for raw data.
Args:
data (np.ndarray): raw data in a 2 dimensional array, the first dimension should not be 1 if statistical uncertainty is to be calculated, i.e. there are multiple measurements of the same time (space).
sys_uncert (float): system uncertainty in absolute value.
data (np.ndarray): raw data in a 2 dimensional array (m, n), the first dimension should not be 1 if
there are multiple (m) measurements of the same time (and place).
Returns:
np.ndarray: raw data with uncertainty in a 2D ndarray.
np.ndarray: raw data with uncertainty in a 2D ndarray with shape (2, n).
"""
pass
# TODO:
# This line of code throws an exception. This is just to make sure you can see
# all the code you need to refine. If you already know how to implement the program
# or have done so, then you can safely delete the three lines of code below, as well
# as this comment.
raise NotImplementedError(
"Delete these 3 lines if you have finished the code or want to test it.".upper()
)
## DONE ##
def get_start_end_temprature(
temprature_data: np.ndarray, threshold: float
) -> Tuple[float, float]:
"""The sensor values at the beginning and end of the experiment are obtained from the maximum and minimum values in the data set and a threshold. The uncertainty of the values is also output.
"""Calculates the average high and low temperatures from a dataset.
This function computes the average of the highest temperatures and the average of the lowest temperatures
within a given threshold from the maximum and minimum temperatures recorded in the dataset. These are
considered as the ending and starting temperatures respectively.
Args:
temprature (np.ndarray): dataset, muss be a numpy.ndarray with 2 dimension.
threshold (float): Threshold for deciding whether the data will be counted as a value before the start of the experiment.
temperature_data (np.ndarray): The temperature dataset as a 2D numpy array.
threshold (float): The threshold percentage used to identify temperatures close to the maximum
and minimum values as high and low temperatures respectively.
Returns:
tuple[float, float]: high temprature, low temprature.
Tuple[float, float]: A tuple containing the average high temperature first and the average low
temperature second.
"""
pass
# TODO:
# Hint: thetemprature_data should contain the raw data of the sensors.
# numpy.ndarray.flatten() function may be useful for multidimensionale arrays.
# This line of code throws an exception. This is just to make sure you can see
# all the code you need to refine. If you already know how to implement the program
# or have done so, then you can safely delete the three lines of code below, as well
# as this comment.
raise NotImplementedError(
"Delete these 3 lines if you have finished the code or want to test it.".upper()
)
## DONE ##
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment