_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q20000
modflow_hob_to_instruction_file
train
def modflow_hob_to_instruction_file(hob_file): """write an instruction file for a modflow head observation file Parameters ---------- hob_file : str modflow hob file Returns ------- df : pandas.DataFrame pandas DataFrame with control file observation information """ ...
python
{ "resource": "" }
q20001
modflow_hydmod_to_instruction_file
train
def modflow_hydmod_to_instruction_file(hydmod_file): """write an instruction file for a modflow hydmod file Parameters ---------- hydmod_file : str modflow hydmod file Returns ------- df : pandas.DataFrame pandas DataFrame with control file observation information Not...
python
{ "resource": "" }
q20002
modflow_read_hydmod_file
train
def modflow_read_hydmod_file(hydmod_file, hydmod_outfile=None): """ read in a binary hydmod file and return a dataframe of the results Parameters ---------- hydmod_file : str modflow hydmod binary file hydmod_outfile : str output file to write. If None, use <hydmod_file>.dat. ...
python
{ "resource": "" }
q20003
apply_mtlist_budget_obs
train
def apply_mtlist_budget_obs(list_filename,gw_filename="mtlist_gw.dat", sw_filename="mtlist_sw.dat", start_datetime="1-1-1970"): """ process an MT3D list file to extract mass budget entries. Parameters ---------- list_filename : str the mt3...
python
{ "resource": "" }
q20004
setup_mflist_budget_obs
train
def setup_mflist_budget_obs(list_filename,flx_filename="flux.dat", vol_filename="vol.dat",start_datetime="1-1'1970",prefix='', save_setup_file=False): """ setup observations of budget volume and flux from modflow list file. writes an instruction file and ...
python
{ "resource": "" }
q20005
apply_mflist_budget_obs
train
def apply_mflist_budget_obs(list_filename,flx_filename="flux.dat", vol_filename="vol.dat", start_datetime="1-1-1970"): """ process a MODFLOW list file to extract flux and volume water budget entries. Parameters ---------- list_filename : str ...
python
{ "resource": "" }
q20006
apply_hds_obs
train
def apply_hds_obs(hds_file): """ process a modflow head save file. A companion function to setup_hds_obs that is called during the forward run process Parameters ---------- hds_file : str a modflow head save filename. if hds_file ends with 'ucn', then the file is treated as a UcnFi...
python
{ "resource": "" }
q20007
modflow_sfr_gag_to_instruction_file
train
def modflow_sfr_gag_to_instruction_file(gage_output_file, ins_file=None, parse_filename=False): """writes an instruction file for an SFR gage output file to read Flow only at all times Parameters ---------- gage_output_file : str the gage output filename (ASCII). ...
python
{ "resource": "" }
q20008
Schur.pandas
train
def pandas(self): """get a pandas dataframe of prior and posterior for all predictions Returns: pandas.DataFrame : pandas.DataFrame a dataframe with prior and posterior uncertainty estimates for all forecasts (predictions) """ names,prior,post...
python
{ "resource": "" }
q20009
Schur.map_parameter_estimate
train
def map_parameter_estimate(self): """ get the posterior expectation for parameters using Bayes linear estimation Returns ------- post_expt : pandas.DataFrame a dataframe with prior and posterior parameter expectations """ res = self.pst.res a...
python
{ "resource": "" }
q20010
Schur.get_parameter_summary
train
def get_parameter_summary(self,include_map=False): """get a summary of the parameter uncertainty Parameters ---------- include_map : bool if True, add the prior and posterior expectations and report standard deviation instead of variance Returns ...
python
{ "resource": "" }
q20011
Schur.get_forecast_summary
train
def get_forecast_summary(self, include_map=False): """get a summary of the forecast uncertainty Parameters ---------- include_map : bool if True, add the prior and posterior expectations and report standard deviation instead of variance Returns -...
python
{ "resource": "" }
q20012
Schur.__contribution_from_parameters
train
def __contribution_from_parameters(self, parameter_names): """private method get the prior and posterior uncertainty reduction as a result of some parameter becoming perfectly known Parameters ---------- parameter_names : list parameter that are perfectly known ...
python
{ "resource": "" }
q20013
Schur.get_conditional_instance
train
def get_conditional_instance(self, parameter_names): """ get a new Schur instance that includes conditional update from some parameters becoming known perfectly Parameters ---------- parameter_names : list parameters that are to be treated as notionally perfectly ...
python
{ "resource": "" }
q20014
Schur.get_par_contribution
train
def get_par_contribution(self,parlist_dict=None,include_prior_results=False): """get a dataframe the prior and posterior uncertainty reduction as a result of some parameter becoming perfectly known Parameters ---------- parlist_dict : dict a nested dictionary-list of...
python
{ "resource": "" }
q20015
ErrVar.omitted_jco
train
def omitted_jco(self): """get the omitted jco Returns ------- omitted_jco : pyemu.Jco Note ---- returns a reference if ErrorVariance.__omitted_jco is None, then dynamically load the attribute before returning """ ...
python
{ "resource": "" }
q20016
ErrVar.omitted_parcov
train
def omitted_parcov(self): """get the omitted prior parameter covariance matrix Returns ------- omitted_parcov : pyemu.Cov Note ---- returns a reference If ErrorVariance.__omitted_parcov is None, attribute is dynamically loaded ...
python
{ "resource": "" }
q20017
ErrVar.get_identifiability_dataframe
train
def get_identifiability_dataframe(self,singular_value=None,precondition=False): """get the parameter identifiability as a pandas dataframe Parameters ---------- singular_value : int the singular spectrum truncation point. Defaults to minimum of non-zero-weighted ...
python
{ "resource": "" }
q20018
ErrVar.variance_at
train
def variance_at(self, singular_value): """get the error variance of all three terms at a singluar value Parameters ---------- singular_value : int singular value to test Returns ------- dict : dict dictionary of (err var term,prediction_n...
python
{ "resource": "" }
q20019
ErrVar.I_minus_R
train
def I_minus_R(self,singular_value): """get I - R at singular value Parameters ---------- singular_value : int singular value to calc R at Returns ------- I - R : pyemu.Matrix identity matrix minus resolution matrix at singular_value ...
python
{ "resource": "" }
q20020
ErrVar.third_prediction
train
def third_prediction(self,singular_value): """get the omitted parameter contribution to prediction error variance at a singular value. used to construct error variance dataframe Parameters ---------- singular_value : int singular value to calc third term at ...
python
{ "resource": "" }
q20021
pp_file_to_dataframe
train
def pp_file_to_dataframe(pp_filename): """ read a pilot point file to a pandas Dataframe Parameters ---------- pp_filename : str pilot point file Returns ------- df : pandas.DataFrame a dataframe with pp_utils.PP_NAMES for columns """ df = pd.read_csv(pp_filename...
python
{ "resource": "" }
q20022
pp_tpl_to_dataframe
train
def pp_tpl_to_dataframe(tpl_filename): """ read a pilot points template file to a pandas dataframe Parameters ---------- tpl_filename : str pilot points template file Returns ------- df : pandas.DataFrame a dataframe with "parnme" included """ inlines = open(tpl_fi...
python
{ "resource": "" }
q20023
write_pp_shapfile
train
def write_pp_shapfile(pp_df,shapename=None): """write pilot points dataframe to a shapefile Parameters ---------- pp_df : pandas.DataFrame or str pilot point dataframe or a pilot point filename. Dataframe must include "x" and "y" shapename : str shapefile name. If None, pp...
python
{ "resource": "" }
q20024
write_pp_file
train
def write_pp_file(filename,pp_df): """write a pilot points dataframe to a pilot points file Parameters ---------- filename : str pilot points file to write pp_df : pandas.DataFrame a dataframe that has columns "x","y","zone", and "value" """ with open(filename,'w') as f: ...
python
{ "resource": "" }
q20025
pilot_points_to_tpl
train
def pilot_points_to_tpl(pp_file,tpl_file=None,name_prefix=None): """write a template file for a pilot points file Parameters ---------- pp_file : str pilot points file tpl_file : str template file name to write. If None, append ".tpl" to the pp_file arg. Default is None ...
python
{ "resource": "" }
q20026
run
train
def run(cmd_str,cwd='.',verbose=False): """ an OS agnostic function to execute command Parameters ---------- cmd_str : str the str to execute with os.system() cwd : str the directory to execute the command in verbose : bool flag to echo to stdout complete cmd str ...
python
{ "resource": "" }
q20027
condition_on_par_knowledge
train
def condition_on_par_knowledge(cov,par_knowledge_dict): """ experimental function to include conditional prior information for one or more parameters in a full covariance matrix """ missing = [] for parnme in par_knowledge_dict.keys(): if parnme not in cov.row_names: missing.ap...
python
{ "resource": "" }
q20028
kl_setup
train
def kl_setup(num_eig,sr,struct,prefixes, factors_file="kl_factors.dat",islog=True, basis_file=None, tpl_dir="."): """setup a karhuenen-Loeve based parameterization for a given geostatistical structure. Parameters ---------- num_eig : int number of basis vectors to ...
python
{ "resource": "" }
q20029
zero_order_tikhonov
train
def zero_order_tikhonov(pst, parbounds=True,par_groups=None, reset=True): """setup preferred-value regularization Parameters ---------- pst : pyemu.Pst the control file instance parbounds : bool flag to weight the prior information equations according ...
python
{ "resource": "" }
q20030
first_order_pearson_tikhonov
train
def first_order_pearson_tikhonov(pst,cov,reset=True,abs_drop_tol=1.0e-3): """setup preferred-difference regularization from a covariance matrix. The weights on the prior information equations are the Pearson correlation coefficients implied by covariance matrix. Parameters ---------- pst : pyem...
python
{ "resource": "" }
q20031
apply_array_pars
train
def apply_array_pars(arr_par_file="arr_pars.csv"): """ a function to apply array-based multipler parameters. Used to implement the parameterization constructed by PstFromFlopyModel during a forward run Parameters ---------- arr_par_file : str path to csv file detailing parameter array multipli...
python
{ "resource": "" }
q20032
PstFromFlopyModel.setup_sfr_obs
train
def setup_sfr_obs(self): """setup sfr ASCII observations""" if not self.sfr_obs: return if self.m.sfr is None: self.logger.lraise("no sfr package found...") org_sfr_out_file = os.path.join(self.org_model_ws,"{0}.sfr.out".format(self.m.name)) if not os.pat...
python
{ "resource": "" }
q20033
PstFromFlopyModel.setup_mult_dirs
train
def setup_mult_dirs(self): """ setup the directories to use for multiplier parameterization. Directories are make within the PstFromFlopyModel.m.model_ws directory """ # setup dirs to hold the original and multiplier model input quantities set_dirs = [] # if len(self.pp_...
python
{ "resource": "" }
q20034
PstFromFlopyModel.setup_model
train
def setup_model(self,model,org_model_ws,new_model_ws): """ setup the flopy.mbase instance for use with multipler parameters. Changes model_ws, sets external_path and writes new MODFLOW input files Parameters ---------- model : flopy.mbase flopy model instance...
python
{ "resource": "" }
q20035
PstFromFlopyModel.get_count
train
def get_count(self,name): """ get the latest counter for a certain parameter type. Parameters ---------- name : str the parameter type Returns ------- count : int the latest count for a parameter type Note ---- ca...
python
{ "resource": "" }
q20036
PstFromFlopyModel.write_u2d
train
def write_u2d(self, u2d): """ write a flopy.utils.Util2D instance to an ASCII text file using the Util2D filename Parameters ---------- u2d : flopy.utils.Util2D Returns ------- filename : str the name of the file written (without path) ...
python
{ "resource": "" }
q20037
PstFromFlopyModel.write_grid_tpl
train
def write_grid_tpl(self,name,tpl_file,zn_array): """ write a template file a for grid-based multiplier parameters Parameters ---------- name : str the base parameter name tpl_file : str the template file to write zn_array : numpy.ndarray ...
python
{ "resource": "" }
q20038
PstFromFlopyModel.grid_prep
train
def grid_prep(self): """ prepare grid-based parameterizations """ if len(self.grid_props) == 0: return if self.grid_geostruct is None: self.logger.warn("grid_geostruct is None,"\ " using ExpVario with contribution=1 and a=(max(delc,delr)*10") ...
python
{ "resource": "" }
q20039
PstFromFlopyModel.kl_prep
train
def kl_prep(self,mlt_df): """ prepare KL based parameterizations Parameters ---------- mlt_df : pandas.DataFrame a dataframe with multiplier array information Note ---- calls pyemu.helpers.setup_kl() """ if len(self.kl_props) == 0: ...
python
{ "resource": "" }
q20040
PstFromFlopyModel.setup_observations
train
def setup_observations(self): """ main entry point for setting up observations """ obs_methods = [self.setup_water_budget_obs,self.setup_hyd, self.setup_smp,self.setup_hob,self.setup_hds, self.setup_sfr_obs] obs_types = ["mflist water budget...
python
{ "resource": "" }
q20041
PstFromFlopyModel.draw
train
def draw(self, num_reals=100, sigma_range=6): """ draw like a boss! Parameters ---------- num_reals : int number of realizations to generate. Default is 100 sigma_range : float number of standard deviations represented by the parameter bou...
python
{ "resource": "" }
q20042
PstFromFlopyModel.write_forward_run
train
def write_forward_run(self): """ write the forward run script forward_run.py """ with open(os.path.join(self.m.model_ws,self.forward_run_file),'w') as f: f.write("import os\nimport numpy as np\nimport pandas as pd\nimport flopy\n") f.write("import pyemu\n") f...
python
{ "resource": "" }
q20043
PstFromFlopyModel.parse_k
train
def parse_k(self,k,vals): """ parse the iterable from a property or boundary condition argument Parameters ---------- k : int or iterable int the iterable vals : iterable of ints the acceptable values that k may contain Returns ------- ...
python
{ "resource": "" }
q20044
PstFromFlopyModel.parse_pakattr
train
def parse_pakattr(self,pakattr): """ parse package-iterable pairs from a property or boundary condition argument Parameters ---------- pakattr : iterable len 2 Returns ------- pak : flopy.PakBase the flopy package from the model instance ...
python
{ "resource": "" }
q20045
PstFromFlopyModel.setup_list_pars
train
def setup_list_pars(self): """ main entry point for setting up list multiplier parameters """ tdf = self.setup_temporal_list_pars() sdf = self.setup_spatial_list_pars() if tdf is None and sdf is None: return os.chdir(self.m.model_ws) ...
python
{ "resource": "" }
q20046
PstFromFlopyModel.list_helper
train
def list_helper(self,k,pak,attr,col): """ helper to setup list multiplier parameters for a given k, pak, attr set. Parameters ---------- k : int or iterable of int the zero-based stress period indices pak : flopy.PakBase= the MODFLOW package ...
python
{ "resource": "" }
q20047
PstFromFlopyModel.setup_smp
train
def setup_smp(self): """ setup observations from PEST-style SMP file pairs """ if self.obssim_smp_pairs is None: return if len(self.obssim_smp_pairs) == 2: if isinstance(self.obssim_smp_pairs[0],str): self.obssim_smp_pairs = [self.obssim_smp_pairs...
python
{ "resource": "" }
q20048
PstFromFlopyModel.setup_hob
train
def setup_hob(self): """ setup observations from the MODFLOW HOB package """ if self.m.hob is None: return hob_out_unit = self.m.hob.iuhobsv new_hob_out_fname = os.path.join(self.m.model_ws,self.m.get_output_attribute(unit=hob_out_unit)) org_hob_out_fname =...
python
{ "resource": "" }
q20049
PstFromFlopyModel.setup_hyd
train
def setup_hyd(self): """ setup observations from the MODFLOW HYDMOD package """ if self.m.hyd is None: return if self.mfhyd: org_hyd_out = os.path.join(self.org_model_ws,self.m.name+".hyd.bin") if not os.path.exists(org_hyd_out): self...
python
{ "resource": "" }
q20050
PstFromFlopyModel.setup_water_budget_obs
train
def setup_water_budget_obs(self): """ setup observations from the MODFLOW list file for volume and flux water buget information """ if self.mflist_waterbudget: org_listfile = os.path.join(self.org_model_ws,self.m.lst.file_name[0]) if os.path.exists(org_listfile):...
python
{ "resource": "" }
q20051
read_resfile
train
def read_resfile(resfile): """load a residual file into a pandas.DataFrame Parameters ---------- resfile : str residual file name Returns ------- pandas.DataFrame : pandas.DataFrame """ assert os.path.exists(resfile),"read_resfile() ...
python
{ "resource": "" }
q20052
res_from_en
train
def res_from_en(pst,enfile): """load ensemble file for residual into a pandas.DataFrame Parameters ---------- enfile : str ensemble file name Returns ------- pandas.DataFrame : pandas.DataFrame """ converters = {"name": str_con, "group": str...
python
{ "resource": "" }
q20053
read_parfile
train
def read_parfile(parfile): """load a pest-compatible .par file into a pandas.DataFrame Parameters ---------- parfile : str pest parameter file name Returns ------- pandas.DataFrame : pandas.DataFrame """ assert os.path.exists(parfile), "Pst.parrep(): parfile not found: " +...
python
{ "resource": "" }
q20054
write_parfile
train
def write_parfile(df,parfile): """ write a pest parameter file from a dataframe Parameters ---------- df : (pandas.DataFrame) dataframe with column names that correspond to the entries in the parameter data section of a pest control file parfile : str name of the parameter f...
python
{ "resource": "" }
q20055
parse_tpl_file
train
def parse_tpl_file(tpl_file): """ parse a pest template file to get the parameter names Parameters ---------- tpl_file : str template file name Returns ------- par_names : list list of parameter names """ par_names = set() with open(tpl_file,'r') as f: ...
python
{ "resource": "" }
q20056
write_to_template
train
def write_to_template(parvals,tpl_file,in_file): """ write parameter values to model input files using template files Parameters ---------- parvals : dict or pandas.Series a way to look up parameter values using parameter names tpl_file : str template file in_file : str ...
python
{ "resource": "" }
q20057
parse_ins_file
train
def parse_ins_file(ins_file): """parse a pest instruction file to get observation names Parameters ---------- ins_file : str instruction file name Returns ------- list of observation names """ obs_names = [] with open(ins_file,'r') as f: header = f.readline()....
python
{ "resource": "" }
q20058
parse_ins_string
train
def parse_ins_string(string): """ split up an instruction file line to get the observation names Parameters ---------- string : str instruction file line Returns ------- obs_names : list list of observation names """ istart_markers = ["[","(","!"] iend_markers ...
python
{ "resource": "" }
q20059
populate_dataframe
train
def populate_dataframe(index,columns, default_dict, dtype): """ helper function to populate a generic Pst dataframe attribute. This function is called as part of constructing a generic Pst instance Parameters ---------- index : (varies) something to use as the dataframe index columns: ...
python
{ "resource": "" }
q20060
generic_pst
train
def generic_pst(par_names=["par1"],obs_names=["obs1"],addreg=False): """generate a generic pst instance. This can used to later fill in the Pst parts programatically. Parameters ---------- par_names : (list) parameter names to setup obs_names : (list) observation names to setup...
python
{ "resource": "" }
q20061
try_run_inschek
train
def try_run_inschek(pst): """ attempt to run INSCHEK for each instruction file, model output file pair in a pyemu.Pst. If the run is successful, the INSCHEK written .obf file is used to populate the pst.observation_data.obsval attribute Parameters ---------- pst : (pyemu.Pst) """ for ...
python
{ "resource": "" }
q20062
get_phi_comps_from_recfile
train
def get_phi_comps_from_recfile(recfile): """read the phi components from a record file by iteration Parameters ---------- recfile : str pest record file name Returns ------- iters : dict nested dictionary of iteration number, {group,contribution} """ iiter = 1 ...
python
{ "resource": "" }
q20063
res_from_obseravtion_data
train
def res_from_obseravtion_data(observation_data): """create a generic residual dataframe filled with np.NaN for missing information Parameters ---------- observation_data : pandas.DataFrame pyemu.Pst.observation_data Returns ------- res_df : pandas.DataFrame """ res_df ...
python
{ "resource": "" }
q20064
clean_missing_exponent
train
def clean_missing_exponent(pst_filename,clean_filename="clean.pst"): """fixes the issue where some terrible fortran program may have written a floating point format without the 'e' - like 1.0-3, really?! Parameters ---------- pst_filename : str the pest control file clean_filename : str...
python
{ "resource": "" }
q20065
Pst.phi
train
def phi(self): """get the weighted total objective function Returns ------- phi : float sum of squared residuals """ sum = 0.0 for grp, contrib in self.phi_components.items(): sum += contrib return sum
python
{ "resource": "" }
q20066
Pst.phi_components
train
def phi_components(self): """ get the individual components of the total objective function Returns ------- dict : dict dictionary of observation group, contribution to total phi Raises ------ Assertion error if Pst.observation_data groups don't matc...
python
{ "resource": "" }
q20067
Pst.phi_components_normalized
train
def phi_components_normalized(self): """ get the individual components of the total objective function normalized to the total PHI being 1.0 Returns ------- dict : dict dictionary of observation group, normalized contribution to total phi Raises ...
python
{ "resource": "" }
q20068
Pst.set_res
train
def set_res(self,res): """ reset the private Pst.res attribute Parameters ---------- res : (varies) something to use as Pst.res attribute """ if isinstance(res,str): res = pst_utils.read_resfile(res) self.__res = res
python
{ "resource": "" }
q20069
Pst.res
train
def res(self): """get the residuals dataframe attribute Returns ------- res : pandas.DataFrame Note ---- if the Pst.__res attribute has not been loaded, this call loads the res dataframe from a file """ if self.__res is not None: ...
python
{ "resource": "" }
q20070
Pst.nprior
train
def nprior(self): """number of prior information equations Returns ------- nprior : int the number of prior info equations """ self.control_data.nprior = self.prior_information.shape[0] return self.control_data.nprior
python
{ "resource": "" }
q20071
Pst.nnz_obs
train
def nnz_obs(self): """ get the number of non-zero weighted observations Returns ------- nnz_obs : int the number of non-zeros weighted observations """ nnz = 0 for w in self.observation_data.weight: if w > 0.0: nnz += 1 ...
python
{ "resource": "" }
q20072
Pst.nobs
train
def nobs(self): """get the number of observations Returns ------- nobs : int the number of observations """ self.control_data.nobs = self.observation_data.shape[0] return self.control_data.nobs
python
{ "resource": "" }
q20073
Pst.npar
train
def npar(self): """get number of parameters Returns ------- npar : int the number of parameters """ self.control_data.npar = self.parameter_data.shape[0] return self.control_data.npar
python
{ "resource": "" }
q20074
Pst.pars_in_groups
train
def pars_in_groups(self): """ return a dictionary of parameter names in each parameter group. Returns: dictionary """ pargp = self.par_groups allpars = dict() for cpg in pargp: allpars[cpg] = [i for i in self.parameter_data.loc[self.param...
python
{ "resource": "" }
q20075
Pst.obs_groups
train
def obs_groups(self): """get the observation groups Returns ------- obs_groups : list a list of unique observation groups """ og = list(self.observation_data.groupby("obgnme").groups.keys()) #og = list(map(pst_utils.SFMT, og)) return og
python
{ "resource": "" }
q20076
Pst.nnz_obs_groups
train
def nnz_obs_groups(self): """ get the observation groups that contain at least one non-zero weighted observation Returns ------- nnz_obs_groups : list a list of observation groups that contain at least one non-zero weighted observation """ ...
python
{ "resource": "" }
q20077
Pst.adj_par_groups
train
def adj_par_groups(self): """get the parameter groups with atleast one adjustable parameter Returns ------- adj_par_groups : list a list of parameter groups with at least one adjustable parameter """ adj_pargp = [] for pargp in self.par_groups: ...
python
{ "resource": "" }
q20078
Pst.prior_groups
train
def prior_groups(self): """get the prior info groups Returns ------- prior_groups : list a list of prior information groups """ og = list(self.prior_information.groupby("obgnme").groups.keys()) #og = list(map(pst_utils.SFMT, og)) return og
python
{ "resource": "" }
q20079
Pst.prior_names
train
def prior_names(self): """ get the prior information names Returns ------- prior_names : list a list of prior information names """ return list(self.prior_information.groupby( self.prior_information.index).groups.keys())
python
{ "resource": "" }
q20080
Pst.nnz_obs_names
train
def nnz_obs_names(self): """get the non-zero weight observation names Returns ------- nnz_obs_names : list a list of non-zero weighted observation names """ # nz_names = [] # for w,n in zip(self.observation_data.weight, # self....
python
{ "resource": "" }
q20081
Pst.zero_weight_obs_names
train
def zero_weight_obs_names(self): """ get the zero-weighted observation names Returns ------- zero_weight_obs_names : list a list of zero-weighted observation names """ self.observation_data.index = self.observation_data.obsnme groups = self.observa...
python
{ "resource": "" }
q20082
Pst._read_df
train
def _read_df(f,nrows,names,converters,defaults=None): """ a private method to read part of an open file into a pandas.DataFrame. Parameters ---------- f : file object nrows : int number of rows to read names : list names to set the columns of the ...
python
{ "resource": "" }
q20083
Pst.rectify_pgroups
train
def rectify_pgroups(self): """ private method to synchronize parameter groups section with the parameter data section """ # add any parameters groups pdata_groups = list(self.parameter_data.loc[:,"pargp"].\ value_counts().keys()) #print(pdata_groups) ...
python
{ "resource": "" }
q20084
Pst._parse_pi_par_names
train
def _parse_pi_par_names(self): """ private method to get the parameter names from prior information equations. Sets a 'names' column in Pst.prior_information that is a list of parameter names """ if self.prior_information.shape[0] == 0: return if "names" in...
python
{ "resource": "" }
q20085
Pst.add_pi_equation
train
def add_pi_equation(self,par_names,pilbl=None,rhs=0.0,weight=1.0, obs_group="pi_obgnme",coef_dict={}): """ a helper to construct a new prior information equation. Parameters ---------- par_names : list parameter names in the equation pilbl : s...
python
{ "resource": "" }
q20086
Pst.write
train
def write(self,new_filename,update_regul=True,version=None): """main entry point to write a pest control file. Parameters ---------- new_filename : str name of the new pest control file update_regul : (boolean) flag to update zero-order Tikhonov prior in...
python
{ "resource": "" }
q20087
Pst.parrep
train
def parrep(self, parfile=None,enforce_bounds=True): """replicates the pest parrep util. replaces the parval1 field in the parameter data section dataframe Parameters ---------- parfile : str parameter file to use. If None, try to use a parameter file...
python
{ "resource": "" }
q20088
Pst.adjust_weights_recfile
train
def adjust_weights_recfile(self, recfile=None,original_ceiling=True): """adjusts the weights by group of the observations based on the phi components in a pest record file so that total phi is equal to the number of non-zero weighted observations Parameters ---------- re...
python
{ "resource": "" }
q20089
Pst.adjust_weights_resfile
train
def adjust_weights_resfile(self, resfile=None,original_ceiling=True): """adjusts the weights by group of the observations based on the phi components in a pest residual file so that total phi is equal to the number of non-zero weighted observations Parameters ---------- ...
python
{ "resource": "" }
q20090
Pst.adjust_weights_discrepancy
train
def adjust_weights_discrepancy(self, resfile=None,original_ceiling=True): """adjusts the weights of each non-zero weight observation based on the residual in the pest residual file so each observations contribution to phi is 1.0 Parameters ---------- resfile : str ...
python
{ "resource": "" }
q20091
Pst._adjust_weights_by_phi_components
train
def _adjust_weights_by_phi_components(self, components,original_ceiling): """resets the weights of observations by group to account for residual phi components. Parameters ---------- components : dict a dictionary of obs group:phi contribution pairs original_...
python
{ "resource": "" }
q20092
Pst.__reset_weights
train
def __reset_weights(self, target_phis, res_idxs, obs_idxs): """private method to reset weights based on target phi values for each group. This method should not be called directly Parameters ---------- target_phis : dict target phi contribution for groups to reweigh...
python
{ "resource": "" }
q20093
Pst.adjust_weights
train
def adjust_weights(self,obs_dict=None, obsgrp_dict=None): """reset the weights of observation groups to contribute a specified amount to the composite objective function Parameters ---------- obs_dict : dict dictionary of obs name,new co...
python
{ "resource": "" }
q20094
Pst.proportional_weights
train
def proportional_weights(self, fraction_stdev=1.0, wmax=100.0, leave_zero=True): """setup weights inversely proportional to the observation value Parameters ---------- fraction_stdev : float the fraction portion of the observation va...
python
{ "resource": "" }
q20095
Pst.calculate_pertubations
train
def calculate_pertubations(self): """ experimental method to calculate finite difference parameter pertubations. The pertubation values are added to the Pst.parameter_data attribute Note ---- user beware! """ self.build_increments() self.paramet...
python
{ "resource": "" }
q20096
Pst.build_increments
train
def build_increments(self): """ experimental method to calculate parameter increments for use in the finite difference pertubation calculations Note ---- user beware! """ self.enforce_bounds() self.add_transform_columns() par_groups = self.parame...
python
{ "resource": "" }
q20097
Pst.add_transform_columns
train
def add_transform_columns(self): """ add transformed values to the Pst.parameter_data attribute """ for col in ["parval1","parlbnd","parubnd","increment"]: if col not in self.parameter_data.columns: continue self.parameter_data.loc[:,col+"_trans"] = (self...
python
{ "resource": "" }
q20098
Pst.enforce_bounds
train
def enforce_bounds(self): """ enforce bounds violation resulting from the parameter pertubation calculations """ too_big = self.parameter_data.loc[:,"parval1"] > \ self.parameter_data.loc[:,"parubnd"] self.parameter_data.loc[too_big,"parval1"] = \ self.pa...
python
{ "resource": "" }
q20099
Pst.from_io_files
train
def from_io_files(cls,tpl_files,in_files,ins_files,out_files,pst_filename=None): """ create a Pst instance from model interface files. Assigns generic values for parameter info. Tries to use INSCHEK to set somewhat meaningful observation values Parameters ---------- tpl...
python
{ "resource": "" }