Commit 72d0366d authored by cponcele's avatar cponcele
Browse files

Add annotation group

parent 4edea1ab
......@@ -104,6 +104,89 @@ class RootGrp:
 
 
# Sub groups
class AnnotationGrp:
@staticmethod
def get_group_path():
return RootGrp.get_group_path()+"Annotation/"
def create_group(self, parent_group: nc.Dataset,vlen_type_dict=None,**attributes):
g = parent_group.createGroup(self.get_group_path())
if vlen_type_dict is None:
vlen_type_dict = {}
#declare vlen types:
for key, value in vlen_type_dict.items():
vlen_type = g.createVLType(vlen_type_dict[key], key)
#write attributes passed as argument
for key, value in attributes.items():
g.setncattr(key, value)
return g
# dimensions names declaration
TIME_DIM_NAME = "time"
def create_dimension(self, group: nc.Dataset, values: dict):
"""Pass as argument an array of dimension to be created and their values (use None for unlimited dimension)"""
for dimension_name in values.keys():
group.createDimension(dimension_name, values[dimension_name])
# Coordinate Variables names
@staticmethod
def TIME():
return AnnotationGrp.get_group_path()+"time"
def create_time(self, group: nc.Dataset, missing_value=None, **attributes):
"""create variable time"""
v = group.createVariable(varname="time", datatype=np.uint64, dimensions=("time"), fill_value=missing_value)
if "axis" not in attributes:
v.axis = "T"
if "calendar" not in attributes:
v.calendar = "gregorian"
if "long_name" not in attributes:
v.long_name = "Timestamps of annotations"
if "standard_name" not in attributes:
v.standard_name = "time"
if "units" not in attributes:
v.units = "nanoseconds since 1970-01-01 00:00:00Z"
#write attributes passed as argument
for key, value in attributes.items():
v.setncattr(key, value)
return v
# Variables names
@staticmethod
def ANNOTATION_CATEGORY():
return AnnotationGrp.get_group_path()+"annotation_category"
def create_annotation_category(self, group: nc.Dataset, missing_value=None, **attributes):
"""create variable annotation_category"""
v = group.createVariable(varname="annotation_category", datatype=str, dimensions=("time"), fill_value=missing_value)
if "long_name" not in attributes:
v.long_name = "Annotation category"
#write attributes passed as argument
for key, value in attributes.items():
v.setncattr(key, value)
return v
@staticmethod
def ANNOTATION_TEXT():
return AnnotationGrp.get_group_path()+"annotation_text"
def create_annotation_text(self, group: nc.Dataset, missing_value=None, **attributes):
"""create variable annotation_text"""
v = group.createVariable(varname="annotation_text", datatype=str, dimensions=("time"), fill_value=missing_value)
if "long_name" not in attributes:
v.long_name = "Annotation text"
#write attributes passed as argument
for key, value in attributes.items():
v.setncattr(key, value)
return v
class EnvironmentGrp:
@staticmethod
def get_group_path():
......
......@@ -33,6 +33,27 @@ class RootGrpValidator:
_mandatory_if_applicable_variables=[]
#Sub groups
class AnnotationGrpValidator:
@staticmethod
def get_group_path_pattern():
return RootGrpValidator.get_group_path_pattern()+"Annotation/"
_enum_types=[]
_vlen_types=[]
#Attributes
_attributes=[]
#Dimensions
_dimensions=["time"]
#Variables
_coordinate_variables=["time"]
#Variables
_mandatory_variables=["annotation_text"]
_optional_variables=["annotation_category"]
_recommanded_variables=[]
_mandatory_if_applicable_variables=[]
class EnvironmentGrpValidator:
@staticmethod
def get_group_path_pattern():
......@@ -43,7 +64,7 @@ class EnvironmentGrpValidator:
#Attributes
_attributes=[]
#Dimensions
#Dimensions
_dimensions=["frequency"]
#Variables
......@@ -66,7 +87,7 @@ class SoundSpeedProfileGrpValidator:
#Attributes
_attributes=[]
#Dimensions
#Dimensions
_dimensions=["profile","sampleCount"]
#Variables
......@@ -89,7 +110,7 @@ class SurfaceSoundSpeedGrpValidator:
#Attributes
_attributes=[]
#Dimensions
#Dimensions
_dimensions=["time"]
#Variables
......@@ -112,7 +133,7 @@ class TideGrpValidator:
#Attributes
_attributes=[]
#Dimensions
#Dimensions
_dimensions=["time"]
#Variables
......@@ -135,7 +156,7 @@ class DynamicDraughtGrpValidator:
#Attributes
_attributes=[]
#Dimensions
#Dimensions
_dimensions=["time"]
#Variables
......@@ -156,7 +177,7 @@ class PlatformGrpValidator:
#Attributes
_attributes=["platform_code_ICES","platform_name","platform_type"]
#Dimensions
#Dimensions
_dimensions=["transducer","position","MRU"]
#Variables
......@@ -179,7 +200,7 @@ class PositionGrpValidator:
#Attributes
_attributes=[]
#Dimensions
#Dimensions
_dimensions=[]
#Variables
......@@ -202,7 +223,7 @@ class PositionSubGroupValidator:
#Attributes
_attributes=["description"]
#Dimensions
#Dimensions
_dimensions=["time"]
#Variables
......@@ -225,7 +246,7 @@ class NmeaGrpValidator:
#Attributes
_attributes=["description"]
#Dimensions
#Dimensions
_dimensions=["time"]
#Variables
......@@ -246,7 +267,7 @@ class AttitudeGrpValidator:
#Attributes
_attributes=[]
#Dimensions
#Dimensions
_dimensions=[]
#Variables
......@@ -269,7 +290,7 @@ class AttitudeSubGroupValidator:
#Attributes
_attributes=["description"]
#Dimensions
#Dimensions
_dimensions=["time"]
#Variables
......@@ -292,7 +313,7 @@ class ProvenanceGrpValidator:
#Attributes
_attributes=["conversion_software_name","conversion_software_version","conversion_time"]
#Dimensions
#Dimensions
_dimensions=["filenames"]
#Variables
......@@ -313,7 +334,7 @@ class SonarGrpValidator:
#Attributes
_attributes=["sonar_manufacturer","sonar_model","sonar_serial_number","sonar_software_name","sonar_software_version","sonar_type"]
#Dimensions
#Dimensions
_dimensions=[]
#Variables
......@@ -336,7 +357,7 @@ class BeamGroup1GrpValidator:
#Attributes
_attributes=["beam_mode","conversion_equation_type","preferred_MRU","preferred_position"]
#Dimensions
#Dimensions
_dimensions=["beam","subbeam","ping_time","tx_beam"]
#Variables
......@@ -359,7 +380,7 @@ class AdcpGrpValidator:
#Attributes
_attributes=[]
#Dimensions
#Dimensions
_dimensions=[]
#Variables
......@@ -382,7 +403,7 @@ class MeanCurrentGrpValidator:
#Attributes
_attributes=[]
#Dimensions
#Dimensions
_dimensions=["mean_time"]
#Variables
......@@ -403,7 +424,7 @@ class BathymetryGrpValidator:
#Attributes
_attributes=["detection_conversion_equation_type"]
#Dimensions
#Dimensions
_dimensions=["detection"]
#Variables
......@@ -426,7 +447,7 @@ class GridGroup1GrpValidator:
#Attributes
_attributes=["beam_mode","conversion_equation_type"]
#Dimensions
#Dimensions
_dimensions=["beam","tx_beam","frequency","ping_axis","range_axis"]
#Variables
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment