from atmPy.instruments.miniSASP import miniSASP
from atmPy.tools import plt_tools
from atmPy.instruments.piccolo import piccolo
%matplotlib inline
plt_tools.setRcParams(plt)

"""
Explanation: Introduction
The miniSASP module is probably one of the more confuse modules and needs to be reorganized. Its goal is to read and process miniSASP data. This includes the convertion to optical depth and aerosol optical depth (correction for the airmass factor and rayleigh scattering).
There is also a function to simulate the sky brightness (as seen by the miniSASP) from a aerosol sizedistribution. This data has not been well tested though.
Imports
End of explanation
"""


ms_raw = miniSASP.read_csv('./data/miniSASP_raw.txt')

ms_raw.data.PhotoAsh.plot()

"""
Explanation: Load a raw miniSASP file
End of explanation
"""


sun_intensities = ms_raw.find_peaks()

ax = sun_intensities.data['550.4'].plot(marker = 'o', linestyle = '')
ax.set_ylim((15,30))

"""
Explanation: Get sun_intensities
here we get the maxima of the peaks from above
End of explanation
"""


picco = piccolo.read_csv('./data/piccolo.log')
sun_intensities = sun_intensities.add_sun_elevetion(picco)

axs = sun_intensities.plot(offset=[3.29,3.44,3.99,4.16],
                    airmassfct=True,
                    move_max = False)
for ax in axs:
    ax.set_xlim((0.1,0.6))

"""
Explanation: Plot as a function of Altitude
sun_intensities does not have Altitude information, which we can get from telemetry data, here from the piccolo auto pilot.
End of explanation
"""


