0

I am using Mac OS Monterey, I am tying to run a python code and get two graphs as output, but not getting any. I have ran the code in both atom and Jupiter notebooks and code is running fine without any errors, but I am still not getting any output.

import glob
from astropy.coordinates import get_icrs_coordinates
from astropy.coordinates import SkyCoord
from astropy.io import fits
import astropy.units as u
import matplotlib as mpl
import numpy as np
import pylab as pl
project_Coords = get_icrs_coordinates('4FGL J1256.9+2736')
ra0=project_Coords.ra.value
dec0=project_Coords.dec.value
def load_event_data():
    f = fits.open('project_merged.fits')
    ra = f['events'].data.field('ra')
    dec = f['events'].data.field('dec')
    en = f['events'].data.field('energy')
    #ph = f['events'].data.field('pulse_phase')
    ph = None
    f.close()
    return ra,dec,en,ph
def make_counts_map():
    ra,dec,en,ph = load_event_data()
    mask = en>1000
    c = SkyCoord(ra[mask]*u.deg,dec[mask]*u.deg,frame = 'icrs')
    c0 = SkyCoord(ra0*u.deg,dec0*u.deg)
    gal = c.galactic
    gal_b = gal.b.value
    gal_l = gal.l.value
    b0 = c0.galactic.b.value
    l0 = c0.galactic.l.value
    l_bins = np.linespace(l0-20,l0+20,41)
    b_bins = np.linespace(b0-20,b0+20,41)
    #Plot sky map
    pl.figure(1); pl.clf()
    pl.hist2d(gal_l,gal_b,bins [l_bins,b_bins] , norm=mpl.colors.LogNorm() ,vmin=2e2,vmax=1e4);
    pl.xlabel('Galactic Longitude')
    pl.ylable('Galactic Latitude')
    pl.colorbar()
    plt.show()
    #plot longitude slice around b= -3
    pl.figure(2); pl.clf()
    mask = np.abs(gal_b - (-3.15)) < 0.5
    pl.gca().set_yselect('log')
    l_bins = np.linspace(l0-20,l0+20,101)
    pl.hist(gal_l[mask],bins=l_bins)
    pl.xlabel('A')
    pl.ylable('B')
  • 3
    For `Jupiter notebook` add `%matplotlib inline` – It_is_Chris Jan 27 '22 at 20:45
  • Does this answer your question? [Purpose of "%matplotlib inline"](https://stackoverflow.com/questions/43027980/purpose-of-matplotlib-inline) – It_is_Chris Jan 27 '22 at 20:48
  • Does this answer your question? [Interactive matplotlib plots in jupyter notebook](https://stackoverflow.com/questions/39428347/interactive-matplotlib-plots-in-jupyter-notebook) – mosc9575 Jan 27 '22 at 20:48
  • @It_is_Chris I tried add it after the last line of code also before the first line of code, the program still run. but still no output – parth patil Jan 28 '22 at 06:34
  • 1
    Do you ever call the function `make_counts_map()`? I doubt it since the last line will give you an error…. – Jody Klymak Jan 28 '22 at 09:47
  • @JodyKlymak I called the function now its giving me the following error " Passing parameters norm and vmin/vmax simultaneously is not supported. Please pass vmin/vmax directly to the norm when creating it." – parth patil Jan 29 '22 at 08:45

0 Answers0