Sharedisochrones.ipynbOpen in CoCalc
Author: Harald Schilly
Views : 17

ISOCHRONES on CoCalc in Python 3

https://isochrones.readthedocs.io/en/latest/

Data globally stored in $ISOCHRONES

In [1]:
import sys sys.executable
'/usr/bin/python3'
In [2]:
sys.version
'3.6.8 (default, Jan 14 2019, 11:02:34) \n[GCC 8.0.1 20180414 (experimental) [trunk revision 259383]]'
In [3]:
import isochrones isochrones
WARNING:root:PyMultiNest not imported. MultiNest fits will not work.
<module 'isochrones' from '/usr/local/lib/python3.6/dist-packages/isochrones/__init__.py'>
In [4]:
isochrones.__version__
'1.2.1'
In [3]:
from isochrones.mist import MIST_Isochrone mist = MIST_Isochrone() mist.radius(1.0, 9.7, 0.0)
WARNING:root:PyMultiNest not imported. MultiNest fits will not work. /usr/local/lib/python3.6/dist-packages/isochrones/mist/grid.py:190: FutureWarning: read_table is deprecated, use read_csv instead, passing sep='\t'. skip_blank_lines=True, names=column_names) /usr/local/lib/python3.6/dist-packages/isochrones/mist/grid.py:195: DtypeWarning: Columns (8) have mixed types. Specify dtype option on import or set low_memory=False. df = super(MISTModelGrid, self).df_all(phot)
Opening /ext/data/isochrones/mist/MIST_v1.1_vvcrit0.0_UBVRIplus.h5 in read-only mode
--------------------------------------------------------------------------- ValueError Traceback (most recent call last) /usr/local/lib/python3.6/dist-packages/isochrones/grid.py in get_hdf(self, phot) 196 try: --> 197 df = pd.read_hdf(h5file, 'df') 198 except: /usr/local/lib/python3.6/dist-packages/pandas/io/pytables.py in read_hdf(path_or_buf, key, mode, **kwargs) 388 key = candidate_only_group._v_pathname --> 389 return store.select(key, auto_close=auto_close, **kwargs) 390 except (ValueError, TypeError): /usr/local/lib/python3.6/dist-packages/pandas/io/pytables.py in select(self, key, where, start, stop, columns, iterator, chunksize, auto_close, **kwargs) 739 --> 740 return it.get_result() 741 /usr/local/lib/python3.6/dist-packages/pandas/io/pytables.py in get_result(self, coordinates) 1517 # directly return the result -> 1518 results = self.func(self.start, self.stop, where) 1519 self.close() /usr/local/lib/python3.6/dist-packages/pandas/io/pytables.py in func(_start, _stop, _where) 732 where=_where, --> 733 columns=columns) 734 /usr/local/lib/python3.6/dist-packages/pandas/io/pytables.py in read(self, start, stop, **kwargs) 2994 values = self.read_array('block{idx}_values'.format(idx=i), -> 2995 start=_start, stop=_stop) 2996 blk = make_block(values, /usr/local/lib/python3.6/dist-packages/pandas/io/pytables.py in read_array(self, key, start, stop) 2539 if isinstance(node, tables.VLArray): -> 2540 ret = node[0][start:stop] 2541 else: /usr/lib/python3/dist-packages/tables/vlarray.py in __getitem__(self, key) 670 (start, stop, step) = self._process_range(key, key + 1, 1) --> 671 return self.read(start, stop, step)[0] 672 elif isinstance(key, slice): /usr/lib/python3/dist-packages/tables/vlarray.py in read(self, start, stop, step) 810 else: --> 811 listarr = self._read_array(start, stop, step) 812 tables/hdf5extension.pyx in tables.hdf5extension.VLArray._read_array() ValueError: cannot set WRITEABLE flag to True of this array During handling of the above exception, another exception occurred: FileModeError Traceback (most recent call last) <ipython-input-3-f7a77d11cbc2> in <module> 1 from isochrones.mist import MIST_Isochrone 2 mist = MIST_Isochrone() ----> 3 mist.radius(1.0, 9.7, 0.0) /usr/local/lib/python3.6/dist-packages/isochrones/isochrone.py in radius(self, *args) 197 198 def radius(self, *args): --> 199 return np.sqrt(G*self.mass(*args)*MSUN/10**self.logg(*args))/RSUN 200 201 def Teff(self, *args): /usr/local/lib/python3.6/dist-packages/isochrones/isochrone.py in logg(self, mass, age, feh) 685 686 def logg(self, mass, age, feh): --> 687 return self.interp_value(mass, age, feh, self.logg_col) 688 689 def logL(self, mass, age, feh): /usr/local/lib/python3.6/dist-packages/isochrones/isochrone.py in interp_value(self, mass, age, feh, icol) 745 def interp_value(self, mass, age, feh, icol): # 4 is log_g 746 if self._ages is None: --> 747 self._initialize() 748 749 try: /usr/local/lib/python3.6/dist-packages/isochrones/isochrone.py in _initialize(self) 608 for attr in ['df','Ncols','fehs','ages','Nfeh','Nage', 609 'minage','maxage','minfeh','maxfeh','minmass','maxmass']: --> 610 _ = getattr(self, attr) 611 612 /usr/local/lib/python3.6/dist-packages/isochrones/isochrone.py in df(self) 614 def df(self): 615 if self._df is None: --> 616 self._df = self.modelgrid(self.bands, **self.modelgrid_kwargs).df 617 return self._df 618 /usr/local/lib/python3.6/dist-packages/isochrones/grid.py in df(self) 95 def df(self): 96 if self._df is None: ---> 97 self._df = self._get_df() 98 99 return self._df /usr/local/lib/python3.6/dist-packages/isochrones/grid.py in _get_df(self) 110 logging.debug('loading {} band from {}'.format(b,s)) 111 if s not in grids: --> 112 grids[s] = self.get_hdf(s) 113 if self.common_columns[0] not in df: 114 df[list(self.common_columns)] = grids[s][list(self.common_columns)] /usr/local/lib/python3.6/dist-packages/isochrones/grid.py in get_hdf(self, phot) 197 df = pd.read_hdf(h5file, 'df') 198 except: --> 199 df = self.write_hdf(phot) 200 return df 201 /usr/local/lib/python3.6/dist-packages/isochrones/grid.py in write_hdf(self, phot) 203 df = self.df_all(phot) 204 h5file = self.hdf_filename(phot) --> 205 df.to_hdf(h5file,'df') 206 logging.info('{} written.'.format(h5file)) 207 return df /usr/local/lib/python3.6/dist-packages/pandas/core/generic.py in to_hdf(self, path_or_buf, key, **kwargs) 2375 """ 2376 from pandas.io import pytables -> 2377 return pytables.to_hdf(path_or_buf, key, self, **kwargs) 2378 2379 def to_msgpack(self, path_or_buf=None, encoding='utf-8', **kwargs): /usr/local/lib/python3.6/dist-packages/pandas/io/pytables.py in to_hdf(path_or_buf, key, value, mode, complevel, complib, append, **kwargs) 272 with HDFStore(path_or_buf, mode=mode, complevel=complevel, 273 complib=complib) as store: --> 274 f(store) 275 else: 276 f(path_or_buf) /usr/local/lib/python3.6/dist-packages/pandas/io/pytables.py in <lambda>(store) 266 f = lambda store: store.append(key, value, **kwargs) 267 else: --> 268 f = lambda store: store.put(key, value, **kwargs) 269 270 path_or_buf = _stringify_path(path_or_buf) /usr/local/lib/python3.6/dist-packages/pandas/io/pytables.py in put(self, key, value, format, append, **kwargs) 887 format = get_option("io.hdf.default_format") or 'fixed' 888 kwargs = self._validate_format(format, kwargs) --> 889 self._write_to_group(key, value, append=append, **kwargs) 890 891 def remove(self, key, where=None, start=None, stop=None): /usr/local/lib/python3.6/dist-packages/pandas/io/pytables.py in _write_to_group(self, key, value, format, index, append, complib, encoding, **kwargs) 1369 # remove the node if we are not appending 1370 if group is not None and not append: -> 1371 self._handle.remove_node(group, recursive=True) 1372 group = None 1373 /usr/lib/python3/dist-packages/tables/file.py in remove_node(self, where, name, recursive) 1756 1757 obj = self.get_node(where, name=name) -> 1758 obj._f_remove(recursive) 1759 1760 /usr/lib/python3/dist-packages/tables/node.py in _f_remove(self, recursive, force) 543 self._g_check_open() 544 file_ = self._v_file --> 545 file_._check_writable() 546 547 if file_.is_undo_enabled(): /usr/lib/python3/dist-packages/tables/file.py in _check_writable(self) 2117 2118 if not self._iswritable(): -> 2119 raise FileModeError("the file is not writable") 2120 2121 FileModeError: the file is not writable
In [6]:
! ls -lh /ext/data/isochrones/mist/
total 2.7G -rw-r--r-- 1 salvus salvus 504M Aug 24 14:29 B-BP-G-H-J-K-Kepler-RP-TESS-V-W1-W2-W3-g-i-r-z.npz -rw-r--r-- 1 salvus salvus 96M Oct 10 2016 MIST_v1.0_CFHT.tar.gz -rw-r--r-- 1 salvus salvus 96M Oct 10 2016 MIST_v1.0_DECam.tar.gz -rw-r--r-- 1 salvus salvus 72M Oct 10 2016 MIST_v1.0_GALEX.tar.gz -rw-r--r-- 1 salvus salvus 223M Oct 10 2016 MIST_v1.0_JWST.tar.gz -rw-r--r-- 1 salvus salvus 96M Oct 10 2016 MIST_v1.0_LSST.tar.gz -rw-r--r-- 1 salvus salvus 102M Oct 10 2016 MIST_v1.0_PanSTARRS.tar.gz -rw-r--r-- 1 salvus salvus 91M Oct 5 2016 MIST_v1.0_SDSS.tar.gz -rw-r--r-- 1 salvus salvus 84M Oct 10 2016 MIST_v1.0_SPITZER.tar.gz -rw-r--r-- 1 salvus salvus 97M Oct 10 2016 MIST_v1.0_SkyMapper.tar.gz -rw-r--r-- 1 salvus salvus 145M Oct 10 2016 MIST_v1.0_UBVRIplus.tar.gz -rw-r--r-- 1 salvus salvus 90M Oct 10 2016 MIST_v1.0_UKIDSS.tar.gz -rw-r--r-- 1 salvus salvus 84M Oct 10 2016 MIST_v1.0_WISE.tar.gz drwxr-xr-x 1 salvus salvus 1.7K Sep 12 2017 MIST_v1.1_vvcrit0.0_SDSS -rw-r--r-- 1 salvus salvus 167M Aug 24 14:29 MIST_v1.1_vvcrit0.0_SDSS.h5 -rw-r--r-- 1 salvus salvus 105M Aug 24 14:28 MIST_v1.1_vvcrit0.0_SDSS.tar.gz drwxr-xr-x 1 salvus salvus 1.8K May 7 15:06 MIST_v1.1_vvcrit0.0_UBVRIplus -rw-r--r-- 1 salvus salvus 288M Aug 24 14:28 MIST_v1.1_vvcrit0.0_UBVRIplus.h5 -rw-r--r-- 1 salvus salvus 177M Aug 24 14:28 MIST_v1.1_vvcrit0.0_UBVRIplus.tar.gz drwxr-xr-x 1 salvus salvus 1.7K Sep 12 2017 MIST_v1.1_vvcrit0.0_WISE -rw-r--r-- 1 salvus salvus 157M Aug 24 14:28 MIST_v1.1_vvcrit0.0_WISE.h5 -rw-r--r-- 1 salvus salvus 98M Aug 24 14:28 MIST_v1.1_vvcrit0.0_WISE.tar.gz
In [7]:
! ls -lh /ext/data/isochrones/dartmouth/
total 160M -rw-r--r-- 1 salvus salvus 32M May 20 2016 LSST.tgz -rw-r--r-- 1 salvus salvus 29M Oct 5 2016 SDSSugriz.tgz -rw-r--r-- 1 salvus salvus 44M May 20 2016 UBVRIJHKsKp.tgz -rw-r--r-- 1 salvus salvus 29M May 20 2016 UKIDSS.tgz -rw-r--r-- 1 salvus salvus 26M May 20 2016 WISE.tgz
In [ ]: