Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit errors when plotting two instruments in same sub plot. #58

Open
canizarl opened this issue Sep 24, 2021 · 0 comments
Open

Unit errors when plotting two instruments in same sub plot. #58

canizarl opened this issue Sep 24, 2021 · 0 comments
Labels

Comments

@canizarl
Copy link

canizarl commented Sep 24, 2021

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
@nabobalis nabobalis added the bug label Sep 24, 2021
@samaloney samaloney added this to the 0.3.1 milestone Oct 28, 2021
@nabobalis nabobalis removed this from the 0.3.1 milestone Nov 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants