How to use the NoRP Python library on SunPy

9 November 2026
M. Shimojo


Contents

  1. Preparation
  2. Obtain and plot the long-term (>a day) data
  3. Obtain and plot the short-term (<a day) data
  4. Fitting a spectrum of a solar flare

1. Preparation

The following procedure can be used on the SunPy environment. Hence, at first, SunPy is installed. The install manual of SunPy is described in the following SunPy website.

Installation, The Sunpy tutorial

After the installation, download the following the python script.

norp_fits.py

Then, put the script on your working directory, or add the path that the script is located using the following commands in the your script.

Let's do analyzing NoRP data on SunPy !!


2. Obtain and plot the Long-Term (>a day) data

2.1. Long-term dataset of Toyokawa/Nobeyama Radio Polarimeters

Continuous monitoring of solar microwave fluxes began in the 1950s at the Toyokawa campus of Nagoya University and has been continued at the Nobeyama campus of the National Astronomical Observatory of Japan. As a result, the observation record now spans more than 70 years. Because the radio telescopes were originally designed to observe solar radio bursts, the microwave flux data obtained by the Nobeyama Radio Polarimeters (NoRP) have a high temporal resolution of 0.1 s. While this resolution is well suited for studies of rapid solar radio phenomena, it is unnecessarily high for investigations of long-term variations in solar microwave fluxes on timescales of a day or longer. To support investigations of the long-term variability of solar microwave fluxes, we provide text files of tables of daily fluxes at 1, 2, 3.75, and 9.4 GHz, along with the corresponding CSV files, via an online repository. Here, the term "daily flux" denotes the solar microwave flux derived from observations obtained in the absence of major solar flares. Because the flux values are calcurated through manual inspection, the dataset has been carefully curated to exclude data affected by poor weather conditions, instrumental malfunctions, radio-frequency interference (RFI), and other observational artifacts. In the following section, we demonstrate the NoRP long-term datasetuse within the SunPy framework.

2.2 Obtain the long-term NoRP dataset from the internet and plot it.

Import the necessary Python libraries, and the TimeSeries object of the Long-Term NoRP data (daily_ts) is createdas using "NoRPDailyTimeSerie" as follows.

"NoRPDailyTimeSeries" automatically retrieves the CSV files from the online archive and creates a TimeSeries object. The NoRP long-term dataset is available in two versions. One contains the observed solar microwave fluxes at Earth, while the other contains fluxes normalized to a distance of 1 AU from the Sun. The latter dataset is corrected for variations in the Sun-Earth distance. For studies of intrinsic solar variability, the corrected dataset should be used by setting the option "au_corr=True". In contrast, if the objective is to investigate the influence of solar activity on Earth's upper atmosphere, the uncorrected dataset should be used by setting "au_corr=False".

Once created, the TimeSeries object returned by NoRPDailyTimeSeries can be analyzed and visualized using the standard SunPy TimeSeries interface. The following example plots the data over the entire observation period.

When you want to plot a part of the data,


3. Obtain and plot the short-term (<a day) data

3.1 The data files of the NoRP observations

The raw NoRP data are stored in a proprietary format that can be read only with the Interactive Data Language (IDL) and the SolarSoftWare (SSW) package. Each raw data file contains observations acquired during a single day. The daily observing period varies with season. Because the IDL/SSW environment is not commonly used outside the solar physics community, we provide NoRP data in FITS format through our website. Each FITS file contains both the raw observational data and the calibrated microwave fluxes obtained by NoRP for a given day. The SunPy interface described below automatically downloads the corresponding FITS file and creates a TimeSeries object from the calibrated microwave fluxes contained in the file.

3.2 Obtain the NoRP FITS files from the internet and plot it.

At first, import the necessary Python libraries, and set the time period and observing frequencies that you want to analyze. Then, search and download the FITS file.

"Fido.search" and "Fido.fetch" shows the following message and puts the FITS file in your working directory.

Then, we create the TimeSeries object from the FITS file and plot it.

Once created, the TimeSeries object returned by NoRPTimeSeries can be analyzed and visualized using the standard SunPy TimeSeries interface. On the day, a flare occurred around 00:20UT. So, we make a TimeSeries object only from the flare period and plot it.

When you want to subtract the background,


4. Fitting a spectrum of a solar flare

4.1 Model microwave spectrum of solar flares

During a solar flare, the solar radio flux can increase significantly. In the microwave range, this enhancement is primarily produced by gyrosynchrotron emission from high-energy electrons accelerated during the flare. In the optically thin regime, the microwave spectrum can be described by a power-law function, and its spectral index provides important information on the energy distribution of the high-energy electrons. However, the microwave emission observed during solar flares, particularly within the NoRP frequency range, generally consists of contributions from both optically thick and optically thin regions. Therefore, deriving the power-law index of the optically thin component requires fitting the observed spectrum with a spectral model, such as that given below, and subsequently estimating the spectral index from the fitted parameters.

Here are 4 fitting parameters: νb is turn-over frequency, F̂ν is turn-over flux density, αtk is power index of low frequency side (optically thick side) and αtn is power index of high frequency side (optically thin side), respectively.

4.2 Preparation for spectrum fitting

Spectral fitting is performed using the Markov Chain Monte Carlo (MCMC) technique. The following library packages for Python are required:

Once the packages have been installed, download the following script and save it in your working directory.

norp_mcmc_fit.py

4.3 Obtain the NoRP data and extract the flare spectrum at the interest time range

At first, import the necessary Python libraries, and set the time period and observing frequencies that you want to analyze. Then, search and download the FITS file.

Next, we create a TimeSeries object from the FITS file. The native time resolution of the NoRP data is 0.1 s. In many cases, this temporal resolution is higher than necessary for spectral fitting, resulting in a relatively low signal-to-noise ratio (S/N) for individual measurements. To improve the S/N ratio, the data are averaged over a specified time interval. In the following example, the data are integrated over 2 seconds, corresponding to 20 consecutive data points. Of course, we need to subtract the background

To extract the flare spectrum over a specific time interval, we first obtain the time array from the TimeSeries object and identify the indices corresponding to the time range of interest. The spectral data within that interval are then extracted from the TimeSeries object

The unit of the fluxes is converted from "Jy" to "SFU" due to avoiding the unstable in the fitting process.

4.4 Spectrum fitting and plot the results

At first, delete the data not used for fitting from the array.

Then, the fititng is started.

The subroutine plots the following and prints out the first guess

The first guess for 1st fitting is not sutable in most cases. Hence, the fitting is not converged as shown in the above plot. In the plot, a0, a1, a3 are F̂ν, αtk, -1 x (αtn - αtk), respectively. a2 is F̂νa3. The fitting using the result of the first fitting process is restarted automatically.

The fitting process is continued until when the fitting is converged or finishing 10 times of the process. The above plot shows the parameter evolutions in the itaration process when the fittig is converged. And then, the below plots are shown.

The blue line is the result of the fitting, and the vertical dashed lines indicates the turn-over frequency. The orange lines shows the range of one-sigma error in the fitting. The process outputs three following values. "sol" includes the result of the fitting parameters (a0,a1,a2,a3), "ferr" inlcudes the one-sigma error of the parameters calculate from the distributions shown in the corner plot, and "fitres" includes αtn, the error of αtn and νb. When the fitting is not converged, only "sol" includes the values.
Then, we plot the results, as follows.

Then, print out the values of the power-law indexes and turn-over frequency.


Back to NoRP Main Page