drsophiemurray / smart_python

Converting SMART to Python3
Other
0 stars 1 forks source link

Error in output when running multiple fitsfiles #7

Closed lacorbet closed 6 years ago

lacorbet commented 6 years ago

When running a for loop to run through multiple fitsfiles, the following error presents:

"File "/usr/lib64/python3.6/site-packages/numpy/core/_methods.py", line 29, in _amin return umr_minimum(a, axis, None, out, keepdims)

ValueError: zero-size array to reduction operation minimum which has no identity"

Here is a link to the code used to run the files: https://gitlab.com/lacorbet/mysmart_project/blob/master/executeall.py

Note: These files all ran fine on my (windows) laptop; perhaps this is a linux issue?

drsophiemurray commented 6 years ago

Thanks for creating the issue @lacorbet! I'll take a look.

lacorbet commented 6 years ago

Code below added to wrapper.py to fix Linux bug:

Visualise

if np.max(np.unique(coredetectionmap.data)) > 0: 
    plot_detections.main(processedmap, coredetectionmap,  pslmap,
                     data_dir, smartdate)
else:
    plot_detections.nodetections(processedmap,data_dir,smartdate)

Code below added to plot_detections.py to fix Linux bug:

Defining plot

def nodetections(processedmap, data_dir, smartdate): figure = plt.figure()

Get same axes

bottom_left = SkyCoord(-1000*u.arcsec, -1000*u.arcsec,
                       frame=processedmap.coordinate_frame)
top_right = SkyCoord(1000*u.arcsec, 1000*u.arcsec,
                     frame=processedmap.coordinate_frame)
submap = processedmap.submap(bottom_left, top_right)
axes = wcsaxes_compat.gca_wcs(processedmap.wcs)
image = processedmap.plot(vmin=-500, vmax=500, axes=axes)
axes.coords.grid(False)
# Draw solar lat/lon grid
overlay = grid_overlay(axes, grid_spacing=10 * u.deg)
plt.colorbar(label='B [G]')
plt.savefig(data_dir+smartdate+'_detections.png',format='png',dpi=1000)
drsophiemurray commented 6 years ago

Ah its the plotting - makes sense! Thanks @lacorbet I'll integrate your fix into the code 👍

lacorbet commented 6 years ago

Great! no problem :)