Package dap4.servlet

Class CDMWrap


  • public class CDMWrap
    extends Object
    Wrap CDM source (NetcdfDataset) to Provide a DAP4 API. More or less the inverse of a DSP. This basically means wrapping various (CDM)Array object to look like DataVariable objects.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected boolean closed  
      protected dap4.dap4lib.cdm.NodeMap<ucar.nc2.Variable,​dap4.core.dmr.DapStructure> compoundmap  
      protected static boolean DEBUG  
      protected dap4.core.dmr.DapDataset dmr  
      protected dap4.core.dmr.DMRFactory dmrfactory  
      protected static boolean DUMPCDL  
      protected static Set<ucar.nc2.dataset.NetcdfDataset.Enhance> ENHANCEMENT  
      protected static String FILLVALUE  
      protected String location  
      protected static boolean nc4loaded  
      protected ucar.nc2.dataset.NetcdfDataset ncdfile  
      protected dap4.dap4lib.cdm.NodeMap<ucar.nc2.CDMNode,​dap4.core.dmr.DapNode> nodemap  
      protected Map<dap4.core.dmr.DapVariable,​CDMData> variables  
      protected dap4.dap4lib.cdm.NodeMap<ucar.nc2.Variable,​dap4.core.dmr.DapVariable> varmap  
      protected dap4.dap4lib.cdm.NodeMap<ucar.nc2.Variable,​dap4.core.dmr.DapSequence> vlenmap  
    • Constructor Summary

      Constructors 
      Constructor Description
      CDMWrap()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void addToParent​(dap4.core.dmr.DapNode parent, dap4.core.dmr.DapVariable dapvar)  
      void addVariableData​(dap4.core.dmr.DapVariable var, CDMData cursor)  
      protected dap4.core.dmr.DapVariable buildatomicvar​(ucar.nc2.Variable cdmvar, dap4.core.dmr.DapNode parent)  
      protected dap4.core.dmr.DapAttribute buildattribute​(ucar.nc2.Attribute cdmattr)  
      protected void buildattributes​(dap4.core.dmr.DapNode node, ucar.nc2.AttributeContainer attributes)  
      protected dap4.core.dmr.DapStructure buildcompoundtype​(ucar.nc2.Variable cdmvar, dap4.core.dmr.DapNode parent)  
      protected dap4.core.dmr.DapDimension builddim​(ucar.nc2.Dimension cdmdim)  
      protected void builddimrefs​(dap4.core.dmr.DapVariable dapvar, List<ucar.nc2.Dimension> cdmdims)
      Assign dimensions to a variable
      void buildDMR()
      Extract the metadata from the NetcdfDataset and build the DMR.
      protected dap4.core.dmr.DapEnumeration buildenum​(ucar.nc2.EnumTypedef cdmenum)  
      protected dap4.core.dmr.DapVariable buildenumvar​(ucar.nc2.Variable cdmvar)  
      protected dap4.core.dmr.DapGroup buildgroup​(ucar.nc2.Group cdmgroup)  
      protected void buildmaps​(dap4.core.dmr.DapVariable dapvar, ucar.nc2.Variable var)  
      protected dap4.core.dmr.DapVariable buildopaquevar​(ucar.nc2.Variable cdmvar)  
      protected dap4.core.dmr.DapSequence buildseqtype​(ucar.nc2.Variable cdmvar)  
      protected void buildseqtypes​(ucar.nc2.Variable cdmvar)
      Walk this variable, including fields, to construct sequence types for any contained vlen dimensions
      protected dap4.core.dmr.DapVariable buildstringvar​(ucar.nc2.Variable cdmvar)  
      protected dap4.core.dmr.DapVariable buildstructvar​(ucar.nc2.Variable cdmvar)  
      protected dap4.core.dmr.DapVariable buildvariable​(ucar.nc2.Variable cdmbasevar, dap4.core.dmr.DapNode parent, List<ucar.nc2.Dimension> cdmdims)  
      void close()  
      protected ucar.nc2.NetcdfFile createNetcdfFile​(String location, ucar.nc2.util.CancelTask canceltask)  
      protected long dapsize​(ucar.nc2.Dimension cdmdim)  
      protected void fillgroup​(dap4.core.dmr.DapGroup dapgroup, ucar.nc2.Group cdmgroup)  
      protected ucar.nc2.Dimension finddimdecl​(ucar.nc2.Dimension dimref)  
      protected ucar.nc2.EnumTypedef findMatchingEnum​(ucar.nc2.EnumTypedef varenum)
      Unfortunately, the CDM Iosp does not actually use the declared enums.
      dap4.core.dmr.DapDataset getDMR()  
      String getLocation()  
      ucar.nc2.dataset.NetcdfDataset getNetcdfDataset()  
      CDMData getVariableData​(dap4.core.dmr.DapVariable var)  
      protected boolean isDimDeclFor​(ucar.nc2.Dimension decl, ucar.nc2.Dimension ref)  
      CDMWrap open​(String filepath)  
      CDMWrap open​(ucar.nc2.dataset.NetcdfDataset ncd)  
      protected void processmappedvariables​(ucar.nc2.Group g)  
      protected void recordNode​(ucar.nc2.CDMNode cdm, dap4.core.dmr.DapNode dap)
      Track generic CDMNode <-> DapNode
      protected void recordSeq​(ucar.nc2.Variable cdm, dap4.core.dmr.DapSequence dap)
      Track Variable <-> DapSequence
      protected void recordStruct​(ucar.nc2.Variable cdm, dap4.core.dmr.DapStructure dap)
      Track Variable <-> DapStructure
      protected void recordVar​(ucar.nc2.Variable cdm, dap4.core.dmr.DapVariable dap)
      Track Variable <-> DapVariable
      CDMWrap setDMR​(dap4.core.dmr.DapDataset dmr)  
      CDMWrap setLocation​(String path)  
      protected boolean shadows​(ucar.nc2.Group parent, ucar.nc2.Group child)  
      protected boolean suppress​(String attrname)
      Some attributes that are added by the NetcdfDataset need to be kept out of the DMR.
      protected boolean validatecdmtype​(ucar.ma2.DataType datatype, Class typeclass)  
    • Field Detail

      • ENHANCEMENT

        protected static Set<ucar.nc2.dataset.NetcdfDataset.Enhance> ENHANCEMENT
      • nc4loaded

        protected static boolean nc4loaded
      • location

        protected String location
      • ncdfile

        protected ucar.nc2.dataset.NetcdfDataset ncdfile
      • closed

        protected boolean closed
      • dmr

        protected dap4.core.dmr.DapDataset dmr
      • dmrfactory

        protected dap4.core.dmr.DMRFactory dmrfactory
      • varmap

        protected dap4.dap4lib.cdm.NodeMap<ucar.nc2.Variable,​dap4.core.dmr.DapVariable> varmap
      • variables

        protected Map<dap4.core.dmr.DapVariable,​CDMData> variables
      • compoundmap

        protected dap4.dap4lib.cdm.NodeMap<ucar.nc2.Variable,​dap4.core.dmr.DapStructure> compoundmap
      • vlenmap

        protected dap4.dap4lib.cdm.NodeMap<ucar.nc2.Variable,​dap4.core.dmr.DapSequence> vlenmap
      • nodemap

        protected dap4.dap4lib.cdm.NodeMap<ucar.nc2.CDMNode,​dap4.core.dmr.DapNode> nodemap
    • Constructor Detail

      • CDMWrap

        public CDMWrap()
    • Method Detail

      • getDMR

        public dap4.core.dmr.DapDataset getDMR()
      • setDMR

        public CDMWrap setDMR​(dap4.core.dmr.DapDataset dmr)
      • getLocation

        public String getLocation()
      • getVariableData

        public CDMData getVariableData​(dap4.core.dmr.DapVariable var)
                                throws dap4.core.util.DapException
        Throws:
        dap4.core.util.DapException
      • addVariableData

        public void addVariableData​(dap4.core.dmr.DapVariable var,
                                    CDMData cursor)
      • getNetcdfDataset

        public ucar.nc2.dataset.NetcdfDataset getNetcdfDataset()
      • open

        public CDMWrap open​(String filepath)
                     throws dap4.core.util.DapException
        Parameters:
        filepath - - absolute path to a file
        Returns:
        CDMDSP instance
        Throws:
        dap4.core.util.DapException
      • open

        public CDMWrap open​(ucar.nc2.dataset.NetcdfDataset ncd)
                     throws dap4.core.util.DapException
        Parameters:
        ncd - netcdf dataset
        Returns:
        the cdmdsp
        Throws:
        dap4.core.util.DapException
      • recordNode

        protected void recordNode​(ucar.nc2.CDMNode cdm,
                                  dap4.core.dmr.DapNode dap)
        Track generic CDMNode <-> DapNode
      • recordVar

        protected void recordVar​(ucar.nc2.Variable cdm,
                                 dap4.core.dmr.DapVariable dap)
        Track Variable <-> DapVariable
      • recordStruct

        protected void recordStruct​(ucar.nc2.Variable cdm,
                                    dap4.core.dmr.DapStructure dap)
        Track Variable <-> DapStructure
      • recordSeq

        protected void recordSeq​(ucar.nc2.Variable cdm,
                                 dap4.core.dmr.DapSequence dap)
        Track Variable <-> DapSequence
      • buildDMR

        public void buildDMR()
                      throws dap4.core.util.DapException
        Extract the metadata from the NetcdfDataset and build the DMR.
        Throws:
        dap4.core.util.DapException
      • fillgroup

        protected void fillgroup​(dap4.core.dmr.DapGroup dapgroup,
                                 ucar.nc2.Group cdmgroup)
                          throws dap4.core.util.DapException
        Throws:
        dap4.core.util.DapException
      • builddim

        protected dap4.core.dmr.DapDimension builddim​(ucar.nc2.Dimension cdmdim)
                                               throws dap4.core.util.DapException
        Throws:
        dap4.core.util.DapException
      • buildenum

        protected dap4.core.dmr.DapEnumeration buildenum​(ucar.nc2.EnumTypedef cdmenum)
                                                  throws dap4.core.util.DapException
        Throws:
        dap4.core.util.DapException
      • buildcompoundtype

        protected dap4.core.dmr.DapStructure buildcompoundtype​(ucar.nc2.Variable cdmvar,
                                                               dap4.core.dmr.DapNode parent)
                                                        throws dap4.core.util.DapException
        Throws:
        dap4.core.util.DapException
      • buildvariable

        protected dap4.core.dmr.DapVariable buildvariable​(ucar.nc2.Variable cdmbasevar,
                                                          dap4.core.dmr.DapNode parent,
                                                          List<ucar.nc2.Dimension> cdmdims)
                                                   throws dap4.core.util.DapException
        Throws:
        dap4.core.util.DapException
      • buildatomicvar

        protected dap4.core.dmr.DapVariable buildatomicvar​(ucar.nc2.Variable cdmvar,
                                                           dap4.core.dmr.DapNode parent)
                                                    throws dap4.core.util.DapException
        Throws:
        dap4.core.util.DapException
      • buildopaquevar

        protected dap4.core.dmr.DapVariable buildopaquevar​(ucar.nc2.Variable cdmvar)
                                                    throws dap4.core.util.DapException
        Throws:
        dap4.core.util.DapException
      • buildstringvar

        protected dap4.core.dmr.DapVariable buildstringvar​(ucar.nc2.Variable cdmvar)
                                                    throws dap4.core.util.DapException
        Throws:
        dap4.core.util.DapException
      • buildenumvar

        protected dap4.core.dmr.DapVariable buildenumvar​(ucar.nc2.Variable cdmvar)
                                                  throws dap4.core.util.DapException
        Throws:
        dap4.core.util.DapException
      • buildstructvar

        protected dap4.core.dmr.DapVariable buildstructvar​(ucar.nc2.Variable cdmvar)
                                                    throws dap4.core.util.DapException
        Throws:
        dap4.core.util.DapException
      • buildseqtype

        protected dap4.core.dmr.DapSequence buildseqtype​(ucar.nc2.Variable cdmvar)
                                                  throws dap4.core.util.DapException
        Throws:
        dap4.core.util.DapException
      • buildseqtypes

        protected void buildseqtypes​(ucar.nc2.Variable cdmvar)
                              throws dap4.core.util.DapException
        Walk this variable, including fields, to construct sequence types for any contained vlen dimensions
        Parameters:
        cdmvar - variable to walk
        Throws:
        dap4.core.util.DapException
      • buildattributes

        protected void buildattributes​(dap4.core.dmr.DapNode node,
                                       ucar.nc2.AttributeContainer attributes)
                                throws dap4.core.util.DapException
        Throws:
        dap4.core.util.DapException
      • buildattribute

        protected dap4.core.dmr.DapAttribute buildattribute​(ucar.nc2.Attribute cdmattr)
                                                     throws dap4.core.util.DapException
        Throws:
        dap4.core.util.DapException
      • builddimrefs

        protected void builddimrefs​(dap4.core.dmr.DapVariable dapvar,
                                    List<ucar.nc2.Dimension> cdmdims)
                             throws dap4.core.util.DapException
        Assign dimensions to a variable
        Parameters:
        dapvar - The variable to which we wish to assign dimensions
        cdmdims - The cdm dimensions from which we will find the dimension info
        Throws:
        dap4.core.util.DapException
      • processmappedvariables

        protected void processmappedvariables​(ucar.nc2.Group g)
                                       throws dap4.core.util.DapException
        Throws:
        dap4.core.util.DapException
      • buildmaps

        protected void buildmaps​(dap4.core.dmr.DapVariable dapvar,
                                 ucar.nc2.Variable var)
                          throws dap4.core.util.DapException
        Parameters:
        dapvar - The variable to which we wish to assign maps
        var - The NetcdfDataset variable from which to extract coord system
        Throws:
        dap4.core.util.DapException
      • buildgroup

        protected dap4.core.dmr.DapGroup buildgroup​(ucar.nc2.Group cdmgroup)
                                             throws dap4.core.util.DapException
        Throws:
        dap4.core.util.DapException
      • findMatchingEnum

        protected ucar.nc2.EnumTypedef findMatchingEnum​(ucar.nc2.EnumTypedef varenum)
                                                 throws dap4.core.util.DapException
        Unfortunately, the CDM Iosp does not actually use the declared enums. Rather, for every enum type'd variable, a new enum decl is defined. So, we need to find the original enum decl that matches the variable's enum.
        Throws:
        dap4.core.util.DapException
      • shadows

        protected boolean shadows​(ucar.nc2.Group parent,
                                  ucar.nc2.Group child)
      • dapsize

        protected long dapsize​(ucar.nc2.Dimension cdmdim)
      • validatecdmtype

        protected boolean validatecdmtype​(ucar.ma2.DataType datatype,
                                          Class typeclass)
      • finddimdecl

        protected ucar.nc2.Dimension finddimdecl​(ucar.nc2.Dimension dimref)
      • isDimDeclFor

        protected boolean isDimDeclFor​(ucar.nc2.Dimension decl,
                                       ucar.nc2.Dimension ref)
      • createNetcdfFile

        protected ucar.nc2.NetcdfFile createNetcdfFile​(String location,
                                                       ucar.nc2.util.CancelTask canceltask)
                                                throws dap4.core.util.DapException
        Throws:
        dap4.core.util.DapException
      • suppress

        protected boolean suppress​(String attrname)
        Some attributes that are added by the NetcdfDataset need to be kept out of the DMR. This function defines that set.
        Parameters:
        attrname - A non-escaped attribute name to be tested for suppression
        Returns:
        true if the attribute should be suppressed, false otherwise.
      • addToParent

        protected void addToParent​(dap4.core.dmr.DapNode parent,
                                   dap4.core.dmr.DapVariable dapvar)
                            throws dap4.core.util.DapException
        Throws:
        dap4.core.util.DapException