Commit 14ec615e authored by PONCELET's avatar PONCELET

adapt converter to vlen variables

parent 33467969
...@@ -1843,10 +1843,6 @@ ...@@ -1843,10 +1843,6 @@
{ {
"name": "tx_beam", "name": "tx_beam",
"comment": "The number of transmit beams in this beam group" "comment": "The number of transmit beams in this beam group"
},
{
"name": "backscatter_sample",
"comment": "the total number of sample in water column data for all ping"
} }
], ],
"coordinatevariables": [ "coordinatevariables": [
...@@ -1939,7 +1935,7 @@ ...@@ -1939,7 +1935,7 @@
"ping_timeDim", "ping_timeDim",
"beamDim" "beamDim"
], ],
"type": "sample_byte_t", "type": "sample_t",
"attributes": [ "attributes": [
{ {
"name": "long_name", "name": "long_name",
...@@ -1949,11 +1945,6 @@ ...@@ -1949,11 +1945,6 @@
"name": "units", "name": "units",
"value": "as appropriate", "value": "as appropriate",
"comment": "Use units appropriate for the data." "comment": "Use units appropriate for the data."
},
{
"name": "scale_factor",
"value": "0.5",
"type": "float"
} }
] ]
}, },
...@@ -1962,8 +1953,9 @@ ...@@ -1962,8 +1953,9 @@
"obligation": "M", "obligation": "M",
"comment": "Real part or amplitude or power of backscatter measurements. Each element in the 2D matrix is a variable length vector (of type sample_t) that contains the samples for that beam and ping time.", "comment": "Real part or amplitude or power of backscatter measurements. Each element in the 2D matrix is a variable length vector (of type sample_t) that contains the samples for that beam and ping time.",
"dims": [ "dims": [
"backscatter_sampleDim" "ping_timeDim",
], "beamDim"
],
"type": "sample_byte_t", "type": "sample_byte_t",
"attributes": [ "attributes": [
{ {
......
...@@ -43,7 +43,7 @@ public class DataTypeConverter { ...@@ -43,7 +43,7 @@ public class DataTypeConverter {
case "DOUBLE": case "DOUBLE":
return DataType.DOUBLE; return DataType.DOUBLE;
case "STRING": case "STRING":
return DataType.BYTE; return DataType.STRING;
default: default:
} }
......
package fr.ifremer.fr.xsf.generator; package fr.ifremer.fr.xsf.generator;
public class NetcdfLayerDeclarer { public class NetcdfLayerDeclarer {
public static String getLayerClass(int dim, String type) throws Exception public static String getLayerClass(int dim, String basetype, String expandedlayerType) throws Exception
{ {
if(DataTypeConverter.isVlen(type)) if(DataTypeConverter.isVlen(basetype))
{ {
DataType baseType=DataTypeConverter.getVlenDataType(type); DataType baseType;
if(expandedlayerType.isEmpty())
baseType=DataTypeConverter.getVlenDataType(basetype);
else
baseType=DataTypeConverter.get(expandedlayerType);
return getVlenLayerClass(dim, baseType); return getVlenLayerClass(dim, baseType);
} }
else else
{ {
String type=expandedlayerType.isEmpty() ? basetype:expandedlayerType;
return getClassicLayerClass(dim, DataTypeConverter.get(type)); return getClassicLayerClass(dim, DataTypeConverter.get(type));
} }
...@@ -37,6 +42,8 @@ public class NetcdfLayerDeclarer { ...@@ -37,6 +42,8 @@ public class NetcdfLayerDeclarer {
return 0 == dim || dim == 1 ? "FloatLoadableLayer1D" : "FloatLoadableLayer2D"; return 0 == dim || dim == 1 ? "FloatLoadableLayer1D" : "FloatLoadableLayer2D";
case DOUBLE: case DOUBLE:
return 0 == dim || dim == 1 ? "DoubleLoadableLayer1D": "DoubleLoadableLayer2D"; return 0 == dim || dim == 1 ? "DoubleLoadableLayer1D": "DoubleLoadableLayer2D";
case STRING:
return 0 == dim || dim == 1 ? "StringLoadableLayer1D": "StringLoadableLayer2D";
default: default:
return null; return null;
} }
......
...@@ -137,6 +137,10 @@ public class PredefinedLayersGenerator { ...@@ -137,6 +137,10 @@ public class PredefinedLayersGenerator {
{ {
List<Layer> layers=new ArrayList<>(); List<Layer> layers=new ArrayList<>();
String lPath=path+"/"+g.getName(); String lPath=path+"/"+g.getName();
for(Variable v:g.getCoordinateVariables())
{
layers.add(parseVariable(g,v,lPath));
}
for(Variable v:g.getVariables()) for(Variable v:g.getVariables())
{ {
layers.add(parseVariable(g,v,lPath)); layers.add(parseVariable(g,v,lPath));
...@@ -155,6 +159,7 @@ public class PredefinedLayersGenerator { ...@@ -155,6 +159,7 @@ public class PredefinedLayersGenerator {
* */ * */
private Layer parseVariable(Group g, Variable v, String lPath) throws Exception { private Layer parseVariable(Group g, Variable v, String lPath) throws Exception {
String layerName=v.getName().toUpperCase(); String layerName=v.getName().toUpperCase();
//find unit //find unit
String unit=""; String unit="";
Optional<Attribute> unitValue=findAttribute(v, "units"); Optional<Attribute> unitValue=findAttribute(v, "units");
...@@ -164,26 +169,25 @@ public class PredefinedLayersGenerator { ...@@ -164,26 +169,25 @@ public class PredefinedLayersGenerator {
} }
//find className //find className
String baselayerType="";
if(v.getType()!=null)
{
baselayerType=v.getType();
} else
{
throw new Exception("Variable "+v.getName() + " has not associated type");
}
Optional<Attribute> sf=findAttribute(v, "scale_factor"); Optional<Attribute> sf=findAttribute(v, "scale_factor");
String layerType=""; String expandedlayerType="";
if(sf.isPresent()) if(sf.isPresent())
{ {
layerType=sf.get().getType(); expandedlayerType=sf.get().getType();
if(layerType==null) if(expandedlayerType==null)
{ {
//assume double scale factor //assume double scale factor
layerType="double"; expandedlayerType="double";
}
} else
{ //we find the type of the variable
if(v.getType()!=null)
{
layerType=v.getType();
} else
{
throw new Exception("Variable "+v.getName() + " has not associated type");
} }
} }
String longName=""; String longName="";
Optional<Attribute> long_name=findAttribute(v, "long_name"); Optional<Attribute> long_name=findAttribute(v, "long_name");
...@@ -191,7 +195,7 @@ public class PredefinedLayersGenerator { ...@@ -191,7 +195,7 @@ public class PredefinedLayersGenerator {
{ {
longName=long_name.get().getValue(); longName=long_name.get().getValue();
} }
String layerClass=NetcdfLayerDeclarer.getLayerClass(v.getDims().size(), layerType); String layerClass=NetcdfLayerDeclarer.getLayerClass(v.getDims().size(),baselayerType, expandedlayerType);
return new Layer(lPath,layerName, layerClass,v.getName(), longName, DataKind.continuous.toString(), unit, lPath); return new Layer(lPath,layerName, layerClass,v.getName(), longName, DataKind.continuous.toString(), unit, lPath);
} }
......
...@@ -20,7 +20,7 @@ public class Group extends Base{ ...@@ -20,7 +20,7 @@ public class Group extends Base{
public List<Attribute> getAttributes() { public List<Attribute> getAttributes() {
return attributes; return attributes;
} }
public List<Type> getTypes() { public List<Type> getTypes() {
return types; return types;
} }
...@@ -33,6 +33,9 @@ public class Group extends Base{ ...@@ -33,6 +33,9 @@ public class Group extends Base{
return variables; return variables;
} }
public List<Variable> getCoordinateVariables() { public List<Variable> getCoordinateVariables() {
//happens in case of deserialization
if(coordinatevariables==null)
coordinatevariables=new ArrayList<Variable>();
return coordinatevariables; return coordinatevariables;
} }
public List<Group> getSubGroups() { public List<Group> getSubGroups() {
......
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