NuGrid / NuGridPy

Python tools to access and analyse NuGrid output data (including from MESA)
http://nugrid.github.io/NuGridPy
BSD 3-Clause "New" or "Revised" License
13 stars 10 forks source link

elemental_abund not working properly with python 3 (in notebooks) #33

Closed fherwig closed 6 years ago

fherwig commented 7 years ago

code to produce this error:

path ='/data/nugrid_apod2/scratch/PPN_August/He_burn_T.25/P1_earlier_lowdilution/'
b = ppn.abu_vector(path)
b.elemental_abund(120)

you may have to use a different ppn run

error message on astrohub:

TypeError                                 Traceback (most recent call last)
<ipython-input-12-55f213f1e4bd> in <module>()
      1 ifig=15;close(ifig);figure(ifig)
----> 2 b.elemental_abund(120,zrange=[1,50])
      3 Xk=cm.plot_keller_obs_Heshell(0.1)

/usr/local/lib/python3.5/dist-packages/nugridpy/data_plot.py in elemental_abund(self, cycle, zrange, ylim, title_items, ref, solar_filename, show_names, label, colour, **kwargs)
   3447         plotType=self._classTest()
   3448         if plotType=='PPN':
-> 3449             self.get(cycle,decayed=True)
   3450             z_el=unique(self.z_iso_to_plot)
   3451             zmin_ind=min(where(z_el>=zrange[0])[0])

/usr/local/lib/python3.5/dist-packages/nugridpy/ppn.py in get(self, attri, fname, numtype, decayed)
    756         if type(attri) is type(1):
    757             print("Calling get method in cycle mode, adding a_iso_to_plot, z.. el.. isotope.. isotope... to instance")
--> 758             self._getcycle(attri,decayed)
    759         elif type(attri) is type("string"):
    760             data=self._getattr(attri,fname,numtype)

/usr/local/lib/python3.5/dist-packages/nugridpy/ppn.py in _getcycle(self, cycle, decayed)
    769 
    770         a_iso_to_plot,z_iso_to_plot,abunds,isotope_to_plot,el_iso_to_plot,isom=\
--> 771             self._process_abundance_vector(a,z,isomers,yps)
    772         self.a_iso_to_plot=a_iso_to_plot
    773         self.isotope_to_plot=isotope_to_plot

/usr/local/lib/python3.5/dist-packages/nugridpy/utils.py in _process_abundance_vector(self, a, z, isomers, yps)
    290                 else:
    291                     isom.append([self.stable_names[int(z[i])]+'-'+str(int(a[i]))+'-'+str(int(isomers[i]-1)),yps[i]])
--> 292         tmp.sort(self.compar)
    293         tmp.sort(self.comparator)
    294         abunds=[]

TypeError: must use keyword argument for key function
fherwig commented 6 years ago

@jerichooconnell this error should appear with any ppn data

jerichooconnell commented 6 years ago

This issue is was fixed with issue #30