idx
int64
0
63k
question
stringlengths
61
4.03k
target
stringlengths
6
1.23k
400
def get_submask ( self , * args , ** kwargs ) -> masktools . CustomMask : if args or kwargs : masks = self . availablemasks mask = masktools . CustomMask ( numpy . full ( self . shape , False ) ) for arg in args : mask = mask + self . _prepare_mask ( arg , masks ) for key , value in kwargs . items ( ) : mask = mask + s...
Get a sub - mask of the mask handled by the actual |Variable| object based on the given arguments .
401
def commentrepr ( self ) -> List [ str ] : if hydpy . pub . options . reprcomments : return [ f'# {line}' for line in textwrap . wrap ( objecttools . description ( self ) , 72 ) ] return [ ]
A list with comments for making string representations more informative .
402
def get_controlfileheader ( model : Union [ str , 'modeltools.Model' ] , parameterstep : timetools . PeriodConstrArg = None , simulationstep : timetools . PeriodConstrArg = None ) -> str : with Parameter . parameterstep ( parameterstep ) : if simulationstep is None : simulationstep = Parameter . simulationstep else : s...
Return the header of a regular or auxiliary parameter control file .
403
def update ( self ) -> None : for subpars in self . secondary_subpars : for par in subpars : try : par . update ( ) except BaseException : objecttools . augment_excmessage ( f'While trying to update parameter ' f'`{objecttools.elementphrase(par)}`' )
Call method |Parameter . update| of all secondary parameters .
404
def save_controls ( self , filepath : Optional [ str ] = None , parameterstep : timetools . PeriodConstrArg = None , simulationstep : timetools . PeriodConstrArg = None , auxfiler : 'auxfiletools.Auxfiler' = None ) : if self . control : variable2auxfile = getattr ( auxfiler , str ( self . model ) , None ) lines = [ get...
Write the control parameters to file .
405
def _get_values_from_auxiliaryfile ( self , auxfile ) : try : frame = inspect . currentframe ( ) . f_back . f_back while frame : namespace = frame . f_locals try : subnamespace = { 'model' : namespace [ 'model' ] , 'focus' : self } break except KeyError : frame = frame . f_back else : raise RuntimeError ( 'Cannot deter...
Try to return the parameter values from the auxiliary control file with the given name .
406
def initinfo ( self ) -> Tuple [ Union [ float , int , bool ] , bool ] : init = self . INIT if ( init is not None ) and hydpy . pub . options . usedefaultvalues : with Parameter . parameterstep ( '1d' ) : return self . apply_timefactor ( init ) , True return variabletools . TYPE2MISSINGVALUE [ self . TYPE ] , False
The actual initial value of the given parameter .
407
def get_timefactor ( cls ) -> float : try : parfactor = hydpy . pub . timegrids . parfactor except RuntimeError : if not ( cls . parameterstep and cls . simulationstep ) : raise RuntimeError ( f'To calculate the conversion factor for adapting ' f'the values of the time-dependent parameters, ' f'you need to define both ...
Factor to adjust a new value of a time - dependent parameter .
408
def revert_timefactor ( cls , values ) : if cls . TIME is True : return values / cls . get_timefactor ( ) if cls . TIME is False : return values * cls . get_timefactor ( ) return values
The inverse version of method |Parameter . apply_timefactor| .
409
def compress_repr ( self ) -> Optional [ str ] : if not hasattr ( self , 'value' ) : return '?' if not self : return f"{self.NDIM * '['}{self.NDIM * ']'}" unique = numpy . unique ( self [ self . mask ] ) if sum ( numpy . isnan ( unique ) ) == len ( unique . flatten ( ) ) : unique = numpy . array ( [ numpy . nan ] ) els...
Try to find a compressed parameter value representation and return it .
410
def refresh ( self ) -> None : if not self : self . values [ : ] = 0. elif len ( self ) == 1 : values = list ( self . _toy2values . values ( ) ) [ 0 ] self . values [ : ] = self . apply_timefactor ( values ) else : for idx , date in enumerate ( timetools . TOY . centred_timegrid ( self . simulationstep ) ) : values = s...
Update the actual simulation values based on the toy - value pairs .
411
def interp ( self , date : timetools . Date ) -> float : xnew = timetools . TOY ( date ) xys = list ( self ) for idx , ( x_1 , y_1 ) in enumerate ( xys ) : if x_1 > xnew : x_0 , y_0 = xys [ idx - 1 ] break else : x_0 , y_0 = xys [ - 1 ] x_1 , y_1 = xys [ 0 ] return y_0 + ( y_1 - y_0 ) / ( x_1 - x_0 ) * ( xnew - x_0 )
Perform a linear value interpolation for the given date and return the result .
412
def update ( self ) -> None : mask = self . mask weights = self . refweights [ mask ] self [ ~ mask ] = numpy . nan self [ mask ] = weights / numpy . sum ( weights )
Update subclass of |RelSubweightsMixin| based on refweights .
413
def alternative_initvalue ( self ) -> Union [ bool , int , float ] : if self . _alternative_initvalue is None : raise AttributeError ( f'No alternative initial value for solver parameter ' f'{objecttools.elementphrase(self)} has been defined so far.' ) else : return self . _alternative_initvalue
A user - defined value to be used instead of the value of class constant INIT .
414
def update ( self ) -> None : indexarray = hydpy . pub . indexer . timeofyear self . shape = indexarray . shape self . values = indexarray
Reference the actual |Indexer . timeofyear| array of the |Indexer| object available in module |pub| .
415
def get_premises_model ( ) : try : app_label , model_name = PREMISES_MODEL . split ( '.' ) except ValueError : raise ImproperlyConfigured ( "OPENINGHOURS_PREMISES_MODEL must be of the" " form 'app_label.model_name'" ) premises_model = get_model ( app_label = app_label , model_name = model_name ) if premises_model is No...
Support for custom company premises model with developer friendly validation .
416
def get_now ( ) : if not get_current_request : return datetime . datetime . now ( ) request = get_current_request ( ) if request : openinghours_now = request . GET . get ( 'openinghours-now' ) if openinghours_now : return datetime . datetime . strptime ( openinghours_now , '%Y%m%d%H%M%S' ) return datetime . datetime . ...
Allows to access global request and read a timestamp from query .
417
def get_closing_rule_for_now ( location ) : now = get_now ( ) if location : return ClosingRules . objects . filter ( company = location , start__lte = now , end__gte = now ) return Company . objects . first ( ) . closingrules_set . filter ( start__lte = now , end__gte = now )
Returns QuerySet of ClosingRules that are currently valid
418
def is_open ( location , now = None ) : if now is None : now = get_now ( ) if has_closing_rule_for_now ( location ) : return False now_time = datetime . time ( now . hour , now . minute , now . second ) if location : ohs = OpeningHours . objects . filter ( company = location ) else : ohs = Company . objects . first ( )...
Is the company currently open? Pass now to test with a specific timestamp . Can be used stand - alone or as a helper .
419
def refweights ( self ) : return numpy . full ( self . shape , 1. / self . shape [ 0 ] , dtype = float )
A |numpy| |numpy . ndarray| with equal weights for all segment junctions ..
420
def add ( self , directory , path = None ) -> None : objecttools . valid_variable_identifier ( directory ) if path is None : path = directory setattr ( self , directory , path )
Add a directory and optionally its path .
421
def basepath ( self ) -> str : return os . path . abspath ( os . path . join ( self . projectdir , self . BASEDIR ) )
Absolute path pointing to the available working directories .
422
def availabledirs ( self ) -> Folder2Path : directories = Folder2Path ( ) for directory in os . listdir ( self . basepath ) : if not directory . startswith ( '_' ) : path = os . path . join ( self . basepath , directory ) if os . path . isdir ( path ) : directories . add ( directory , path ) elif directory . endswith (...
Names and paths of the available working directories .
423
def currentdir ( self ) -> str : if self . _currentdir is None : directories = self . availabledirs . folders if len ( directories ) == 1 : self . currentdir = directories [ 0 ] elif self . DEFAULTDIR in directories : self . currentdir = self . DEFAULTDIR else : prefix = ( f'The current working directory of the ' f'{ob...
Name of the current working directory containing the relevant files .
424
def currentpath ( self ) -> str : return os . path . join ( self . basepath , self . currentdir )
Absolute path of the current working directory .
425
def filenames ( self ) -> List [ str ] : return sorted ( fn for fn in os . listdir ( self . currentpath ) if not fn . startswith ( '_' ) )
Names of the files contained in the the current working directory .
426
def filepaths ( self ) -> List [ str ] : path = self . currentpath return [ os . path . join ( path , name ) for name in self . filenames ]
Absolute path names of the files contained in the current working directory .
427
def zip_currentdir ( self ) -> None : with zipfile . ZipFile ( f'{self.currentpath}.zip' , 'w' ) as zipfile_ : for filepath , filename in zip ( self . filepaths , self . filenames ) : zipfile_ . write ( filename = filepath , arcname = filename ) del self . currentdir
Pack the current working directory in a zip file .
428
def load_files ( self ) -> selectiontools . Selections : devicetools . Node . clear_all ( ) devicetools . Element . clear_all ( ) selections = selectiontools . Selections ( ) for ( filename , path ) in zip ( self . filenames , self . filepaths ) : devicetools . Node . extract_new ( ) devicetools . Element . extract_new...
Read all network files of the current working directory structure their contents in a |selectiontools . Selections| object and return it .
429
def save_files ( self , selections ) -> None : try : currentpath = self . currentpath selections = selectiontools . Selections ( selections ) for selection in selections : if selection . name == 'complete' : continue path = os . path . join ( currentpath , selection . name + '.py' ) selection . save_networkfile ( filep...
Save the |Selection| objects contained in the given |Selections| instance to separate network files .
430
def save_file ( self , filename , text ) : if not filename . endswith ( '.py' ) : filename += '.py' path = os . path . join ( self . currentpath , filename ) with open ( path , 'w' , encoding = "utf-8" ) as file_ : file_ . write ( text )
Save the given text under the given control filename and the current path .
431
def load_file ( self , filename ) : _defaultdir = self . DEFAULTDIR try : if not filename . endswith ( '.py' ) : filename += '.py' try : self . DEFAULTDIR = ( 'init_' + hydpy . pub . timegrids . sim . firstdate . to_string ( 'os' ) ) except KeyError : pass filepath = os . path . join ( self . currentpath , filename ) w...
Read and return the content of the given file .
432
def save_file ( self , filename , text ) : _defaultdir = self . DEFAULTDIR try : if not filename . endswith ( '.py' ) : filename += '.py' try : self . DEFAULTDIR = ( 'init_' + hydpy . pub . timegrids . sim . lastdate . to_string ( 'os' ) ) except AttributeError : pass path = os . path . join ( self . currentpath , file...
Save the given text under the given condition filename and the current path .
433
def load_file ( self , sequence ) : try : if sequence . filetype_ext == 'npy' : sequence . series = sequence . adjust_series ( * self . _load_npy ( sequence ) ) elif sequence . filetype_ext == 'asc' : sequence . series = sequence . adjust_series ( * self . _load_asc ( sequence ) ) elif sequence . filetype_ext == 'nc' :...
Load data from an external data file an pass it to the given |IOSequence| .
434
def save_file ( self , sequence , array = None ) : if array is None : array = sequence . aggregate_series ( ) try : if sequence . filetype_ext == 'nc' : self . _save_nc ( sequence , array ) else : filepath = sequence . filepath_ext if ( ( array is not None ) and ( array . info [ 'type' ] != 'unmodified' ) ) : filepath ...
Write the date stored in |IOSequence . series| of the given |IOSequence| into an external data file .
435
def open_netcdf_reader ( self , flatten = False , isolate = False , timeaxis = 1 ) : self . _netcdf_reader = netcdftools . NetCDFInterface ( flatten = bool ( flatten ) , isolate = bool ( isolate ) , timeaxis = int ( timeaxis ) )
Prepare a new |NetCDFInterface| object for reading data .
436
def open_netcdf_writer ( self , flatten = False , isolate = False , timeaxis = 1 ) : self . _netcdf_writer = netcdftools . NetCDFInterface ( flatten = bool ( flatten ) , isolate = bool ( isolate ) , timeaxis = int ( timeaxis ) )
Prepare a new |NetCDFInterface| object for writing data .
437
def calc_nkor_v1 ( self ) : con = self . parameters . control . fastaccess inp = self . sequences . inputs . fastaccess flu = self . sequences . fluxes . fastaccess for k in range ( con . nhru ) : flu . nkor [ k ] = con . kg [ k ] * inp . nied
Adjust the given precipitation values .
438
def calc_tkor_v1 ( self ) : con = self . parameters . control . fastaccess inp = self . sequences . inputs . fastaccess flu = self . sequences . fluxes . fastaccess for k in range ( con . nhru ) : flu . tkor [ k ] = con . kt [ k ] + inp . teml
Adjust the given air temperature values .
439
def calc_et0_v1 ( self ) : con = self . parameters . control . fastaccess inp = self . sequences . inputs . fastaccess flu = self . sequences . fluxes . fastaccess for k in range ( con . nhru ) : flu . et0 [ k ] = ( con . ke [ k ] * ( ( ( 8.64 * inp . glob + 93. * con . kf [ k ] ) * ( flu . tkor [ k ] + 22. ) ) / ( 165...
Calculate reference evapotranspiration after Turc - Wendling .
440
def calc_et0_wet0_v1 ( self ) : con = self . parameters . control . fastaccess inp = self . sequences . inputs . fastaccess flu = self . sequences . fluxes . fastaccess log = self . sequences . logs . fastaccess for k in range ( con . nhru ) : flu . et0 [ k ] = ( con . wfet0 [ k ] * con . ke [ k ] * inp . pet + ( 1. - ...
Correct the given reference evapotranspiration and update the corresponding log sequence .
441
def calc_evpo_v1 ( self ) : con = self . parameters . control . fastaccess der = self . parameters . derived . fastaccess flu = self . sequences . fluxes . fastaccess for k in range ( con . nhru ) : flu . evpo [ k ] = con . fln [ con . lnk [ k ] - 1 , der . moy [ self . idx_sim ] ] * flu . et0 [ k ]
Calculate land use and month specific values of potential evapotranspiration .
442
def calc_nbes_inzp_v1 ( self ) : con = self . parameters . control . fastaccess der = self . parameters . derived . fastaccess flu = self . sequences . fluxes . fastaccess sta = self . sequences . states . fastaccess for k in range ( con . nhru ) : if con . lnk [ k ] in ( WASSER , FLUSS , SEE ) : flu . nbes [ k ] = 0. ...
Calculate stand precipitation and update the interception storage accordingly .
443
def calc_sbes_v1 ( self ) : con = self . parameters . control . fastaccess flu = self . sequences . fluxes . fastaccess for k in range ( con . nhru ) : if flu . nbes [ k ] <= 0. : flu . sbes [ k ] = 0. elif flu . tkor [ k ] >= ( con . tgr [ k ] + con . tsp [ k ] / 2. ) : flu . sbes [ k ] = 0. elif flu . tkor [ k ] <= (...
Calculate the frozen part of stand precipitation .
444
def calc_wgtf_v1 ( self ) : con = self . parameters . control . fastaccess flu = self . sequences . fluxes . fastaccess for k in range ( con . nhru ) : if con . lnk [ k ] in ( WASSER , FLUSS , SEE ) : flu . wgtf [ k ] = 0. else : flu . wgtf [ k ] = ( max ( con . gtf [ k ] * ( flu . tkor [ k ] - con . treft [ k ] ) , 0 ...
Calculate the potential snowmelt .
445
def calc_schm_wats_v1 ( self ) : con = self . parameters . control . fastaccess flu = self . sequences . fluxes . fastaccess sta = self . sequences . states . fastaccess for k in range ( con . nhru ) : if con . lnk [ k ] in ( WASSER , FLUSS , SEE ) : sta . wats [ k ] = 0. flu . schm [ k ] = 0. else : sta . wats [ k ] +...
Calculate the actual amount of water melting within the snow cover .
446
def calc_qbb_v1 ( self ) : con = self . parameters . control . fastaccess der = self . parameters . derived . fastaccess flu = self . sequences . fluxes . fastaccess sta = self . sequences . states . fastaccess for k in range ( con . nhru ) : if ( ( con . lnk [ k ] in ( VERS , WASSER , FLUSS , SEE ) ) or ( sta . bowa [...
Calculate the amount of base flow released from the soil .
447
def calc_qdb_v1 ( self ) : con = self . parameters . control . fastaccess flu = self . sequences . fluxes . fastaccess sta = self . sequences . states . fastaccess aid = self . sequences . aides . fastaccess for k in range ( con . nhru ) : if con . lnk [ k ] == WASSER : flu . qdb [ k ] = 0. elif ( ( con . lnk [ k ] in ...
Calculate direct runoff released from the soil .
448
def calc_bowa_v1 ( self ) : con = self . parameters . control . fastaccess flu = self . sequences . fluxes . fastaccess sta = self . sequences . states . fastaccess aid = self . sequences . aides . fastaccess for k in range ( con . nhru ) : if con . lnk [ k ] in ( VERS , WASSER , FLUSS , SEE ) : sta . bowa [ k ] = 0. e...
Update soil moisture and correct fluxes if necessary .
449
def calc_qbgz_v1 ( self ) : con = self . parameters . control . fastaccess flu = self . sequences . fluxes . fastaccess sta = self . sequences . states . fastaccess sta . qbgz = 0. for k in range ( con . nhru ) : if con . lnk [ k ] == SEE : sta . qbgz += con . fhru [ k ] * ( flu . nkor [ k ] - flu . evi [ k ] ) elif co...
Aggregate the amount of base flow released by all soil type HRUs and the net precipitation above water areas of type |SEE| .
450
def calc_qigz1_v1 ( self ) : con = self . parameters . control . fastaccess flu = self . sequences . fluxes . fastaccess sta = self . sequences . states . fastaccess sta . qigz1 = 0. for k in range ( con . nhru ) : sta . qigz1 += con . fhru [ k ] * flu . qib1 [ k ]
Aggregate the amount of the first interflow component released by all HRUs .
451
def calc_qigz2_v1 ( self ) : con = self . parameters . control . fastaccess flu = self . sequences . fluxes . fastaccess sta = self . sequences . states . fastaccess sta . qigz2 = 0. for k in range ( con . nhru ) : sta . qigz2 += con . fhru [ k ] * flu . qib2 [ k ]
Aggregate the amount of the second interflow component released by all HRUs .
452
def calc_qdgz_v1 ( self ) : con = self . parameters . control . fastaccess flu = self . sequences . fluxes . fastaccess flu . qdgz = 0. for k in range ( con . nhru ) : if con . lnk [ k ] == FLUSS : flu . qdgz += con . fhru [ k ] * ( flu . nkor [ k ] - flu . evi [ k ] ) elif con . lnk [ k ] not in ( WASSER , SEE ) : flu...
Aggregate the amount of total direct flow released by all HRUs .
453
def calc_qdgz1_qdgz2_v1 ( self ) : con = self . parameters . control . fastaccess flu = self . sequences . fluxes . fastaccess sta = self . sequences . states . fastaccess if flu . qdgz > con . a2 : sta . qdgz2 = ( flu . qdgz - con . a2 ) ** 2 / ( flu . qdgz + con . a1 - con . a2 ) sta . qdgz1 = flu . qdgz - sta . qdgz...
Seperate total direct flow into a small and a fast component .
454
def calc_qbga_v1 ( self ) : der = self . parameters . derived . fastaccess old = self . sequences . states . fastaccess_old new = self . sequences . states . fastaccess_new if der . kb <= 0. : new . qbga = new . qbgz elif der . kb > 1e200 : new . qbga = old . qbga + new . qbgz - old . qbgz else : d_temp = ( 1. - modelu...
Perform the runoff concentration calculation for base flow .
455
def calc_qiga1_v1 ( self ) : der = self . parameters . derived . fastaccess old = self . sequences . states . fastaccess_old new = self . sequences . states . fastaccess_new if der . ki1 <= 0. : new . qiga1 = new . qigz1 elif der . ki1 > 1e200 : new . qiga1 = old . qiga1 + new . qigz1 - old . qigz1 else : d_temp = ( 1....
Perform the runoff concentration calculation for the first interflow component .
456
def calc_qiga2_v1 ( self ) : der = self . parameters . derived . fastaccess old = self . sequences . states . fastaccess_old new = self . sequences . states . fastaccess_new if der . ki2 <= 0. : new . qiga2 = new . qigz2 elif der . ki2 > 1e200 : new . qiga2 = old . qiga2 + new . qigz2 - old . qigz2 else : d_temp = ( 1....
Perform the runoff concentration calculation for the second interflow component .
457
def calc_qdga1_v1 ( self ) : der = self . parameters . derived . fastaccess old = self . sequences . states . fastaccess_old new = self . sequences . states . fastaccess_new if der . kd1 <= 0. : new . qdga1 = new . qdgz1 elif der . kd1 > 1e200 : new . qdga1 = old . qdga1 + new . qdgz1 - old . qdgz1 else : d_temp = ( 1....
Perform the runoff concentration calculation for slow direct runoff .
458
def calc_qdga2_v1 ( self ) : der = self . parameters . derived . fastaccess old = self . sequences . states . fastaccess_old new = self . sequences . states . fastaccess_new if der . kd2 <= 0. : new . qdga2 = new . qdgz2 elif der . kd2 > 1e200 : new . qdga2 = old . qdga2 + new . qdgz2 - old . qdgz2 else : d_temp = ( 1....
Perform the runoff concentration calculation for fast direct runoff .
459
def calc_q_v1 ( self ) : con = self . parameters . control . fastaccess flu = self . sequences . fluxes . fastaccess sta = self . sequences . states . fastaccess aid = self . sequences . aides . fastaccess flu . q = sta . qbga + sta . qiga1 + sta . qiga2 + sta . qdga1 + sta . qdga2 if ( not con . negq ) and ( flu . q <...
Calculate the final runoff .
460
def calc_outputs_v1 ( self ) : con = self . parameters . control . fastaccess der = self . parameters . derived . fastaccess flu = self . sequences . fluxes . fastaccess for pdx in range ( 1 , der . nmbpoints ) : if con . xpoints [ pdx ] > flu . input : break for bdx in range ( der . nmbbranches ) : flu . outputs [ bdx...
Performs the actual interpolation or extrapolation .
461
def pick_input_v1 ( self ) : flu = self . sequences . fluxes . fastaccess inl = self . sequences . inlets . fastaccess flu . input = 0. for idx in range ( inl . len_total ) : flu . input += inl . total [ idx ] [ 0 ]
Updates |Input| based on |Total| .
462
def pass_outputs_v1 ( self ) : der = self . parameters . derived . fastaccess flu = self . sequences . fluxes . fastaccess out = self . sequences . outlets . fastaccess for bdx in range ( der . nmbbranches ) : out . branched [ bdx ] [ 0 ] += flu . outputs [ bdx ]
Updates |Branched| based on |Outputs| .
463
def connect ( self ) : nodes = self . element . inlets total = self . sequences . inlets . total if total . shape != ( len ( nodes ) , ) : total . shape = len ( nodes ) for idx , node in enumerate ( nodes ) : double = node . get_double ( 'inlets' ) total . set_pointer ( double , idx ) for ( idx , name ) in enumerate ( ...
Connect the |LinkSequence| instances handled by the actual model to the |NodeSequence| instances handled by one inlet node and multiple oulet nodes .
464
def update ( self ) : pars = self . subpars . pars responses = pars . control . responses fluxes = pars . model . sequences . fluxes self ( len ( responses ) ) fluxes . qpin . shape = self . value fluxes . qpout . shape = self . value fluxes . qma . shape = self . value fluxes . qar . shape = self . value
Determine the number of response functions .
465
def update ( self ) : responses = self . subpars . pars . control . responses self . shape = len ( responses ) self ( responses . ar_orders )
Determine the total number of AR coefficients .
466
def update ( self ) : pars = self . subpars . pars coefs = pars . control . responses . ar_coefs self . shape = coefs . shape self ( coefs ) pars . model . sequences . logs . logout . shape = self . shape
Determine all AR coefficients .
467
def update ( self ) : pars = self . subpars . pars coefs = pars . control . responses . ma_coefs self . shape = coefs . shape self ( coefs ) pars . model . sequences . logs . login . shape = self . shape
Determine all MA coefficients .
468
def __getiterable ( value ) : if isinstance ( value , Selection ) : return [ value ] try : for selection in value : if not isinstance ( selection , Selection ) : raise TypeError return list ( value ) except TypeError : raise TypeError ( f'Binary operations on Selections objects are defined for ' f'other Selections obje...
Try to convert the given argument to a |list| of |Selection| objects and return it .
469
def search_upstream ( self , device : devicetools . Device , name : str = 'upstream' ) -> 'Selection' : try : selection = Selection ( name ) if isinstance ( device , devicetools . Node ) : node = self . nodes [ device . name ] return self . __get_nextnode ( node , selection ) if isinstance ( device , devicetools . Elem...
Return the network upstream of the given starting point including the starting point itself .
470
def select_upstream ( self , device : devicetools . Device ) -> 'Selection' : upstream = self . search_upstream ( device ) self . nodes = upstream . nodes self . elements = upstream . elements return self
Restrict the current selection to the network upstream of the given starting point including the starting point itself .
471
def search_modeltypes ( self , * models : ModelTypesArg , name : str = 'modeltypes' ) -> 'Selection' : try : typelist = [ ] for model in models : if not isinstance ( model , modeltools . Model ) : model = importtools . prepare_model ( model ) typelist . append ( type ( model ) ) typetuple = tuple ( typelist ) selection...
Return a |Selection| object containing only the elements currently handling models of the given types .
472
def search_nodenames ( self , * substrings : str , name : str = 'nodenames' ) -> 'Selection' : try : selection = Selection ( name ) for node in self . nodes : for substring in substrings : if substring in node . name : selection . nodes += node break return selection except BaseException : values = objecttools . enumer...
Return a new selection containing all nodes of the current selection with a name containing at least one of the given substrings .
473
def search_elementnames ( self , * substrings : str , name : str = 'elementnames' ) -> 'Selection' : try : selection = Selection ( name ) for element in self . elements : for substring in substrings : if substring in element . name : selection . elements += element break return selection except BaseException : values =...
Return a new selection containing all elements of the current selection with a name containing at least one of the given substrings .
474
def copy ( self , name : str ) -> 'Selection' : return type ( self ) ( name , copy . copy ( self . nodes ) , copy . copy ( self . elements ) )
Return a new |Selection| object with the given name and copies of the handles |Nodes| and |Elements| objects based on method |Devices . copy| .
475
def save_networkfile ( self , filepath : Union [ str , None ] = None , write_nodes : bool = True ) -> None : if filepath is None : filepath = self . name + '.py' with open ( filepath , 'w' , encoding = "utf-8" ) as file_ : file_ . write ( '# -*- coding: utf-8 -*-\n' ) file_ . write ( '\nfrom hydpy import Node, Element\...
Save the selection as a network file .
476
def calc_qpin_v1 ( self ) : der = self . parameters . derived . fastaccess flu = self . sequences . fluxes . fastaccess for idx in range ( der . nmb - 1 ) : if flu . qin < der . maxq [ idx ] : flu . qpin [ idx ] = 0. elif flu . qin < der . maxq [ idx + 1 ] : flu . qpin [ idx ] = flu . qin - der . maxq [ idx ] else : fl...
Calculate the input discharge portions of the different response functions .
477
def calc_login_v1 ( self ) : der = self . parameters . derived . fastaccess flu = self . sequences . fluxes . fastaccess log = self . sequences . logs . fastaccess for idx in range ( der . nmb ) : for jdx in range ( der . ma_order [ idx ] - 2 , - 1 , - 1 ) : log . login [ idx , jdx + 1 ] = log . login [ idx , jdx ] for...
Refresh the input log sequence for the different MA processes .
478
def calc_qma_v1 ( self ) : der = self . parameters . derived . fastaccess flu = self . sequences . fluxes . fastaccess log = self . sequences . logs . fastaccess for idx in range ( der . nmb ) : flu . qma [ idx ] = 0. for jdx in range ( der . ma_order [ idx ] ) : flu . qma [ idx ] += der . ma_coefs [ idx , jdx ] * log ...
Calculate the discharge responses of the different MA processes .
479
def calc_qar_v1 ( self ) : der = self . parameters . derived . fastaccess flu = self . sequences . fluxes . fastaccess log = self . sequences . logs . fastaccess for idx in range ( der . nmb ) : flu . qar [ idx ] = 0. for jdx in range ( der . ar_order [ idx ] ) : flu . qar [ idx ] += der . ar_coefs [ idx , jdx ] * log ...
Calculate the discharge responses of the different AR processes .
480
def calc_qpout_v1 ( self ) : der = self . parameters . derived . fastaccess flu = self . sequences . fluxes . fastaccess for idx in range ( der . nmb ) : flu . qpout [ idx ] = flu . qma [ idx ] + flu . qar [ idx ]
Calculate the ARMA results for the different response functions .
481
def calc_logout_v1 ( self ) : der = self . parameters . derived . fastaccess flu = self . sequences . fluxes . fastaccess log = self . sequences . logs . fastaccess for idx in range ( der . nmb ) : for jdx in range ( der . ar_order [ idx ] - 2 , - 1 , - 1 ) : log . logout [ idx , jdx + 1 ] = log . logout [ idx , jdx ] ...
Refresh the log sequence for the different AR processes .
482
def calc_qout_v1 ( self ) : der = self . parameters . derived . fastaccess flu = self . sequences . fluxes . fastaccess flu . qout = 0. for idx in range ( der . nmb ) : flu . qout += flu . qpout [ idx ]
Sum up the results of the different response functions .
483
def update ( self ) : con = self . subpars . pars . control self ( con . ypoints . shape [ 0 ] )
Determine the number of branches
484
def update ( self ) : mod = self . subpars . pars . model con = mod . parameters . control flu = mod . sequences . fluxes flu . h = con . hm mod . calc_qg ( ) self ( flu . qg )
Update value based on the actual |calc_qg_v1| method .
485
def update ( self ) : pars = self . subpars . pars self ( int ( round ( pars . control . lag ) ) ) pars . model . sequences . states . qjoints . shape = self + 1
Determines in how many segments the whole reach needs to be divided to approximate the desired lag time via integer rounding . Adjusts the shape of sequence |QJoints| additionally .
486
def view ( data , enc = None , start_pos = None , delimiter = None , hdr_rows = None , idx_cols = None , sheet_index = 0 , transpose = False , wait = None , recycle = None , detach = None , metavar = None , title = None ) : global WAIT , RECYCLE , DETACH , VIEW model = read_model ( data , enc = enc , delimiter = delimi...
View the supplied data in an interactive graphical table widget .
487
def gather_registries ( ) -> Tuple [ Dict , Mapping , Mapping ] : id2devices = copy . copy ( _id2devices ) registry = copy . copy ( _registry ) selection = copy . copy ( _selection ) dict_ = globals ( ) dict_ [ '_id2devices' ] = { } dict_ [ '_registry' ] = { Node : { } , Element : { } } dict_ [ '_selection' ] = { Node ...
Get and clear the current |Node| and |Element| registries .
488
def reset_registries ( dicts : Tuple [ Dict , Mapping , Mapping ] ) : dict_ = globals ( ) dict_ [ '_id2devices' ] = dicts [ 0 ] dict_ [ '_registry' ] = dicts [ 1 ] dict_ [ '_selection' ] = dicts [ 2 ]
Reset the current |Node| and |Element| registries .
489
def startswith ( self , name : str ) -> List [ str ] : return sorted ( keyword for keyword in self if keyword . startswith ( name ) )
Return a list of all keywords starting with the given string .
490
def endswith ( self , name : str ) -> List [ str ] : return sorted ( keyword for keyword in self if keyword . endswith ( name ) )
Return a list of all keywords ending with the given string .
491
def contains ( self , name : str ) -> List [ str ] : return sorted ( keyword for keyword in self if name in keyword )
Return a list of all keywords containing the given string .
492
def update ( self , * names : Any ) -> None : _names = [ str ( name ) for name in names ] self . _check_keywords ( _names ) super ( ) . update ( _names )
Before updating the given names are checked to be valid variable identifiers .
493
def add ( self , name : Any ) -> None : self . _check_keywords ( [ str ( name ) ] ) super ( ) . add ( str ( name ) )
Before adding a new name it is checked to be valid variable identifiers .
494
def add_device ( self , device : Union [ DeviceType , str ] ) -> None : try : if self . mutable : _device = self . get_contentclass ( ) ( device ) self . _name2device [ _device . name ] = _device _id2devices [ _device ] [ id ( self ) ] = self else : raise RuntimeError ( f'Adding devices to immutable ' f'{objecttools.cl...
Add the given |Node| or |Element| object to the actual |Nodes| or |Elements| object .
495
def remove_device ( self , device : Union [ DeviceType , str ] ) -> None : try : if self . mutable : _device = self . get_contentclass ( ) ( device ) try : del self . _name2device [ _device . name ] except KeyError : raise ValueError ( f'The actual {objecttools.classname(self)} ' f'object does not handle such a device....
Remove the given |Node| or |Element| object from the actual |Nodes| or |Elements| object .
496
def keywords ( self ) -> Set [ str ] : return set ( keyword for device in self for keyword in device . keywords if keyword not in self . _shadowed_keywords )
A set of all keywords of all handled devices .
497
def copy ( self : DevicesTypeBound ) -> DevicesTypeBound : new = type ( self ) ( ) vars ( new ) . update ( vars ( self ) ) vars ( new ) [ '_name2device' ] = copy . copy ( self . _name2device ) vars ( new ) [ '_shadowed_keywords' ] . clear ( ) for device in self : _id2devices [ device ] [ id ( new ) ] = new return new
Return a shallow copy of the actual |Nodes| or |Elements| object .
498
def prepare_allseries ( self , ramflag : bool = True ) -> None : self . prepare_simseries ( ramflag ) self . prepare_obsseries ( ramflag )
Call methods |Node . prepare_simseries| and |Node . prepare_obsseries| .
499
def prepare_simseries ( self , ramflag : bool = True ) -> None : for node in printtools . progressbar ( self ) : node . prepare_simseries ( ramflag )
Call method |Node . prepare_simseries| of all handled |Node| objects .