Commit 3dd1b75e authored by PONCELET's avatar PONCELET

update in model and adapt generator for beam angles and enum generation

parent ff6aa7e9
...@@ -5457,9 +5457,9 @@ ...@@ -5457,9 +5457,9 @@
] ]
}, },
{ {
"name": "rx_beam_rotation_alpha", "name": "rx_beam_rotation_phi",
"obligation": "M", "obligation": "M",
"comment": "The extrinsic z-x-z clockwise rotation about the _z_-axis of the platform coordinate system needed to give the beam coordinate system.", "comment": "The intrinsic _z_–_y_’–_x_” clockwise rotation about the _x_-axis of the platform coordinate system needed to give the receive beam coordinate system.",
"dims": [ "dims": [
"ping_time", "ping_time",
"beam" "beam"
...@@ -5468,7 +5468,7 @@ ...@@ -5468,7 +5468,7 @@
"attributes": [ "attributes": [
{ {
"name": "long_name", "name": "long_name",
"value": "angular rotation about the _z_ axis" "value": "receive beam angular rotation about the _x_ axis"
}, },
{ {
"name": "units", "name": "units",
...@@ -5482,9 +5482,9 @@ ...@@ -5482,9 +5482,9 @@
] ]
}, },
{ {
"name": "rx_beam_rotation_beta", "name": "rx_beam_rotation_theta",
"obligation": "M", "obligation": "M",
"comment": "The extrinsic z-x-z clockwise rotation about the _x_-axis of the platform coordinate system needed to give the beam coordinate system.", "comment": "The intrinsic _z_–_y_’–_x_” clockwise rotation about the _y_-axis of the platform coordinate system needed to give the receive beam coordinate system.",
"dims": [ "dims": [
"ping_time", "ping_time",
"beam" "beam"
...@@ -5493,7 +5493,7 @@ ...@@ -5493,7 +5493,7 @@
"attributes": [ "attributes": [
{ {
"name": "long_name", "name": "long_name",
"value": "angular rotation about the _x_ axis" "value": "receive beam angular rotation about the _y_ axis"
}, },
{ {
"name": "units", "name": "units",
...@@ -5501,15 +5501,15 @@ ...@@ -5501,15 +5501,15 @@
}, },
{ {
"name": "valid_range", "name": "valid_range",
"value": "-180.0f, 180.0f", "value": "-90.0f, 90.0f",
"type": "float" "type": "float"
} }
] ]
}, },
{ {
"name": "rx_beam_rotation_gamma", "name": "rx_beam_rotation_psi",
"obligation": "M", "obligation": "M",
"comment": "The extrinsic z-x-z clockwise rotation about the _z_-axis of the platform coordinate system needed to give the beam coordinate system.", "comment": "The intrinsic _z_–_y_’–_x_” clockwise about the _z_-axis of the platform coordinate system needed to give the receive beam coordinate system.",
"dims": [ "dims": [
"ping_time", "ping_time",
"beam" "beam"
...@@ -5518,7 +5518,7 @@ ...@@ -5518,7 +5518,7 @@
"attributes": [ "attributes": [
{ {
"name": "long_name", "name": "long_name",
"value": "angular rotation about the _z_ axis" "value": "receive beam angular rotation about the _z_ axis"
}, },
{ {
"name": "units", "name": "units",
...@@ -5531,85 +5531,11 @@ ...@@ -5531,85 +5531,11 @@
} }
] ]
}, },
{ {
"name": "beam_direction_x", "name": "tx_beam_rotation_phi",
"obligation": "M",
"comment": "The _x_-axis coordinate of a unit vector in the beam direction for each beam and ping in the FACS coordinate system (ie relative to the vertical)",
"dims": [
"ping_time",
"beam"
],
"type": "float",
"attributes": [
{
"name": "long_name",
"value": "_x_-component of the vector that gives the pointing direction of the beam, in sonar beam coordinate system"
},
{
"name": "crs",
"value": "FACS"
},
{
"name": "valid_range",
"value": "-1.0f, 1.0f",
"type": "float"
}
]
},
{
"name": "beam_direction_y",
"obligation": "M",
"comment": "The _y_-axis coordinate of a unit vector in the beam direction for each beam and ping, in the FACS coordinate system (ie relative to the vertical)",
"dims": [
"ping_time",
"beam"
],
"type": "float",
"attributes": [
{
"name": "long_name",
"value": "_y_-component of the vector that gives the pointing direction of the beam, in the FACS coordinate system (ie relative to the vertical)"
},
{
"name": "valid_range",
"value": "-1.0f, 1.0f",
"type": "float"
},
{
"name": "crs",
"value": "FACS"
}
]
},
{
"name": "beam_direction_z",
"obligation": "M",
"comment": "The _z_-axis coordinate of a unit vector in the beam direction for each beam and ping, in the FACS coordinate system (ie relative to the vertical)",
"dims": [
"ping_time",
"beam"
],
"type": "float",
"attributes": [
{
"name": "long_name",
"value": "_z_-component of the vector that gives the pointing direction of the beam, in the FACS coordinate system (ie relative to the vertical)"
},
{
"name": "valid_range",
"value": "-1.0f, 1.0f",
"type": "float"
},
{
"name": "crs",
"value": "FACS"
}
]
},
{
"name": "tx_beam_direction_x",
"obligation": "M", "obligation": "M",
"comment": "The _x_-axis coordinate of a unit vector in the beam direction for each tx_beam and ping, as per the sonar beam coordinate system.", "comment": "The intrinsic _z_–_y_’–_x_” clockwise rotation about the _x_-axis of the platform coordinate system needed to give the transmit beam coordinate system.",
"dims": [ "dims": [
"ping_time", "ping_time",
"tx_beam" "tx_beam"
...@@ -5618,23 +5544,23 @@ ...@@ -5618,23 +5544,23 @@
"attributes": [ "attributes": [
{ {
"name": "long_name", "name": "long_name",
"value": "_x_-component of the vector that gives the pointing direction of the tx_beam, in sonar beam coordinate system" "value": "transmit beam angular rotation about the _x_ axis"
}, },
{ {
"name": "units", "name": "units",
"value": "1" "value": "arc_degree"
}, },
{ {
"name": "valid_range", "name": "valid_range",
"value": "-1.0f, 1.0f", "value": "-180.0f, 180.0f",
"type": "float" "type": "float"
} }
] ]
}, },
{ {
"name": "tx_beam_direction_y", "name": "tx_beam_rotation_theta",
"obligation": "M", "obligation": "M",
"comment": "The _y_-axis coordinate of a unit vector in the tx_beam direction for each beam and ping, as per the sonar beam coordinate system.", "comment": "The intrinsic _z_–_y_’–_x_” clockwise about the _y_-axis of the platform coordinate system needed to give the transmit beam coordinate system.",
"dims": [ "dims": [
"ping_time", "ping_time",
"tx_beam" "tx_beam"
...@@ -5643,23 +5569,23 @@ ...@@ -5643,23 +5569,23 @@
"attributes": [ "attributes": [
{ {
"name": "long_name", "name": "long_name",
"value": "_y_-component of the vector that gives the pointing direction of the tx_beam, in sonar beam coordinate system" "value": "transmit beam angular rotation about the _y_ axis"
}, },
{ {
"name": "units", "name": "units",
"value": "1" "value": "arc_degree"
}, },
{ {
"name": "valid_range", "name": "valid_range",
"value": "-1.0f, 1.0f", "value": "-180.0f, 180.0f",
"type": "float" "type": "float"
} }
] ]
}, },
{ {
"name": "tx_beam_direction_z", "name": "tx_beam_rotation_psi",
"obligation": "M", "obligation": "M",
"comment": "The _z_-axis coordinate of a unit vector in the tx_beam direction for each beam and ping, as per the sonar beam coordinate system.", "comment": "The intrinsic _z_–_y_’–_x_” clockwise about the _z_-axis of the platform coordinate system needed to give the transmit beam coordinate system.",
"dims": [ "dims": [
"ping_time", "ping_time",
"tx_beam" "tx_beam"
...@@ -5668,15 +5594,15 @@ ...@@ -5668,15 +5594,15 @@
"attributes": [ "attributes": [
{ {
"name": "long_name", "name": "long_name",
"value": "_z_-component of the vector that gives the pointing direction of the tx_beam, in sonar beam coordinate system" "value": "transmit beam angular rotation about the _z_ axis"
}, },
{ {
"name": "units", "name": "units",
"value": "1" "value": "arc_degree"
}, },
{ {
"name": "valid_range", "name": "valid_range",
"value": "-1.0f, 1.0f", "value": "-180.0f, 180.0f",
"type": "float" "type": "float"
} }
] ]
...@@ -6391,7 +6317,7 @@ ...@@ -6391,7 +6317,7 @@
{ {
"name": "platform_vertical_offset", "name": "platform_vertical_offset",
"obligation": "M", "obligation": "M",
"comment": "Distance from the platform reference point to the water line (distance are positives downwards). For ships and similar, this is called heave, but the concept applies equally well to underwater vehicle depth.", "comment": "Distance from the platform reference point to the water line (distance are positives downwards). For ships and similar, this is called heave and is added to the dynamic draught at the time of the ping but the concept applies equally well to underwater vehicle depth.",
"dims": [ "dims": [
"ping_time" "ping_time"
], ],
...@@ -6437,7 +6363,7 @@ ...@@ -6437,7 +6363,7 @@
{ {
"name": "waterline_to_chart_datum", "name": "waterline_to_chart_datum",
"obligation": "O", "obligation": "O",
"comment": "Vertical translation vector at the time of the ping matching the distance from the water line to the chart data reference (typically Lowest Astronomical Tide or Mean Sea Level). This variable is the vector obtains by adding the tide, the dynamic draught at the time of the ping and allow to position samples in an absolute referential.", "comment": "Vertical translation vector at the time of the ping matching the distance from the water line to the chart data reference (typically Lowest Astronomical Tide or Mean Sea Level). This variable is the vector that contains the tide and allows for the positioning of samples in an absolute reference system.",
"dims": [ "dims": [
"ping_time" "ping_time"
], ],
...@@ -6478,7 +6404,9 @@ ...@@ -6478,7 +6404,9 @@
}, },
{ {
"name": "valid_min", "name": "valid_min",
"value": "0" "value": "0",
"type": "short"
} }
] ]
} }
...@@ -8484,6 +8412,25 @@ ...@@ -8484,6 +8412,25 @@
"ping_time" "ping_time"
], ],
"type": "float", "type": "float",
"comment": "Projector beam steering angle horizontal from 7000 datagram",
"attributes": [
{
"name": "units",
"value": "degree"
}
],
"fileTypes": [
"s7k"
]
},
{
"name": "projector_beam_steering_angle_vertical",
"dims": [
"ping_time"
],
"type": "float",
"comment": "Projector beam steering angle vertical from 7000 datagram",
"attributes": [ "attributes": [
{ {
"name": "units", "name": "units",
...@@ -9010,6 +8957,44 @@ ...@@ -9010,6 +8957,44 @@
"s7k" "s7k"
] ]
}, },
{
"name": "raw_rx_beam_pointing_angle",
"dims": [
"ping_time",
"beam"
],
"type": "float",
"attributes": [
{
"name": "unit",
"value": "degree"
}
],
"fileTypes": [
"all","kmall"
],
"comment": "The receiver beam pointing angle as given by the constructor. Match BeamPointingAngle of Water column datagram for all files and BeamPointAngReVertical_deg for kmall files "
},
{
"name": "raw_tx_beam_tilt_angle",
"dims": [
"ping_time",
"tx_beam"
],
"type": "float",
"attributes": [
{
"name": "unit",
"value": "degree"
}
],
"fileTypes": [
"all","kmall"
],
"comment": "The receiver tx beam tilt angle as given by the constructor. Match TiltAngleReTx_deg of kmall WCD datagrams and Water column"
},
{ {
"name": "beam_horizontal_direction_angle", "name": "beam_horizontal_direction_angle",
"dims": [ "dims": [
......
...@@ -6,18 +6,27 @@ import java.util.List; ...@@ -6,18 +6,27 @@ import java.util.List;
public class DataTypeConverter { public class DataTypeConverter {
private static HashMap<String , DataType > vlen_specific_types=new HashMap<>(); private static HashMap<String , DataType > vlen_specific_types=new HashMap<>();
public static DataType get(String value) throws Exception public static String getName(String value) throws Exception
{ {
switch(value.toUpperCase()) switch(value.toUpperCase())
{ {
case "BOOLEAN":
return DataType.BOOLEAN;
//on triche un peu et map les types enum sur des bytes
case "TRANSDUCER_TYPE_T": case "TRANSDUCER_TYPE_T":
case "DETECTION_TYPE_T": case "DETECTION_TYPE_T":
case "TRANSMIT_T": case "TRANSMIT_T":
case "BEAM_STABILISATION_T": case "BEAM_STABILISATION_T":
case "BEAM_T": case "BEAM_T":
return "getEnum(\""+value+"\").getValue()";
default:
return "DataType."+get(value).name();
}
}
public static DataType get(String value) throws Exception
{
switch(value.toUpperCase())
{
case "BOOLEAN":
return DataType.BOOLEAN;
case "BYTE": case "BYTE":
return DataType.BYTE; return DataType.BYTE;
case "CHAR": case "CHAR":
...@@ -46,8 +55,6 @@ public class DataTypeConverter { ...@@ -46,8 +55,6 @@ public class DataTypeConverter {
return DataType.STRING; return DataType.STRING;
default: default:
} }
throw new Exception("Unknown netcdf type " + value); throw new Exception("Unknown netcdf type " + value);
} }
/** /**
...@@ -58,6 +65,11 @@ public class DataTypeConverter { ...@@ -58,6 +65,11 @@ public class DataTypeConverter {
return vlen_specific_types.containsKey(name); return vlen_specific_types.containsKey(name);
} }
public static boolean is_enum(String name)
{
return name.endsWith("_t");
}
/** /**
* declare a specific type * declare a specific type
* @param name the name of the type * @param name the name of the type
......
...@@ -15,6 +15,8 @@ public class NetcdfLayerDeclarer { ...@@ -15,6 +15,8 @@ public class NetcdfLayerDeclarer {
else else
{ {
String type=expandedlayerType.isEmpty() ? basetype:expandedlayerType; String type=expandedlayerType.isEmpty() ? basetype:expandedlayerType;
if(DataTypeConverter.is_enum(type))
return getClassicLayerClass(dim, DataType.BYTE);
return getClassicLayerClass(dim, DataTypeConverter.get(type)); return getClassicLayerClass(dim, DataTypeConverter.get(type));
} }
......
...@@ -5,7 +5,19 @@ import java.util.List; ...@@ -5,7 +5,19 @@ import java.util.List;
import java.util.function.Function; import java.util.function.Function;
public class SCAttributeAdapter { public class SCAttributeAdapter {
public static List<String> getSourceDeclaration(Attribute attribute) {
return Arrays.asList(
String.format("\tpublic static final String %s=\"%s\";", "ATT_"+attribute.name.toUpperCase(),attribute.name));
}
public static List<String> getSourceCode(Group group, Attribute attribute) {
if(attribute.getType()==null)
{
//treat as String
return Arrays.asList(String.format("addAttribute(\"%s\", \"%s\");","ATT_"+attribute.name.toUpperCase(), attribute.value == null ? "":attribute.value.replace("+","")));
}
return Arrays.asList(String.format("addAttribute(\"%s\", %s);","ATT_"+attribute.name.toUpperCase(), formatAttribute(attribute,attribute.getType())));
}
public static List<String> getSourceCode(Variable variable, Attribute attribute) { public static List<String> getSourceCode(Variable variable, Attribute attribute) {
if(attribute.getName().compareTo("_FillValue")==0){ if(attribute.getName().compareTo("_FillValue")==0){
......
...@@ -68,6 +68,7 @@ public class SCGroupAdapter { ...@@ -68,6 +68,7 @@ public class SCGroupAdapter {
classToImportSet.add("import fr.ifremer.globe.netcdf.ucar.DataType;"); classToImportSet.add("import fr.ifremer.globe.netcdf.ucar.DataType;");
classToImportSet.add("import fr.ifremer.globe.netcdf.ucar.NCException;"); classToImportSet.add("import fr.ifremer.globe.netcdf.ucar.NCException;");
classToImportSet.add("import fr.ifremer.globe.netcdf.ucar.NCGroup;"); classToImportSet.add("import fr.ifremer.globe.netcdf.ucar.NCGroup;");
classToImportSet.add("import fr.ifremer.globe.netcdf.util.Pair;");
if (!group.variables.isEmpty()) if (!group.variables.isEmpty())
classToImportSet.add("import fr.ifremer.globe.netcdf.ucar.NCVariable;"); classToImportSet.add("import fr.ifremer.globe.netcdf.ucar.NCVariable;");
...@@ -86,6 +87,14 @@ public class SCGroupAdapter { ...@@ -86,6 +87,14 @@ public class SCGroupAdapter {
if (group.getGroupCategory() == GroupCategory.eStandard) if (group.getGroupCategory() == GroupCategory.eStandard)
sourceCode.add(String.format("\n\tpublic static final String GROUP_NAME = \"%s\";", group.name)); sourceCode.add(String.format("\n\tpublic static final String GROUP_NAME = \"%s\";", group.name));
// group attribute declaration
if(group.attributes.size()>0)
{
sourceCode.add("\n\t/**group attributes names declaration*/");
}
group.attributes.forEach(v -> sourceCode.addAll(SCAttributeAdapter.getSourceDeclaration(v)));
// Dimension name code generation // Dimension name code generation
if (!group.dims.isEmpty()) { if (!group.dims.isEmpty()) {
sourceCode.add("\n\t/**dimensions names declaration*/"); sourceCode.add("\n\t/**dimensions names declaration*/");
...@@ -145,7 +154,7 @@ public class SCGroupAdapter { ...@@ -145,7 +154,7 @@ public class SCGroupAdapter {
if (!group.attributes.isEmpty()) { if (!group.attributes.isEmpty()) {
sourceCode.add("\n\t\t/** Group attributes **/"); sourceCode.add("\n\t\t/** Group attributes **/");
group.attributes.forEach( group.attributes.forEach(
att -> SCAttributeAdapter.getSourceCode(att, s -> s).forEach(src -> sourceCode.add("\t\t" + src))); att -> SCAttributeAdapter.getSourceCode(group,att).forEach(src -> sourceCode.add("\t\t" + src)));
} }
// Variables declaration // Variables declaration
...@@ -331,7 +340,7 @@ public class SCGroupAdapter { ...@@ -331,7 +340,7 @@ public class SCGroupAdapter {
} }
dictionary+="}"; dictionary+="}";