def doFUNCTION(self,wl_min=10.0,wl_max=20.0,function='linear'): """ Replace all opacities by an extrapolation below a cut-off wavelength. @keyword wl_min: lower boundary interpolation range and the cutoff wavelength for the extrapolation (default: 10.0) @type wl_min: float @keyword wl_max: upper boundary interpolation range (default: 20.0) @type wl_max: float @keyword function: type of function used for the inter/extrapolation See Interpol.pEval for function types (default: 'linear') @type function: string """ #raise TypeError("WARNING! The CustumOpa().doFUNCTION method is obsolete! New version NYI.") #- Select relevant inputlines (not saving the scattering matrices) self.opacity_file = True inputsel = [line for line in self.input_data if len(line) == 4] inputsel = array([[float(f) for f in line] for line in inputsel]) wl = inputsel[:,0] function = function.lower() #- Select the extrapolation and interpolation regions. wl_low = wl[wl < wl_min] wlinter = wl[(wl >= wl_min) * (wl <= wl_max)] abs_inter = inputsel[:,2][(wl >= wl_min) * (wl <= wl_max)] sca_inter = inputsel[:,3][(wl >= wl_min) * (wl <= wl_max)] #- Fit the interpolation region and extrapolate this to lower wavelength abs_p0 = [abs_inter[0],wl[0],1,1] sca_p0 = [sca_inter[0],wl[0],1,1] abs_low = Interpol.fitFunction(x_in=wlinter,y_in=abs_inter,\ x_out=wl_low,func=function,\ initial=abs_p0,show=1) abs_low = array([a > 0 and a or 0 for a in abs_low]) sca_low = Interpol.fitFunction(x_in=wlinter,y_in=sca_inter,\ x_out=wl_low,func=function,\ initial=sca_p0,show=1) sca_low = array([s > 0 and s or 0 for s in sca_low]) ext_low = abs_low + sca_low #- Set the output data self.output_data = [array([w,el,al,sl]) for w,el,al,sl in zip(wl_low,ext_low,\ abs_low,sca_low)] self.output_data.extend(inputsel[wl >= wl_min])
def doFUNCTION(self,wl_min=10.0,wl_max=20.0,function='linear'): """ Replace all opacities by an extrapolation below a cut-off wavelength. @keyword wl_min: lower boundary interpolation range and the cutoff wavelength for the extrapolation (default: 10.0) @type wl_min: float @keyword wl_max: upper boundary interpolation range (default: 20.0) @type wl_max: float @keyword function: type of function used for the inter/extrapolation See Interpol.pEval for function types (default: 'linear') @type function: string """ #raise TypeError("WARNING! The CustumOpa().doFUNCTION method is obsolete! New version NYI.") #- Select relevant inputlines (not saving the scattering matrices) self.opacity_file = True inputsel = [line for line in self.input_data if len(line) == 4] inputsel = array([[float(f) for f in line] for line in inputsel]) wl = inputsel[:,0] function = function.lower() #- Select the extrapolation and interpolation regions. wl_low = wl[wl < wl_min] wlinter = wl[(wl >= wl_min) * (wl <= wl_max)] abs_inter = inputsel[:,2][(wl >= wl_min) * (wl <= wl_max)] sca_inter = inputsel[:,3][(wl >= wl_min) * (wl <= wl_max)] #- Fit the interpolation region and extrapolate this to lower wavelength abs_p0 = [abs_inter[0],wl[0],1,1] sca_p0 = [sca_inter[0],wl[0],1,1] abs_low = Interpol.fitFunction(x_in=wlinter,y_in=abs_inter,\ x_out=wl_low,func=function,\ initial=abs_p0,show=1) abs_low = array([a > 0 and a or 0 for a in abs_low]) sca_low = Interpol.fitFunction(x_in=wlinter,y_in=sca_inter,\ x_out=wl_low,func=function,\ initial=sca_p0,show=1) sca_low = array([s > 0 and s or 0 for s in sca_low]) ext_low = abs_low + sca_low #- Set the output data self.output_data = [array([w,el,al,sl]) for w,el,al,sl in zip(wl_low,ext_low,\ abs_low,sca_low)] self.output_data.extend(inputsel[wl >= wl_min])
def divideContinuum(self,w,f,dtype,frindex): ''' Divide flux by the continuum flux in a dust feature. @param w: The wavelength grid @type w: list/array @param f: The flux grid @type f: list/array @param dtype: data type (only 'model','sws' for now) @type dtype: string @param frindex: The index in the franges list for this entry. @type frindex: int @keyword plot: Show a plot of the continuum division @type plot: bool ''' fr1,fr2 = self.franges[frindex][0],self.franges[frindex][1] fr3,fr4 = self.franges[frindex][2],self.franges[frindex][3] w_in = list(w[(w>fr1) * (w<fr2)]) + list(w[(w>fr3) * (w<fr4)]) f_in = list(f[(w>fr1) * (w<fr2)]) + list(f[(w>fr3) * (w<fr4)]) w_cont = w[(w>self.frmin*0.9)*(w<self.frmax*1.1)] f_ori = f[(w>self.frmin*0.9)*(w<self.frmax*1.1)] f_cont = Interpol.fitFunction(x_in=w_in,y_in=f_in,x_out=w_cont,\ func=self.func[frindex]) self.cont_division[dtype] = dict() self.cont_division[dtype]['w_feat'] = w_cont self.cont_division[dtype]['f_feat'] = f_ori self.cont_division[dtype]['w_fitsel_feat'] = w_in self.cont_division[dtype]['f_fitsel_feat'] = f_in self.cont_division[dtype]['f_interp'] = f_cont self.cont_division[dtype]['f_division'] = f_ori/f_cont if self.plot: x = [w_cont,w_cont] y = [f_ori,f_cont] Plotting2.plotCols(x=x,y=y,xmin=self.frmin*0.9,xmax=self.frmax*1.1,\ ylogscale=0,xlogscale=0)
def divideContinuum(self, w, f, dtype, frindex): ''' Divide flux by the continuum flux in a dust feature. @param w: The wavelength grid @type w: list/array @param f: The flux grid @type f: list/array @param dtype: data type (only 'model','sws' for now) @type dtype: string @param frindex: The index in the franges list for this entry. @type frindex: int @keyword plot: Show a plot of the continuum division @type plot: bool ''' fr1, fr2 = self.franges[frindex][0], self.franges[frindex][1] fr3, fr4 = self.franges[frindex][2], self.franges[frindex][3] w_in = list(w[(w > fr1) * (w < fr2)]) + list(w[(w > fr3) * (w < fr4)]) f_in = list(f[(w > fr1) * (w < fr2)]) + list(f[(w > fr3) * (w < fr4)]) w_cont = w[(w > self.frmin * 0.9) * (w < self.frmax * 1.1)] f_ori = f[(w > self.frmin * 0.9) * (w < self.frmax * 1.1)] f_cont = Interpol.fitFunction(x_in=w_in,y_in=f_in,x_out=w_cont,\ func=self.func[frindex]) self.cont_division[dtype] = dict() self.cont_division[dtype]['w_feat'] = w_cont self.cont_division[dtype]['f_feat'] = f_ori self.cont_division[dtype]['w_fitsel_feat'] = w_in self.cont_division[dtype]['f_fitsel_feat'] = f_in self.cont_division[dtype]['f_interp'] = f_cont self.cont_division[dtype]['f_division'] = f_ori / f_cont if self.plot: x = [w_cont, w_cont] y = [f_ori, f_cont] Plotting2.plotCols(x=x,y=y,xmin=self.frmin*0.9,xmax=self.frmax*1.1,\ ylogscale=0,xlogscale=0)