|
| 1 | +package com.bc.fiduceo.reader.insitu.sic_cci; |
| 2 | + |
| 3 | +import com.bc.fiduceo.util.NetCDFUtils; |
| 4 | +import com.bc.fiduceo.util.VariableProxy; |
| 5 | +import ucar.ma2.DataType; |
| 6 | +import ucar.nc2.Attribute; |
| 7 | +import ucar.nc2.Variable; |
| 8 | + |
| 9 | +import java.text.ParseException; |
| 10 | +import java.util.ArrayList; |
| 11 | +import java.util.List; |
| 12 | + |
| 13 | +import static com.bc.fiduceo.util.NetCDFUtils.*; |
| 14 | + |
| 15 | +public class QSCATSectionParser extends AbstractSectionParser { |
| 16 | + |
| 17 | + @Override |
| 18 | + List<Variable> getVariables() { |
| 19 | + final List<Variable> variables = new ArrayList<>(); |
| 20 | + |
| 21 | + createCommonVariables(variables, "QSCAT_"); |
| 22 | + |
| 23 | + ArrayList<Attribute> attributes = new ArrayList<>(); |
| 24 | + variables.add(new VariableProxy("QSCAT_upstreamfile", DataType.CHAR, attributes)); |
| 25 | + |
| 26 | + attributes = new ArrayList<>(); |
| 27 | + attributes.add(new Attribute(CF_FILL_VALUE_NAME, NetCDFUtils.getDefaultFillValue(float.class))); |
| 28 | + attributes.add(new Attribute(CF_LONG_NAME, "QUIKSCAT backscatter (dB) (HH)")); |
| 29 | + attributes.add(new Attribute(CF_UNITS_NAME, "db")); |
| 30 | + variables.add(new VariableProxy("QSCAT_sigma0_inner", DataType.FLOAT, attributes)); |
| 31 | + |
| 32 | + attributes = new ArrayList<>(); |
| 33 | + attributes.add(new Attribute(CF_FILL_VALUE_NAME, NetCDFUtils.getDefaultFillValue(float.class))); |
| 34 | + attributes.add(new Attribute(CF_LONG_NAME, "QUIKSCAT backscatter (dB) - masked (HH)")); |
| 35 | + attributes.add(new Attribute(CF_UNITS_NAME, "db")); |
| 36 | + variables.add(new VariableProxy("QSCAT_sigma0_mask_inner", DataType.FLOAT, attributes)); |
| 37 | + |
| 38 | + attributes = new ArrayList<>(); |
| 39 | + attributes.add(new Attribute(CF_FILL_VALUE_NAME, NetCDFUtils.getDefaultFillValue(short.class))); |
| 40 | + attributes.add(new Attribute(CF_LONG_NAME, "Number of QUIKSCAT samples (HH)")); |
| 41 | + variables.add(new VariableProxy("QSCAT_nb_inner", DataType.SHORT, attributes)); |
| 42 | + |
| 43 | + attributes = new ArrayList<>(); |
| 44 | + attributes.add(new Attribute(CF_FILL_VALUE_NAME, NetCDFUtils.getDefaultFillValue(float.class))); |
| 45 | + attributes.add(new Attribute(CF_LONG_NAME, "Standard deviation of nb_inner datapoints in daily map (HH) - (not dB)")); |
| 46 | + variables.add(new VariableProxy("QSCAT_std_inner", DataType.FLOAT, attributes)); |
| 47 | + |
| 48 | + attributes = new ArrayList<>(); |
| 49 | + attributes.add(new Attribute(CF_FILL_VALUE_NAME, NetCDFUtils.getDefaultFillValue(float.class))); |
| 50 | + attributes.add(new Attribute(CF_LONG_NAME, "QUIKSCAT backscatter (dB) (VV)")); |
| 51 | + attributes.add(new Attribute(CF_UNITS_NAME, "db")); |
| 52 | + variables.add(new VariableProxy("QSCAT_sigma0_outer", DataType.FLOAT, attributes)); |
| 53 | + |
| 54 | + attributes = new ArrayList<>(); |
| 55 | + attributes.add(new Attribute(CF_FILL_VALUE_NAME, NetCDFUtils.getDefaultFillValue(float.class))); |
| 56 | + attributes.add(new Attribute(CF_LONG_NAME, "QUIKSCAT backscatter (dB) - masked (VV)")); |
| 57 | + attributes.add(new Attribute(CF_UNITS_NAME, "db")); |
| 58 | + variables.add(new VariableProxy("QSCAT_sigma0_mask_outer", DataType.FLOAT, attributes)); |
| 59 | + |
| 60 | + attributes = new ArrayList<>(); |
| 61 | + attributes.add(new Attribute(CF_FILL_VALUE_NAME, NetCDFUtils.getDefaultFillValue(short.class))); |
| 62 | + attributes.add(new Attribute(CF_LONG_NAME, "Number of QUIKSCAT samples (VV)")); |
| 63 | + variables.add(new VariableProxy("QSCAT_nb_outer", DataType.SHORT, attributes)); |
| 64 | + |
| 65 | + attributes = new ArrayList<>(); |
| 66 | + attributes.add(new Attribute(CF_FILL_VALUE_NAME, NetCDFUtils.getDefaultFillValue(float.class))); |
| 67 | + attributes.add(new Attribute(CF_LONG_NAME, "Standard deviation of nb_outer datapoints in daily map (VV) - (not dB)")); |
| 68 | + variables.add(new VariableProxy("QSCAT_std_outer", DataType.FLOAT, attributes)); |
| 69 | + |
| 70 | + return variables; |
| 71 | + } |
| 72 | + |
| 73 | + @Override |
| 74 | + int getNumVariables() { |
| 75 | + return 13; |
| 76 | + } |
| 77 | + |
| 78 | + @Override |
| 79 | + String getNamePrefix() { |
| 80 | + return "QSCAT"; |
| 81 | + } |
| 82 | + |
| 83 | + @Override |
| 84 | + Section parse(String[] tokens, int offset) throws ParseException { |
| 85 | + final Section section = new Section(); |
| 86 | + |
| 87 | + section.add("QSCAT_latitude", parseFloat(tokens[offset])); |
| 88 | + section.add("QSCAT_longitude", parseFloat(tokens[offset + 1])); |
| 89 | + section.add("QSCAT_time", parseUtcTime(tokens[offset + 2])); |
| 90 | + section.add("QSCAT_reference-id", parseString(tokens[offset + 3])); |
| 91 | + section.add("QSCAT_upstreamfile", parseString(tokens[offset + 4])); |
| 92 | + section.add("QSCAT_sigma0_inner", parseFloat(tokens[offset + 5])); |
| 93 | + section.add("QSCAT_sigma0_mask_inner", parseFloat(tokens[offset + 6])); |
| 94 | + section.add("QSCAT_nb_inner", parseShort(tokens[offset + 7])); |
| 95 | + section.add("QSCAT_std_inner", parseFloat(tokens[offset + 8])); |
| 96 | + section.add("QSCAT_sigma0_outer", parseFloat(tokens[offset + 9])); |
| 97 | + section.add("QSCAT_sigma0_mask_outer", parseFloat(tokens[offset + 10])); |
| 98 | + section.add("QSCAT_nb_outer", parseShort(tokens[offset + 11])); |
| 99 | + section.add("QSCAT_std_outer", parseFloat(tokens[offset + 12])); |
| 100 | + |
| 101 | + return section; |
| 102 | + } |
| 103 | +} |
0 commit comments