File:Power spectrum of sunspot number, from 1945 to 2017.png
Original file (959 × 1,560 pixels, file size: 325 KB, MIME type: image/png)
This is a file from the Wikimedia Commons. Information from its description page there is shown below. Commons is a freely licensed media file repository. You can help. |
Summary
DescriptionPower spectrum of sunspot number, from 1945 to 2017.png |
English: The daily sunspot number from 1945-01-02 to 2017-06-30, and its power spectral analysis. There are two prominent peaks corresponding to its 27-day cycle and 11-year cycle.
See "The 27-day signal in sunspot number series and the solar dynamo" (JL Le Mouël, MG Shnirman, EM Blanter - Solar Physics, 2007) data from NOAA plotted in Python ```python import pandas as pd import matplotlib.pyplot as plt from urllib.request import urlopen from io import StringIO
url = "https://ngdc.noaa.gov/stp/space-weather/solar-data/solar-indices/sunspot-numbers/american/lists/list_aavso-arssn_daily.txt" raw_data = urlopen(url).read().decode('utf-8') print("data retrieved")
data_lines = raw_data.split('\n')[3:]
data = StringIO('\n'.join(data_lines))
columns = ['Year', 'Month', 'Day', 'SSN']
df = pd.read_csv(data, delim_whitespace=True, names=columns)
df['Date'] = pd.to_datetime(df'Year', 'Month', 'Day')
df.set_index('Date', inplace=True)
df = df.dropna(subset=['SSN']) import numpy as np ssn = df['SSN'] n = len(ssn)
yf = np.fft.fft(ssn)
power_spectrum = np.abs(yf[:n//2]) ** 2
xf = np.fft.fftfreq(n, d=1) # Assume the time step d=1
xf = xf[:n//2]
fig, axes = plt.subplot_mosaic("A;B;B", figsize=(10, 16))
ax = axes["A"] ax.scatter(df.index, df['SSN'], s=0.5) ax.set_title('Sunspot Number Over Time') ax.set_xlabel('Date') ax.set_ylabel('SSN')
ax = axes["B"] ax.set_xscale('log') ax.set_yscale('log') ax.scatter(xf, power_spectrum, s=1) num_segments = 100
num_segments = 100 min_log_freq = np.log(np.min(xf[xf > 0])) # Exclude zero frequency max_log_freq = np.log(np.max(xf)) log_freq_range = max_log_freq - min_log_freq for i in range(num_segments): start = i * len(xf) // num_segments end = (i + 1) * len(xf) // num_segments avg_log_freq = np.mean(np.log(xf[start:end][xf[start:end] > 0])) # Exclude zero frequency alpha = 1 - ((avg_log_freq - min_log_freq) / log_freq_range) # Calculate alpha relative to log-frequency range alpha = alpha**2 ax.loglog(xf[start:end], power_spectrum[start:end], color='b', alpha=alpha) solar_cycle = (10.7 * 365) ax.vlines(1/solar_cycle, ymin=10**2, ymax=10**12, linestyle='--', linewidth=0.5) ax.text(1/solar_cycle, 10**12, 'Solar cycle = 10.7 years', rotation=0, verticalalignment='center', fontsize=12) lunar_cycle = 27.3 ax.vlines(1/lunar_cycle, ymin=10**2, ymax=10**12, linestyle='--', linewidth=0.5) ax.text(1/lunar_cycle, 10**12, 'Monthly cycle = 27.3 days', rotation=0, verticalalignment='center', fontsize=12)
nonzero_indices = xf > 10**(-4) xf_nonzero = xf[nonzero_indices] power_spectrum_nonzero = power_spectrum[nonzero_indices]
weights = 1 / xf_nonzero
log_xf = np.log(xf_nonzero) log_power_spectrum = np.log(power_spectrum_nonzero)
A = np.vstack([log_xf, np.ones(len(log_xf))]).T b = log_power_spectrum
x, residuals, rank, s = np.linalg.lstsq(A * np.sqrt(weights[:, np.newaxis]), b * np.sqrt(weights), rcond=None)
b_weighted = x[0] log_a_weighted = x[1] a_weighted = np.exp(log_a_weighted) xf_fit = np.linspace(np.min(xf_nonzero), np.max(xf_nonzero), 1000) power_spectrum_fit_weighted = a_weighted * xf_fit ** b_weighted ax.loglog(xf_fit, power_spectrum_fit_weighted, 'r-', label=f'S(f) = {a_weighted:.2e} * f^{{{b_weighted:.2f}}}', color="black", linewidth=1, alpha=0.5, linestyle="--") ax.legend() ax.set_title('Power Spectrum of SSN') ax.set_xlabel('Frequency [day^(-1)]') ax.set_ylabel('Power Spectrum') ax.grid(True)
plt.tight_layout() plt.show() ``` |
Date | |
Source | Own work |
Author | Cosmia Nebula |
Licensing
- You are free:
- to share – to copy, distribute and transmit the work
- to remix – to adapt the work
- Under the following conditions:
- attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
- share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.
Items portrayed in this file
depicts
some value
13 July 2023
image/png
File history
Click on a date/time to view the file as it appeared at that time.
Date/Time | Thumbnail | Dimensions | User | Comment | |
---|---|---|---|---|---|
current | 04:37, 14 July 2023 | 959 × 1,560 (325 KB) | Cosmia Nebula | Uploaded while editing "Sunspot" on en.wikipedia.org |
File usage
The following page uses this file:
Metadata
This file contains additional information, probably added from the digital camera or scanner used to create or digitize it.
If the file has been modified from its original state, some details may not fully reflect the modified file.
Software used | |
---|---|
Horizontal resolution | 39.37 dpc |
Vertical resolution | 39.37 dpc |