problem in PDRT_Example_Model_Plotting.ipynb

52 views
Skip to first unread message

Pablo Garcia

unread,
Jun 21, 2023, 4:59:25 PM6/21/23
to PDR Toolbox
Dear Marc,
I am making my way through all jupyter notebooks examples to get them running in my machine (MacBook Pro, Ventura 13.4). While running the PDRT_Example_Model_Plotting.ipynb notebook, I encountered the following error:

mp.plot("CI_609",legend=False,contours=True,label=True)

/Users/fondecyt/opt/anaconda3/lib/python3.8/site-packages/pdrtpy/measurement.py:337: DeprecationWarning: `interp2d` is deprecated! `interp2d` is deprecated in SciPy 1.10 and will be removed in SciPy 1.12.0. For legacy code, nearly bug-for-bug compatible replacements are `RectBivariateSpline` on regular grids, and `bisplrep`/`bisplev` for scattered 2D data. In new code, for regular grids use `RegularGridInterpolator` instead. For scattered data, prefer `LinearNDInterpolator` or `CloughTocher2DInterpolator`. For more details see `https://gist.github.com/ev-br/8544371b40f414b7eaf3fe6217209bff` self._interp_log = interp2d(self._world_axis[0],self._world_axis[1],z=self.data,kind=kind,bounds_error=True) /Users/fondecyt/opt/anaconda3/lib/python3.8/site-packages/pdrtpy/measurement.py:338: DeprecationWarning: `interp2d` is deprecated! `interp2d` is deprecated in SciPy 1.10 and will be removed in SciPy 1.12.0. For legacy code, nearly bug-for-bug compatible replacements are `RectBivariateSpline` on regular grids, and `bisplrep`/`bisplev` for scattered 2D data. In new code, for regular grids use `RegularGridInterpolator` instead. For scattered data, prefer `LinearNDInterpolator` or `CloughTocher2DInterpolator`. For more details see `https://gist.github.com/ev-br/8544371b40f414b7eaf3fe6217209bff` self._interp_lin = interp2d(self._world_axis_lin[0],self._world_axis_lin[1],z=self.data,kind=kind,bounds_error=True)

I have all package versions suggested  in the "requirements.txt" file installed. In particular:

# packages in environment at /Users/fondecyt/anaconda3:

#

# Name                    Version                   Build  Channel

scipy                     1.10.0          py310ha516a68_1  


so I guess, an update of the corresponding routine in the PDRToolBox using scip is needed?.

Also, when running:

mp.phasespace(identifiers1,reciprocal=[False,True],
              nax1_clip=[100,1E6]*u.Unit("cm-3"),
              nax2_clip=[10,1E6]*utils.habing_unit)
mp.savefig("CII_OI_FIR.png")

I get the following error:

