Skip to content

Conversation

@nilsvanvelzen
Copy link
Member

No description provided.

@nilsvanvelzen nilsvanvelzen self-assigned this Mar 13, 2019
@nilsvanvelzen
Copy link
Member Author

Codacy Here is an overview of what got changed by this pull request:

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.
Copy link
Member Author

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".
Copy link
Member Author

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.
Copy link
Member Author

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.
Copy link
Member Author

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)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codacy 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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codacy 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)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codacy Issue found: Use of exec

"""
```

* `get_time_horizon(self)` should return a time object spanning the start and end of the simulation.
Copy link
Member Author

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.
Copy link
Member Author

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.
Copy link
Member Author

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.
Copy link
Member Author

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}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codacy Issue found: Trailing whitespace

"""
return self.current_time

def announce_observed_values(self, descriptions):
Copy link
Member Author

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)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codacy Issue found: Use of exec

@@ -0,0 +1,182 @@
## Using the main program
Copy link
Member Author

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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


* `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.
Copy link
Member Author

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()

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codacy Issue found: Trailing whitespace

# ensembleModel@stochParameter=false
# ensembleModel@stochForcing=true
# ensembleModel@stochInit=true

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codacy 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.
Copy link
Member Author

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.
Copy link
Member Author

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`.
Copy link
Member Author

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)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codacy Issue found: Use of exec detected.

:param descriptions: an ObservationDescriptions object with meta data for the observations.
:return:
"""
None
Copy link
Member Author

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants