Commit 14ec615e authored by PONCELET's avatar PONCELET

adapt converter to vlen variables

parent 33467969
......@@ -1843,10 +1843,6 @@
{
"name": "tx_beam",
"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": [
......@@ -1939,7 +1935,7 @@
"ping_timeDim",
"beamDim"
],
"type": "sample_byte_t",
"type": "sample_t",
"attributes": [
{
"name": "long_name",
......@@ -1949,11 +1945,6 @@
"name": "units",
"value": "as appropriate",
"comment": "Use units appropriate for the data."
},
{
"name": "scale_factor",
"value": "0.5",
"type": "float"
}
]
},
......@@ -1962,8 +1953,9 @@
"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.",
"dims": [
"backscatter_sampleDim"
],
"ping_timeDim",
"beamDim"
],
"type": "sample_byte_t",
"attributes": [
{
......
......@@ -43,7 +43,7 @@ public class DataTypeConverter {
case "DOUBLE":
return DataType.DOUBLE;
case "STRING":
return DataType.BYTE;
return DataType.STRING;
default:
}
......
package fr.ifremer.fr.xsf.generator;
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);
}
else
{
String type=expandedlayerType.isEmpty() ? basetype:expandedlayerType;
return getClassicLayerClass(dim, DataTypeConverter.get(type));
}
......@@ -37,6 +42,8 @@ public class NetcdfLayerDeclarer {
return 0 == dim || dim == 1 ? "FloatLoadableLayer1D" : "FloatLoadableLayer2D";
case DOUBLE:
return 0 == dim || dim == 1 ? "DoubleLoadableLayer1D": "DoubleLoadableLayer2D";
case STRING:
return 0 == dim || dim == 1 ? "StringLoadableLayer1D": "StringLoadableLayer2D";
default:
return null;
}
......
......@@ -137,6 +137,10 @@ public class PredefinedLayersGenerator {
{
List<Layer> layers=new ArrayList<>();
String lPath=path+"/"+g.getName();
for(Variable v:g.getCoordinateVariables())
{
layers.add(parseVariable(g,v,lPath));
}
for(Variable v:g.getVariables())
{
layers.add(parseVariable(g,v,lPath));
......@@ -155,6 +159,7 @@ public class PredefinedLayersGenerator {
* */
private Layer parseVariable(Group g, Variable v, String lPath) throws Exception {
String layerName=v.getName().toUpperCase();
//find unit
String unit="";
Optional<Attribute> unitValue=findAttribute(v, "units");
......@@ -164,26 +169,25 @@ public class PredefinedLayersGenerator {
}
//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");
String layerType="";
String expandedlayerType="";
if(sf.isPresent())
{
layerType=sf.get().getType();
if(layerType==null)
expandedlayerType=sf.get().getType();
if(expandedlayerType==null)
{
//assume double scale factor
layerType="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");
expandedlayerType="double";
}
}
}
String longName="";
Optional<Attribute> long_name=findAttribute(v, "long_name");
......@@ -191,7 +195,7 @@ public class PredefinedLayersGenerator {
{
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);
}
......
......@@ -20,7 +20,7 @@ public class Group extends Base{
public List<Attribute> getAttributes() {
return attributes;
}
public List<Type> getTypes() {
return types;
}
......@@ -33,6 +33,9 @@ public class Group extends Base{
return variables;
}
public List<Variable> getCoordinateVariables() {
//happens in case of deserialization
if(coordinatevariables==null)
coordinatevariables=new ArrayList<Variable>();
return coordinatevariables;
}
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