--------------------------------------------------------------------------- ValueError Traceback (most recent call last) Cell In[17], line 1 ----> 1 mp.phasespace(identifiers1,reciprocal=[False,True], 2 nax1_clip=[100,1E6]*u.Unit("cm-3"), 3 nax2_clip=[10,1E6]*utils.habing_unit) 4 mp.savefig("CII_OI_FIR.png") File ~/opt/anaconda3/lib/python3.8/site-packages/pdrtpy/plot/modelplot.py:538, in ModelPlot.phasespace(self, identifiers, nax1_clip, nax2_clip, reciprocal, **kwargs) 536 self._axis.tick_params(axis='both',bottom=True,top=True,left=True,right=True, which='both') 537 if kwargs_opts['grid']: --> 538 self._axis.grid(b=True,which='major',axis='both',lw=kwargs_opts['linewidth']/2, 539 color='k',alpha=0.33) 540 self._axis.grid(b=True,which='minor',axis='both',lw=kwargs_opts['linewidth']/2, 541 color='k',alpha=0.22,linestyle='--') 542 if kwargs_opts['legend']: 543 # Manually build the legend. Create the column headers for the legend 544 # and blank handles and labels to take up space for the headers and 545 # when the number of naxis1 and naxis2 traces 546 # are not equal. File ~/opt/anaconda3/lib/python3.8/site-packages/matplotlib/axes/_base.py:3194, in _AxesBase.grid(self, visible, which, axis, **kwargs) 3192 _api.check_in_list(['x', 'y', 'both'], axis=axis) 3193 if axis in ['x', 'both']: -> 3194 self.xaxis.grid(visible, which=which, **kwargs) 3195 if axis in ['y', 'both']: 3196 self.yaxis.grid(visible, which=which, **kwargs) File ~/opt/anaconda3/lib/python3.8/site-packages/matplotlib/axis.py:1660, in Axis.grid(self, visible, which, **kwargs) 1657 if which in ['major', 'both']: 1658 gridkw['gridOn'] = (not self._major_tick_kw['gridOn'] 1659 if visible is None else visible) -> 1660 self.set_tick_params(which='major', **gridkw) 1661 self.stale = True File ~/opt/anaconda3/lib/python3.8/site-packages/matplotlib/axis.py:932, in Axis.set_tick_params(self, which, reset, **kwargs) 919 """ 920 Set appearance parameters for ticks, ticklabels, and gridlines. 921 (...) 929 gridlines. 930 """ 931 _api.check_in_list(['major', 'minor', 'both'], which=which) --> 932 kwtrans = self._translate_tick_params(kwargs) 934 # the kwargs are stored in self._major/minor_tick_kw so that any 935 # future new ticks will automatically get them 936 if reset: File ~/opt/anaconda3/lib/python3.8/site-packages/matplotlib/axis.py:1076, in Axis._translate_tick_params(kw, reverse) 1074 for key in kw_: 1075 if key not in allowed_keys: -> 1076 raise ValueError( 1077 "keyword %s is not recognized; valid keywords are %s" 1078 % (key, allowed_keys)) 1079 kwtrans.update(kw_) 1080 return kwtrans ValueError: keyword grid_b is not recognized; valid keywords are ['size', 'width', 'color', 'tickdir', 'pad', 'labelsize', 'labelcolor', 'zorder', 'gridOn', 'tick1On', 'tick2On', 'label1On', 'label2On', 'length', 'direction', 'left', 'bottom', 'right', 'top', 'labelleft', 'labelbottom', 'labelright', 'labeltop', 'labelrotation', 'grid_agg_filter', 'grid_alpha', 'grid_animated', 'grid_antialiased', 'grid_clip_box', 'grid_clip_on', 'grid_clip_path', 'grid_color', 'grid_dash_capstyle', 'grid_dash_joinstyle', 'grid_dashes', 'grid_data', 'grid_drawstyle', 'grid_figure', 'grid_fillstyle', 'grid_gapcolor', 'grid_gid', 'grid_in_layout', 'grid_label', 'grid_linestyle', 'grid_linewidth', 'grid_marker', 'grid_markeredgecolor', 'grid_markeredgewidth', 'grid_markerfacecolor', 'grid_markerfacecoloralt', 'grid_markersize', 'grid_markevery', 'grid_mouseover', 'grid_path_effects', 'grid_picker', 'grid_pickradius', 'grid_rasterized', 'grid_sketch_params', 'grid_snap', 'grid_solid_capstyle', 'grid_solid_joinstyle', 'grid_transform', 'grid_url', 'grid_visible', 'grid_xdata', 'grid_ydata', 'grid_zorder', 'grid_aa', 'grid_c', 'grid_ds', 'grid_ls', 'grid_lw', 'grid_mec', 'grid_mew', 'grid_mfc', 'grid_mfcalt', 'grid_ms']

Any thoughts?.

Thanks!

Saludos
Pablo







Marc W. Pound

unread,
Jun 22, 2023, 12:31:46 PM6/22/23
to PDR Toolbox

(solved offline with Pablo).  Putting the solution here for future reference:
--------------


Dear Marc,
thanks for the quick response. I just updated to Ventura 3.4.1 and re-installed the PDR tool box (v2.3.1).
Now, apart from the warning messages, eveything is working fine.

Thanks
Pablo.

--------------

Hi Pablo,

1) I know  about the scipy interpolator change, as I get those warnings too.  I just have not yet made it a priority to change the toolbox to use the routines, but will have to take care of it soon.  Scipy is not yet at 1.12 where they will be deprecated.

2) For the grid,   matplotlib has changed the "b" parameter to "visible"  in version 3.5.0.   I fixed this for pdrtpy version 2.3.1 -- what version are you using?

import pdrtpy
pdrtpy.version()

should show "2.3.1"

Marc
Reply all
Reply to author
Forward
0 new messages