analyze module¶
A module containing various methods for analyzing the cloudiness of images.
This module is designed to be used in conjunction with downloaded images to perform statistical analyses and plotting. Methods are provided for analyzing months of data and saving the cloudiness values to a file. It is then possible to take this data and plot it in various forms, across a variety of different plots. The cloudiness can be plotted as a histogram, and two different models can be fit to the histograms. These two models are a double Gaussian and a Gaussian-Poisson hybrid.
-
analyze.analyze()[source]¶ Determine cloudiness of images for every day from January 1, 2017 onward.
See also
histogram.cloudiness()- Calculate the cloudiness of a histogram.
Notes
For each night, all images taken that day are downloaded. For every night analyzed, the cloudiness values for every image taken during that night are written to “Data/yyyymm/yyyymmdd.txt” where yyyymmdd corresponds to the date analyzed.
-
analyze.find_fit(data, divs)[source]¶ Find the best fit to a weekly histogram.
Parameters: - data (array_like) – The cloudiness data used in generating a histogram.
- divs (array_like) – The lower bounds on the divisions used in generating a histogram.
Returns: Tuple, where the first item is a list of coefficients corresponding to the best fit, and the second item is an identifying number that corresponds to which fit (a double gaussian or a Gaussian and Poisson hybrid) is the best. 0 and 1 correspond to a double Gaussian, and 2 and 3 correspond to a Gaussian and Poisson hybrid.
Return type:
-
analyze.fit_function(xdata, func='gg', init=None)[source]¶ Fit a function to a histogram.
Parameters: - xdata (array_like) – The cloudiness data used to compute a histogram.
- func (str, optional) – Which function to fit. “gg” corresponds to a double Gaussian hybrid, and “gp” corresponds to a Gaussian and Poisson hybrid function. Defaults to “gg”.
- init (list, optional) – A list of initial guesses for the function fitting. Defaults to None. If None, uses an initial guess of [0.1,0.5,0.5,3,0] for a double Gaussian hybrid function, and [0.1,0.5,3,0] for a Gaussian and Poisson hybrid function.
Returns: An object corresponding to the fit function.
Return type:
-
analyze.function_gg(params, x)[source]¶ A double Gaussian hybrid function.
Parameters: - params (array_like) – A list containing all of the defining parameters for the function. The first item is the standard deviation of the first (lower) Gaussian, the second is the mean of the first Gaussian, the third is the standard deviation of the second (higher) Gaussian, the fourth is the mean of the second Gaussian, and the fifth is a fraction that defines how biased the function should be towards the first Gaussian. For example, if the provided fraction is 1 then the function is only the first Gaussian, whereas if the provided fraction is 0 the function is only the second Gaussian.
- x (array_like) – The x coordinates to plug into the function.
Returns: The function values corresponding to the input x values.
Return type: Notes
The function is normalized so that the area under the curve from 0 to infinity is equal to 1.
-
analyze.function_gp(params, x)[source]¶ A Gaussian and Poisson hybrid function.
Parameters: - params (array_like) – A list containing all of the defining parameters for the function. The first item is the standard deviation of the Gaussian, the second is the mean of the Gaussian, the third is the mean and variance of the Poisson, and the fourth is a fraction that defines how biased the function should be towards the Gaussian. For example, if the provided fraction is 1 then the function is only a Gaussian, whereas if the provided fraction is 0 the function is only the a Poisson.
- x (array_like) – The x coordinates to plug into the function.
Returns: The function values corresponding to the input x values.
Return type: Notes
The function is normalized so that the area under the curve from 0 to infinity is equal to 1.
-
analyze.get_latest_analyzed()[source]¶ Find the latest analyzed date.
Returns: The latest date analyzed in yyyymmdd format. Return type: str Notes
The latest date analyzed is found by searching through Data/ for the latest month that has been analyzed, and then searching through that month for the latest day that has been analyzed.
-
analyze.histo()[source]¶ Generate weekly histograms of cloudiness values for 2016 and 2017.
Notes
The cloudiness values for every image saved using
analyze()are loaded and collated into histograms containing one week each. Each week produces three histograms: one with only 2016 images, one with only 2017 images, and one with both on the same histogram. The 159 histograms are saved to “Images/Plots/Weeks”.
-
analyze.model()[source]¶ Model the dependence of cloudiness on the moon phase.
Notes
Cloudiness is plotted on the y-axis against the moon phase on the x-axis, and then np.linalg is used to find a quadratic model that fits this data. This model is used to remove the dependence of moon phase on the cloudiness data.
-
analyze.month_plot()[source]¶ Generate a plot of nightly cloudiness for each month.
Notes
The cloudiness values for every image saved using
analyze()are loaded. These values are plotted, with all images for a given month on a single plot. Plots are saved in “Images/Plots/” with the filename “scatter-month.png”.
-
analyze.plot(years=['2015', '2016', '2017'], fit_histograms=False)[source]¶ Generate various cloudiness plots and save them to Images/Plots.
Parameters: Notes
The cloudiness values for every image saved using
analyze()are loaded. These values are further analyzed to create new plots. The generated plots include plots of Cloudiness vs Moon Phase, Cloudiness vs Hours since sunset, Cloudiness vs Normalized time after sunset, Cloudiness vs Hours before sunrise, and Cloudiness vs Week Number. These plots are saved to Images/Plots. If fit_histograms is true, the weekly histograms will be fit by a double Gaussian or Gaussian-Poisson hybrid function, after which plots of week number versus the various fit parameters will be made and saved as well.
-
analyze.to_csv()[source]¶ Convert the saved daily cloudiness data to a CSV file.
Notes
The cloudiness values for every image saved using
analyze()are loaded and converted to a single CSV file: data.csv. The CSV file has 5 headers: Date & Time, Year, Week Number, Normalized Time after Sunset and Cloudiness Relative to the Mean.