-
-
Notifications
You must be signed in to change notification settings - Fork 22
Description
Description
When plotting two instruments with different frequency units on to the same subplot, the subplot ignores one of the units and assumes it is the same units as the other instrument.
Expected vs Actual behavior
Take wind waves as an example:
When getting data from FIDO, RAD1 is in kHz and RAD2 is in MHz.
Plotting in different subplots shows this correctly. The units are in the y-label and the values are correct.
If you want to plot as a continuum, you need to plot in same subplot. When plotting in the same subplot, it displays at the same value, disregarding the units. So 10MHz in RAD2 will be displayed as 10kHz in a subplot with RAD1 which is already in kHz.
The correct behaviour would be that 10MHz would be displayed as 10^4 kHz or displaying everything in MHz.
Steps to Reproduce
Below is code to reproduce the bug.
Code goes here
from datetime import datetime
import astropy.units as u
import numpy as np
from astropy.time import Time
# from astropy.io import fits
from matplotlib import pyplot as plt
from matplotlib.colors import LogNorm
from sunpy.net import Fido, attrs as a
from radiospectra import net #let Fido know about the radio clients
from radiospectra.spectrogram2 import Spectrogram # in the process of updating old spectrogram
if __name__=="__main__":
# Fido
query = Fido.search(a.Time('2020-07-11T02:15', '2020-07-11T02:50'), a.Instrument.waves)
waves_files = Fido.fetch(query['waves'])
waves_spec = Spectrogram(sorted(waves_files))
waves_mm_l = np.percentile(waves_spec[0].data, [1,99])
waves_mm_h = np.percentile(waves_spec[1].data, [1,99])
fig, axes = plt.subplots(2, 1, sharex=True, figsize=(10, 11.5))
waves_spec[0].plot(axes=axes[0], norm=LogNorm(vmin=waves_mm_l[0], vmax=waves_mm_l[1]))
waves_spec[1].plot(axes=axes[1], norm=LogNorm(vmin=waves_mm_h[0], vmax=waves_mm_h[1]))
# # by default y-axis low to hight flip so moving away fro sun with time
axes[0].set_ylim(reversed(axes[0].get_ylim()))
axes[1].set_ylim(reversed(axes[1].get_ylim()))
# log y-axis
axes[0].set_yscale('log')
axes[1].set_yscale('log')
axes[0].set_xlim(datetime(2020, 7, 11, 2,15), datetime(2020, 7, 11, 2,50))
plt.show(block=False)
fig, axes = plt.subplots(2, 1, sharex=True, figsize=(10, 11.5))
waves_spec[0].plot(axes=axes[0], norm=LogNorm(vmin=waves_mm_l[0], vmax=waves_mm_l[1]))
waves_spec[1].plot(axes=axes[0], norm=LogNorm(vmin=waves_mm_h[0], vmax=waves_mm_h[1]))
# # by default y-axis low to hight flip so moving away fro sun with time
axes[0].set_ylim(reversed(axes[0].get_ylim()))
# log y-axis
axes[0].set_yscale('log')
axes[0].set_xlim(datetime(2020, 7, 11, 2,15), datetime(2020, 7, 11, 2,50))
plt.show(block=False)
System Details
- SunPy Version: 3.0.1
- Astropy Version: 4.2.1
- Python Version: Python 3.8.8
- OS information: Mac OS 10.16
- radiospectra version: 0.3.1.dev24+g075df3f