viroconwebcontour.models module¶
Models for viroconweb, e.g. for a measurement file and a environmental contour.
-
class
contour.models.
AdditionalContourOption
(*args, **kwargs)[source]¶ Bases:
django.db.models.base.Model
Additional options describing how an environmental contour was created.
Since different environmental contour methods are available some options are only applicable to one method. Consequently, AdditionalContourOption can be used as a dictionary to specify additional options.
The idea how this model works is based on this stackoverflow post: https://stackoverflow.com/questions/402217/how-to-store-a-dictionary-on-a-django-model
-
exception
DoesNotExist
¶ Bases:
django.core.exceptions.ObjectDoesNotExist
-
exception
MultipleObjectsReturned
¶ Bases:
django.core.exceptions.MultipleObjectsReturned
-
environmental_contour
¶ Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
child.parent
is aForwardManyToOneDescriptor
instance.
-
environmental_contour_id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
objects
= <django.db.models.manager.Manager object>¶
-
option_key
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
option_value
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
exception
-
class
contour.models.
ContourPath
(*args, **kwargs)[source]¶ Bases:
django.db.models.base.Model
Model for the path of an environmental contour.
One or multiple ContourPath instances can be associated to an EnvironmentalContour instance.
The points of the path have their own model (ExtremeEnvDesignCondition) and are connected via the ContourPath primary key.
-
exception
DoesNotExist
¶ Bases:
django.core.exceptions.ObjectDoesNotExist
-
exception
MultipleObjectsReturned
¶ Bases:
django.core.exceptions.MultipleObjectsReturned
-
environmental_contour
¶ Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
child.parent
is aForwardManyToOneDescriptor
instance.
-
environmental_contour_id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
extremeenvdesigncondition_set
¶ Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
parent.children
is aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
objects
= <django.db.models.manager.Manager object>¶
-
exception
-
class
contour.models.
DistributionModel
(*args, **kwargs)[source]¶ Bases:
django.db.models.base.Model
Model for the distribution of a single random variable.
For example the random variable significant wave height, can be defined with this model. Its name would be ‘significant wave height’, its symbol ‘Hs’ and its distribution ‘Weibull’. In addition one would need 3 ParameterModel objects, which define the distributions parameters (scale, shape, location).
-
DISTRIBUTIONS
= (('Normal', 'Normal Distribution'), ('Weibull', 'Weibull'), ('Lognormal_SigmaMu', 'Log-Normal'), ('KernelDensity', 'Kernel Density'))¶
-
exception
DoesNotExist
¶ Bases:
django.core.exceptions.ObjectDoesNotExist
-
exception
MultipleObjectsReturned
¶ Bases:
django.core.exceptions.MultipleObjectsReturned
-
distribution
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
get_distribution_display
(**morekwargs)¶
-
id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
name
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
objects
= <django.db.models.manager.Manager object>¶
-
parametermodel_set
¶ Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
parent.children
is aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
plottedfigure_set
¶ Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
parent.children
is aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
probabilistic_model
¶ Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
child.parent
is aForwardManyToOneDescriptor
instance.
-
probabilistic_model_id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
symbol
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
-
class
contour.models.
EEDCScalar
(*args, **kwargs)[source]¶ Bases:
django.db.models.base.Model
Model for the value of one dimension of an extreme env. design condition.
Multiple EEDCScalar instances make up an ExtremEnvDesignCondition instance.
-
exception
DoesNotExist
¶ Bases:
django.core.exceptions.ObjectDoesNotExist
-
EEDC
¶ Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
child.parent
is aForwardManyToOneDescriptor
instance.
-
EEDC_id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
exception
MultipleObjectsReturned
¶ Bases:
django.core.exceptions.MultipleObjectsReturned
-
id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
objects
= <django.db.models.manager.Manager object>¶
-
x
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
exception
-
class
contour.models.
EnvironmentalContour
(*args, **kwargs)[source]¶ Bases:
django.db.models.base.Model
Model for an environmental contour.
The model contains the the settings, which were used to create the contour and the primary key to the probabilistic model on which it is based on. Additional options, which are a dictionary, have their own model (AdditionalContourOption) and are connected via the primary key to an EnvironmentalContour instance. The contour’s path (the EEDCs) are also connected via two own models (Contourpath and ExtremeEnvDesignCondition).
-
exception
DoesNotExist
¶ Bases:
django.core.exceptions.ObjectDoesNotExist
-
exception
MultipleObjectsReturned
¶ Bases:
django.core.exceptions.MultipleObjectsReturned
-
additionalcontouroption_set
¶ Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
parent.children
is aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
contour_method
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
contourpath_set
¶ Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
parent.children
is aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
design_conditions_csv
¶ The descriptor for the file attribute on the model instance. Returns a FieldFile when accessed so you can do stuff like:
>>> from myapp.models import MyModel >>> instance = MyModel.objects.get(pk=1) >>> instance.file.size
Assigns a file object on assignment so you can do:
>>> with open('/path/to/hello.world', 'r') as f: ... instance.file = File(f)
-
fitting_method
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
latex_report
¶ The descriptor for the file attribute on the model instance. Returns a FieldFile when accessed so you can do stuff like:
>>> from myapp.models import MyModel >>> instance = MyModel.objects.get(pk=1) >>> instance.file.size
Assigns a file object on assignment so you can do:
>>> with open('/path/to/hello.world', 'r') as f: ... instance.file = File(f)
-
objects
= <django.db.models.manager.Manager object>¶
-
path_of_statics
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
plottedfigure_set
¶ Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
parent.children
is aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
primary_user
¶ Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
child.parent
is aForwardManyToOneDescriptor
instance.
-
primary_user_id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
probabilistic_model
¶ Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
child.parent
is aForwardManyToOneDescriptor
instance.
-
probabilistic_model_id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
return_period
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
secondary_user
¶ Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
pizza.toppings
andtopping.pizzas
areManyToManyDescriptor
instances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
state_duration
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
exception
-
class
contour.models.
ExtremeEnvDesignCondition
(*args, **kwargs)[source]¶ Bases:
django.db.models.base.Model
Model for a single extreme environmental design conditions.
Multiple ExtremeEnvDesignCondition instances make up a ContourPath instance.
For each dimension an EEDCScalar instance is needed and connected via the primary key to an ExtremeEnvDesignCondition instance.
-
exception
DoesNotExist
¶ Bases:
django.core.exceptions.ObjectDoesNotExist
-
exception
MultipleObjectsReturned
¶ Bases:
django.core.exceptions.MultipleObjectsReturned
-
contour_path
¶ Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
child.parent
is aForwardManyToOneDescriptor
instance.
-
contour_path_id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
eedcscalar_set
¶ Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
parent.children
is aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
objects
= <django.db.models.manager.Manager object>¶
-
exception
-
class
contour.models.
MeasureFileModel
(*args, **kwargs)[source]¶ Bases:
django.db.models.base.Model
Model for a file containing measurement data.
A MeasureFileModel object holds a measurement file. It is associated to a user (owner) and can be shared with other users.
-
exception
DoesNotExist
¶ Bases:
django.core.exceptions.ObjectDoesNotExist
-
exception
MultipleObjectsReturned
¶ Bases:
django.core.exceptions.MultipleObjectsReturned
-
get_next_by_upload_date
(**morekwargs)¶
-
get_previous_by_upload_date
(**morekwargs)¶
-
id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
measure_file
¶ The descriptor for the file attribute on the model instance. Returns a FieldFile when accessed so you can do stuff like:
>>> from myapp.models import MyModel >>> instance = MyModel.objects.get(pk=1) >>> instance.file.size
Assigns a file object on assignment so you can do:
>>> with open('/path/to/hello.world', 'r') as f: ... instance.file = File(f)
-
objects
= <django.db.models.manager.Manager object>¶
-
path_of_statics
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
primary_user
¶ Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
child.parent
is aForwardManyToOneDescriptor
instance.
-
primary_user_id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
probabilisticmodel_set
¶ Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
parent.children
is aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
scatter_plot
¶ Just like the FileDescriptor, but for ImageFields. The only difference is assigning the width/height to the width_field/height_field, if appropriate.
-
secondary_user
¶ Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
pizza.toppings
andtopping.pizzas
areManyToManyDescriptor
instances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
title
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
upload_date
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
exception
-
class
contour.models.
ParameterModel
(*args, **kwargs)[source]¶ Bases:
django.db.models.base.Model
Model for one parameter of a distribution, e.g. scale.
The parameter model can either be a constant value, e.g. x0 = 1.5 or it can be a function, which describes the parameter’s depedency on another variable. The two available funtions have 3 parameters each, which are represented by x0, x1 and x2.
-
exception
DoesNotExist
¶ Bases:
django.core.exceptions.ObjectDoesNotExist
-
FUNCTIONS
= ((None, 'None'), ('power3', 'power function'), ('exp3', 'exponential'))¶
-
exception
MultipleObjectsReturned
¶ Bases:
django.core.exceptions.MultipleObjectsReturned
-
clean
()[source]¶ Validates if the parameter of a distribution has valid values.
For example a Normal distribution’s scale parameter (sigma) must be > 0. If this is not the case, a ValidationError is raised.
-
dependency
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
distribution
¶ Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
child.parent
is aForwardManyToOneDescriptor
instance.
-
distribution_id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
function
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
get_function_display
(**morekwargs)¶
-
id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
name
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
objects
= <django.db.models.manager.Manager object>¶
-
plottedfigure_set
¶ Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
parent.children
is aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
x0
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
x1
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
x2
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
exception
-
class
contour.models.
PlottedFigure
(*args, **kwargs)[source]¶ Bases:
django.db.models.base.Model
Has an ImageField, which stores an image crated with matplotlib
By having a class with an ImageField a ProbabilisticModel or an EnvironmentalContour instance can have multiple images associated to it using a many-to-one relation.
-
exception
DoesNotExist
¶ Bases:
django.core.exceptions.ObjectDoesNotExist
-
exception
MultipleObjectsReturned
¶ Bases:
django.core.exceptions.MultipleObjectsReturned
-
distribution_model
¶ Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
child.parent
is aForwardManyToOneDescriptor
instance.
-
distribution_model_id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
environmental_contour
¶ Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
child.parent
is aForwardManyToOneDescriptor
instance.
-
environmental_contour_id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
image
¶ Just like the FileDescriptor, but for ImageFields. The only difference is assigning the width/height to the width_field/height_field, if appropriate.
-
objects
= <django.db.models.manager.Manager object>¶
-
parameter_model
¶ Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
child.parent
is aForwardManyToOneDescriptor
instance.
-
parameter_model_id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
probabilistic_model
¶ Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
child.parent
is aForwardManyToOneDescriptor
instance.
-
probabilistic_model_id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
exception
-
class
contour.models.
ProbabilisticModel
(*args, **kwargs)[source]¶ Bases:
django.db.models.base.Model
Model for a multivariate distribution, e.g. a sea state description.
A ProbabilisticModel object is associated to a user (owner) and can be shared with other users. It has a name and can be connected to measurement data. If a probabilistic model is defined, in addition X DistributionModel objects are needed to define the distributions.
-
exception
DoesNotExist
¶ Bases:
django.core.exceptions.ObjectDoesNotExist
-
exception
MultipleObjectsReturned
¶ Bases:
django.core.exceptions.MultipleObjectsReturned
-
collection_name
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
distributionmodel_set
¶ Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
parent.children
is aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
environmentalcontour_set
¶ Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
parent.children
is aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
get_next_by_upload_date
(**morekwargs)¶
-
get_previous_by_upload_date
(**morekwargs)¶
-
id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
measure_file_model
¶ Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
child.parent
is aForwardManyToOneDescriptor
instance.
-
measure_file_model_id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
objects
= <django.db.models.manager.Manager object>¶
-
path_of_statics
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
plottedfigure_set
¶ Accessor to the related objects manager on the reverse side of a many-to-one relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
parent.children
is aReverseManyToOneDescriptor
instance.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
primary_user
¶ Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.
In the example:
class Child(Model): parent = ForeignKey(Parent, related_name='children')
child.parent
is aForwardManyToOneDescriptor
instance.
-
primary_user_id
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
secondary_user
¶ Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.
In the example:
class Pizza(Model): toppings = ManyToManyField(Topping, related_name='pizzas')
pizza.toppings
andtopping.pizzas
areManyToManyDescriptor
instances.Most of the implementation is delegated to a dynamically defined manager class built by
create_forward_many_to_many_manager()
defined below.
-
upload_date
¶ A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.
-
exception
-
contour.models.
file_time_stamp
()[source]¶ Returns the current time as a string as year-month-day-hour-minute.
-
contour.models.
media_directory_path
(instance, filename)[source]¶ Creates the path where to upload a media file.
The path is: MEDIA_ROOT/<username>/<model_abbvrevation>/<pk>/<time_stamp>_<random_hash>_ <filename>
Parameters: - instance (EnvironmentalContour, MeasureFileModel or PlottedFigure,) – These models have media files, which need a directory.
- filename (String,) – Name of the measurement file, e.g. “data_points.csv”.
Returns: path
Return type: