def addSupplementaryPressureSalinityProfile(self, key: str):
        self.addDataDescription(key + "TemplatePressureTempSalinity", BufrFXYTemplate(3, 6, 18))

        self.addDataDescription(key + "IndicatorForDigitization",BufrFXYInt(0, 2, 32, 2, True))
        self.addDataDescription(key + "MeasurementType",BufrFXYInt(0, 8, 34, 4, True))

        # replication descriptors
        self.addDataDescription(key + "DelayedReplication", BufrFXYDelayedReplication(9, True)) # replication of next 9 items
        self.addDataDescription(key + "ExtendedDelayedReplication",BufrFXYInt(0, 31, 2, 16, True))   # number of replications (i.e. levels)

        # replicated section
        self.addDataDescription(key + "WaterPressure",BufrFXYDoubleReplication(0, 7, 65, -3.0, 0.0, 17, True))
        self.addDataDescription(key + "WaterPressure_QualifierForGTSPPQualityClass",BufrFXYIntReplication(0, 8, 80, 6, True))   # pressure at a level = 10
        self.addDataDescription(key + "WaterPressure_GlobalGTSPPQualityClass",BufrFXYIntReplication(0, 33, 50, 4, True))

        self.addDataDescription(key + "SeaWaterTemperature",BufrFXYDoubleReplication(0, 22, 45, 3.0, 0.0, 19, True))
        self.addDataDescription(key + "SeaWaterTemperature_QualifierForGTSPPQualityClass",BufrFXYIntReplication(0, 8, 80, 6, True))    # water temperature at a level = 11
        self.addDataDescription(key + "SeaWaterTemperature_GlobalGTSPPQualityClass",BufrFXYIntReplication(0, 33, 50, 4, True))

        self.addDataDescription(key + "Salinity",BufrFXYDoubleReplication(0, 22, 64, 3.0, 0.0, 17, True))
        self.addDataDescription(key + "Salinity_QualifierForGTSPPQualityClass",BufrFXYIntReplication(0, 8, 80, 6, True))   # salinity at a level = 12
        self.addDataDescription(key + "Salinity_GlobalGTSPPQualityClass",BufrFXYIntReplication(0, 33, 50, 4, True))

        # end marker?
        self.addDataDescription(key + "MeasurementTypeCancel",BufrFXYInt(0, 8, 34, 4, True))

        pass
    def addDissolvedOxygenProfile(self, key: str):
        self.addDataDescription(key + "TemplatePressureTemp", BufrFXYTemplate(3, 6, 37))

        # replication descriptors
        self.addDataDescription(key + "DelayedReplication", BufrFXYDelayedReplication(9, True)) # replication of next 9 items
        self.addDataDescription(key + "ExtendedDelayedReplication",BufrFXYInt(0, 31, 2, 16, True))   # number of replications (i.e. levels)

        # replicated section
        self.addDataDescription(key + "Depth",BufrFXYDoubleReplication(0, 7, 62, 0.0, 0.0, 17, True))
        self.addDataDescription(key + "Depth_QualifierForGTSPPQualityClass",BufrFXYIntReplication(0, 8, 80, 6, True))   # depth at a level = 13
        self.addDataDescription(key + "Depth_GlobalGTSPPQualityClass",BufrFXYIntReplication(0, 33, 50, 4, True))

        self.addDataDescription(key + "WaterPressure",BufrFXYDoubleReplication(0, 7, 65, -3.0, 0.0, 17, True))
        self.addDataDescription(key + "WaterPressure_QualifierForGTSPPQualityClass",BufrFXYIntReplication(0, 8, 80, 6, True))   # pressure at a level = 10
        self.addDataDescription(key + "WaterPressure_GlobalGTSPPQualityClass",BufrFXYIntReplication(0, 33, 50, 4, True))

        self.addDataDescription(key + "DissolvedOxygen",BufrFXYDoubleReplication(0, 22, 188, 3.0, 0.0, 19, True))
        self.addDataDescription(key + "DissolvedOxygen_QualifierForGTSPPQualityClass",BufrFXYIntReplication(0, 8, 80, 6, True))  # dissolved oxygen at a level = 16
        self.addDataDescription(key + "DissolvedOxygen_GlobalGTSPPQualityClass",BufrFXYIntReplication(0, 33, 50, 4, True))
        pass
    def __init__(self, argoChannels: dict):
        super(ArgoNetCDFBufrEncoder, self).__init__()

        #pdb.set_trace()

        # main bufr sequence
        self.addDataDescription("TemplateArgo", BufrFXYTemplate(3, 15, 3))

        self.addDataDescription("WMOMarineObservingPlatform",BufrFXYInt(0, 1, 87, 23, True))
        self.addDataDescription("ObservingPlatformManufacturesModel",BufrFXYString(0, 1, 85, 20, True))
        self.addDataDescription("ObservingPlatformManufacturesSerialNumber",BufrFXYString(0, 1, 86, 32, True))
        self.addDataDescription("BuoyType",BufrFXYInt(0, 2, 36, 2, True))
        self.addDataDescription("DataCollectionAndOrLocationSystem",BufrFXYInt(0, 2, 148, 5, True))
        self.addDataDescription("DataTypeOfBuoy",BufrFXYInt(0, 2, 149, 6, True))
        self.addDataDescription("FloatCycleNumber",BufrFXYInt(0, 22, 55, 10, True))
        self.addDataDescription("DirectionOfProfile",BufrFXYInt(0, 22, 56, 2, True))
        self.addDataDescription("InstrumentTypeForWaterTemperatureProfileMeasurement",BufrFXYInt(0, 22, 67, 10, True))

        #self.addDataDescription("TemplateDate", BufrFXYTemplate(3, 1, 11))
        self.addDataDescription("Year",BufrFXYInt(0, 4, 1, 12, True))
        self.addDataDescription("Month",BufrFXYInt(0, 4, 2, 4, True))
        self.addDataDescription("Day",BufrFXYInt(0, 4, 3, 6, True))

        #self.addDataDescription("TemplateTime", BufrFXYTemplate(3, 1, 12))
        self.addDataDescription("Hour",BufrFXYInt(0, 4, 4, 5, True))
        self.addDataDescription("Minute",BufrFXYInt(0, 4, 5, 6, True))

        #self.addDataDescription("TemplatePosition", BufrFXYTemplate(3, 1, 21))
        self.addDataDescription("LatitudeCoarse",BufrFXYDouble(0, 5, 1, 5.0, 9000000.0, 25, True))
        self.addDataDescription("LongitudeCoarse",BufrFXYDouble(0, 6, 1, 5.0, 18000000.0, 26, True))

        self.addDataDescription("Position_QualifierForGTSPPQualityClass",BufrFXYInt(0, 8, 80, 6, True))
        self.addDataDescription("Position_GlobalGTSPPQualityClass",BufrFXYInt(0, 33, 50, 4, True))

        # replication descriptors
        self.addDataDescription("DelayedReplication", BufrFXYDelayedReplication(9, True)) # replication of next 9 items
        self.addDataDescription("ExtendedDelayedReplication",BufrFXYInt(0, 31, 2, 16, True))   # number of replications (i.e. levels)

        # replicated section
        self.addDataDescription("WaterPressure",BufrFXYDoubleReplication(0, 7, 65, -3.0, 0.0, 17, True))
        self.addDataDescription("WaterPressure_QualifierForGTSPPQualityClass",BufrFXYIntReplication(0, 8, 80, 6, True))    # pressure at a level = 10
        self.addDataDescription("WaterPressure_GlobalGTSPPQualityClass",BufrFXYIntReplication(0, 33, 50, 4, True))

        self.addDataDescription("SeaWaterTemperature",BufrFXYDoubleReplication(0, 22, 45, 3.0, 0.0, 19, True))
        self.addDataDescription("SeaWaterTemperature_QualifierForGTSPPQualityClass",BufrFXYIntReplication(0, 8, 80, 6, True))    # water temperature at a level = 11
        self.addDataDescription("SeaWaterTemperature_GlobalGTSPPQualityClass",BufrFXYIntReplication(0, 33, 50, 4, True))

        self.addDataDescription("Salinity",BufrFXYDoubleReplication(0, 22, 64, 3.0, 0.0, 17, True))
        self.addDataDescription("Salinity_QualifierForGTSPPQualityClass",BufrFXYIntReplication(0, 8, 80, 6, True))   # salinity at a level = 12
        self.addDataDescription("Salinity_GlobalGTSPPQualityClass",BufrFXYIntReplication(0, 33, 50, 4, True))

        # add any additional bufr templates for other Argo profiles
        self.additionalProfiles = []
        numProfiles = argoChannels["N_PROF"].value
        if numProfiles>1:
            samplingSchemesInFile = argoChannels["VERTICAL_SAMPLING_SCHEME"].value
            # check that primary is first
            if not samplingSchemesInFile[0].startswith(self.verticalSamlingSchemes[0]):
                raise Exception("First vertical sampling scheme is not a primary")
            # add profiles for secondary profiles
            for profileNo, samplingScheme in enumerate(samplingSchemesInFile):
                if samplingScheme.startswith(self.verticalSamlingSchemes[1]):
                    profileNamePrefix = "Complimentary" + str(profileNo)    # used for keeping the keys unique for all profiles
                    # save a list of tuples for the additional profiles, for use when adding the data
                    salinity = argoChannels["PSAL"].value[profileNo]
                    oxygen = argoChannels["DOXY"].value[profileNo]
                    oxygenAvailable = oxygen.count() > 0    # include oxygen if there are some values which are not masked
                    salinityAvailable = salinity.count() > 0    # include salinity if there are some values which are not masked
                    self.additionalProfiles.append((profileNamePrefix, profileNo, samplingScheme.rstrip(), salinityAvailable, oxygenAvailable))
                    if salinityAvailable:
                        self.addSupplementaryPressureSalinityProfile(profileNamePrefix)
                    else:
                        self.addSupplementaryPressureProfile(profileNamePrefix)
                pass
            pass

        self.DissolvedOxygenProfile = ""
        # add dissolved oxygen profile?
        if "DOXY" in argoChannels:
            dissolvedOxygen = argoChannels["DOXY"].value[0]
            oxygenAvailable = dissolvedOxygen.count() > 0    # include oxygen if there are some values which are not masked
            if oxygenAvailable:
                self.DissolvedOxygenProfile = "DissolvedOxygen"
                self.addDissolvedOxygenProfile(self.DissolvedOxygenProfile)
                pass
            pass

        pass