Commit 59a7481f authored by cponcele's avatar cponcele
Browse files

Add python code generator for sonar-netcdf validator

parent 28c843d7
......@@ -372,6 +372,8 @@
},
{
"name": "salinity",
"obligation": "M",
"comment": "Salinity of water at given depth,For a Sound velocity profile",
"dims": [
"profile",
......@@ -391,6 +393,8 @@
},
{
"name": "absorption",
"obligation": "O",
"comment": "Absorption values",
"dims": [
"profile",
......
{
"name": "Sonar",
"dims": [
],
"types": [
{
......@@ -55,16 +55,16 @@
}
],
"variables": [
],
"coordinatevariables": [],
"subGroups": [
{
"name": "Beam_group1",
"groupCategory": "eSensor",
"groupCategory": "eMultipleInstance",
"dims": [
{
"javaValue": "dataProxy.getWcBeamCount()",
......@@ -1717,13 +1717,13 @@
{
"name": "missing_value",
"value": "1",
"type": "byte"
"type": "byte"
},
{
"name": "flag_mask",
"value": "1b,2b"
}
]
},
......@@ -2367,9 +2367,9 @@
"name": "long_name",
"value": "distance between swaths"
},
{
"name": "comment",
"value": "Achieved distance between swaths, in percent relative to required swath distance"
{
"name": "comment",
"value": "Achieved distance between swaths, in percent relative to required swath distance"
}
]
},
......@@ -5006,6 +5006,9 @@
},
{
"name": "status",
"obligation": "M",
"comment": "invalidity flag for soundings data, if one of the byte field is set (value != 0) the data are considered as invalid for the given reasons : rejected (rejected by user operation, detailed reason is given by the detailed status field), invalid_acquisition (marked invalid by sounder), invalid_conversion (tagged as invalid during file creation, typically missing datagram), invalid_swath (swath is invalidated typically by the user), invalid_sounding_row (range of sounding invalidated along sounding_row dimension)",
"dims": [
"ping_time",
......@@ -5033,6 +5036,8 @@
},
{
"name": "status_detail",
"obligation": "M",
"comment": "detailed status for rejected sounding (byte field of status) manual (rejected manually by operator), rejected automatically, doubtfull (typically cube algorithm), unknown (rejected by another reason)",
"dims": [
"ping_time",
......@@ -5060,6 +5065,8 @@
},
{
"name": "detection_type",
"obligation": "M",
"comment": "type of detection",
"dims": [
"ping_time",
......@@ -5433,6 +5440,8 @@
},
{
"name": "seabed_image_start_range",
"obligation": "O",
"dims": [
"ping_time",
"detection"
......@@ -5451,6 +5460,8 @@
},
{
"name": "seabed_image_center",
"obligation": "O",
"dims": [
"ping_time",
"detection"
......@@ -6609,7 +6620,7 @@
},
{
"name": "Grid_group1",
"groupCategory": "eSensor",
"groupCategory": "eMultipleInstance",
"dims": [
{
......@@ -7832,7 +7843,7 @@
"obligation": "M",
"comment": "Depth of the cell to the water line (distance are positives downwards).",
"dims": [
"range_axis",
"range_axis",
"beam"
],
"type": "float",
......
......@@ -76,6 +76,7 @@ public class CodeGenerator {
new AsciiDoctorGenerator().run(root, Paths.get(outputDir.getAbsolutePath()).toFile());
new JavaSourceCodeGenerator().run(root, Paths.get(outputDir.getAbsolutePath(), "code").toFile());
new PythonSourceCodeGenerator().run(root, Paths.get(outputDir.getAbsolutePath(), "code").toFile());
new PythonValidatorModelGenerator().run(root, Paths.get(outputDir.getAbsolutePath(), "code").toFile());
}
System.out.println("Done ");
......
package fr.ifremer.fr.xsf.generator;
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import fr.ifremer.fr.xsf.generator.model.Group;
import fr.ifremer.fr.xsf.generator.model.SCGroupAdapter;
public class PythonValidatorModelGenerator {
private static String OUTPUT_FOLDER_API = "python";
/**
* generate documentation in excel file format
* @throws Exception
**/
public void run(Group root, File outputDir) throws Exception
{
generateSourceFile(Paths.get(outputDir.getAbsolutePath(),OUTPUT_FOLDER_API).toFile(), root);
}
/**
* Generates source files
*
* @throws URISyntaxException
*/
private void generateSourceFile(File outputDir, Group group)
throws IOException {
if (!outputDir.exists())
Files.createDirectories(outputDir.toPath());
Path outputFolder=outputDir.toPath();
Files.write(outputFolder.resolve(Paths.get("sonar_validator_model.py")),
SCGroupAdapter.getValidatorSourceCode(group,"",""));
}
}
......@@ -4,7 +4,7 @@ import java.util.ArrayList;
import java.util.List;
enum GroupCategory{
eStandard,eSensor
eStandard,eSensor,eMultipleInstance
}
public class Group extends Base{
......
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