-
Notifications
You must be signed in to change notification settings - Fork 31
Feature python enkf #76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Feature python enkf #76
Conversation
|
Issues
======
- Added 29
Complexity increasing per file
==============================
- py_openda/py_openda/costFunctions/CsvStochObserver.py 2
- py_openda/py_openda/algorithms/ensemble_kalman.py 3
- py_openda/py_openda/costFunctions/LorenzStochModelFactory.py 8
- py_openda/py_openda/costFunctions/GenericEnsembleKalmanFilter.py 4
- py_openda/py_openda/costFunctions/JObjects.py 6
- py_openda/py_openda/costFunctions/LorenzStochModelInstance.py 8
- py_openda/py_openda/utils/py4j_utils.py 5
- py_openda/examples/py_kalman/enkf_swan.py 4
Clones added
============
- py_openda/py_openda/costFunctions/JObjects.py 1
- py_openda/py_openda/costFunctions/LorenzStochModelInstance.py 1
See the complete overview on Codacy |
|
|
||
| TODO: java observation description maken! | ||
|
|
||
| * `get_observation_descriptions(self)` returns the observation descriptions that the model instance can use to determine which elements of the state vector corresponds to quantities that are observed. Keep in mind that there is no utility routine for creating a java observation description from python, so for now you cannot combine a python observer with a java model. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
|
||
| * `get_observations(self, descriptions)` returns values of the state vector that correspond to the given observation descriptions. These descriptions are given by the stoch observer, so pay special attention when trying to use them. | ||
|
|
||
| * `update_state(self, state_array, main_or_ens)` changes the state vector based on the input `state_array`. Note that the input is a little different depending on whether the model to be updated is an ensemble member or the main model. For an ensemblemember `state_array` should be added to the state vector, while for the main model it is supposed to replace the state vector. This is controlled by the `main_or_ens` argument, which is a string equal to either "main" or "ens". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
|
||
| TODO: Misschien leuk om init ook met alleen een xml file als input te doen? | ||
|
|
||
| * `__init__(self, config=None, scriptdir=None)` initializes the object. Here `config` is the stochObserver element of the main `.oda` configuration file as a dictionary. `scriptdir` is the directory containing the `.oda` file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| """ | ||
| ``` | ||
|
|
||
| * `__init__(self, config, scriptdir)` initializes the object. Here `config` is the stochModelFactory element of the main `.oda` configuration file as a dictionary. `scriptdir` is the directory containing the `.oda` file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| observer_config_xml = config.get('configFile') | ||
| self.observer = None | ||
| observer_object = 'gateway.jvm.'+config.get('@className') | ||
| exec('self.observer =%s()' % observer_object) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue found: Use of exec detected.
| """ | ||
| (self.param, self.param_uncertainty, self.state, self.state_uncertainty, self.sys_mean, | ||
| self.sys_std, self.span) = model_attributes | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue found: Trailing whitespace
| model_config_xml = config.get('configFile') | ||
| self.model_factory = None | ||
| model_object = 'gateway.jvm.'+config.get('@className') | ||
| exec('self.model_factory =%s()' % model_object) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue found: Use of exec
| """ | ||
| ``` | ||
|
|
||
| * `get_time_horizon(self)` should return a time object spanning the start and end of the simulation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
|
||
| * `get_observation_descriptions(self)` returns the observation descriptions that the model instance can use to determine which elements of the state vector corresponds to quantities that are observed. Keep in mind that there is no utility routine for creating a java observation description from python, so for now you cannot combine a python observer with a java model. | ||
|
|
||
| * `get_sqrt_covariance(self)` generates an np array representing the squared covariance matrix. Note that you first have to convert the output yourself. For this you can use the utility routine `j_vector_array_to_np_array(j_sqrt)` if you have a java vector array. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
|
||
| * `compute(self, time)` runs the model until the given time. | ||
|
|
||
| * `get_observations(self, descriptions)` returns values of the state vector that correspond to the given observation descriptions. These descriptions are given by the stoch observer, so pay special attention when trying to use them. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
|
||
| * `get_time_horizon(self)` should return a time object spanning the start and end of the simulation. | ||
|
|
||
| * `get_current_time(self)` returns the time up to which the state vector has been calculated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| noise_config = {'@stochParameter':False, '@stochForcing':False, '@stochInit':False} | ||
| elif main_or_ens == "ens": | ||
| noise_config = {'@stochParameter':False, '@stochForcing':True, '@stochInit':True} | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue found: Trailing whitespace
| """ | ||
| return self.current_time | ||
|
|
||
| def announce_observed_values(self, descriptions): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue found: Method could be a function
| observer_config_xml = config.get('configFile') | ||
| self.observer = None | ||
| observer_object = 'gateway.jvm.'+config.get('@className') | ||
| exec('self.observer =%s()' % observer_object) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue found: Use of exec
| @@ -0,0 +1,182 @@ | |||
| ## Using the main program | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| elif isinstance(obj, np.ndarray): | ||
| obj = obj.squeeze().tolist() | ||
| elif isinstance(obj, list): | ||
| None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue found: Statement seems to have no effect
|
|
||
| * `get_sqrt_covariance(self)` generates an np array representing the squared covariance matrix. Note that you first have to convert the output yourself. For this you can use the utility routine `j_vector_array_to_np_array(j_sqrt)` if you have a java vector array. | ||
|
|
||
| * `get_realizations(self)` creates realizations of the observed values using the mean and the standarddeviation of the measurement. The output will be converted automatically. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| from setuptools import setup, find_packages | ||
| with open("README.txt", 'r') as f: | ||
| long_description = f.read() | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue found: Trailing whitespace
| # ensembleModel@stochParameter=false | ||
| # ensembleModel@stochForcing=true | ||
| # ensembleModel@stochInit=true | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue found: Trailing whitespace
|
|
||
| * `get_current_time(self)` returns the time up to which the state vector has been calculated. | ||
|
|
||
| * `announce_observed_values(self, descriptions)` function which can be used to make sure that the model will save the observations described by the descriptions. This function does get called by the main algorithm, but it does not have to do anything if your implementation does not need it to. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
|
||
| * `get_times(self)` lists all the times where there are observations available. The output will automatically be converted to a python list of time objects. | ||
|
|
||
| * `get_count(self)` simply returns an integer indicating the number of measurements available. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
|
||
| * `__init__(self, config=None, scriptdir=None)` initializes the object. Here `config` is the stochObserver element of the main `.oda` configuration file as a dictionary. `scriptdir` is the directory containing the `.oda` file. | ||
|
|
||
| * `create_selection(self, model_span)` creates a new stoch observer, limited to the span given by the time object `model_span`. The class of the output should be the same as the class of `self`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| model_config_xml = config.get('configFile') | ||
| self.model_factory = None | ||
| model_object = 'gateway.jvm.'+config.get('@className') | ||
| exec('self.model_factory =%s()' % model_object) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue found: Use of exec detected.
| :param descriptions: an ObservationDescriptions object with meta data for the observations. | ||
| :return: | ||
| """ | ||
| None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue found: Statement seems to have no effect
| * `get_observation_descriptions(self)` returns the observation descriptions that the model instance can use to determine which elements of the state vector corresponds to quantities that are observed. Keep in mind that there is no utility routine for creating a java observation description from python, so for now you cannot combine a python observer with a java model. | ||
|
|
||
| * `get_sqrt_covariance(self)` generates an np array representing the squared covariance matrix. Note that you first have to convert the output yourself. For this you can use the utility routine `j_vector_array_to_np_array(j_sqrt)` if you have a java vector array. | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No description provided.