def rho_gen(self): """ A wrapper for calc_rho_zr. Upon executing, generates rho and rho cdf inverse """ # Check that sigma has been generated if not hasattr(self._parent, 'sigma'): raise RuntimeError, 'Must load/generate sigma before calculating rho' # Numerically calculate rho(z,r) for a given sigma. rho(z,r) # obeys vertical hydrostatic equilibrium (approximately) rho_array, z, r = calc_rho_zr.rho_zr(self._parent) # Create a complete rho object. Includes rho spline and CDF inverse rho = calc_rho_zr.rho_from_array(self._parent, rho_array, z, r) # Save to ICobj self._parent.rho = rho print 'rho stored in <IC instance>.rho'
def rho_gen(self): """ A wrapper for calc_rho_zr. Upon executing, generates rho and rho cdf inverse """ # Check that sigma has been generated if not hasattr(self._parent, 'sigma'): raise RuntimeError,'Must load/generate sigma before calculating rho' # Numerically calculate rho(z,r) for a given sigma. rho(z,r) # obeys vertical hydrostatic equilibrium (approximately) rho_array, z, r = calc_rho_zr.rho_zr(self._parent) # Create a complete rho object. Includes rho spline and CDF inverse rho = calc_rho_zr.rho_from_array(self._parent, rho_array, z, r) # Save to ICobj self._parent.rho = rho print 'rho stored in <IC instance>.rho'
def rho(self,rho_dict): """ Generates a rho object and stores it in ICobj.rho rho_dict should be a dictionary containing: 'z': 1D array of z values 'r': 1D array of r values 'rho': 2D array of rho evaluated at z,r Exaple: rho_dict = pickle.load(open('rhofile.p', 'rb')) # Load up a rho dict ICobj.add.rho(rho_dict) # create ICobj.rho """ # Create rho object (includes a spline interpolation) rho_binned = rho_dict['rho'] z_bins = rho_dict['z'] r_bins = rho_dict['r'] self._parent.rho = calc_rho_zr.rho_from_array(self._parent, rho_binned, z_bins, r_bins) print 'rho stored in <IC instance>.rho'